summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNataniel Borges <natanieljr@google.com>2019-09-23 15:45:41 +0200
committerNataniel Borges <natanieljr@google.com>2019-09-25 16:10:50 +0200
commit89888bf124e9eb59d04e77895cd671b9421d658e (patch)
treedb4c6824ec761f207d86964d4456bbbca029fc80 /tests
parent7943776f9afcec14ab53b00222199fbae1676dd3 (diff)
New FlickerTests: Start IME tests with app rotated by 90 degrees
Test: atest FlickerTests:CloseImeWindowToAppTest FlickerTests:CloseImeWindowToHomeTest Change-Id: Ib78e3ecf5629938b722e067027098b8c43a64771
Diffstat (limited to 'tests')
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java34
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java39
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java30
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java8
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java9
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/NonRotationTestBase.java80
6 files changed, 147 insertions, 53 deletions
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java
index 9deb97726542..00bb5ac4ae7e 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java
@@ -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(
- InstrumentationRegistry.getInstrumentation(),
- "com.android.server.wm.flicker.testapp", "ImeApp");
+ 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());
- }
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java
index cce5a2a7cc0d..f69bb3abb036 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java
@@ -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(
- InstrumentationRegistry.getInstrumentation(),
- "com.android.server.wm.flicker.testapp", "ImeApp");
+ 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());
- }
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java
index 1d44ea490f25..e3da88685e0b 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java
@@ -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)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java
index 9836655bc013..cedd88c0056a 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java
@@ -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();
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java b/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java
index 6e8e0c3c76c5..883d59ea8a92 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java
@@ -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;
@@ -111,6 +111,13 @@ public class FlickerTestBase {
}
/**
+ * 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.
*/
void checkResults(Consumer<TransitionResult> assertion) {
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/NonRotationTestBase.java b/tests/FlickerTests/src/com/android/server/wm/flicker/NonRotationTestBase.java
new file mode 100644
index 000000000000..54941dc0f585
--- /dev/null
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/NonRotationTestBase.java
@@ -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());
+ }
+}