using entry point instead of manually fetching fields from application

This commit is contained in:
Adam Brown 2022-08-08 12:18:05 +01:00
parent 5c994ebfdd
commit cfe5a4d212

View File

@ -21,6 +21,8 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
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 kotlinx.coroutines.runBlocking
import org.junit.rules.TestWatcher
@ -39,10 +41,11 @@ class ClearCurrentSessionRule : TestWatcher() {
runBlocking {
reflectAnalyticDatastore(context).edit { it.clear() }
runCatching {
val holder = (context.applicationContext as VectorApplication).activeSessionHolder
holder.getSafeActiveSession()?.signOutService()?.signOut(true)
(context.applicationContext as VectorApplication).vectorPreferences.clearPreferences()
holder.clearActiveSession()
val entryPoint = EntryPoints.get(context.applicationContext, SingletonEntryPoint::class.java)
val sessionHolder = entryPoint.activeSessionHolder()
sessionHolder.getSafeActiveSession()?.signOutService()?.signOut(true)
entryPoint.vectorPreferences().clearPreferences()
sessionHolder.clearActiveSession()
}
}
return super.apply(base, description)