Loading packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt +18 −7 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.DEFAULT_INITIAL_DELAY_MILLIS import com.android.systemui.topwindoweffects.data.repository.DEFAULT_LONG_PRESS_POWER_DURATION_MILLIS Loading @@ -50,6 +51,7 @@ import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.mockito.verification.VerificationMode @SmallTest @RunWith(AndroidJUnit4::class) Loading @@ -59,6 +61,8 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController @Mock private lateinit var viewModelFactory: SqueezeEffectViewModel.Factory private val Kosmos.underTest by Loading @@ -73,6 +77,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { squeezeEffectInteractor = SqueezeEffectInteractor(squeezeEffectRepository = fakeSqueezeEffectRepository), appZoomOutOptional = Optional.empty(), notificationShadeWindowController = notificationShadeWindowController, ) } Loading @@ -97,7 +102,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { underTest.start() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } @Test Loading @@ -113,7 +118,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { // add additional 1ms time to simulate initial delay duration has passed advanceTime((expectedDelay + 1).milliseconds) verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(times(1)) } @Test Loading @@ -129,7 +134,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { // subtract 1ms time to simulate initial delay duration is yet not finished advanceTime((expectedDelay - 1).milliseconds) verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } @Test Loading @@ -149,7 +154,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } @Test Loading @@ -169,7 +174,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(times(1)) } @Test Loading @@ -190,7 +195,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(times(1)) } @Test Loading @@ -211,6 +216,12 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } private fun verifyAddViewAndTopUi(mode: VerificationMode) { verify(windowManager, mode).addView(any<View>(), any<WindowManager.LayoutParams>()) verify(notificationShadeWindowController, mode) .setRequestTopUi(true, TopLevelWindowEffects.TAG) } } packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt +10 −1 Original line number Diff line number Diff line Loading @@ -22,11 +22,13 @@ import android.view.Gravity import android.view.WindowInsets import android.view.WindowManager import androidx.annotation.DrawableRes import androidx.annotation.VisibleForTesting import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.keyevent.domain.interactor.KeyEventInteractor import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel Loading Loading @@ -54,6 +56,7 @@ constructor( private val viewModelFactory: SqueezeEffectViewModel.Factory, // TODO(b/409930584): make AppZoomOut non-optional private val appZoomOutOptional: Optional<AppZoomOut>, private val notificationShadeWindowController: NotificationShadeWindowController, ) : CoreStartable { private var root: EffectsWindowRoot? = null Loading Loading @@ -99,6 +102,7 @@ constructor( physicalPixelDisplaySizeRatio: Float, ) { if (root == null) { notificationShadeWindowController.setRequestTopUi(true, TAG) root = EffectsWindowRoot( context = context, Loading @@ -107,6 +111,7 @@ constructor( bottomRoundedCornerResourceId = bottomRoundedCornerId, physicalPixelDisplaySizeRatio = physicalPixelDisplaySizeRatio, onEffectFinished = { notificationShadeWindowController.setRequestTopUi(false, TAG) if (root?.isAttachedToWindow == true) { windowManager.removeView(root) root = null Loading Loading @@ -148,4 +153,8 @@ constructor( return lp } companion object { @VisibleForTesting const val TAG = "TopLevelWindowEffects" } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt +18 −7 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.testKosmos import com.android.systemui.topwindoweffects.data.repository.DEFAULT_INITIAL_DELAY_MILLIS import com.android.systemui.topwindoweffects.data.repository.DEFAULT_LONG_PRESS_POWER_DURATION_MILLIS Loading @@ -50,6 +51,7 @@ import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.mockito.verification.VerificationMode @SmallTest @RunWith(AndroidJUnit4::class) Loading @@ -59,6 +61,8 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController @Mock private lateinit var viewModelFactory: SqueezeEffectViewModel.Factory private val Kosmos.underTest by Loading @@ -73,6 +77,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { squeezeEffectInteractor = SqueezeEffectInteractor(squeezeEffectRepository = fakeSqueezeEffectRepository), appZoomOutOptional = Optional.empty(), notificationShadeWindowController = notificationShadeWindowController, ) } Loading @@ -97,7 +102,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { underTest.start() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } @Test Loading @@ -113,7 +118,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { // add additional 1ms time to simulate initial delay duration has passed advanceTime((expectedDelay + 1).milliseconds) verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(times(1)) } @Test Loading @@ -129,7 +134,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { // subtract 1ms time to simulate initial delay duration is yet not finished advanceTime((expectedDelay - 1).milliseconds) verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } @Test Loading @@ -149,7 +154,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } @Test Loading @@ -169,7 +174,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(times(1)) } @Test Loading @@ -190,7 +195,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, times(1)).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(times(1)) } @Test Loading @@ -211,6 +216,12 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { runCurrent() verify(windowManager, never()).addView(any<View>(), any<WindowManager.LayoutParams>()) verifyAddViewAndTopUi(never()) } private fun verifyAddViewAndTopUi(mode: VerificationMode) { verify(windowManager, mode).addView(any<View>(), any<WindowManager.LayoutParams>()) verify(notificationShadeWindowController, mode) .setRequestTopUi(true, TopLevelWindowEffects.TAG) } }
packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt +10 −1 Original line number Diff line number Diff line Loading @@ -22,11 +22,13 @@ import android.view.Gravity import android.view.WindowInsets import android.view.WindowManager import androidx.annotation.DrawableRes import androidx.annotation.VisibleForTesting import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.keyevent.domain.interactor.KeyEventInteractor import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel Loading Loading @@ -54,6 +56,7 @@ constructor( private val viewModelFactory: SqueezeEffectViewModel.Factory, // TODO(b/409930584): make AppZoomOut non-optional private val appZoomOutOptional: Optional<AppZoomOut>, private val notificationShadeWindowController: NotificationShadeWindowController, ) : CoreStartable { private var root: EffectsWindowRoot? = null Loading Loading @@ -99,6 +102,7 @@ constructor( physicalPixelDisplaySizeRatio: Float, ) { if (root == null) { notificationShadeWindowController.setRequestTopUi(true, TAG) root = EffectsWindowRoot( context = context, Loading @@ -107,6 +111,7 @@ constructor( bottomRoundedCornerResourceId = bottomRoundedCornerId, physicalPixelDisplaySizeRatio = physicalPixelDisplaySizeRatio, onEffectFinished = { notificationShadeWindowController.setRequestTopUi(false, TAG) if (root?.isAttachedToWindow == true) { windowManager.removeView(root) root = null Loading Loading @@ -148,4 +153,8 @@ constructor( return lp } companion object { @VisibleForTesting const val TAG = "TopLevelWindowEffects" } }