using entry point instead of manually fetching fields from application
This commit is contained in:
parent
5c994ebfdd
commit
cfe5a4d212
@ -21,6 +21,8 @@ import androidx.datastore.core.DataStore
|
|||||||
import androidx.datastore.preferences.core.Preferences
|
import androidx.datastore.preferences.core.Preferences
|
||||||
import androidx.datastore.preferences.core.edit
|
import androidx.datastore.preferences.core.edit
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import dagger.hilt.EntryPoints
|
||||||
|
import im.vector.app.core.di.SingletonEntryPoint
|
||||||
import im.vector.app.features.analytics.store.AnalyticsStore
|
import im.vector.app.features.analytics.store.AnalyticsStore
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.rules.TestWatcher
|
import org.junit.rules.TestWatcher
|
||||||
@ -39,10 +41,11 @@ class ClearCurrentSessionRule : TestWatcher() {
|
|||||||
runBlocking {
|
runBlocking {
|
||||||
reflectAnalyticDatastore(context).edit { it.clear() }
|
reflectAnalyticDatastore(context).edit { it.clear() }
|
||||||
runCatching {
|
runCatching {
|
||||||
val holder = (context.applicationContext as VectorApplication).activeSessionHolder
|
val entryPoint = EntryPoints.get(context.applicationContext, SingletonEntryPoint::class.java)
|
||||||
holder.getSafeActiveSession()?.signOutService()?.signOut(true)
|
val sessionHolder = entryPoint.activeSessionHolder()
|
||||||
(context.applicationContext as VectorApplication).vectorPreferences.clearPreferences()
|
sessionHolder.getSafeActiveSession()?.signOutService()?.signOut(true)
|
||||||
holder.clearActiveSession()
|
entryPoint.vectorPreferences().clearPreferences()
|
||||||
|
sessionHolder.clearActiveSession()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.apply(base, description)
|
return super.apply(base, description)
|
||||||
|
Loading…
Reference in New Issue
Block a user