New FlickerTests: Start IME tests with app rotated by 90 degrees
Test: atest FlickerTests:CloseImeWindowToAppTest FlickerTests:CloseImeWindowToHomeTest Change-Id: Ib78e3ecf5629938b722e067027098b8c43a64771
This commit is contained in:
@@ -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 {
|
||||
|
||||
private static final String IME_WINDOW_TITLE = "InputMethod";
|
||||
private IAppHelper mImeTestApp = new StandardAppHelper(
|
||||
InstrumentationRegistry.getInstrumentation(),
|
||||
"com.android.server.wm.flicker.testapp", "ImeApp");
|
||||
static final String IME_WINDOW_TITLE = "InputMethod";
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
private static final String IME_WINDOW_TITLE = "InputMethod";
|
||||
private IAppHelper mImeTestApp = new StandardAppHelper(
|
||||
InstrumentationRegistry.getInstrumentation(),
|
||||
"com.android.server.wm.flicker.testapp", "ImeApp");
|
||||
static final String IME_WINDOW_TITLE = "InputMethod";
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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 android.view.Surface.rotationToString;
|
||||
|
||||
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.Surface;
|
||||
|
||||
import androidx.test.filters.FlakyTest;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class NonRotationTestBase extends FlickerTestBase {
|
||||
|
||||
int mBeginRotation;
|
||||
|
||||
public NonRotationTestBase(String beginRotationName, int beginRotation) {
|
||||
this.mBeginRotation = beginRotation;
|
||||
}
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static Collection<Object[]> getParams() {
|
||||
int[] supportedRotations =
|
||||
{Surface.ROTATION_0, Surface.ROTATION_90};
|
||||
Collection<Object[]> params = new ArrayList<>();
|
||||
|
||||
for (int begin : supportedRotations) {
|
||||
params.add(new Object[]{rotationToString(begin), begin});
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
@FlakyTest(bugId = 141361128)
|
||||
@Ignore("Waiting bug feedback")
|
||||
@Test
|
||||
public void checkCoveredRegion_noUncoveredRegions() {
|
||||
Rect displayBounds = getDisplayBounds(mBeginRotation);
|
||||
checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
|
||||
displayBounds).forAllEntries());
|
||||
}
|
||||
|
||||
@FlakyTest(bugId = 141361128)
|
||||
@Ignore("Waiting bug feedback")
|
||||
@Test
|
||||
public void checkVisibility_navBarLayerIsAlwaysVisible() {
|
||||
checkResults(result -> LayersTraceSubject.assertThat(result)
|
||||
.showsLayer(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
|
||||
}
|
||||
|
||||
@FlakyTest(bugId = 141361128)
|
||||
@Ignore("Waiting bug feedback")
|
||||
@Test
|
||||
public void checkVisibility_statusBarLayerIsAlwaysVisible() {
|
||||
checkResults(result -> LayersTraceSubject.assertThat(result)
|
||||
.showsLayer(STATUS_BAR_WINDOW_TITLE).forAllEntries());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user