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

Commit af3a5e49 authored by Nataniel Borges's avatar Nataniel Borges Committed by android-build-merger
Browse files

New FlickerTests: Start IME alongside the app (0 and 90 degrees)

am: 4bfe8160

Change-Id: Ia0c5764de88d26e8bf5df5e8b09108f610845821
parents 679b4f29 4bfe8160
Loading
Loading
Loading
Loading
+77 −0
Original line number Original line 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 Original line 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();
    }
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@ import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusT
import androidx.test.InstrumentationRegistry;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.filters.LargeTest;


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

import org.junit.Before;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.Test;
@@ -42,14 +44,12 @@ public class CloseImeWindowToAppTest extends NonRotationTestBase {
    public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) {
    public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);
        super(beginRotationName, beginRotation);


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


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


+4 −5
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@ import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusT
import androidx.test.InstrumentationRegistry;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.filters.LargeTest;


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

import org.junit.Before;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.Test;
@@ -42,15 +44,12 @@ public class CloseImeWindowToHomeTest extends NonRotationTestBase {
    public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) {
    public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) {
        super(beginRotationName, beginRotation);
        super(beginRotationName, beginRotation);


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


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


+20 −45
Original line number Original line Diff line number Diff line
@@ -37,10 +37,10 @@ import android.support.test.uiautomator.Until;
import android.util.Rational;
import android.util.Rational;
import android.view.Surface;
import android.view.Surface;


import androidx.test.InstrumentationRegistry;

import com.android.server.wm.flicker.TransitionRunner.TransitionBuilder;
import com.android.server.wm.flicker.TransitionRunner.TransitionBuilder;
import com.android.server.wm.flicker.helpers.AutomationUtils;
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.
 * Collection of common transitions which can be used to test different apps or scenarios.
@@ -73,18 +73,6 @@ 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
    static TransitionBuilder openAppWarm(IAppHelper testApp, UiDevice
            device) {
            device) {
        return TransitionRunner.newBuilder()
        return TransitionRunner.newBuilder()
@@ -201,15 +189,16 @@ class CommonTransitions {
                .repeat(ITERATIONS);
                .repeat(ITERATIONS);
    }
    }


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


    static TransitionBuilder editTextLoseFocusToHome(IAppHelper testApp, UiDevice device,
    static TransitionBuilder editTextLoseFocusToHome(ImeAppHelper testApp, UiDevice device,
            int beginRotation, boolean clickOnEditText) {
            int beginRotation) {
        return TransitionRunner.newBuilder()
        return TransitionRunner.newBuilder()
                .withTag("editTextLoseFocusToHome_" + testApp.getLauncherName()
                .withTag("editTextLoseFocusToHome_" + testApp.getLauncherName()
                        + rotationToString(beginRotation))
                        + rotationToString(beginRotation))
@@ -252,19 +241,15 @@ class CommonTransitions {
                .runBefore(device::pressHome)
                .runBefore(device::pressHome)
                .runBefore(() -> setRotation(device, beginRotation))
                .runBefore(() -> setRotation(device, beginRotation))
                .runBefore(testApp::open)
                .runBefore(testApp::open)
                .runBefore(() -> {
                .runBefore(() -> testApp.clickEditTextWidget(device))
                    if (clickOnEditText) {
                        clickEditTextWidget(device, testApp);
                    }
                })
                .run(device::pressHome)
                .run(device::pressHome)
                .run(device::waitForIdle)
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
                .runAfterAll(testApp::exit)
                .repeat(ITERATIONS);
                .repeat(ITERATIONS);
    }
    }


    static TransitionBuilder editTextLoseFocusToApp(IAppHelper testApp, UiDevice device,
    static TransitionBuilder editTextLoseFocusToApp(ImeAppHelper testApp, UiDevice device,
            int beginRotation, boolean clickOnEditText) {
            int beginRotation) {
        return TransitionRunner.newBuilder()
        return TransitionRunner.newBuilder()
                .withTag("editTextLoseFocusToApp_" + testApp.getLauncherName()
                .withTag("editTextLoseFocusToApp_" + testApp.getLauncherName()
                        + rotationToString(beginRotation))
                        + rotationToString(beginRotation))
@@ -272,55 +257,45 @@ class CommonTransitions {
                .runBefore(device::pressHome)
                .runBefore(device::pressHome)
                .runBefore(() -> setRotation(device, beginRotation))
                .runBefore(() -> setRotation(device, beginRotation))
                .runBefore(testApp::open)
                .runBefore(testApp::open)
                .runBefore(() -> {
                .runBefore(() -> testApp.clickEditTextWidget(device))
                    if (clickOnEditText) {
                        clickEditTextWidget(device, testApp);
                    }
                })
                .run(device::pressBack)
                .run(device::pressBack)
                .run(device::waitForIdle)
                .run(device::waitForIdle)
                .runAfterAll(testApp::exit)
                .runAfterAll(testApp::exit)
                .repeat(ITERATIONS);
                .repeat(ITERATIONS);
    }
    }


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


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


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