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

Commit 04103ccf authored by Justin Weir's avatar Justin Weir
Browse files

Parameterize NotificationShadeWindowViewControllerTest

Parameterizes NotificationShadeWindowViewControllerTest for the scene
container flag.

Bug: 334874076
Test: ran affected tests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I04410751526e36c972e5ae058cd7cd894fb141e5
parent 53667488
Loading
Loading
Loading
Loading
+61 −37
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 * Copyright (C) 2024 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.
@@ -17,7 +17,7 @@
package com.android.systemui.shade

import android.content.Context
import android.testing.AndroidTestingRunner
import android.platform.test.flag.junit.FlagsParameterization
import android.testing.TestableLooper.RunWithLooper
import android.view.KeyEvent
import android.view.MotionEvent
@@ -35,9 +35,11 @@ import com.android.systemui.bouncer.ui.binder.BouncerViewBinder
import com.android.systemui.classifier.FalsingCollectorFake
import com.android.systemui.dock.DockManager
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags.LOCKSCREEN_WALLPAPER_DREAM_ENABLED
import com.android.systemui.flags.Flags.SPLIT_SHADE_SUBPIXEL_OPTIMIZATION
import com.android.systemui.flags.andSceneContainer
import com.android.systemui.keyevent.domain.interactor.SysUIKeyEventHandler
import com.android.systemui.keyguard.KeyguardUnlockAnimationController
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -45,6 +47,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler
import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor
import com.android.systemui.statusbar.DragDownHelper
@@ -69,11 +72,13 @@ import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
@@ -86,15 +91,15 @@ import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
import kotlin.test.assertEquals
import java.util.Optional
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters
import org.mockito.Mockito.`when` as whenever

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidTestingRunner::class)
@RunWith(ParameterizedAndroidJunit4::class)
@RunWithLooper(setAsMainLooper = true)
class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization?) : SysuiTestCase() {

    @Mock private lateinit var view: NotificationShadeWindowView
    @Mock private lateinit var sysuiStatusBarStateController: SysuiStatusBarStateController
@@ -150,6 +155,10 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {

    private lateinit var featureFlagsClassic: FakeFeatureFlagsClassic

    init {
        mSetFlagsRule.setFlagsParameterization(flags!!)
    }

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
@@ -166,7 +175,9 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        featureFlagsClassic = FakeFeatureFlagsClassic()
        featureFlagsClassic.set(SPLIT_SHADE_SUBPIXEL_OPTIMIZATION, true)
        featureFlagsClassic.set(LOCKSCREEN_WALLPAPER_DREAM_ENABLED, false)
        if (!SceneContainerFlag.isEnabled) {
            mSetFlagsRule.disableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
        }
        mSetFlagsRule.enableFlags(Flags.FLAG_REVAMPED_BOUNCER_MESSAGES)

        testScope = TestScope()
@@ -375,6 +386,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        }

    @Test
    @DisableSceneContainer
    fun handleDispatchTouchEvent_nsslMigrationOff_userActivity_not_called() {
        mSetFlagsRule.disableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        underTest.setStatusBarViewController(phoneStatusBarViewController)
@@ -386,7 +398,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {

    @Test
    fun handleDispatchTouchEvent_nsslMigrationOn_userActivity() {
        mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        enableMigrateClocksFlag()
        underTest.setStatusBarViewController(phoneStatusBarViewController)

        interactionEventHandler.handleDispatchTouchEvent(DOWN_EVENT)
@@ -428,7 +440,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        // AND the lock icon wants the touch
        whenever(lockIconViewController.willHandleTouchWhileDozing(DOWN_EVENT)).thenReturn(true)

        mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        enableMigrateClocksFlag()

        // THEN touch should NOT be intercepted by NotificationShade
        assertThat(interactionEventHandler.shouldInterceptTouchEvent(DOWN_EVENT)).isFalse()
@@ -447,7 +459,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        whenever(quickSettingsController.shouldQuickSettingsIntercept(any(), any(), any()))
                .thenReturn(false)

        mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        enableMigrateClocksFlag()

        // THEN touch should be intercepted by NotificationShade
        assertThat(interactionEventHandler.shouldInterceptTouchEvent(DOWN_EVENT)).isTrue()
@@ -466,7 +478,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        whenever(quickSettingsController.shouldQuickSettingsIntercept(any(), any(), any()))
                .thenReturn(true)

        mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        enableMigrateClocksFlag()

        // THEN touch should be intercepted by NotificationShade
        assertThat(interactionEventHandler.shouldInterceptTouchEvent(DOWN_EVENT)).isTrue()
@@ -493,7 +505,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        whenever(shadeViewController.handleExternalInterceptTouch(DOWN_EVENT))
                .thenReturn(true)

        mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        enableMigrateClocksFlag()

        // THEN touch should be intercepted by NotificationShade
        assertThat(interactionEventHandler.shouldInterceptTouchEvent(DOWN_EVENT)).isTrue()
@@ -616,15 +628,27 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {

    @Test
    fun cancelCurrentTouch_callsDragDownHelper() {
        mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        enableMigrateClocksFlag()
        underTest.cancelCurrentTouch()

        verify(dragDownHelper).stopDragging()
    }

    private fun enableMigrateClocksFlag() {
        if (!Flags.migrateClocksToBlueprint()) {
            mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
        }
    }

    companion object {
        private val DOWN_EVENT = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
        private val MOVE_EVENT = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_MOVE, 0f, 0f, 0)
        private const val VIEW_BOTTOM = 100

        @JvmStatic
        @Parameters(name = "{0}")
        fun getParams(): List<FlagsParameterization> {
            return FlagsParameterization.allCombinationsOf().andSceneContainer()
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class ShadeTestUtilLegacyImpl(val testScope: TestScope, val shadeRepository: Fak
    }
}

/** Sets up shade state for tests when the scene container flag is disabled. */
/** Sets up shade state for tests when the scene container flag is enabled. */
class ShadeTestUtilSceneImpl(val testScope: TestScope, val sceneInteractor: SceneInteractor) :
    ShadeTestUtilDelegate {
    override fun setShadeAndQsExpansionInternal(shadeExpansion: Float, qsExpansion: Float) {