diff --git a/vector/src/androidTest/java/im/vector/app/ClearCurrentSessionRule.kt b/vector/src/androidTest/java/im/vector/app/ClearCurrentSessionRule.kt index 735e96c1e0..f09e522932 100644 --- a/vector/src/androidTest/java/im/vector/app/ClearCurrentSessionRule.kt +++ b/vector/src/androidTest/java/im/vector/app/ClearCurrentSessionRule.kt @@ -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)