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

Test: atest FlickerTests:CloseImeAutoOpenWindowToAppTest
Change-Id: I8ed60eb5e4653cdcf4d31402069be7da96c5d2bb
This commit is contained in:
Nataniel Borges
2019-09-23 15:52:58 +02:00
parent 89888bf124
commit 4bfe816030
14 changed files with 392 additions and 75 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

@@ -21,6 +21,8 @@ import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusT
import androidx.test.InstrumentationRegistry; import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
import com.android.server.wm.flicker.helpers.ImeAppHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
@@ -42,14 +44,12 @@ public class CloseImeWindowToAppTest extends NonRotationTestBase {
public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) { public CloseImeWindowToAppTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation); super(beginRotationName, beginRotation);
mTestApp = new StandardAppHelper( mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "ImeApp");
} }
@Before @Before
public void runTransition() { public void runTransition() {
run(editTextLoseFocusToApp(mTestApp, mUiDevice, mBeginRotation, /* clickOnEditField */true) run(editTextLoseFocusToApp((ImeAppHelper) mTestApp, mUiDevice, mBeginRotation)
.includeJankyRuns().build()); .includeJankyRuns().build());
} }

View File

@@ -21,6 +21,8 @@ import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusT
import androidx.test.InstrumentationRegistry; import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
import com.android.server.wm.flicker.helpers.ImeAppHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
@@ -42,15 +44,12 @@ public class CloseImeWindowToHomeTest extends NonRotationTestBase {
public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) { public CloseImeWindowToHomeTest(String beginRotationName, int beginRotation) {
super(beginRotationName, beginRotation); super(beginRotationName, beginRotation);
mTestApp = new StandardAppHelper( mTestApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "ImeApp");
} }
@Before @Before
public void runTransition() { public void runTransition() {
run(editTextLoseFocusToHome(mTestApp, mUiDevice, mBeginRotation, run(editTextLoseFocusToHome((ImeAppHelper) mTestApp, mUiDevice, mBeginRotation)
/* clickOnEditField */ true)
.includeJankyRuns().build()); .includeJankyRuns().build());
} }

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,18 +73,6 @@ class CommonTransitions {
} }
} }
private static void clickEditTextWidget(UiDevice device, IAppHelper testApp) {
UiObject2 editText = device.findObject(By.res(testApp.getPackage(), "plain_text_input"));
editText.click();
sleep(500);
}
private static void clickEnterPipButton(UiDevice device, IAppHelper testApp) {
UiObject2 enterPipButton = device.findObject(By.res(testApp.getPackage(), "enter_pip"));
enterPipButton.click();
sleep(500);
}
static TransitionBuilder openAppWarm(IAppHelper testApp, UiDevice static TransitionBuilder openAppWarm(IAppHelper testApp, UiDevice
device) { device) {
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
@@ -201,15 +189,16 @@ class CommonTransitions {
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder editTextSetFocus(UiDevice device) { static TransitionBuilder editTextSetFocus(ImeAppHelper testApp, UiDevice device,
IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(), int beginRotation) {
"com.android.server.wm.flicker.testapp", "ImeApp");
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("editTextSetFocus_" + testApp.getLauncherName()) .withTag("editTextSetFocus_" + testApp.getLauncherName()
+ rotationToString(beginRotation))
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(() -> setRotation(device, beginRotation))
.runBefore(testApp::open) .runBefore(testApp::open)
.run(() -> clickEditTextWidget(device, testApp)) .run(() -> testApp.clickEditTextWidget(device))
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
@@ -243,8 +232,8 @@ class CommonTransitions {
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder editTextLoseFocusToHome(IAppHelper testApp, UiDevice device, static TransitionBuilder editTextLoseFocusToHome(ImeAppHelper testApp, UiDevice device,
int beginRotation, boolean clickOnEditText) { int beginRotation) {
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("editTextLoseFocusToHome_" + testApp.getLauncherName() .withTag("editTextLoseFocusToHome_" + testApp.getLauncherName()
+ rotationToString(beginRotation)) + rotationToString(beginRotation))
@@ -252,19 +241,15 @@ class CommonTransitions {
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(() -> setRotation(device, beginRotation)) .runBefore(() -> setRotation(device, beginRotation))
.runBefore(testApp::open) .runBefore(testApp::open)
.runBefore(() -> { .runBefore(() -> testApp.clickEditTextWidget(device))
if (clickOnEditText) {
clickEditTextWidget(device, testApp);
}
})
.run(device::pressHome) .run(device::pressHome)
.run(device::waitForIdle) .run(device::waitForIdle)
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder editTextLoseFocusToApp(IAppHelper testApp, UiDevice device, static TransitionBuilder editTextLoseFocusToApp(ImeAppHelper testApp, UiDevice device,
int beginRotation, boolean clickOnEditText) { int beginRotation) {
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("editTextLoseFocusToApp_" + testApp.getLauncherName() .withTag("editTextLoseFocusToApp_" + testApp.getLauncherName()
+ rotationToString(beginRotation)) + rotationToString(beginRotation))
@@ -272,55 +257,45 @@ class CommonTransitions {
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(() -> setRotation(device, beginRotation)) .runBefore(() -> setRotation(device, beginRotation))
.runBefore(testApp::open) .runBefore(testApp::open)
.runBefore(() -> { .runBefore(() -> testApp.clickEditTextWidget(device))
if (clickOnEditText) {
clickEditTextWidget(device, testApp);
}
})
.run(device::pressBack) .run(device::pressBack)
.run(device::waitForIdle) .run(device::waitForIdle)
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder enterPipMode(UiDevice device) { static TransitionBuilder enterPipMode(PipAppHelper testApp, UiDevice device) {
IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "PipApp");
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("enterPipMode_" + testApp.getLauncherName()) .withTag("enterPipMode_" + testApp.getLauncherName())
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(testApp::open) .runBefore(testApp::open)
.run(() -> clickEnterPipButton(device, testApp)) .run(() -> testApp.clickEnterPipButton(device))
.runAfter(() -> closePipWindow(device)) .runAfter(() -> closePipWindow(device))
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder exitPipModeToHome(UiDevice device) { static TransitionBuilder exitPipModeToHome(PipAppHelper testApp, UiDevice device) {
IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "PipApp");
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("exitPipModeToHome_" + testApp.getLauncherName()) .withTag("exitPipModeToHome_" + testApp.getLauncherName())
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(testApp::open) .runBefore(testApp::open)
.runBefore(() -> clickEnterPipButton(device, testApp)) .runBefore(() -> testApp.clickEnterPipButton(device))
.run(() -> closePipWindow(device)) .run(() -> closePipWindow(device))
.run(device::waitForIdle) .run(device::waitForIdle)
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)
.repeat(ITERATIONS); .repeat(ITERATIONS);
} }
static TransitionBuilder exitPipModeToApp(UiDevice device) { static TransitionBuilder exitPipModeToApp(PipAppHelper testApp, UiDevice device) {
IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
"com.android.server.wm.flicker.testapp", "PipApp");
return TransitionRunner.newBuilder() return TransitionRunner.newBuilder()
.withTag("exitPipModeToApp_" + testApp.getLauncherName()) .withTag("exitPipModeToApp_" + testApp.getLauncherName())
.runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen) .runBeforeAll(AutomationUtils::wakeUpAndGoToHomeScreen)
.runBefore(device::pressHome) .runBefore(device::pressHome)
.runBefore(testApp::open) .runBefore(testApp::open)
.runBefore(() -> clickEnterPipButton(device, testApp)) .runBefore(() -> testApp.clickEnterPipButton(device))
.run(() -> expandPipWindow(device)) .run(() -> expandPipWindow(device))
.run(device::waitForIdle) .run(device::waitForIdle)
.runAfterAll(testApp::exit) .runAfterAll(testApp::exit)

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;
@@ -121,7 +124,9 @@ public class DebugTest {
*/ */
@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();
} }
@@ -130,10 +135,9 @@ public class DebugTest {
*/ */
@Test @Test
public void editTextLoseFocusToHome() { public void editTextLoseFocusToHome() {
IAppHelper testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(), ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
"com.android.server.wm.flicker.testapp", "ImeApp"); CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0)
CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0, .includeJankyRuns().recordEachRun()
/* clickOnEditField */true).includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
@@ -142,8 +146,9 @@ public class DebugTest {
*/ */
@Test @Test
public void editTextLoseFocusToApp() { public void editTextLoseFocusToApp() {
CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0, ImeAppHelper testApp = new ImeAppHelper(InstrumentationRegistry.getInstrumentation());
/* clickOnEditField */true).includeJankyRuns().recordEachRun() CommonTransitions.editTextLoseFocusToHome(testApp, uiDevice, Surface.ROTATION_0)
.includeJankyRuns().recordEachRun()
.build().run(); .build().run();
} }
@@ -154,7 +159,9 @@ public class DebugTest {
*/ */
@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();
} }
/** /**
@@ -162,7 +169,8 @@ public class DebugTest {
*/ */
@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();
} }
@@ -171,7 +179,8 @@ public class DebugTest {
*/ */
@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

@@ -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

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