Loading packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/PerDisplayStoreImplTest.kt +2 −3 Original line number Diff line number Diff line Loading @@ -20,9 +20,8 @@ import android.view.Display import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.runBlocking Loading @@ -37,7 +36,7 @@ import org.mockito.kotlin.mock @SmallTest class PerDisplayStoreImplTest : SysuiTestCase() { private val kosmos = testKosmos().also { it.testDispatcher = it.unconfinedTestDispatcher } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val fakeDisplayRepository = kosmos.displayRepository Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLegacySettingSyncerTest.kt +17 −31 Original line number Diff line number Diff line Loading @@ -23,8 +23,9 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.unconfinedTestScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.res.R import com.android.systemui.settings.FakeUserTracker import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots Loading @@ -33,7 +34,7 @@ import com.android.systemui.util.FakeSharedPreferences import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.android.systemui.util.settings.unconfinedDispatcherFakeSettings import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.advanceUntilIdle Loading @@ -51,10 +52,10 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { private val kosmos = testKosmos() private val testDispatcher = kosmos.unconfinedTestDispatcher private val testScope = kosmos.unconfinedTestScope private val settings = kosmos.unconfinedDispatcherFakeSettings private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope private val settings = kosmos.fakeSettings @Mock private lateinit var sharedPrefs: FakeSharedPreferences Loading @@ -79,13 +80,7 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { context = context, userFileManager = mock { whenever( getSharedPreferences( anyString(), anyInt(), anyInt(), ) ) whenever(getSharedPreferences(anyString(), anyInt(), anyInt())) .thenReturn(FakeSharedPreferences()) }, userTracker = FakeUserTracker(), Loading @@ -109,17 +104,14 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { testScope.runTest { val job = underTest.startSyncing() settings.putInt( Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1, ) settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1) assertThat( selectionManager .getSelections() .getOrDefault( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START, emptyList() emptyList(), ) ) .contains(BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS) Loading @@ -132,21 +124,15 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { testScope.runTest { val job = underTest.startSyncing() settings.putInt( Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1, ) settings.putInt( Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0, ) settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1) settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0) assertThat( selectionManager .getSelections() .getOrDefault( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START, emptyList() emptyList(), ) ) .doesNotContain(BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS) Loading @@ -161,7 +147,7 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { selectionManager.setSelections( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END, listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET) listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET), ) advanceUntilIdle() Loading @@ -177,11 +163,11 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { selectionManager.setSelections( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END, listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET) listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET), ) selectionManager.setSelections( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END, emptyList() emptyList(), ) assertThat(settings.getInt(Settings.Secure.LOCKSCREEN_SHOW_WALLET)).isEqualTo(0) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarOrchestratorTest.kt +2 −3 Original line number Diff line number Diff line Loading @@ -22,9 +22,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.plugins.DarkIconDispatcher import com.android.systemui.plugins.mockPluginDependencyProvider import com.android.systemui.plugins.statusbar.StatusBarStateController Loading Loading @@ -57,7 +56,7 @@ import org.mockito.kotlin.verify @RunWith(AndroidJUnit4::class) class StatusBarOrchestratorTest : SysuiTestCase() { private val kosmos = testKosmos().also { it.testDispatcher = it.unconfinedTestDispatcher } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val fakeStatusBarModePerDisplayRepository = kosmos.fakeStatusBarModePerDisplayRepository private val mockPluginDependencyProvider = kosmos.mockPluginDependencyProvider Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/MultiDisplayStatusBarContentInsetsProviderStoreTest.kt +2 −3 Original line number Diff line number Diff line Loading @@ -21,9 +21,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest Loading @@ -37,7 +36,7 @@ import org.mockito.kotlin.verify @RunWith(AndroidJUnit4::class) class MultiDisplayStatusBarContentInsetsProviderStoreTest : SysuiTestCase() { private val kosmos = testKosmos().also { it.testDispatcher = it.unconfinedTestDispatcher } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val fakeDisplayRepository = kosmos.displayRepository private val underTest = kosmos.multiDisplayStatusBarContentInsetsProviderStore Loading packages/SystemUI/multivalentTests/src/com/android/systemui/user/data/repository/UserRepositoryImplTest.kt +16 −44 Original line number Diff line number Diff line Loading @@ -24,14 +24,15 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.unconfinedTestScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.settings.FakeUserTracker import com.android.systemui.testKosmos import com.android.systemui.user.data.model.SelectedUserModel import com.android.systemui.user.data.model.SelectionStatus import com.android.systemui.user.data.model.UserSwitcherSettingsModel import com.android.systemui.util.settings.unconfinedDispatcherFakeGlobalSettings import com.android.systemui.util.settings.fakeGlobalSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers Loading @@ -52,10 +53,10 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) class UserRepositoryImplTest : SysuiTestCase() { private val kosmos = testKosmos() private val testDispatcher = kosmos.unconfinedTestDispatcher private val testScope = kosmos.unconfinedTestScope private val globalSettings = kosmos.unconfinedDispatcherFakeGlobalSettings private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope private val globalSettings = kosmos.fakeGlobalSettings @Mock private lateinit var manager: UserManager Loading Loading @@ -131,11 +132,7 @@ class UserRepositoryImplTest : SysuiTestCase() { whenever(mainUser.identifier).thenReturn(mainUserId) underTest = create(testScope.backgroundScope) val initialExpectedValue = setUpUsers( count = 3, selectedIndex = 0, ) val initialExpectedValue = setUpUsers(count = 3, selectedIndex = 0) var userInfos: List<UserInfo>? = null var selectedUserInfo: UserInfo? = null val job1 = underTest.userInfos.onEach { userInfos = it }.launchIn(this) Loading @@ -146,11 +143,7 @@ class UserRepositoryImplTest : SysuiTestCase() { assertThat(selectedUserInfo).isEqualTo(initialExpectedValue[0]) assertThat(underTest.lastSelectedNonGuestUserId).isEqualTo(selectedUserInfo?.id) val secondExpectedValue = setUpUsers( count = 4, selectedIndex = 1, ) val secondExpectedValue = setUpUsers(count = 4, selectedIndex = 1) underTest.refreshUsers() assertThat(userInfos).isEqualTo(secondExpectedValue) assertThat(selectedUserInfo).isEqualTo(secondExpectedValue[1]) Loading @@ -158,11 +151,7 @@ class UserRepositoryImplTest : SysuiTestCase() { val selectedNonGuestUserId = selectedUserInfo?.id val thirdExpectedValue = setUpUsers( count = 2, isLastGuestUser = true, selectedIndex = 1, ) setUpUsers(count = 2, isLastGuestUser = true, selectedIndex = 1) underTest.refreshUsers() assertThat(userInfos).isEqualTo(thirdExpectedValue) assertThat(selectedUserInfo).isEqualTo(thirdExpectedValue[1]) Loading @@ -177,12 +166,7 @@ class UserRepositoryImplTest : SysuiTestCase() { fun refreshUsers_sortsByCreationTime_guestUserLast() = testScope.runTest { underTest = create(testScope.backgroundScope) val unsortedUsers = setUpUsers( count = 3, selectedIndex = 0, isLastGuestUser = true, ) val unsortedUsers = setUpUsers(count = 3, selectedIndex = 0, isLastGuestUser = true) unsortedUsers[0].creationTime = 999 unsortedUsers[1].creationTime = 900 unsortedUsers[2].creationTime = 950 Loading @@ -207,10 +191,7 @@ class UserRepositoryImplTest : SysuiTestCase() { ): List<UserInfo> { val userInfos = (0 until count).map { index -> createUserInfo( index, isGuest = isLastGuestUser && index == count - 1, ) createUserInfo(index, isGuest = isLastGuestUser && index == count - 1) } whenever(manager.aliveUsers).thenReturn(userInfos) tracker.set(userInfos, selectedIndex) Loading @@ -224,16 +205,10 @@ class UserRepositoryImplTest : SysuiTestCase() { var selectedUserInfo: UserInfo? = null val job = underTest.selectedUserInfo.onEach { selectedUserInfo = it }.launchIn(this) setUpUsers( count = 2, selectedIndex = 0, ) setUpUsers(count = 2, selectedIndex = 0) tracker.onProfileChanged() assertThat(selectedUserInfo?.id).isEqualTo(0) setUpUsers( count = 2, selectedIndex = 1, ) setUpUsers(count = 2, selectedIndex = 1) tracker.onProfileChanged() assertThat(selectedUserInfo?.id).isEqualTo(1) job.cancel() Loading Loading @@ -287,10 +262,7 @@ class UserRepositoryImplTest : SysuiTestCase() { job.cancel() } private fun createUserInfo( id: Int, isGuest: Boolean, ): UserInfo { private fun createUserInfo(id: Int, isGuest: Boolean): UserInfo { val flags = 0 return UserInfo( id, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/PerDisplayStoreImplTest.kt +2 −3 Original line number Diff line number Diff line Loading @@ -20,9 +20,8 @@ import android.view.Display import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.runBlocking Loading @@ -37,7 +36,7 @@ import org.mockito.kotlin.mock @SmallTest class PerDisplayStoreImplTest : SysuiTestCase() { private val kosmos = testKosmos().also { it.testDispatcher = it.unconfinedTestDispatcher } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val fakeDisplayRepository = kosmos.displayRepository Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLegacySettingSyncerTest.kt +17 −31 Original line number Diff line number Diff line Loading @@ -23,8 +23,9 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.unconfinedTestScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.res.R import com.android.systemui.settings.FakeUserTracker import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots Loading @@ -33,7 +34,7 @@ import com.android.systemui.util.FakeSharedPreferences import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.android.systemui.util.settings.unconfinedDispatcherFakeSettings import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.advanceUntilIdle Loading @@ -51,10 +52,10 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { private val kosmos = testKosmos() private val testDispatcher = kosmos.unconfinedTestDispatcher private val testScope = kosmos.unconfinedTestScope private val settings = kosmos.unconfinedDispatcherFakeSettings private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope private val settings = kosmos.fakeSettings @Mock private lateinit var sharedPrefs: FakeSharedPreferences Loading @@ -79,13 +80,7 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { context = context, userFileManager = mock { whenever( getSharedPreferences( anyString(), anyInt(), anyInt(), ) ) whenever(getSharedPreferences(anyString(), anyInt(), anyInt())) .thenReturn(FakeSharedPreferences()) }, userTracker = FakeUserTracker(), Loading @@ -109,17 +104,14 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { testScope.runTest { val job = underTest.startSyncing() settings.putInt( Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1, ) settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1) assertThat( selectionManager .getSelections() .getOrDefault( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START, emptyList() emptyList(), ) ) .contains(BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS) Loading @@ -132,21 +124,15 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { testScope.runTest { val job = underTest.startSyncing() settings.putInt( Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1, ) settings.putInt( Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0, ) settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1) settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0) assertThat( selectionManager .getSelections() .getOrDefault( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START, emptyList() emptyList(), ) ) .doesNotContain(BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS) Loading @@ -161,7 +147,7 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { selectionManager.setSelections( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END, listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET) listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET), ) advanceUntilIdle() Loading @@ -177,11 +163,11 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { selectionManager.setSelections( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END, listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET) listOf(BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET), ) selectionManager.setSelections( KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END, emptyList() emptyList(), ) assertThat(settings.getInt(Settings.Secure.LOCKSCREEN_SHOW_WALLET)).isEqualTo(0) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarOrchestratorTest.kt +2 −3 Original line number Diff line number Diff line Loading @@ -22,9 +22,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.plugins.DarkIconDispatcher import com.android.systemui.plugins.mockPluginDependencyProvider import com.android.systemui.plugins.statusbar.StatusBarStateController Loading Loading @@ -57,7 +56,7 @@ import org.mockito.kotlin.verify @RunWith(AndroidJUnit4::class) class StatusBarOrchestratorTest : SysuiTestCase() { private val kosmos = testKosmos().also { it.testDispatcher = it.unconfinedTestDispatcher } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val fakeStatusBarModePerDisplayRepository = kosmos.fakeStatusBarModePerDisplayRepository private val mockPluginDependencyProvider = kosmos.mockPluginDependencyProvider Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/MultiDisplayStatusBarContentInsetsProviderStoreTest.kt +2 −3 Original line number Diff line number Diff line Loading @@ -21,9 +21,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest Loading @@ -37,7 +36,7 @@ import org.mockito.kotlin.verify @RunWith(AndroidJUnit4::class) class MultiDisplayStatusBarContentInsetsProviderStoreTest : SysuiTestCase() { private val kosmos = testKosmos().also { it.testDispatcher = it.unconfinedTestDispatcher } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val fakeDisplayRepository = kosmos.displayRepository private val underTest = kosmos.multiDisplayStatusBarContentInsetsProviderStore Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/user/data/repository/UserRepositoryImplTest.kt +16 −44 Original line number Diff line number Diff line Loading @@ -24,14 +24,15 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.unconfinedTestDispatcher import com.android.systemui.kosmos.unconfinedTestScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.settings.FakeUserTracker import com.android.systemui.testKosmos import com.android.systemui.user.data.model.SelectedUserModel import com.android.systemui.user.data.model.SelectionStatus import com.android.systemui.user.data.model.UserSwitcherSettingsModel import com.android.systemui.util.settings.unconfinedDispatcherFakeGlobalSettings import com.android.systemui.util.settings.fakeGlobalSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers Loading @@ -52,10 +53,10 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) class UserRepositoryImplTest : SysuiTestCase() { private val kosmos = testKosmos() private val testDispatcher = kosmos.unconfinedTestDispatcher private val testScope = kosmos.unconfinedTestScope private val globalSettings = kosmos.unconfinedDispatcherFakeGlobalSettings private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope private val globalSettings = kosmos.fakeGlobalSettings @Mock private lateinit var manager: UserManager Loading Loading @@ -131,11 +132,7 @@ class UserRepositoryImplTest : SysuiTestCase() { whenever(mainUser.identifier).thenReturn(mainUserId) underTest = create(testScope.backgroundScope) val initialExpectedValue = setUpUsers( count = 3, selectedIndex = 0, ) val initialExpectedValue = setUpUsers(count = 3, selectedIndex = 0) var userInfos: List<UserInfo>? = null var selectedUserInfo: UserInfo? = null val job1 = underTest.userInfos.onEach { userInfos = it }.launchIn(this) Loading @@ -146,11 +143,7 @@ class UserRepositoryImplTest : SysuiTestCase() { assertThat(selectedUserInfo).isEqualTo(initialExpectedValue[0]) assertThat(underTest.lastSelectedNonGuestUserId).isEqualTo(selectedUserInfo?.id) val secondExpectedValue = setUpUsers( count = 4, selectedIndex = 1, ) val secondExpectedValue = setUpUsers(count = 4, selectedIndex = 1) underTest.refreshUsers() assertThat(userInfos).isEqualTo(secondExpectedValue) assertThat(selectedUserInfo).isEqualTo(secondExpectedValue[1]) Loading @@ -158,11 +151,7 @@ class UserRepositoryImplTest : SysuiTestCase() { val selectedNonGuestUserId = selectedUserInfo?.id val thirdExpectedValue = setUpUsers( count = 2, isLastGuestUser = true, selectedIndex = 1, ) setUpUsers(count = 2, isLastGuestUser = true, selectedIndex = 1) underTest.refreshUsers() assertThat(userInfos).isEqualTo(thirdExpectedValue) assertThat(selectedUserInfo).isEqualTo(thirdExpectedValue[1]) Loading @@ -177,12 +166,7 @@ class UserRepositoryImplTest : SysuiTestCase() { fun refreshUsers_sortsByCreationTime_guestUserLast() = testScope.runTest { underTest = create(testScope.backgroundScope) val unsortedUsers = setUpUsers( count = 3, selectedIndex = 0, isLastGuestUser = true, ) val unsortedUsers = setUpUsers(count = 3, selectedIndex = 0, isLastGuestUser = true) unsortedUsers[0].creationTime = 999 unsortedUsers[1].creationTime = 900 unsortedUsers[2].creationTime = 950 Loading @@ -207,10 +191,7 @@ class UserRepositoryImplTest : SysuiTestCase() { ): List<UserInfo> { val userInfos = (0 until count).map { index -> createUserInfo( index, isGuest = isLastGuestUser && index == count - 1, ) createUserInfo(index, isGuest = isLastGuestUser && index == count - 1) } whenever(manager.aliveUsers).thenReturn(userInfos) tracker.set(userInfos, selectedIndex) Loading @@ -224,16 +205,10 @@ class UserRepositoryImplTest : SysuiTestCase() { var selectedUserInfo: UserInfo? = null val job = underTest.selectedUserInfo.onEach { selectedUserInfo = it }.launchIn(this) setUpUsers( count = 2, selectedIndex = 0, ) setUpUsers(count = 2, selectedIndex = 0) tracker.onProfileChanged() assertThat(selectedUserInfo?.id).isEqualTo(0) setUpUsers( count = 2, selectedIndex = 1, ) setUpUsers(count = 2, selectedIndex = 1) tracker.onProfileChanged() assertThat(selectedUserInfo?.id).isEqualTo(1) job.cancel() Loading Loading @@ -287,10 +262,7 @@ class UserRepositoryImplTest : SysuiTestCase() { job.cancel() } private fun createUserInfo( id: Int, isGuest: Boolean, ): UserInfo { private fun createUserInfo(id: Int, isGuest: Boolean): UserInfo { val flags = 0 return UserInfo( id, Loading