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

Commit b685ccae authored by Evan Rosky's avatar Evan Rosky
Browse files

Fix ReOpenImeWindowTest flicker test for shell transitions

In this case, legacy transitions is incorrect because it was
written before live-tiles and, due to some quirk, still manages
to pass the now-incorrect test. However, the test is technically
wrong and thus shell transitions doesn't pass. This CL fixes the
tests when shell transitions is enabled.

Specifically, there are a few tests explicitly called "X is ALWAYS
visible" which should test that the window in question remains
visible throughout the test. However, the test was adjusted to
test that the windows go away and come back. With shell transitions
the windows behave correctly, so we can remove the adjustments.

Bug: 193565597
Test: atest ReOpenImeWindowTest
Change-Id: I33c5b6327e5b5762958b66ff20d5fe67b9566c10
Merged-In: I33c5b6327e5b5762958b66ff20d5fe67b9566c10
parent e7b68347
Loading
Loading
Loading
Loading
+36 −7
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm.flicker.ime


import android.app.Instrumentation
import android.app.Instrumentation
import android.content.ComponentName
import android.content.ComponentName
import android.os.SystemProperties
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.Presubmit
import android.view.Surface
import android.view.Surface
import android.view.WindowManagerPolicyConstants
import android.view.WindowManagerPolicyConstants
@@ -43,6 +44,7 @@ import com.android.server.wm.flicker.statusBarLayerIsVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsVisible
import com.android.server.wm.flicker.statusBarWindowIsVisible
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
import org.junit.Assume
import org.junit.FixMethodOrder
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith
@@ -61,6 +63,8 @@ import org.junit.runners.Parameterized
class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.config.startRotation)
    private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.config.startRotation)
    private val isShellTransitionsEnabled =
            SystemProperties.getBoolean("persist.debug.shell_transit", false)


    @FlickerBuilderProvider
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
    fun buildFlicker(): FlickerBuilder {
@@ -122,15 +126,17 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {


    @Presubmit
    @Presubmit
    @Test
    @Test
    fun imeWindowIsAlwaysVisible() = testSpec.imeWindowIsAlwaysVisible(true)
    fun imeWindowIsAlwaysVisible() = testSpec.imeWindowIsAlwaysVisible(!isShellTransitionsEnabled)


    @Presubmit
    @Presubmit
    @Test
    @Test
    fun imeAppWindowVisibility() {
    fun imeAppWindowVisibilityLegacy() {
        // the app starts visible in live tile, then becomes invisible during animation and
        Assume.assumeFalse(isShellTransitionsEnabled)
        // is again launched. Since we log 1x per frame, sometimes the activity visibility and
        // the app starts visible in live tile, and stays visible for the duration of entering
        // the app visibility are updated together, sometimes not, thus ignore activity check
        // and exiting overview. However, legacy transitions seem to have a bug which causes
        // at the start
        // everything to restart during the test, so expect the app to disappear and come back.
        // Since we log 1x per frame, sometimes the activity visibility and the app visibility
        // are updated together, sometimes not, thus ignore activity check at the start
        testSpec.assertWm {
        testSpec.assertWm {
            this.isAppWindowVisible(testApp.component, ignoreActivity = true)
            this.isAppWindowVisible(testApp.component, ignoreActivity = true)
                    .then()
                    .then()
@@ -140,6 +146,19 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
        }
        }
    }
    }


    @Presubmit
    @Test
    fun imeAppWindowVisibility() {
        Assume.assumeTrue(isShellTransitionsEnabled)
        // the app starts visible in live tile, and stays visible for the duration of entering
        // and exiting overview. Since we log 1x per frame, sometimes the activity visibility
        // and the app visibility are updated together, sometimes not, thus ignore activity
        // check at the start
        testSpec.assertWm {
            this.isAppWindowVisible(testApp.component, ignoreActivity = true)
        }
    }

    @Presubmit
    @Presubmit
    @Test
    @Test
    // During testing the launcher is always in portrait mode
    // During testing the launcher is always in portrait mode
@@ -155,7 +174,8 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {


    @Presubmit
    @Presubmit
    @Test
    @Test
    fun imeLayerIsBecomesVisible() {
    fun imeLayerIsBecomesVisibleLegacy() {
        Assume.assumeFalse(isShellTransitionsEnabled)
        testSpec.assertLayers {
        testSpec.assertLayers {
            this.isVisible(WindowManagerStateHelper.IME_COMPONENT)
            this.isVisible(WindowManagerStateHelper.IME_COMPONENT)
                    .then()
                    .then()
@@ -165,6 +185,15 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
        }
        }
    }
    }


    @Presubmit
    @Test
    fun imeLayerIsBecomesVisible() {
        Assume.assumeTrue(isShellTransitionsEnabled)
        testSpec.assertLayers {
            this.isVisible(WindowManagerStateHelper.IME_COMPONENT)
        }
    }

    @Presubmit
    @Presubmit
    @Test
    @Test
    fun appLayerReplacesLauncher() {
    fun appLayerReplacesLauncher() {