Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3685ea5 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Android (Google) Code Review
Browse files

Merge changes I40eeeda1,I942da826 into main

* changes:
  [SB][ComposeIcons] Sort icons based on ordered slot names
  [SB][ComposeIcons] Add OrderedIconSlotNamesRepository
parents 2c60891e 2d20afe1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
@@ -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)
        }

+6 −6
Original line number Diff line number Diff line
@@ -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
@@ -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

@@ -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(
@@ -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
+11 −15
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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
+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()
        }
}
+5 −7
Original line number Diff line number Diff line
@@ -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
@@ -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

@@ -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