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

Commit f2a739d5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "flicker-rotation"

* changes:
  New FlickerTests: Run split screen tests at 0 and 90 degrees
  New FlickerTests: Start app warm and cold at both 0 and 90 degrees
  New FlickerTests: Start IME alongside the app (0 and 90 degrees)
  New FlickerTests: Start IME tests with app rotated by 90 degrees
parents e8e63908 40c517af
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm.flicker;

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

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;

import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper;

import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
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(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CloseImeAutoOpenWindowToAppTest extends CloseImeWindowToAppTest {

    public CloseImeAutoOpenWindowToAppTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);

        mTestApp = new ImeAppAutoFocusHelper(InstrumentationRegistry.getInstrumentation());
    }

    @Before
    public void runTransition() {
        run(editTextLoseFocusToApp((ImeAppAutoFocusHelper) mTestApp, mUiDevice, mBeginRotation)
                .includeJankyRuns().build());
    }

    @FlakyTest(bugId = 141458352)
    @Ignore("Waiting bug feedback")
    @Test
    public void checkVisibility_imeLayerBecomesInvisible() {
        super.checkVisibility_imeLayerBecomesInvisible();
    }

    @FlakyTest(bugId = 141458352)
    @Ignore("Waiting bug feedback")
    @Test
    public void checkVisibility_imeAppLayerIsAlwaysVisible() {
        super.checkVisibility_imeAppLayerIsAlwaysVisible();
    }

    @FlakyTest(bugId = 141458352)
    @Ignore("Waiting bug feedback")
    @Test
    public void checkVisibility_imeAppWindowIsAlwaysVisible() {
        super.checkVisibility_imeAppWindowIsAlwaysVisible();
    }

}
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm.flicker;

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

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;

import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper;

import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
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(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CloseImeAutoOpenWindowToHomeTest extends CloseImeWindowToHomeTest {

    public CloseImeAutoOpenWindowToHomeTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);

        mTestApp = new ImeAppAutoFocusHelper(InstrumentationRegistry.getInstrumentation());
    }

    @Before
    public void runTransition() {
        run(editTextLoseFocusToHome((ImeAppAutoFocusHelper) mTestApp, mUiDevice, mBeginRotation)
                .includeJankyRuns().build());
    }

    @FlakyTest(bugId = 141458352)
    @Ignore("Waiting bug feedback")
    @Test
    public void checkVisibility_imeWindowBecomesInvisible() {
        super.checkVisibility_imeWindowBecomesInvisible();
    }

    @FlakyTest(bugId = 141458352)
    @Ignore("Waiting bug feedback")
    @Test
    public void checkVisibility_imeLayerBecomesInvisible() {
        super.checkVisibility_imeLayerBecomesInvisible();
    }
}
+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 com.android.server.wm.flicker.helpers.ImeAppHelper;

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";

    public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);

    private static final String IME_WINDOW_TITLE = "InputMethod";
    private IAppHelper mImeTestApp = new StandardAppHelper(
            InstrumentationRegistry.getInstrumentation(),
            "com.android.server.wm.flicker.testapp", "ImeApp");
        mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
    }

    @Before
    public void runTransition() {
        super.runTransition(editTextLoseFocusToApp(mUiDevice)
        run(editTextLoseFocusToApp((ImeAppHelper) mTestApp, mUiDevice, mBeginRotation)
                .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());
    }
}
+17 −21
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.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 com.android.server.wm.flicker.helpers.ImeAppHelper;

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";

    public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);

    private static final String IME_WINDOW_TITLE = "InputMethod";
    private IAppHelper mImeTestApp = new StandardAppHelper(
            InstrumentationRegistry.getInstrumentation(),
            "com.android.server.wm.flicker.testapp", "ImeApp");
        mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
    }

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

@@ -72,24 +74,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());
    }
}
+43 −49
Original line number Diff line number Diff line
@@ -37,10 +37,10 @@ import android.support.test.uiautomator.Until;
import android.util.Rational;
import android.view.Surface;

import androidx.test.InstrumentationRegistry;

import com.android.server.wm.flicker.TransitionRunner.TransitionBuilder;
import com.android.server.wm.flicker.helpers.AutomationUtils;
import com.android.server.wm.flicker.helpers.ImeAppHelper;
import com.android.server.wm.flicker.helpers.PipAppHelper;

/**
 * Collection of common transitions which can be used to test different apps or scenarios.
@@ -73,26 +73,17 @@ class CommonTransitions {
        }
    }

    private static void clickEditTextWidget(UiDevice device, IAppHelper testApp) {
        UiObject2 editText = device.findObject(By.res(testApp.getPackage(), "plain_text_input"));
        editText.click();
        sleep(500);
    }

    private static void clickEnterPipButton(UiDevice device, IAppHelper testApp) {
        UiObject2 enterPipButton = device.findObject(By.res(testApp.getPackage(), "enter_pip"));
        enterPipButton.click();
        sleep(500);
    }

    static TransitionBuilder openAppWarm(IAppHelper testApp, UiDevice
            device) {
            device, int beginRotation) {
        return TransitionRunner.newBuilder()
                .withTag("OpenAppWarm_" + testApp.getLauncherName())
                .withTag("OpenAppWarm_" + testApp.getLauncherName()
                        + rotationToString(beginRotation))
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBeforeAll(() -> setRotation(device, beginRotation))
                .runBeforeAll(testApp::open)
                .runBefore(device::pressHome)
                .runBefore(device::waitForIdle)
                .runBefore(() -> setRotation(device, beginRotation))
                .run(testApp::open)
                .runAfterAll(testApp::exit)
                .runAfterAll(AutomationUtils::setDefaultWait)
@@ -127,16 +118,19 @@ class CommonTransitions {
                .repeat(ITERATIONS);
    }

    static TransitionBuilder getOpenAppCold(IAppHelper testApp,
            UiDevice device) {
    static TransitionBuilder openAppCold(IAppHelper testApp,
            UiDevice device, int beginRotation) {
        return TransitionRunner.newBuilder()
                .withTag("OpenAppCold_" + testApp.getLauncherName())
                .withTag("OpenAppCold_" + testApp.getLauncherName()
                        + rotationToString(beginRotation))
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBefore(device::pressHome)
                .runBeforeAll(() -> setRotation(device, beginRotation))
                .runBefore(testApp::exit)
                .runBefore(device::waitForIdle)
                .run(testApp::open)
                .runAfterAll(testApp::exit)
                .runAfterAll(() -> setRotation(device, Surface.ROTATION_0))
                .repeat(ITERATIONS);
    }

@@ -201,28 +195,31 @@ class CommonTransitions {
                .repeat(ITERATIONS);
    }

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

    static TransitionBuilder resizeSplitScreen(IAppHelper testAppTop, IAppHelper testAppBottom,
            UiDevice device, Rational startRatio, Rational stopRatio) {
    static TransitionBuilder resizeSplitScreen(IAppHelper testAppTop, ImeAppHelper testAppBottom,
            UiDevice device, int beginRotation, Rational startRatio, Rational stopRatio) {
        String testTag = "resizeSplitScreen_" + testAppTop.getLauncherName() + "_"
                + testAppBottom.getLauncherName() + "_"
                + startRatio.toString().replace("/", ":") + "_to_"
                + stopRatio.toString().replace("/", ":");
                + stopRatio.toString().replace("/", ":") + "_"
                + rotationToString(beginRotation);
        return TransitionRunner.newBuilder()
                .withTag(testTag)
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBeforeAll(() -> setRotation(device, beginRotation))
                .runBeforeAll(() -> clearRecents(device))
                .runBefore(testAppBottom::open)
                .runBefore(device::pressHome)
@@ -234,6 +231,7 @@ class CommonTransitions {
                            By.res(device.getLauncherPackageName(), "snapshot"));
                    snapshot.click();
                })
                .runBefore(() -> testAppBottom.clickEditTextWidget(device))
                .runBefore(() -> AutomationUtils.resizeSplitScreen(device, startRatio))
                .run(() -> AutomationUtils.resizeSplitScreen(device, stopRatio))
                .runAfter(() -> exitSplitScreen(device))
@@ -243,74 +241,70 @@ 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(ImeAppHelper testApp, UiDevice device,
            int beginRotation) {
        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(() -> testApp.clickEditTextWidget(device))
                .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(ImeAppHelper testApp, UiDevice device,
            int beginRotation) {
        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(() -> testApp.clickEditTextWidget(device))
                .run(device::pressBack)
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
                .repeat(ITERATIONS);
    }

    static TransitionBuilder enterPipMode(UiDevice device) {
        IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "PipApp");
    static TransitionBuilder enterPipMode(PipAppHelper testApp, UiDevice device) {
        return TransitionRunner.newBuilder()
                .withTag("enterPipMode_" + testApp.getLauncherName())
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBefore(device::pressHome)
                .runBefore(testApp::open)
                .run(() -> clickEnterPipButton(device, testApp))
                .run(() -> testApp.clickEnterPipButton(device))
                .runAfter(() -> closePipWindow(device))
                .runAfterAll(testApp::exit)
                .repeat(ITERATIONS);
    }

    static TransitionBuilder exitPipModeToHome(UiDevice device) {
        IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "PipApp");
    static TransitionBuilder exitPipModeToHome(PipAppHelper testApp, UiDevice device) {
        return TransitionRunner.newBuilder()
                .withTag("exitPipModeToHome_" + testApp.getLauncherName())
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBefore(device::pressHome)
                .runBefore(testApp::open)
                .runBefore(() -> clickEnterPipButton(device, testApp))
                .runBefore(() -> testApp.clickEnterPipButton(device))
                .run(() -> closePipWindow(device))
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
                .repeat(ITERATIONS);
    }

    static TransitionBuilder exitPipModeToApp(UiDevice device) {
        IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
                "com.android.server.wm.flicker.testapp", "PipApp");
    static TransitionBuilder exitPipModeToApp(PipAppHelper testApp, UiDevice device) {
        return TransitionRunner.newBuilder()
                .withTag("exitPipModeToApp_" + testApp.getLauncherName())
                .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
                .runBefore(device::pressHome)
                .runBefore(testApp::open)
                .runBefore(() -> clickEnterPipButton(device, testApp))
                .runBefore(() -> testApp.clickEnterPipButton(device))
                .run(() -> expandPipWindow(device))
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
Loading