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

Commit 2a1e8c10 authored by Charles Chen's avatar Charles Chen
Browse files

Verify whether bubble task view bounds match task

Test: atest EnterBubbleViaBubbleMenuTest
Bug: 396020056
Flag: TEST_ONLY

Change-Id: Iadd0779d0eb694dfa43308229217a454810aef39
parent 57c7a87a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ import org.junit.runners.Parameterized
 *
 * Actions:
 * ```
 *     Long press [simpleApp] icon to show [AppIconMenu].
 *     Click the bubble menu to launch [simpleApp] into bubble.
 *     Long press [testApp] icon to show app icon menu.
 *     Click the bubble menu to launch [testApp] into bubble.
 * ```
 * Verified tests:
 * - [BubbleFlickerTestBase]
+38 −0
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package com.android.wm.shell.flicker.bubbles.testcase

import android.tools.traces.component.ComponentNameMatcher
import android.tools.traces.component.ComponentNameMatcher.Companion.BUBBLE
import android.tools.traces.component.ComponentNameMatcher.Companion.BUBBLE_TASK_VIEW
import android.tools.traces.component.ComponentNameMatcher.Companion.LAUNCHER
import android.tools.traces.component.IComponentNameMatcher
import com.android.server.wm.flicker.helpers.ImeAppHelper
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerSubjects
import org.junit.Test

@@ -145,4 +147,40 @@ interface BubbleAppBecomesExpandedTestCases : BubbleFlickerSubjects {
        layerTraceEntrySubjectAtEnd.visibleRegion(BUBBLE)
            .coversAtLeast(layerTraceEntrySubjectAtEnd.visibleRegion(testApp).region)
    }

    /**
     * Verifies whether the below bounds match:
     * - Bubble task bounds in WM hierarchy
     * - Bubble task layer bounds
     * - Bubble task view layer bounds
     */
    @Test
    fun bubbleTaskBoundsMatchBubbleTaskView() {
        // Get the WM task bounds of bubble app.
        val bubbleAppTask = wmStateSubjectAtEnd.wmState.getTaskForActivity(testApp)
            ?: error("Bubble app task not found")
        val taskBounds = bubbleAppTask.bounds
        // Get the task layer bounds of bubble app.
        val taskLayer = layerTraceEntrySubjectAtEnd
            .findAncestorLayer(testApp) { it.isTask }
            ?: error("Bubble app task layer not found")
        val taskLayerBounds = taskLayer.screenBounds
        // Get the bounds of bubble task view layer.
        val bubbleTaskViewLayer = layerTraceEntrySubjectAtEnd
            .findAncestorLayer(testApp) {
                BUBBLE_TASK_VIEW.layerMatchesAnyOf(it)
            } ?: error("Bubble app task view not found")
        val bubbleTaskViewLayerBounds = bubbleTaskViewLayer.screenBounds

        if (testApp is ImeAppHelper) {
            // If the IME shows, the task and task view layer may be resized to fit the IME layer,
            // while WM task bounds remain unchanged.
            bubbleTaskViewLayerBounds.coversExactly(taskLayerBounds.region)
            bubbleTaskViewLayerBounds.coversAtMost(taskBounds)
        } else {
            // Otherwise, bubble task view bounds must match task bounds.
            bubbleTaskViewLayerBounds.coversExactly(taskLayerBounds.region)
            taskLayerBounds.coversExactly(taskBounds)
        }
    }
}
 No newline at end of file
+5 −2
Original line number Diff line number Diff line
@@ -456,9 +456,12 @@ internal object BubbleFlickerTestHelper {

        waitAndAssertBubbleAppInExpandedState(testApp, wmHelper)

        // The bubble will be occluded if IME shows.
        if (testApp !is ImeAppHelper) {
            assertWithMessage("The education must not show for Application bubble")
                .that(Root.get().bubble.isEducationVisible).isFalse()
        }
    }

    private fun waitAndAssertBubbleAppInExpandedState(
        testApp: StandardAppHelper,