Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyevent/domain/interactor/KeyEventInteractorTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -64,10 +64,10 @@ class KeyEventInteractorTest : SysuiTestCase() { val isPowerButtonLongPressed by collectLastValue( underTest.isPowerButtonLongPressed) repository.setPowerButtonBeingLongPressed(false) repository.setPowerButtonLongPressed(false) assertThat(isPowerButtonLongPressed).isFalse() repository.setPowerButtonBeingLongPressed(true) repository.setPowerButtonLongPressed(true) assertThat(isPowerButtonLongPressed).isTrue() } } packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/SqueezeEffectInteractorTest.kt 0 → 100644 +64 −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.topwindoweffects import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.fakeSqueezeEffectRepository import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class SqueezeEffectInteractorTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val Kosmos.underTest by Kosmos.Fixture { SqueezeEffectInteractor( squeezeEffectRepository = fakeSqueezeEffectRepository ) } @Test fun testIsSqueezeEffectDisabled_whenDisabledInRepository() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = false val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isFalse() } @Test fun testIsSqueezeEffectEnabled_whenEnabledInRepository() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = true val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isTrue() } } No newline at end of file packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/SqueezeEffectRepositoryTest.kt 0 → 100644 +96 −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.topwindoweffects import android.os.Handler import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.provider.Settings.Global.POWER_BUTTON_LONG_PRESS import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.shared.Flags import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl import com.android.systemui.util.settings.FakeGlobalSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.StandardTestDispatcher import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class SqueezeEffectRepositoryTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val globalSettings = FakeGlobalSettings(StandardTestDispatcher()) @Mock private lateinit var bgHandler: Handler private val Kosmos.underTest by Kosmos.Fixture { SqueezeEffectRepositoryImpl( bgHandler = bgHandler, bgCoroutineContext = testScope.testScheduler, globalSettings = globalSettings ) } @Before fun setup() { MockitoAnnotations.initMocks(this) } @DisableFlags(Flags.FLAG_ENABLE_LPP_SQUEEZE_EFFECT) @Test fun testSqueezeEffectDisabled_WhenFlagDisabled() = kosmos.runTest { val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isFalse() } @EnableFlags(Flags.FLAG_ENABLE_LPP_SQUEEZE_EFFECT) @Test fun testSqueezeEffectDisabled_WhenFlagEnabled_GlobalSettingsDisabled() = kosmos.runTest { globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 0) val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isFalse() } @EnableFlags(Flags.FLAG_ENABLE_LPP_SQUEEZE_EFFECT) @Test fun testSqueezeEffectEnabled_WhenFlagEnabled_GlobalSettingEnabled() = kosmos.runTest { globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 5) val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isTrue() } } No newline at end of file packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt 0 → 100644 +102 −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.topwindoweffects import android.view.View import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.app.viewcapture.ViewCapture import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.fakeSqueezeEffectRepository import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot 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.any import org.mockito.kotlin.doNothing import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class TopLevelWindowEffectsTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var viewCapture: Lazy<ViewCapture> private val Kosmos.underTest by Kosmos.Fixture { TopLevelWindowEffects( context = mContext, applicationScope = testScope.backgroundScope, windowManager = ViewCaptureAwareWindowManager( windowManager = windowManager, lazyViewCapture = viewCapture, isViewCaptureEnabled = false ), squeezeEffectInteractor = SqueezeEffectInteractor( squeezeEffectRepository = fakeSqueezeEffectRepository ) ) } @Before fun setup() { MockitoAnnotations.initMocks(this) doNothing().whenever(windowManager).addView(any<View>(), any<WindowManager.LayoutParams>()) doNothing().whenever(windowManager).removeView(any<View>()) doNothing().whenever(windowManager).removeView(any<EffectsWindowRoot>()) } @Test fun noWindowWhenSqueezeEffectDisabled() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = false underTest.start() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) } @Test fun addViewToWindowWhenSqueezeEffectEnabled() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = true underTest.start() verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) } } No newline at end of file packages/SystemUI/tests/utils/src/com/android/systemui/keyevent/data/repository/FakeKeyEventRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class FakeKeyEventRepository @Inject constructor() : KeyEventRepository { _isPowerButtonDown.value = isDown } fun setPowerButtonBeingLongPressed(isLongPressed: Boolean) { fun setPowerButtonLongPressed(isLongPressed: Boolean) { _isPowerButtonLongPressed.value = isLongPressed } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyevent/domain/interactor/KeyEventInteractorTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -64,10 +64,10 @@ class KeyEventInteractorTest : SysuiTestCase() { val isPowerButtonLongPressed by collectLastValue( underTest.isPowerButtonLongPressed) repository.setPowerButtonBeingLongPressed(false) repository.setPowerButtonLongPressed(false) assertThat(isPowerButtonLongPressed).isFalse() repository.setPowerButtonBeingLongPressed(true) repository.setPowerButtonLongPressed(true) assertThat(isPowerButtonLongPressed).isTrue() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/SqueezeEffectInteractorTest.kt 0 → 100644 +64 −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.topwindoweffects import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.fakeSqueezeEffectRepository import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class SqueezeEffectInteractorTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val Kosmos.underTest by Kosmos.Fixture { SqueezeEffectInteractor( squeezeEffectRepository = fakeSqueezeEffectRepository ) } @Test fun testIsSqueezeEffectDisabled_whenDisabledInRepository() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = false val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isFalse() } @Test fun testIsSqueezeEffectEnabled_whenEnabledInRepository() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = true val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isTrue() } } No newline at end of file
packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/SqueezeEffectRepositoryTest.kt 0 → 100644 +96 −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.topwindoweffects import android.os.Handler import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.provider.Settings.Global.POWER_BUTTON_LONG_PRESS import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.shared.Flags import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl import com.android.systemui.util.settings.FakeGlobalSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.StandardTestDispatcher import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class SqueezeEffectRepositoryTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val globalSettings = FakeGlobalSettings(StandardTestDispatcher()) @Mock private lateinit var bgHandler: Handler private val Kosmos.underTest by Kosmos.Fixture { SqueezeEffectRepositoryImpl( bgHandler = bgHandler, bgCoroutineContext = testScope.testScheduler, globalSettings = globalSettings ) } @Before fun setup() { MockitoAnnotations.initMocks(this) } @DisableFlags(Flags.FLAG_ENABLE_LPP_SQUEEZE_EFFECT) @Test fun testSqueezeEffectDisabled_WhenFlagDisabled() = kosmos.runTest { val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isFalse() } @EnableFlags(Flags.FLAG_ENABLE_LPP_SQUEEZE_EFFECT) @Test fun testSqueezeEffectDisabled_WhenFlagEnabled_GlobalSettingsDisabled() = kosmos.runTest { globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 0) val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isFalse() } @EnableFlags(Flags.FLAG_ENABLE_LPP_SQUEEZE_EFFECT) @Test fun testSqueezeEffectEnabled_WhenFlagEnabled_GlobalSettingEnabled() = kosmos.runTest { globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 5) val isSqueezeEffectEnabled by collectLastValue(underTest.isSqueezeEffectEnabled) assertThat(isSqueezeEffectEnabled).isTrue() } } No newline at end of file
packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt 0 → 100644 +102 −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.topwindoweffects import android.view.View import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.app.viewcapture.ViewCapture import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.fakeSqueezeEffectRepository import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot 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.any import org.mockito.kotlin.doNothing import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class TopLevelWindowEffectsTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var viewCapture: Lazy<ViewCapture> private val Kosmos.underTest by Kosmos.Fixture { TopLevelWindowEffects( context = mContext, applicationScope = testScope.backgroundScope, windowManager = ViewCaptureAwareWindowManager( windowManager = windowManager, lazyViewCapture = viewCapture, isViewCaptureEnabled = false ), squeezeEffectInteractor = SqueezeEffectInteractor( squeezeEffectRepository = fakeSqueezeEffectRepository ) ) } @Before fun setup() { MockitoAnnotations.initMocks(this) doNothing().whenever(windowManager).addView(any<View>(), any<WindowManager.LayoutParams>()) doNothing().whenever(windowManager).removeView(any<View>()) doNothing().whenever(windowManager).removeView(any<EffectsWindowRoot>()) } @Test fun noWindowWhenSqueezeEffectDisabled() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = false underTest.start() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) } @Test fun addViewToWindowWhenSqueezeEffectEnabled() = kosmos.runTest { fakeSqueezeEffectRepository.isSqueezeEffectEnabled.value = true underTest.start() verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) } } No newline at end of file
packages/SystemUI/tests/utils/src/com/android/systemui/keyevent/data/repository/FakeKeyEventRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class FakeKeyEventRepository @Inject constructor() : KeyEventRepository { _isPowerButtonDown.value = isDown } fun setPowerButtonBeingLongPressed(isLongPressed: Boolean) { fun setPowerButtonLongPressed(isLongPressed: Boolean) { _isPowerButtonLongPressed.value = isLongPressed } } Loading