Merge changes from topic "flicker"

* changes:
  New flicker test: Add rotation to split screen test
  Ensure screenshot layer appears during rotation
  New FlickerTests: Create initial flicker tests for Pip
This commit is contained in:
Jorim Jaggi
2020-02-27 11:39:03 +00:00
committed by Gerrit Code Review
10 changed files with 291 additions and 60 deletions

View File

@@ -9,6 +9,14 @@
<option name="screen-always-on" value="on" />
<!-- prevents the phone from restarting -->
<option name="force-skip-system-props" value="true" />
<!-- set WM tracing verbose level to all -->
<option name="run-command" value="adb shell cmd window tracing level all" />
<!-- inform WM to log all transactions -->
<option name="run-command" value="adb shell cmd window tracing transaction" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.DeviceCleaner">
<!-- keeps the screen on during tests -->
<option name="cleanup-action" value="REBOOT" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true"/>

View File

@@ -144,6 +144,19 @@ public class ChangeAppRotationTest extends FlickerTestBase {
);
}
@Test
public void checkVisibility_screenshotLayerBecomesInvisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer(mTestApp.getPackage())
.then()
.replaceVisibleLayer(mTestApp.getPackage(), "Screenshot")
.then()
.showsLayer(mTestApp.getPackage()).and().showsLayer("Screenshot")
.then()
.replaceVisibleLayer("Screenshot", mTestApp.getPackage())
.forAllEntries());
}
@FlakyTest(bugId = 140855415)
@Ignore("Waiting bug feedback")
@Test

View File

@@ -20,7 +20,6 @@ import static android.os.SystemClock.sleep;
import static android.view.Surface.rotationToString;
import static com.android.server.wm.flicker.helpers.AutomationUtils.clearRecents;
import static com.android.server.wm.flicker.helpers.AutomationUtils.closePipWindow;
import static com.android.server.wm.flicker.helpers.AutomationUtils.exitSplitScreen;
import static com.android.server.wm.flicker.helpers.AutomationUtils.expandPipWindow;
import static com.android.server.wm.flicker.helpers.AutomationUtils.launchSplitScreen;
@@ -176,11 +175,15 @@ class CommonTransitions {
.repeat(ITERATIONS);
}
static TransitionBuilder appToSplitScreen(IAppHelper testApp, UiDevice device) {
static TransitionBuilder appToSplitScreen(IAppHelper testApp, UiDevice device,
int beginRotation) {
final String testTag = "appToSplitScreen_" + testApp.getLauncherName() + "_"
+ rotationToString(beginRotation);
return TransitionRunner.newBuilder()
.withTag("appToSplitScreen_" + testApp.getLauncherName())
.withTag(testTag)
.recordAllRuns()
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBeforeAll(() -> setRotation(device, beginRotation))
.runBefore(testApp::open)
.runBefore(device::waitForIdle)
.runBefore(() -> sleep(500))
@@ -285,41 +288,52 @@ class CommonTransitions {
.repeat(ITERATIONS);
}
static TransitionBuilder enterPipMode(PipAppHelper testApp, UiDevice device) {
static TransitionBuilder enterPipMode(PipAppHelper testApp, UiDevice device,
int beginRotation) {
return TransitionRunner.newBuilder()
.withTag("enterPipMode_" + testApp.getLauncherName())
.withTag("enterPipMode_" + testApp.getLauncherName()
+ rotationToString(beginRotation))
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome)
.runBefore(() -> setRotation(device, beginRotation))
.runBefore(testApp::open)
.run(() -> testApp.clickEnterPipButton(device))
.runAfter(() -> closePipWindow(device))
.runAfter(() -> testApp.closePipWindow(device))
.runAfterAll(testApp::exit)
.repeat(ITERATIONS);
}
static TransitionBuilder exitPipModeToHome(PipAppHelper testApp, UiDevice device) {
static TransitionBuilder exitPipModeToHome(PipAppHelper testApp, UiDevice device,
int beginRotation) {
return TransitionRunner.newBuilder()
.withTag("exitPipModeToHome_" + testApp.getLauncherName())
.withTag("exitPipModeToHome_" + testApp.getLauncherName()
+ rotationToString(beginRotation))
.recordAllRuns()
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome)
.runBefore(() -> setRotation(device, beginRotation))
.runBefore(testApp::open)
.runBefore(() -> testApp.clickEnterPipButton(device))
.run(() -> closePipWindow(device))
.run(() -> testApp.clickEnterPipButton(device))
.run(() -> testApp.closePipWindow(device))
.run(device::waitForIdle)
.runAfterAll(testApp::exit)
.run(testApp::exit)
.repeat(ITERATIONS);
}
static TransitionBuilder exitPipModeToApp(PipAppHelper testApp, UiDevice device) {
static TransitionBuilder exitPipModeToApp(PipAppHelper testApp, UiDevice device,
int beginRotation) {
return TransitionRunner.newBuilder()
.withTag("exitPipModeToApp_" + testApp.getLauncherName())
.withTag("exitPipModeToApp_" + testApp.getLauncherName()
+ rotationToString(beginRotation))
.recordAllRuns()
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome)
.runBefore(testApp::open)
.runBefore(() -> testApp.clickEnterPipButton(device))
.run(device::pressHome)
.run(() -> setRotation(device, beginRotation))
.run(testApp::open)
.run(() -> testApp.clickEnterPipButton(device))
.run(() -> expandPipWindow(device))
.run(device::waitForIdle)
.runAfterAll(testApp::exit)
.run(testApp::exit)
.repeat(ITERATIONS);
}
}

View File

@@ -94,7 +94,8 @@ public class DebugTest {
*/
@Test
public void openAppToSplitScreen() {
CommonTransitions.appToSplitScreen(testApp, uiDevice).includeJankyRuns().recordAllRuns()
CommonTransitions.appToSplitScreen(testApp, uiDevice,
Surface.ROTATION_0).includeJankyRuns().recordAllRuns()
.build().run();
}
@@ -116,7 +117,7 @@ public class DebugTest {
ImeAppHelper bottomApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.resizeSplitScreen(testApp, bottomApp, uiDevice, Surface.ROTATION_0,
new Rational(1, 3), new Rational(2, 3))
.includeJankyRuns().recordEachRun().build().run();
.includeJankyRuns().build().run();
}
// IME tests
@@ -128,7 +129,7 @@ public class DebugTest {
public void editTextSetFocus() {
ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.editTextSetFocus(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.includeJankyRuns()
.build().run();
}
@@ -139,7 +140,7 @@ public class DebugTest {
public void editTextLoseFocusToHome() {
ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.includeJankyRuns()
.build().run();
}
@@ -150,7 +151,7 @@ public class DebugTest {
public void editTextLoseFocusToApp() {
ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.includeJankyRuns()
.build().run();
}
@@ -162,7 +163,7 @@ public class DebugTest {
@Test
public void enterPipMode() {
PipAppHelper testApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.enterPipMode(testApp, uiDevice).includeJankyRuns().recordEachRun()
CommonTransitions.enterPipMode(testApp, uiDevice, Surface.ROTATION_0).includeJankyRuns()
.build().run();
}
@@ -172,7 +173,8 @@ public class DebugTest {
@Test
public void exitPipModeToHome() {
PipAppHelper testApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.exitPipModeToHome(testApp, uiDevice).includeJankyRuns().recordEachRun()
CommonTransitions.exitPipModeToHome(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns()
.build().run();
}
@@ -182,7 +184,7 @@ public class DebugTest {
@Test
public void exitPipModeToApp() {
PipAppHelper testApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.exitPipModeToApp(testApp, uiDevice).includeJankyRuns().recordEachRun()
CommonTransitions.exitPipModeToApp(testApp, uiDevice, Surface.ROTATION_0).includeJankyRuns()
.build().run();
}
}

View File

@@ -19,6 +19,8 @@ package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.openAppCold;
import static com.android.server.wm.flicker.WmTraceSubject.assertThat;
import android.view.Surface;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;
@@ -76,10 +78,20 @@ public class OpenAppColdTest extends NonRotationTestBase {
@Test
public void checkVisibility_wallpaperLayerBecomesInvisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("Wallpaper")
.then()
.hidesLayer("Wallpaper")
.forAllEntries());
if (mBeginRotation == Surface.ROTATION_0) {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("Wallpaper")
.then()
.replaceVisibleLayer("Wallpaper", mTestApp.getPackage())
.forAllEntries());
} else {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("Wallpaper")
.then()
.replaceVisibleLayer("Wallpaper", "Screenshot")
.then()
.showsLayer(mTestApp.getPackage())
.forAllEntries());
}
}
}

View File

@@ -17,35 +17,38 @@
package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.appToSplitScreen;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
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 open app to split screen.
* To run this test: {@code atest FlickerTests:OpenAppToSplitScreenTest}
*/
@LargeTest
@RunWith(AndroidJUnit4.class)
@RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OpenAppToSplitScreenTest extends FlickerTestBase {
public class OpenAppToSplitScreenTest extends NonRotationTestBase {
public OpenAppToSplitScreenTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation);
public OpenAppToSplitScreenTest() {
this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "SimpleApp");
}
@Before
public void runTransition() {
super.runTransition(appToSplitScreen(mTestApp, mUiDevice).includeJankyRuns().build());
super.runTransition(appToSplitScreen(mTestApp, mUiDevice, mBeginRotation)
.includeJankyRuns()
.build());
}
@Test
@@ -69,25 +72,6 @@ public class OpenAppToSplitScreenTest extends FlickerTestBase {
.forAllEntries());
}
@Test
public void checkCoveredRegion_noUncoveredRegions() {
checkResults(result ->
LayersTraceSubject.assertThat(result)
.coversRegion(getDisplayBounds()).forAllEntries());
}
@Test
public void checkVisibility_navBarLayerIsAlwaysVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
}
@Test
public void checkVisibility_statusBarLayerIsAlwaysVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer(STATUS_BAR_WINDOW_TITLE).forAllEntries());
}
@Test
public void checkVisibility_dividerLayerBecomesVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)

View File

@@ -19,6 +19,8 @@ package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.openAppWarm;
import static com.android.server.wm.flicker.WmTraceSubject.assertThat;
import android.view.Surface;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;
@@ -76,10 +78,20 @@ public class OpenAppWarmTest extends NonRotationTestBase {
@Test
public void checkVisibility_wallpaperLayerBecomesInvisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("Wallpaper")
.then()
.hidesLayer("Wallpaper")
.forAllEntries());
if (mBeginRotation == Surface.ROTATION_0) {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("Wallpaper")
.then()
.replaceVisibleLayer("Wallpaper", mTestApp.getPackage())
.forAllEntries());
} else {
checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("Wallpaper")
.then()
.replaceVisibleLayer("Wallpaper", "Screenshot")
.then()
.showsLayer(mTestApp.getPackage())
.forAllEntries());
}
}
}

View File

@@ -0,0 +1,89 @@
/*
* 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.exitPipModeToApp;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import com.android.server.wm.flicker.helpers.PipAppHelper;
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 Pip launch.
* To run this test: {@code atest FlickerTests:PipToAppTest}
*/
@LargeTest
@RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PipToAppTest extends NonRotationTestBase {
static final String sPipWindowTitle = "PipMenuActivity";
public PipToAppTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation);
this.mTestApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
}
@Before
public void runTransition() {
run(exitPipModeToApp((PipAppHelper) mTestApp, mUiDevice, mBeginRotation)
.includeJankyRuns().build());
}
@Test
public void checkVisibility_pipWindowBecomesVisible() {
checkResults(result -> WmTraceSubject.assertThat(result)
.skipUntilFirstAssertion()
.showsAppWindowOnTop(sPipWindowTitle)
.then()
.hidesAppWindow(sPipWindowTitle)
.forAllEntries());
}
@Test
public void checkVisibility_pipLayerBecomesVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.skipUntilFirstAssertion()
.showsLayer(sPipWindowTitle)
.then()
.hidesLayer(sPipWindowTitle)
.forAllEntries());
}
@Test
public void checkVisibility_backgroundWindowVisibleBehindPipLayer() {
checkResults(result -> WmTraceSubject.assertThat(result)
.skipUntilFirstAssertion()
.showsAppWindowOnTop(sPipWindowTitle)
.then()
.showsBelowAppWindow("Wallpaper")
.then()
.showsAppWindowOnTop(mTestApp.getPackage())
.then()
.hidesAppWindowOnTop(mTestApp.getPackage())
.forAllEntries());
}
}

View File

@@ -0,0 +1,93 @@
/*
* 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.exitPipModeToHome;
import android.view.Surface;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.server.wm.flicker.helpers.PipAppHelper;
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;
/**
* Test Pip launch.
* To run this test: {@code atest FlickerTests:PipToHomeTest}
*/
@LargeTest
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PipToHomeTest extends FlickerTestBase {
static final String sPipWindowTitle = "PipActivity";
// public PipToHomeTest(String beginRotationName, int beginRotation) {
public PipToHomeTest() {
// super(beginRotationName, beginRotation);
this.mTestApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
}
@Before
public void runTransition() {
// run(exitPipModeToHome((PipAppHelper) mTestApp, mUiDevice, mBeginRotation)
run(exitPipModeToHome((PipAppHelper) mTestApp, mUiDevice, Surface.ROTATION_0)
.includeJankyRuns().build());
}
@Ignore
@Test
public void checkVisibility_pipWindowBecomesVisible() {
checkResults(result -> WmTraceSubject.assertThat(result)
.skipUntilFirstAssertion()
.showsAppWindowOnTop(sPipWindowTitle)
.then()
.hidesAppWindow(sPipWindowTitle)
.forAllEntries());
}
@Test
public void checkVisibility_pipLayerBecomesVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result)
.skipUntilFirstAssertion()
.showsLayer(sPipWindowTitle)
.then()
.hidesLayer(sPipWindowTitle)
.forAllEntries());
}
@Ignore
@Test
public void checkVisibility_backgroundWindowVisibleBehindPipLayer() {
checkResults(result -> WmTraceSubject.assertThat(result)
.showsAppWindowOnTop(sPipWindowTitle)
.then()
.showsBelowAppWindow("Wallpaper")
.then()
.showsAppWindowOnTop("Wallpaper")
.forAllEntries());
}
}

View File

@@ -40,4 +40,8 @@ public class PipAppHelper extends FlickerAppHelper {
}
}
public void closePipWindow(UiDevice device) {
AutomationUtils.closePipWindow(device);
}
}