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

Commit 89888bf1 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

New FlickerTests: Start IME tests with app rotated by 90 degrees

Test: atest FlickerTests:CloseImeWindowToAppTest FlickerTests:CloseImeWindowToHomeTest
Change-Id: Ib78e3ecf5629938b722e067027098b8c43a64771
parent 7943776f
Loading
Loading
Loading
Loading
+15 −19
Original line number Diff line number Diff line
@@ -17,37 +17,39 @@
package com.android.server.wm.flicker;

import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusToApp;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;

import android.platform.helpers.IAppHelper;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;

/**
 * Test IME window closing back to app window transitions.
 * To run this test: {@code atest FlickerTests:CloseImeWindowToAppTest}
 */
@LargeTest
@RunWith(AndroidJUnit4.class)
@RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CloseImeWindowToAppTest extends FlickerTestBase {
public class CloseImeWindowToAppTest extends NonRotationTestBase {

    static final String IME_WINDOW_TITLE = "InputMethod";

    private static final String IME_WINDOW_TITLE = "InputMethod";
    private IAppHelper mImeTestApp = new StandardAppHelper(
    public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);

        mTestApp = new StandardAppHelper(
                InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "ImeApp");
    }

    @Before
    public void runTransition() {
        super.runTransition(editTextLoseFocusToApp(mUiDevice)
        run(editTextLoseFocusToApp(mTestApp, mUiDevice, mBeginRotation, /* clickOnEditField */true)
                .includeJankyRuns().build());
    }

@@ -63,20 +65,14 @@ public class CloseImeWindowToAppTest extends FlickerTestBase {
    @Test
    public void checkVisibility_imeAppLayerIsAlwaysVisible() {
        checkResults(result -> LayersTraceSubject.assertThat(result)
                .showsLayer(mImeTestApp.getPackage())
                .showsLayer(mTestApp.getPackage())
                .forAllEntries());
    }

    @Test
    public void checkVisibility_imeAppWindowIsAlwaysVisible() {
        checkResults(result -> WmTraceSubject.assertThat(result)
                .showsAppWindowOnTop(mImeTestApp.getPackage())
                .showsAppWindowOnTop(mTestApp.getPackage())
                .forAllEntries());
    }

    @Test
    public void checkCoveredRegion_noUncoveredRegions() {
        checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
                getDisplayBounds()).forAllEntries());
    }
}
+18 −21
Original line number Diff line number Diff line
@@ -17,37 +17,40 @@
package com.android.server.wm.flicker;

import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusToHome;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;

import android.platform.helpers.IAppHelper;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;

/**
 * Test IME window closing to home transitions.
 * To run this test: {@code atest FlickerTests:CloseImeWindowToHomeTest}
 */
@LargeTest
@RunWith(AndroidJUnit4.class)
@RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CloseImeWindowToHomeTest extends FlickerTestBase {
public class CloseImeWindowToHomeTest extends NonRotationTestBase {

    static final String IME_WINDOW_TITLE = "InputMethod";

    private static final String IME_WINDOW_TITLE = "InputMethod";
    private IAppHelper mImeTestApp = new StandardAppHelper(
    public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);

        mTestApp = new StandardAppHelper(
                InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "ImeApp");
    }

    @Before
    public void runTransition() {
        super.runTransition(editTextLoseFocusToHome(mUiDevice)
        run(editTextLoseFocusToHome(mTestApp, mUiDevice, mBeginRotation,
                /* clickOnEditField */ true)
                .includeJankyRuns().build());
    }

@@ -72,24 +75,18 @@ public class CloseImeWindowToHomeTest extends FlickerTestBase {
    @Test
    public void checkVisibility_imeAppLayerBecomesInvisible() {
        checkResults(result -> LayersTraceSubject.assertThat(result)
                .showsLayer(mImeTestApp.getPackage())
                .showsLayer(mTestApp.getPackage())
                .then()
                .hidesLayer(mImeTestApp.getPackage())
                .hidesLayer(mTestApp.getPackage())
                .forAllEntries());
    }

    @Test
    public void checkVisibility_imeAppWindowBecomesInvisible() {
        checkResults(result -> WmTraceSubject.assertThat(result)
                .showsAppWindowOnTop(mImeTestApp.getPackage())
                .showsAppWindowOnTop(mTestApp.getPackage())
                .then()
                .hidesAppWindowOnTop(mImeTestApp.getPackage())
                .hidesAppWindowOnTop(mTestApp.getPackage())
                .forAllEntries());
    }

    @Test
    public void checkCoveredRegion_noUncoveredRegions() {
        checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
                getDisplayBounds()).forAllEntries());
    }
}
+20 −10
Original line number Diff line number Diff line
@@ -243,30 +243,40 @@ class CommonTransitions {
                .repeat(ITERATIONS);
    }

    static TransitionBuilder editTextLoseFocusToHome(UiDevice device) {
        IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "ImeApp");
    static TransitionBuilder editTextLoseFocusToHome(IAppHelper testApp, UiDevice device,
            int beginRotation, boolean clickOnEditText) {
        return TransitionRunner.newBuilder()
                .withTag("editTextLoseFocusToHome_" + testApp.getLauncherName())
                .withTag("editTextLoseFocusToHome_" + testApp.getLauncherName()
                        + rotationToString(beginRotation))
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBefore(device::pressHome)
                .runBefore(() -> setRotation(device, beginRotation))
                .runBefore(testApp::open)
                .runBefore(() -> clickEditTextWidget(device, testApp))
                .runBefore(() -> {
                    if (clickOnEditText) {
                        clickEditTextWidget(device, testApp);
                    }
                })
                .run(device::pressHome)
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
                .repeat(ITERATIONS);
    }

    static TransitionBuilder editTextLoseFocusToApp(UiDevice device) {
        IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "ImeApp");
    static TransitionBuilder editTextLoseFocusToApp(IAppHelper testApp, UiDevice device,
            int beginRotation, boolean clickOnEditText) {
        return TransitionRunner.newBuilder()
                .withTag("editTextLoseFocusToApp_" + testApp.getLauncherName())
                .withTag("editTextLoseFocusToApp_" + testApp.getLauncherName()
                        + rotationToString(beginRotation))
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBefore(device::pressHome)
                .runBefore(() -> setRotation(device, beginRotation))
                .runBefore(testApp::open)
                .runBefore(() -> clickEditTextWidget(device, testApp))
                .runBefore(() -> {
                    if (clickOnEditText) {
                        clickEditTextWidget(device, testApp);
                    }
                })
                .run(device::pressBack)
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
+6 −2
Original line number Diff line number Diff line
@@ -130,7 +130,10 @@ public class DebugTest {
     */
    @Test
    public void editTextLoseFocusToHome() {
        CommonTransitions.editTextLoseFocusToHome(uiDevice).includeJankyRuns().recordEachRun()
        IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "ImeApp");
        CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0,
                /* clickOnEditField */true).includeJankyRuns().recordEachRun()
                .build().run();
    }

@@ -139,7 +142,8 @@ public class DebugTest {
     */
    @Test
    public void editTextLoseFocusToApp() {
        CommonTransitions.editTextLoseFocusToHome(uiDevice).includeJankyRuns().recordEachRun()
        CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0,
                /* clickOnEditField */true).includeJankyRuns().recordEachRun()
                .build().run();
    }

+8 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ public class FlickerTestBase {
    /**
     * Runs a transition, returns a cached result if the transition has run before.
     */
    void runTransition(TransitionRunner transition) {
    void run(TransitionRunner transition) {
        if (transitionResults.containsKey(transition.getTestTag())) {
            mResults = transitionResults.get(transition.getTestTag());
            return;
@@ -110,6 +110,13 @@ public class FlickerTestBase {
        transitionResults.put(transition.getTestTag(), mResults);
    }

    /**
     * Runs a transition, returns a cached result if the transition has run before.
     */
    void runTransition(TransitionRunner transition) {
        run(transition);
    }

    /**
     * Goes through a list of transition results and checks assertions on each result.
     */
Loading