summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-06-25 07:43:47 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-06-25 07:43:47 +0000
commit031a85c53634bc4e39405e968c931fb027eea810 (patch)
tree284f747c48667a8db17036ebb620e756c117e7e9
parent29077cf374f7229254c6224a29ed7bc690a62268 (diff)
parent8ba7bf8802d7418aedad999ba5dcc9d77d3db1fa (diff)
downloadplatform_testing-031a85c53634bc4e39405e968c931fb027eea810.tar.gz
release-request-c5216b17-dc50-4b24-831c-dc696ed657cc-for-git_oc-dr1-release-4133426 snap-temp-L83500000077479774
Change-Id: I60bf505295ce24646922182a7a6fde84892e1206
-rw-r--r--libraries/app-helpers/handheld/src/android/platform/test/helpers/handheld/IChromeHelper.java (renamed from libraries/app-helpers/handheld/src/android/platform/test/helpers/handheld/AbstractChromeHelper.java)7
-rw-r--r--libraries/launcher-helper/src/android/support/test/launcherhelper/TvLauncherStrategy.java81
-rw-r--r--tests/jank/uibench/src/com/android/uibench/janktests/UiBenchTextJankTests.java11
3 files changed, 80 insertions, 19 deletions
diff --git a/libraries/app-helpers/handheld/src/android/platform/test/helpers/handheld/AbstractChromeHelper.java b/libraries/app-helpers/handheld/src/android/platform/test/helpers/handheld/IChromeHelper.java
index 7589d22fb..9362fec96 100644
--- a/libraries/app-helpers/handheld/src/android/platform/test/helpers/handheld/AbstractChromeHelper.java
+++ b/libraries/app-helpers/handheld/src/android/platform/test/helpers/handheld/IChromeHelper.java
@@ -19,12 +19,7 @@ package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
-public abstract class AbstractChromeHelper extends AbstractStandardAppHelper {
-
- public AbstractChromeHelper(Instrumentation instr) {
- super(instr);
- }
-
+public interface IChromeHelper extends IStandardAppHelper {
/**
* Setup expectations: Chrome is open and on a standard page, i.e. a tab is open.
*
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/TvLauncherStrategy.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/TvLauncherStrategy.java
index c11af4632..610fdbba0 100644
--- a/libraries/launcher-helper/src/android/support/test/launcherhelper/TvLauncherStrategy.java
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/TvLauncherStrategy.java
@@ -191,13 +191,25 @@ public class TvLauncherStrategy implements ILeanbackLauncherStrategy {
}
/**
+ * Returns a {@link BySelector} describing a given favorite app
+ */
+ public BySelector getFavoriteAppSelector(String appName) {
+ return By.res(getSupportedLauncherPackage(), "favorite_app_banner").text(appName);
+ }
+
+ /**
+ * Returns a {@link BySelector} describing a given app in Apps View
+ */
+ public BySelector getAppInAppsViewSelector(String appName) {
+ return By.res(getSupportedLauncherPackage(), "app_title").text(appName);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
public long launch(String appName, String packageName) {
- BySelector appSelector = By.res(getSupportedLauncherPackage(),
- "app_banner_image").desc(appName);
- return launchApp(this, appSelector, packageName, isGame(packageName));
+ return launchApp(this, appName, packageName, isGame(packageName));
}
/**
@@ -322,7 +334,26 @@ public class TvLauncherStrategy implements ILeanbackLauncherStrategy {
return expected;
}
- protected long launchApp(ILauncherStrategy launcherStrategy, BySelector appSelector,
+ /**
+ * Select the given app in All Apps activity in zigzag manner.
+ * When the All Apps opens, the focus is always at the top left.
+ * Search from left to right, and down to the next row, from right to left, and
+ * down to the next row like a zigzag pattern until it founds a given app.
+ */
+ public UiObject2 selectAppInAllAppsZigZag(BySelector appSelector, String packageName) {
+ Direction direction = Direction.RIGHT;
+ UiObject2 app = select(appSelector, direction, UI_TRANSITION_WAIT_TIME);
+ while (app == null && move(Direction.DOWN)) {
+ direction = Direction.reverse(direction);
+ app = select(appSelector, direction, UI_TRANSITION_WAIT_TIME);
+ }
+ if (app != null) {
+ Log.i(LOG_TAG, String.format("The app %s is selected", packageName));
+ }
+ return app;
+ }
+
+ protected long launchApp(ILauncherStrategy launcherStrategy, String appName,
String packageName, boolean isGame) {
unlockDeviceIfAsleep();
@@ -335,13 +366,17 @@ public class TvLauncherStrategy implements ILeanbackLauncherStrategy {
launcherStrategy.open();
selectAppsRow();
- // Search for the app in the Apps row first.
+ // Search for the app in the Favorite Apps row first.
// If not exists, open the 'All Apps' and search for the app there
UiObject2 app = null;
- if (mDevice.hasObject(appSelector)) {
- app = selectBidirect(By.focused(true).hasDescendant(appSelector), Direction.RIGHT);
+ BySelector favAppSelector = getFavoriteAppSelector(appName);
+ if (mDevice.hasObject(favAppSelector)) {
+ app = selectBidirect(By.focused(true).hasDescendant(favAppSelector), Direction.RIGHT);
} else {
- app = selectAppInAllApps(appSelector, packageName);
+ openAllApps(true);
+ // Find app in Apps View in zigzag mode with app selector for Apps View
+ // because the app title no longer appears until focused.
+ app = selectAppInAllAppsZigZag(getAppInAppsViewSelector(appName), packageName);
}
if (app == null) {
throw new RuntimeException(
@@ -479,6 +514,36 @@ public class TvLauncherStrategy implements ILeanbackLauncherStrategy {
return object;
}
+ /**
+ * Simulate a move pressing a key code.
+ * Return true if a focus is shifted on TV UI, otherwise false.
+ */
+ public boolean move(Direction direction) {
+ int keyCode = KeyEvent.KEYCODE_UNKNOWN;
+ switch (direction) {
+ case LEFT:
+ keyCode = KeyEvent.KEYCODE_DPAD_LEFT;
+ break;
+ case RIGHT:
+ keyCode = KeyEvent.KEYCODE_DPAD_RIGHT;
+ break;
+ case UP:
+ keyCode = KeyEvent.KEYCODE_DPAD_UP;
+ break;
+ case DOWN:
+ keyCode = KeyEvent.KEYCODE_DPAD_DOWN;
+ break;
+ default:
+ throw new RuntimeException(String.format("This direction %s is not supported.",
+ direction));
+ }
+ UiObject2 focus = mDevice.wait(Until.findObject(By.focused(true)),
+ UI_TRANSITION_WAIT_TIME);
+ mDPadUtil.pressKeyCodeAndWait(keyCode);
+ return !focus.equals(mDevice.wait(Until.findObject(By.focused(true)),
+ UI_TRANSITION_WAIT_TIME));
+ }
+
// Unsupported methods
diff --git a/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchTextJankTests.java b/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchTextJankTests.java
index 64b786eb8..1e8f8d787 100644
--- a/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchTextJankTests.java
+++ b/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchTextJankTests.java
@@ -60,11 +60,12 @@ public class UiBenchTextJankTests extends JankTestBase {
}
// Measure jank metrics for EditText Typing
- @JankTest(beforeTest = "openEditTextTyping", expectedFrames = EXPECTED_FRAMES)
- @GfxMonitor(processName = PACKAGE_NAME)
- public void testEditTextTyping() {
- SystemClock.sleep(UiBenchJankTestsHelper.FULL_TEST_DURATION);
- }
+ // Reenable the test after b/62917134 is fixed
+ // @JankTest(beforeTest = "openEditTextTyping", expectedFrames = EXPECTED_FRAMES)
+ // @GfxMonitor(processName = PACKAGE_NAME)
+ // public void testEditTextTyping() {
+ // SystemClock.sleep(UiBenchJankTestsHelper.FULL_TEST_DURATION);
+ //}
// Open Layout Cache High Hitrate
public void openLayoutCacheHighHitrate() {