Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeHomeStatusBarViewModel.kt +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel import android.content.Context import android.graphics.Color import android.graphics.Rect import android.graphics.RectF Loading Loading @@ -88,7 +89,7 @@ class FakeHomeStatusBarViewModel( override val systemStatusIconsViewModelFactory: SystemStatusIconsViewModel.Factory = object : SystemStatusIconsViewModel.Factory { override fun create(): SystemStatusIconsViewModel = override fun create(context: Context): SystemStatusIconsViewModel = mock(SystemStatusIconsViewModel::class.java) } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/airplane/ui/viewmodel/AirplaneModeIconViewModelTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.systemstatusicons.airplane.ui.viewmodel import android.content.testableContext import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -32,7 +33,6 @@ import com.android.systemui.statusbar.pipeline.shared.data.repository.connectivi import com.android.systemui.statusbar.pipeline.shared.data.repository.fake import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -41,7 +41,7 @@ import org.junit.runner.RunWith class AirplaneModeIconViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val underTest = kosmos.airplaneModeIconViewModelFactory.create() private val fakeConnectivityRepository = kosmos.connectivityRepository.fake private val expectedAirplaneIcon = Icon.Resource( Loading @@ -49,9 +49,9 @@ class AirplaneModeIconViewModelTest : SysuiTestCase() { contentDescription = ContentDescription.Resource(R.string.accessibility_airplane_mode), ) @Before fun setUp() { underTest.activateIn(kosmos.testScope) private val underTest = kosmos.airplaneModeIconViewModelFactory.create(kosmos.testableContext).apply { activateIn(kosmos.testScope) } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/bluetooth/ui/viewmodel/BluetoothIconViewModelTest.kt +11 −15 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.systemstatusicons.bluetooth.ui.viewmodel import android.bluetooth.BluetoothProfile import android.content.testableContext import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading @@ -33,11 +34,9 @@ import com.android.systemui.statusbar.policy.bluetooth.data.repository.bluetooth import com.android.systemui.statusbar.systemstatusicons.SystemStatusIconsInCompose import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @SmallTest Loading @@ -46,17 +45,14 @@ import org.mockito.kotlin.whenever class BluetoothIconViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() @Mock private lateinit var cachedDevice: CachedBluetoothDevice private lateinit var underTest: BluetoothIconViewModel @Before fun setUp() { MockitoAnnotations.openMocks(this) whenever(cachedDevice.isConnected).thenReturn(true) whenever(cachedDevice.maxConnectionState).thenReturn(BluetoothProfile.STATE_CONNECTED) underTest = kosmos.bluetoothIconViewModelFactory.create() underTest.activateIn(kosmos.testScope) private val cachedDevice = mock<CachedBluetoothDevice>().apply { whenever(isConnected).thenReturn(true) whenever(maxConnectionState).thenReturn(BluetoothProfile.STATE_CONNECTED) } private val underTest = kosmos.bluetoothIconViewModelFactory.create(kosmos.testableContext).apply { activateIn(kosmos.testScope) } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/data/repository/OrderedIconSlotNamesRepositoryTest.kt 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.systemstatusicons.data.repository import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class OrderedIconSlotNamesRepositoryTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() @Test fun repository_orderPreserved() = kosmos.runTest { val iconSlotNames = arrayOf("A", "B", "C") kosmos.statusBarConfigIconSlotNames = iconSlotNames assertThat(orderedIconSlotNamesRepository.orderedIconSlotNames.value) .isEqualTo(iconSlotNames.toList()) } @Test fun repository_usesEmptyList() = kosmos.runTest { kosmos.statusBarConfigIconSlotNames = emptyArray<String>() assertThat(orderedIconSlotNamesRepository.orderedIconSlotNames.value).isEmpty() } } packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/ethernet/ui/viewmodel/EthernetIconViewModelTest.kt +5 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.systemstatusicons.ethernet.ui.viewmodel import android.content.testableContext import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.AccessibilityContentDescriptions Loading @@ -32,7 +33,6 @@ import com.android.systemui.statusbar.pipeline.shared.data.repository.connectivi import com.android.systemui.statusbar.pipeline.shared.data.repository.fake import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -45,11 +45,9 @@ class EthernetIconViewModelTest : SysuiTestCase() { kosmos.connectivityRepository.fake } private val underTest = kosmos.ethernetIconViewModelFactory.create() @Before fun setUp() { underTest.activateIn(kosmos.testScope) private val underTest = kosmos.ethernetIconViewModelFactory.create(kosmos.testableContext).apply { activateIn(kosmos.testScope) } @Test Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeHomeStatusBarViewModel.kt +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel import android.content.Context import android.graphics.Color import android.graphics.Rect import android.graphics.RectF Loading Loading @@ -88,7 +89,7 @@ class FakeHomeStatusBarViewModel( override val systemStatusIconsViewModelFactory: SystemStatusIconsViewModel.Factory = object : SystemStatusIconsViewModel.Factory { override fun create(): SystemStatusIconsViewModel = override fun create(context: Context): SystemStatusIconsViewModel = mock(SystemStatusIconsViewModel::class.java) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/airplane/ui/viewmodel/AirplaneModeIconViewModelTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.systemstatusicons.airplane.ui.viewmodel import android.content.testableContext import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -32,7 +33,6 @@ import com.android.systemui.statusbar.pipeline.shared.data.repository.connectivi import com.android.systemui.statusbar.pipeline.shared.data.repository.fake import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -41,7 +41,7 @@ import org.junit.runner.RunWith class AirplaneModeIconViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val underTest = kosmos.airplaneModeIconViewModelFactory.create() private val fakeConnectivityRepository = kosmos.connectivityRepository.fake private val expectedAirplaneIcon = Icon.Resource( Loading @@ -49,9 +49,9 @@ class AirplaneModeIconViewModelTest : SysuiTestCase() { contentDescription = ContentDescription.Resource(R.string.accessibility_airplane_mode), ) @Before fun setUp() { underTest.activateIn(kosmos.testScope) private val underTest = kosmos.airplaneModeIconViewModelFactory.create(kosmos.testableContext).apply { activateIn(kosmos.testScope) } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/bluetooth/ui/viewmodel/BluetoothIconViewModelTest.kt +11 −15 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.systemstatusicons.bluetooth.ui.viewmodel import android.bluetooth.BluetoothProfile import android.content.testableContext import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading @@ -33,11 +34,9 @@ import com.android.systemui.statusbar.policy.bluetooth.data.repository.bluetooth import com.android.systemui.statusbar.systemstatusicons.SystemStatusIconsInCompose import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @SmallTest Loading @@ -46,17 +45,14 @@ import org.mockito.kotlin.whenever class BluetoothIconViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() @Mock private lateinit var cachedDevice: CachedBluetoothDevice private lateinit var underTest: BluetoothIconViewModel @Before fun setUp() { MockitoAnnotations.openMocks(this) whenever(cachedDevice.isConnected).thenReturn(true) whenever(cachedDevice.maxConnectionState).thenReturn(BluetoothProfile.STATE_CONNECTED) underTest = kosmos.bluetoothIconViewModelFactory.create() underTest.activateIn(kosmos.testScope) private val cachedDevice = mock<CachedBluetoothDevice>().apply { whenever(isConnected).thenReturn(true) whenever(maxConnectionState).thenReturn(BluetoothProfile.STATE_CONNECTED) } private val underTest = kosmos.bluetoothIconViewModelFactory.create(kosmos.testableContext).apply { activateIn(kosmos.testScope) } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/data/repository/OrderedIconSlotNamesRepositoryTest.kt 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.systemstatusicons.data.repository import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class OrderedIconSlotNamesRepositoryTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() @Test fun repository_orderPreserved() = kosmos.runTest { val iconSlotNames = arrayOf("A", "B", "C") kosmos.statusBarConfigIconSlotNames = iconSlotNames assertThat(orderedIconSlotNamesRepository.orderedIconSlotNames.value) .isEqualTo(iconSlotNames.toList()) } @Test fun repository_usesEmptyList() = kosmos.runTest { kosmos.statusBarConfigIconSlotNames = emptyArray<String>() assertThat(orderedIconSlotNamesRepository.orderedIconSlotNames.value).isEmpty() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/systemstatusicons/ethernet/ui/viewmodel/EthernetIconViewModelTest.kt +5 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.systemstatusicons.ethernet.ui.viewmodel import android.content.testableContext import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.AccessibilityContentDescriptions Loading @@ -32,7 +33,6 @@ import com.android.systemui.statusbar.pipeline.shared.data.repository.connectivi import com.android.systemui.statusbar.pipeline.shared.data.repository.fake import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -45,11 +45,9 @@ class EthernetIconViewModelTest : SysuiTestCase() { kosmos.connectivityRepository.fake } private val underTest = kosmos.ethernetIconViewModelFactory.create() @Before fun setUp() { underTest.activateIn(kosmos.testScope) private val underTest = kosmos.ethernetIconViewModelFactory.create(kosmos.testableContext).apply { activateIn(kosmos.testScope) } @Test Loading