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

Commit d1f61363 authored by Eric Lin's avatar Eric Lin
Browse files

Remove FlickerPropertyInitializer helper class.

Remove the unnecessary FlickerPropertyInitializer helper class since
BubbleFlickerTestBase already contains all required flicker test
properties. The FlickerPropertyInitializer was creating duplicate
instances of instrumentation, uiDevice, wmHelper, tapl, and testApp
fields that were redundant with the parent test base class.

Consolidate all flicker properties directly into a named companion
object called FlickerProperties within BubbleFlickerTestBase for better
readability and organization. This eliminates the inheritance chain
while maintaining the same functionality. Test classes can still declare
their own testApp in their companion object and override the
BubbleFlickerTestBase#testApp property when needed, such as for tests
requiring specialized app helpers like ImeShownOnAppStartHelper or
ScrollToFinishHelper.

This refactoring simplifies the class hierarchy, reduces code
duplication, and makes the test structure more straightforward without
changing the existing test behavior or capabilities.

Bug: 387193964
Flag: EXEMPT TEST_ONLY
Test: atest WMShellExplicitFlickerTestsBubbles
Change-Id: I57d1c2765646fc6f8c90b68cd0939b00ab846f40
parent b1963dc6
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.flicker.bubbles

import android.graphics.Point
import android.platform.systemui_tapl.ui.Root
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresFlagsEnabled
@@ -28,7 +29,6 @@ import com.android.wm.shell.flicker.bubbles.utils.ApplyPerParameterRule
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.collapseBubbleAppViaTouchOutside
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.expandBubbleAppViaBubbleBar
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.launchBubbleViaBubbleMenu
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import com.google.common.truth.Truth.assertWithMessage
import org.junit.Assume.assumeTrue
@@ -66,12 +66,11 @@ import org.junit.runners.Parameterized
@Presubmit
@RunWith(Parameterized::class)
class BubbleBarMovesTest(navBar: NavBar) : BubbleFlickerTestBase(), ExpandBubbleTestCases {
    companion object : FlickerPropertyInitializer() {

        /**
         * Whether the bubble bar position is changed.
         */
        private var bubbleBarPosChanges: Boolean = false
    companion object {

        private lateinit var bubbleBarBeforeTransition: Point
        private lateinit var bubbleBarAfterTransition: Point

        private val recordTraceWithTransitionRule = RecordTraceWithTransitionRule(
            setUpBeforeTransition = {
@@ -80,10 +79,9 @@ class BubbleBarMovesTest(navBar: NavBar) : BubbleFlickerTestBase(), ExpandBubble
                collapseBubbleAppViaTouchOutside(testApp, wmHelper)
            },
            transition = {
                val bubbleBarBeforeTransition = Root.get().bubbleBar.visibleCenter
                bubbleBarBeforeTransition = Root.get().bubbleBar.visibleCenter
                Root.get().bubbleBar.dragToTheOtherSide()
                val bubbleBarAfterTransition = Root.get().bubbleBar.visibleCenter
                bubbleBarPosChanges = (bubbleBarBeforeTransition != bubbleBarAfterTransition)
                bubbleBarAfterTransition = Root.get().bubbleBar.visibleCenter
                expandBubbleAppViaBubbleBar(testApp, uiDevice, wmHelper)
            },
            tearDownAfterTransition = { testApp.exit(wmHelper) }
@@ -97,7 +95,7 @@ class BubbleBarMovesTest(navBar: NavBar) : BubbleFlickerTestBase(), ExpandBubble
    @get:Rule
    val setUpRule = ApplyPerParameterRule(
        Utils.testSetupRule(navBar).around(recordTraceWithTransitionRule),
        params = arrayOf(navBar)
        params = arrayOf(navBar),
    )

    override val traceDataReader
@@ -116,7 +114,7 @@ class BubbleBarMovesTest(navBar: NavBar) : BubbleFlickerTestBase(), ExpandBubble
    @Test
    fun bubbleBarMovesToTheOtherSide() {
        assertWithMessage("The bubble bar position must be changed")
            .that(bubbleBarPosChanges)
            .isTrue()
            .that(bubbleBarAfterTransition)
            .isNotEqualTo(bubbleBarBeforeTransition)
    }
}
+4 −10
Original line number Diff line number Diff line
@@ -28,15 +28,12 @@ import com.android.wm.shell.flicker.bubbles.testcase.BubbleAlwaysVisibleTestCase
import com.android.wm.shell.flicker.bubbles.utils.ApplyPerParameterRule
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.collapseBubbleAppViaTouchOutside
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.launchBubbleViaBubbleMenu
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.Rule
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Test that when the taskbar is shown, the bubble bar is also shown.
@@ -66,12 +63,12 @@ import org.junit.runners.Parameterized
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Presubmit
@RunWith(Parameterized::class)
class BubbleBarVisibilityTest(navBar: NavBar) : BubbleFlickerTestBase(),
class BubbleBarVisibilityTest : BubbleFlickerTestBase(),
    BubbleAlwaysVisibleTestCases {

    companion object : FlickerPropertyInitializer() {
    companion object {
        private val fullscreenApp = NonResizeableAppHelper(instrumentation)

        private val recordTraceWithTransitionRule = RecordTraceWithTransitionRule(
            setUpBeforeTransition = {
                launchBubbleViaBubbleMenu(testApp, tapl, wmHelper)
@@ -106,15 +103,12 @@ class BubbleBarVisibilityTest(navBar: NavBar) : BubbleFlickerTestBase(),
        )

        // Don't verify 3-button because the task bar is persistent.
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun data(): List<NavBar> = listOf(NavBar.MODE_GESTURAL)
        private val navBar = NavBar.MODE_GESTURAL
    }

    @get:Rule
    val setUpRule = ApplyPerParameterRule(
        Utils.testSetupRule(navBar).around(recordTraceWithTransitionRule),
        params = arrayOf(navBar)
    )

    override val traceDataReader
+36 −7
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.flicker.bubbles

import android.app.Instrumentation
import android.platform.test.flag.junit.CheckFlagsRule
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import android.tools.Tag
@@ -28,15 +29,18 @@ import android.tools.flicker.subject.wm.WindowManagerStateSubject
import android.tools.flicker.subject.wm.WindowManagerTraceSubject
import android.tools.io.Reader
import android.tools.traces.component.ComponentNameMatcher
import android.tools.traces.parsers.WindowManagerStateHelper
import android.tools.traces.surfaceflinger.LayerTraceEntry
import android.tools.traces.wm.WindowManagerState
import androidx.annotation.CallSuper
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel
import com.android.server.wm.flicker.assertNavBarPosition
import com.android.server.wm.flicker.assertStatusBarLayerPosition
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerSubjects
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -100,12 +104,11 @@ abstract class BubbleFlickerTestBase : BubbleFlickerSubjects {
    override val isGesturalNavBar = tapl.navigationModel == NavigationModel.ZERO_BUTTON

    /**
     * The test app to verify.
     * The app used in flicker tests to verify with.
     *
     * Note that it's necessary to override this `testApp` if the test use [SimpleAppHelper].
     * Note that it's necessary to override this [testApp] if the test use [SimpleAppHelper].
     */
    override val testApp: StandardAppHelper
        get() = BubbleFlickerTestBase.testApp
    override val testApp: StandardAppHelper = FlickerProperties.testApp

    /**
     * Initialize subjects inherited from [FlickerSubject].
@@ -235,5 +238,31 @@ abstract class BubbleFlickerTestBase : BubbleFlickerSubjects {

// endregion

    companion object : FlickerPropertyInitializer()
    /**
     * Essential properties to launch flicker tests.
     */
    companion object FlickerProperties {
        val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
        val uiDevice: UiDevice = UiDevice.getInstance(instrumentation)

        /**
         * Helper class to wait on [WindowManagerState] or [LayerTraceEntry] conditions.
         *
         * This is also used to wait for transition completes.
         */
        val wmHelper = WindowManagerStateHelper(
            instrumentation,
            clearCacheAfterParsing = false,
        )

        /**
         * Used for building the scenario.
         */
        val tapl: LauncherInstrumentation = LauncherInstrumentation()

        /**
         * The default app used in flicker tests to verify with.
         */
        val testApp: StandardAppHelper = SimpleAppHelper(instrumentation)
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import com.android.wm.shell.flicker.bubbles.testcase.BubbleAlwaysVisibleTestCase
import com.android.wm.shell.flicker.bubbles.utils.ApplyPerParameterRule
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.collapseBubbleAppViaBackKey
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.launchBubbleViaBubbleMenu
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import com.google.common.truth.Truth
import org.junit.Assume
@@ -68,7 +67,7 @@ class BubbleIconMoveTest(navBar: NavBar) :
    BubbleFlickerTestBase(),
    BubbleAlwaysVisibleTestCases {

    companion object : FlickerPropertyInitializer() {
    companion object {
        private var bubblePositionChanged = false

        private val recordTraceWithTransitionRule = RecordTraceWithTransitionRule(
@@ -98,7 +97,7 @@ class BubbleIconMoveTest(navBar: NavBar) :
    @get:Rule
    val setUpRule = ApplyPerParameterRule(
        Utils.testSetupRule(navBar).around(recordTraceWithTransitionRule),
        params = arrayOf(navBar)
        params = arrayOf(navBar),
    )

    override val traceDataReader
+2 −4
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import com.android.wm.shell.flicker.bubbles.utils.ApplyPerParameterRule
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.BubbleLaunchSource.FROM_TASK_BAR
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.collapseBubbleAppViaTouchOutside
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.launchBubbleViaBubbleMenu
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import org.junit.Assume
import org.junit.Before
@@ -65,8 +64,7 @@ import org.junit.runners.Parameterized
class CollapseBubbleAppFromOverviewTest(navBar: NavBar) : BubbleFlickerTestBase(),
    CollapseBubbleAppTestCases {

    companion object : FlickerPropertyInitializer() {

    companion object {
        private val recordTraceWithTransitionRule = RecordTraceWithTransitionRule(
            setUpBeforeTransition = {
                launchBubbleViaBubbleMenu(testApp, tapl, wmHelper, fromSource = FROM_TASK_BAR)
@@ -92,7 +90,7 @@ class CollapseBubbleAppFromOverviewTest(navBar: NavBar) : BubbleFlickerTestBase(
    @get:Rule
    val setUpRule = ApplyPerParameterRule(
        Utils.testSetupRule(navBar).around(recordTraceWithTransitionRule),
        params = arrayOf(navBar)
        params = arrayOf(navBar),
    )

    override val traceDataReader
Loading