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
This commit is contained in:
Treehugger Robot
2019-09-27 14:21:58 +00:00
committed by Gerrit Code Review
19 changed files with 592 additions and 235 deletions

View File

@@ -0,0 +1,77 @@
/*
* 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();
}
}

View File

@@ -0,0 +1,69 @@
/*
* 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();
}
}

View File

@@ -17,37 +17,39 @@
package com.android.server.wm.flicker; package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusToApp; 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.InstrumentationRegistry;
import androidx.test.filters.LargeTest; 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.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
/** /**
* Test IME window closing back to app window transitions. * Test IME window closing back to app window transitions.
* To run this test: {@code atest FlickerTests:CloseImeWindowToAppTest} * To run this test: {@code atest FlickerTests:CloseImeWindowToAppTest}
*/ */
@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CloseImeWindowToAppTest extends FlickerTestBase { public class CloseImeWindowToAppTest extends NonRotationTestBase {
private static final String IME_WINDOW_TITLE = "InputMethod"; static final String IME_WINDOW_TITLE = "InputMethod";
private IAppHelper mImeTestApp = new StandardAppHelper(
InstrumentationRegistry.getInstrumentation(), public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) {
"com.android.server.wm.flicker.testapp", "ImeApp"); super(beginRotationName, beginRotation);
mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
}
@Before @Before
public void runTransition() { public void runTransition() {
super.runTransition(editTextLoseFocusToApp(mUiDevice) run(editTextLoseFocusToApp((ImeAppHelper) mTestApp, mUiDevice, mBeginRotation)
.includeJankyRuns().build()); .includeJankyRuns().build());
} }
@@ -63,20 +65,14 @@ public class CloseImeWindowToAppTest extends FlickerTestBase {
@Test @Test
public void checkVisibility_imeAppLayerIsAlwaysVisible() { public void checkVisibility_imeAppLayerIsAlwaysVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result) checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer(mImeTestApp.getPackage()) .showsLayer(mTestApp.getPackage())
.forAllEntries()); .forAllEntries());
} }
@Test @Test
public void checkVisibility_imeAppWindowIsAlwaysVisible() { public void checkVisibility_imeAppWindowIsAlwaysVisible() {
checkResults(result -> WmTraceSubject.assertThat(result) checkResults(result -> WmTraceSubject.assertThat(result)
.showsAppWindowOnTop(mImeTestApp.getPackage()) .showsAppWindowOnTop(mTestApp.getPackage())
.forAllEntries()); .forAllEntries());
} }
@Test
public void checkCoveredRegion_noUncoveredRegions() {
checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
getDisplayBounds()).forAllEntries());
}
} }

View File

@@ -17,37 +17,39 @@
package com.android.server.wm.flicker; package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusToHome; 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.InstrumentationRegistry;
import androidx.test.filters.LargeTest; 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.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
/** /**
* Test IME window closing to home transitions. * Test IME window closing to home transitions.
* To run this test: {@code atest FlickerTests:CloseImeWindowToHomeTest} * To run this test: {@code atest FlickerTests:CloseImeWindowToHomeTest}
*/ */
@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CloseImeWindowToHomeTest extends FlickerTestBase { public class CloseImeWindowToHomeTest extends NonRotationTestBase {
private static final String IME_WINDOW_TITLE = "InputMethod"; static final String IME_WINDOW_TITLE = "InputMethod";
private IAppHelper mImeTestApp = new StandardAppHelper(
InstrumentationRegistry.getInstrumentation(), public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) {
"com.android.server.wm.flicker.testapp", "ImeApp"); super(beginRotationName, beginRotation);
mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
}
@Before @Before
public void runTransition() { public void runTransition() {
super.runTransition(editTextLoseFocusToHome(mUiDevice) run(editTextLoseFocusToHome((ImeAppHelper) mTestApp, mUiDevice, mBeginRotation)
.includeJankyRuns().build()); .includeJankyRuns().build());
} }
@@ -72,24 +74,18 @@ public class CloseImeWindowToHomeTest extends FlickerTestBase {
@Test @Test
public void checkVisibility_imeAppLayerBecomesInvisible() { public void checkVisibility_imeAppLayerBecomesInvisible() {
checkResults(result -> LayersTraceSubject.assertThat(result) checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer(mImeTestApp.getPackage()) .showsLayer(mTestApp.getPackage())
.then() .then()
.hidesLayer(mImeTestApp.getPackage()) .hidesLayer(mTestApp.getPackage())
.forAllEntries()); .forAllEntries());
} }
@Test @Test
public void checkVisibility_imeAppWindowBecomesInvisible() { public void checkVisibility_imeAppWindowBecomesInvisible() {
checkResults(result -> WmTraceSubject.assertThat(result) checkResults(result -> WmTraceSubject.assertThat(result)
.showsAppWindowOnTop(mImeTestApp.getPackage()) .showsAppWindowOnTop(mTestApp.getPackage())
.then() .then()
.hidesAppWindowOnTop(mImeTestApp.getPackage()) .hidesAppWindowOnTop(mTestApp.getPackage())
.forAllEntries()); .forAllEntries());
} }
@Test
public void checkCoveredRegion_noUncoveredRegions() {
checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
getDisplayBounds()).forAllEntries());
}
} }

View File

@@ -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,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 static TransitionBuilder openAppWarm(IAppHelper testApp, UiDevice
device) { device, int beginRotation) {
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("OpenAppWarm_" + testApp.getLauncherName()) .withTag("OpenAppWarm_" + testApp.getLauncherName()
+ rotationToString(beginRotation))
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBeforeAll(() -> setRotation(device, beginRotation))
.runBeforeAll(testApp::open) .runBeforeAll(testApp::open)
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(device::waitForIdle) .runBefore(device::waitForIdle)
.runBefore(() -> setRotation(device, beginRotation))
.run(testApp::open) .run(testApp::open)
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.runAfterAll(AutomationUtils::setDefaultWait) .runAfterAll(AutomationUtils::setDefaultWait)
@@ -127,16 +118,19 @@ class CommonTransitions {
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder getOpenAppCold(IAppHelper testApp, static TransitionBuilder openAppCold(IAppHelper testApp,
UiDevice device) { UiDevice device, int beginRotation) {
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("OpenAppCold_" + testApp.getLauncherName()) .withTag("OpenAppCold_" + testApp.getLauncherName()
+ rotationToString(beginRotation))
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBeforeAll(() -> setRotation(device, beginRotation))
.runBefore(testApp::exit) .runBefore(testApp::exit)
.runBefore(device::waitForIdle) .runBefore(device::waitForIdle)
.run(testApp::open) .run(testApp::open)
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.runAfterAll(() -> setRotation(device, Surface.ROTATION_0))
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
@@ -201,28 +195,31 @@ 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);
} }
static TransitionBuilder resizeSplitScreen(IAppHelper testAppTop, IAppHelper testAppBottom, static TransitionBuilder resizeSplitScreen(IAppHelper testAppTop, ImeAppHelper testAppBottom,
UiDevice device, Rational startRatio, Rational stopRatio) { UiDevice device, int beginRotation, Rational startRatio, Rational stopRatio) {
String testTag = "resizeSplitScreen_" + testAppTop.getLauncherName() + "_" String testTag = "resizeSplitScreen_" + testAppTop.getLauncherName() + "_"
+ testAppBottom.getLauncherName() + "_" + testAppBottom.getLauncherName() + "_"
+ startRatio.toString().replace("/", ":") + "_to_" + startRatio.toString().replace("/", ":") + "_to_"
+ stopRatio.toString().replace("/", ":"); + stopRatio.toString().replace("/", ":") + "_"
+ rotationToString(beginRotation);
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag(testTag) .withTag(testTag)
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBeforeAll(() -> setRotation(device, beginRotation))
.runBeforeAll(() -> clearRecents(device)) .runBeforeAll(() -> clearRecents(device))
.runBefore(testAppBottom::open) .runBefore(testAppBottom::open)
.runBefore(device::pressHome) .runBefore(device::pressHome)
@@ -234,6 +231,7 @@ class CommonTransitions {
By.res(device.getLauncherPackageName(), "snapshot")); By.res(device.getLauncherPackageName(), "snapshot"));
snapshot.click(); snapshot.click();
}) })
.runBefore(() -> testAppBottom.clickEditTextWidget(device))
.runBefore(() -> AutomationUtils.resizeSplitScreen(device, startRatio)) .runBefore(() -> AutomationUtils.resizeSplitScreen(device, startRatio))
.run(() -> AutomationUtils.resizeSplitScreen(device, stopRatio)) .run(() -> AutomationUtils.resizeSplitScreen(device, stopRatio))
.runAfter(() -> exitSplitScreen(device)) .runAfter(() -> exitSplitScreen(device))
@@ -243,74 +241,70 @@ class CommonTransitions {
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder editTextLoseFocusToHome(UiDevice device) { static TransitionBuilder editTextLoseFocusToHome(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("editTextLoseFocusToHome_" + testApp.getLauncherName()) .withTag("editTextLoseFocusToHome_" + 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)
.runBefore(() -> clickEditTextWidget(device, testApp)) .runBefore(() -> testApp.clickEditTextWidget(device))
.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(UiDevice device) { static TransitionBuilder editTextLoseFocusToApp(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("editTextLoseFocusToApp_" + testApp.getLauncherName()) .withTag("editTextLoseFocusToApp_" + 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)
.runBefore(() -> clickEditTextWidget(device, testApp)) .runBefore(() -> testApp.clickEditTextWidget(device))
.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)

View File

@@ -25,6 +25,9 @@ import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4;
import com.android.server.wm.flicker.helpers.ImeAppHelper;
import com.android.server.wm.flicker.helpers.PipAppHelper;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@@ -44,23 +47,25 @@ public class DebugTest {
private UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); private UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
/** /**
* atest FlickerTest:DebugTests#openAppCold * atest FlickerTests:DebugTest#openAppCold
*/ */
@Test @Test
public void openAppCold() { public void openAppCold() {
CommonTransitions.getOpenAppCold(testApp, uiDevice).recordAllRuns().build().run(); CommonTransitions.openAppCold(testApp, uiDevice, Surface.ROTATION_0)
.recordAllRuns().build().run();
} }
/** /**
* atest FlickerTest:DebugTests#openAppWarm * atest FlickerTests:DebugTest#openAppWarm
*/ */
@Test @Test
public void openAppWarm() { public void openAppWarm() {
CommonTransitions.openAppWarm(testApp, uiDevice).recordAllRuns().build().run(); CommonTransitions.openAppWarm(testApp, uiDevice, Surface.ROTATION_0)
.recordAllRuns().build().run();
} }
/** /**
* atest FlickerTest:DebugTests#changeOrientationFromNaturalToLeft * atest FlickerTests:DebugTest#changeOrientationFromNaturalToLeft
*/ */
@Test @Test
public void changeOrientationFromNaturalToLeft() { public void changeOrientationFromNaturalToLeft() {
@@ -69,7 +74,7 @@ public class DebugTest {
} }
/** /**
* atest FlickerTest:DebugTests#closeAppWithBackKey * atest FlickerTests:DebugTest#closeAppWithBackKey
*/ */
@Test @Test
public void closeAppWithBackKey() { public void closeAppWithBackKey() {
@@ -77,7 +82,7 @@ public class DebugTest {
} }
/** /**
* atest FlickerTest:DebugTests#closeAppWithHomeKey * atest FlickerTests:DebugTest#closeAppWithHomeKey
*/ */
@Test @Test
public void closeAppWithHomeKey() { public void closeAppWithHomeKey() {
@@ -85,7 +90,7 @@ public class DebugTest {
} }
/** /**
* atest FlickerTest:DebugTests#openAppToSplitScreen * atest FlickerTests:DebugTest#openAppToSplitScreen
*/ */
@Test @Test
public void openAppToSplitScreen() { public void openAppToSplitScreen() {
@@ -94,7 +99,7 @@ public class DebugTest {
} }
/** /**
* atest FlickerTest:DebugTests#splitScreenToLauncher * atest FlickerTests:DebugTest#splitScreenToLauncher
*/ */
@Test @Test
public void splitScreenToLauncher() { public void splitScreenToLauncher() {
@@ -104,70 +109,80 @@ public class DebugTest {
} }
/** /**
* atest FlickerTest:DebugTests#resizeSplitScreen * atest FlickerTests:DebugTest#resizeSplitScreen
*/ */
@Test @Test
public void resizeSplitScreen() { public void resizeSplitScreen() {
IAppHelper bottomApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(), ImeAppHelper bottomApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
"com.android.server.wm.flicker.testapp", "ImeApp"); CommonTransitions.resizeSplitScreen(testApp, bottomApp, uiDevice, Surface.ROTATION_0,
CommonTransitions.resizeSplitScreen(testApp, bottomApp, uiDevice, new Rational(1, 3), new Rational(1, 3), new Rational(2, 3))
new Rational(2, 3)).includeJankyRuns().recordEachRun().build().run(); .includeJankyRuns().recordEachRun().build().run();
} }
// IME tests // IME tests
/** /**
* atest FlickerTest:DebugTests#editTextSetFocus * atest FlickerTests:DebugTest#editTextSetFocus
*/ */
@Test @Test
public void editTextSetFocus() { public void editTextSetFocus() {
CommonTransitions.editTextSetFocus(uiDevice).includeJankyRuns().recordEachRun() ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.editTextSetFocus(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
/** /**
* atest FlickerTest:DebugTests#editTextLoseFocusToHome * atest FlickerTests:DebugTest#editTextLoseFocusToHome
*/ */
@Test @Test
public void editTextLoseFocusToHome() { public void editTextLoseFocusToHome() {
CommonTransitions.editTextLoseFocusToHome(uiDevice).includeJankyRuns().recordEachRun() ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
/** /**
* atest FlickerTest:DebugTests#editTextLoseFocusToApp * atest FlickerTests:DebugTest#editTextLoseFocusToApp
*/ */
@Test @Test
public void editTextLoseFocusToApp() { public void editTextLoseFocusToApp() {
CommonTransitions.editTextLoseFocusToHome(uiDevice).includeJankyRuns().recordEachRun() ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
// PIP tests // PIP tests
/** /**
* atest FlickerTest:DebugTests#enterPipMode * atest FlickerTests:DebugTest#enterPipMode
*/ */
@Test @Test
public void enterPipMode() { public void enterPipMode() {
CommonTransitions.enterPipMode(uiDevice).includeJankyRuns().recordEachRun().build().run(); PipAppHelper testApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.enterPipMode(testApp, uiDevice).includeJankyRuns().recordEachRun()
.build().run();
} }
/** /**
* atest FlickerTest:DebugTests#exitPipModeToHome * atest FlickerTests:DebugTest#exitPipModeToHome
*/ */
@Test @Test
public void exitPipModeToHome() { public void exitPipModeToHome() {
CommonTransitions.exitPipModeToHome(uiDevice).includeJankyRuns().recordEachRun() PipAppHelper testApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.exitPipModeToHome(testApp, uiDevice).includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
/** /**
* atest FlickerTest:DebugTests#exitPipModeToApp * atest FlickerTests:DebugTest#exitPipModeToApp
*/ */
@Test @Test
public void exitPipModeToApp() { public void exitPipModeToApp() {
CommonTransitions.exitPipModeToApp(uiDevice).includeJankyRuns().recordEachRun() PipAppHelper testApp = new PipAppHelper(InstrumentationRegistry.getInstrumentation());
CommonTransitions.exitPipModeToApp(testApp, uiDevice).includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
} }

View File

@@ -98,7 +98,7 @@ public class FlickerTestBase {
/** /**
* Runs a transition, returns a cached result if the transition has run before. * 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())) { if (transitionResults.containsKey(transition.getTestTag())) {
mResults = transitionResults.get(transition.getTestTag()); mResults = transitionResults.get(transition.getTestTag());
return; return;
@@ -110,6 +110,13 @@ public class FlickerTestBase {
transitionResults.put(transition.getTestTag(), mResults); 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. * Goes through a list of transition results and checks assertions on each result.
*/ */

View File

@@ -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());
}
}

View File

@@ -16,14 +16,12 @@
package com.android.server.wm.flicker; package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.getOpenAppCold; import static com.android.server.wm.flicker.CommonTransitions.openAppCold;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
import static com.android.server.wm.flicker.WmTraceSubject.assertThat; import static com.android.server.wm.flicker.WmTraceSubject.assertThat;
import androidx.test.InstrumentationRegistry; import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest; import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
@@ -31,36 +29,28 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
/** /**
* Test cold launch app from launcher. * Test cold launch app from launcher.
* To run this test: {@code atest FlickerTests:OpenAppColdTest} * To run this test: {@code atest FlickerTests:OpenAppColdTest}
*/ */
@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OpenAppColdTest extends FlickerTestBase { public class OpenAppColdTest extends NonRotationTestBase {
public OpenAppColdTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation);
public OpenAppColdTest() {
this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(), this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "SimpleApp"); "com.android.server.wm.flicker.testapp", "SimpleApp");
} }
@Before @Before
public void runTransition() { public void runTransition() {
super.runTransition(getOpenAppCold(mTestApp, mUiDevice).build()); run(openAppCold(mTestApp, mUiDevice, mBeginRotation)
} .includeJankyRuns().build());
@Test
public void checkVisibility_navBarWindowIsAlwaysVisible() {
checkResults(result -> assertThat(result)
.showsAboveAppWindow(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
}
@Test
public void checkVisibility_statusBarWindowIsAlwaysVisible() {
checkResults(result -> assertThat(result)
.showsAboveAppWindow(STATUS_BAR_WINDOW_TITLE).forAllEntries());
} }
@Test @Test
@@ -72,6 +62,8 @@ public class OpenAppColdTest extends FlickerTestBase {
.forAllEntries()); .forAllEntries());
} }
@FlakyTest(bugId = 140855415)
@Ignore("Waiting bug feedback")
@Test @Test
public void checkZOrder_appWindowReplacesLauncherAsTopWindow() { public void checkZOrder_appWindowReplacesLauncherAsTopWindow() {
checkResults(result -> assertThat(result) checkResults(result -> assertThat(result)
@@ -82,26 +74,6 @@ public class OpenAppColdTest extends FlickerTestBase {
.forAllEntries()); .forAllEntries());
} }
@Test
@FlakyTest(bugId = 141235985)
@Ignore("Waiting bug feedback")
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 @Test
public void checkVisibility_wallpaperLayerBecomesInvisible() { public void checkVisibility_wallpaperLayerBecomesInvisible() {
checkResults(result -> LayersTraceSubject.assertThat(result) checkResults(result -> LayersTraceSubject.assertThat(result)

View File

@@ -17,13 +17,11 @@
package com.android.server.wm.flicker; package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.openAppWarm; import static com.android.server.wm.flicker.CommonTransitions.openAppWarm;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
import static com.android.server.wm.flicker.WmTraceSubject.assertThat; import static com.android.server.wm.flicker.WmTraceSubject.assertThat;
import androidx.test.InstrumentationRegistry; import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest; import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
@@ -31,36 +29,28 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
/** /**
* Test warm launch app. * Test warm launch app.
* To run this test: {@code atest FlickerTests:OpenAppWarmTest} * To run this test: {@code atest FlickerTests:OpenAppWarmTest}
*/ */
@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OpenAppWarmTest extends FlickerTestBase { public class OpenAppWarmTest extends NonRotationTestBase {
public OpenAppWarmTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation);
public OpenAppWarmTest() {
this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(), this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "SimpleApp"); "com.android.server.wm.flicker.testapp", "SimpleApp");
} }
@Before @Before
public void runTransition() { public void runTransition() {
super.runTransition(openAppWarm(mTestApp, mUiDevice).includeJankyRuns().build()); super.runTransition(openAppWarm(mTestApp, mUiDevice, mBeginRotation)
} .includeJankyRuns().build());
@Test
public void checkVisibility_navBarIsAlwaysVisible() {
checkResults(result -> assertThat(result)
.showsAboveAppWindow(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
}
@Test
public void checkVisibility_statusBarIsAlwaysVisible() {
checkResults(result -> assertThat(result)
.showsAboveAppWindow(STATUS_BAR_WINDOW_TITLE).forAllEntries());
} }
@Test @Test
@@ -72,6 +62,8 @@ public class OpenAppWarmTest extends FlickerTestBase {
.forAllEntries()); .forAllEntries());
} }
@FlakyTest(bugId = 140855415)
@Ignore("Waiting bug feedback")
@Test @Test
public void checkZOrder_appWindowReplacesLauncherAsTopWindow() { public void checkZOrder_appWindowReplacesLauncherAsTopWindow() {
checkResults(result -> assertThat(result) checkResults(result -> assertThat(result)
@@ -82,26 +74,6 @@ public class OpenAppWarmTest extends FlickerTestBase {
.forAllEntries()); .forAllEntries());
} }
@FlakyTest(bugId = 141235985)
@Ignore("Waiting bug feedback")
@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 @Test
public void checkVisibility_wallpaperLayerBecomesInvisible() { public void checkVisibility_wallpaperLayerBecomesInvisible() {
checkResults(result -> LayersTraceSubject.assertThat(result) checkResults(result -> LayersTraceSubject.assertThat(result)

View File

@@ -17,31 +17,39 @@
package com.android.server.wm.flicker; package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.editTextSetFocus; import static com.android.server.wm.flicker.CommonTransitions.editTextSetFocus;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest; 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.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
/** /**
* Test IME window opening transitions. * Test IME window opening transitions.
* To run this test: {@code atest FlickerTests:OpenImeWindowTest} * To run this test: {@code atest FlickerTests:OpenImeWindowTest}
*/ */
@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OpenImeWindowTest extends FlickerTestBase { public class OpenImeWindowTest extends NonRotationTestBase {
private static final String IME_WINDOW_TITLE = "InputMethod"; private static final String IME_WINDOW_TITLE = "InputMethod";
public OpenImeWindowTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation);
mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
}
@Before @Before
public void runTransition() { public void runTransition() {
super.runTransition(editTextSetFocus(mUiDevice) run(editTextSetFocus((ImeAppHelper) mTestApp, mUiDevice, mBeginRotation)
.includeJankyRuns().build()); .includeJankyRuns().build());
} }
@@ -62,10 +70,4 @@ public class OpenImeWindowTest extends FlickerTestBase {
.showsLayer(IME_WINDOW_TITLE) .showsLayer(IME_WINDOW_TITLE)
.forAllEntries()); .forAllEntries());
} }
@Test
public void checkCoveredRegion_noUncoveredRegions() {
checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
getDisplayBounds()).forAllEntries());
}
} }

View File

@@ -24,13 +24,13 @@ import static com.android.server.wm.flicker.WindowUtils.getNavigationBarHeight;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import android.graphics.Rect; import android.graphics.Rect;
import android.platform.helpers.IAppHelper;
import android.util.Rational; import android.util.Rational;
import androidx.test.InstrumentationRegistry; import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest; import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest; 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.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
@@ -38,57 +38,48 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
/** /**
* Test split screen resizing window transitions. * Test split screen resizing window transitions.
* To run this test: {@code atest FlickerTests:ResizeSplitScreenTest} * To run this test: {@code atest FlickerTests:ResizeSplitScreenTest}
*/ */
@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 140856143) @FlakyTest(bugId = 140854698)
@Ignore("Waiting bug feedback") @Ignore("Waiting bug feedback")
public class ResizeSplitScreenTest extends FlickerTestBase { public class ResizeSplitScreenTest extends NonRotationTestBase {
private static String sSimpleActivity = "SimpleActivity";
private static String sImeActivity = "ImeActivity";
public ResizeSplitScreenTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation);
public ResizeSplitScreenTest() {
this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(), this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "SimpleApp"); "com.android.server.wm.flicker.testapp", "SimpleApp");
} }
@Before @Before
public void runTransition() { public void runTransition() {
IAppHelper bottomApp = new StandardAppHelper(InstrumentationRegistry ImeAppHelper bottomApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
.getInstrumentation(), run(resizeSplitScreen(mTestApp, bottomApp, mUiDevice, mBeginRotation,
"com.android.server.wm.flicker.testapp", "ImeApp"); new Rational(1, 3), new Rational(2, 3))
super.runTransition(resizeSplitScreen(mTestApp, bottomApp, mUiDevice, new Rational(1, 3), .includeJankyRuns().build());
new Rational(2, 3)).includeJankyRuns().build());
}
@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 @Test
public void checkVisibility_topAppLayerIsAlwaysVisible() { public void checkVisibility_topAppLayerIsAlwaysVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result) checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("SimpleActivity") .showsLayer(sSimpleActivity)
.forAllEntries()); .forAllEntries());
} }
@Test @Test
public void checkVisibility_bottomAppLayerIsAlwaysVisible() { public void checkVisibility_bottomAppLayerIsAlwaysVisible() {
checkResults(result -> LayersTraceSubject.assertThat(result) checkResults(result -> LayersTraceSubject.assertThat(result)
.showsLayer("ImeActivity") .showsLayer(sImeActivity)
.forAllEntries()); .forAllEntries());
} }
@@ -149,11 +140,11 @@ public class ResizeSplitScreenTest extends FlickerTestBase {
displayBounds.bottom - getNavigationBarHeight()); displayBounds.bottom - getNavigationBarHeight());
LayersTraceSubject.assertThat(result) LayersTraceSubject.assertThat(result)
.hasVisibleRegion("SimpleActivity", startingTopAppBounds) .hasVisibleRegion(sSimpleActivity, startingTopAppBounds)
.atTheEnd(); .atTheEnd();
LayersTraceSubject.assertThat(result) LayersTraceSubject.assertThat(result)
.hasVisibleRegion("ImeActivity", startingBottomAppBounds) .hasVisibleRegion(sImeActivity, startingBottomAppBounds)
.atTheEnd(); .atTheEnd();
}); });
} }
@@ -175,14 +166,14 @@ public class ResizeSplitScreenTest extends FlickerTestBase {
@Test @Test
public void checkVisibility_topAppWindowIsAlwaysVisible() { public void checkVisibility_topAppWindowIsAlwaysVisible() {
checkResults(result -> WmTraceSubject.assertThat(result) checkResults(result -> WmTraceSubject.assertThat(result)
.showsAppWindow("SimpleActivity") .showsAppWindow(sSimpleActivity)
.forAllEntries()); .forAllEntries());
} }
@Test @Test
public void checkVisibility_bottomAppWindowIsAlwaysVisible() { public void checkVisibility_bottomAppWindowIsAlwaysVisible() {
checkResults(result -> WmTraceSubject.assertThat(result) checkResults(result -> WmTraceSubject.assertThat(result)
.showsAppWindow("ImeActivity") .showsAppWindow(sImeActivity)
.forAllEntries()); .forAllEntries());
} }

View File

@@ -0,0 +1,31 @@
/*
* 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.helpers;
import android.app.Instrumentation;
import com.android.server.wm.flicker.StandardAppHelper;
public abstract class FlickerAppHelper extends StandardAppHelper {
static int sFindTimeout = 10000;
static String sFlickerPackage = "com.android.server.wm.flicker.testapp";
public FlickerAppHelper(Instrumentation instr, String launcherName) {
super(instr, sFlickerPackage, launcherName);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.UiDevice;
public class ImeAppAutoFocusHelper extends ImeAppHelper {
public ImeAppAutoFocusHelper(Instrumentation instr) {
super(instr, "ImeAppAutoFocus");
}
public void clickEditTextWidget(UiDevice device) {
// do nothing (the app is focused automatically)
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.helpers;
import static android.os.SystemClock.sleep;
import android.app.Instrumentation;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
public class ImeAppHelper extends FlickerAppHelper {
ImeAppHelper(Instrumentation instr, String launcherName) {
super(instr, launcherName);
}
public ImeAppHelper(Instrumentation instr) {
this(instr, "ImeApp");
}
public void clickEditTextWidget(UiDevice device) {
UiObject2 editText = device.findObject(By.res(getPackage(), "plain_text_input"));
editText.click();
sleep(500);
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.helpers;
import static com.android.server.wm.flicker.helpers.AutomationUtils.getPipWindowSelector;
import android.app.Instrumentation;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
public class PipAppHelper extends FlickerAppHelper {
public PipAppHelper(Instrumentation instr) {
super(instr, "PipApp");
}
public void clickEnterPipButton(UiDevice device) {
UiObject2 enterPipButton = device.findObject(By.res(getPackage(), "enter_pip"));
enterPipButton.click();
UiObject2 pipWindow = device.wait(Until.findObject(getPipWindowSelector()), sFindTimeout);
if (pipWindow == null) {
throw new RuntimeException("Unable to find PIP window");
}
}
}

View File

@@ -38,6 +38,15 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".ImeActivityAutoFocus"
android:taskAffinity="com.android.server.wm.flicker.testapp.ImeActivityAutoFocus"
android:windowSoftInputMode="stateVisible"
android:label="ImeAppAutoFocus">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".PipActivity" <activity android:name=".PipActivity"
android:resizeableActivity="true" android:resizeableActivity="true"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"

View File

@@ -18,6 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:background="@android:color/holo_green_light"> android:background="@android:color/holo_green_light">
<EditText android:id="@+id/plain_text_input" <EditText android:id="@+id/plain_text_input"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -0,0 +1,30 @@
/*
* 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.testapp;
import android.widget.EditText;
public class ImeActivityAutoFocus extends ImeActivity {
@Override
protected void onStart() {
super.onStart();
EditText editTextField = findViewById(R.id.plain_text_input);
editTextField.requestFocus();
}
}