diff options
author | Allen Hair <allenhair@google.com> | 2014-08-19 09:23:19 -0700 |
---|---|---|
committer | Richard Coles <torne@google.com> | 2014-11-18 19:38:31 +0000 |
commit | 86972eac40c7eb99bfd7621ba78586ed4d87ba52 (patch) | |
tree | 22821b006b17c4be5b953e5e5a9aa32419c094fa /chromium | |
parent | ca01ad7b3df82e5b05b49562851c957d1264c9f3 (diff) | |
download | webview-86972eac40c7eb99bfd7621ba78586ed4d87ba52.tar.gz |
Update WebViewFlingTest to use new UiAutomator API.
Change-Id: I932fc013c923c502082a9cb81fabe130bdf8c928
(cherry picked from commit c287310ea4204c907e76593e2b0d6a874c88c813)
Diffstat (limited to 'chromium')
-rw-r--r-- | chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java b/chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java index efd9f27..16eee7f 100644 --- a/chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java +++ b/chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java @@ -22,8 +22,10 @@ import android.os.SystemClock; import android.support.test.jank.JankTest; import android.support.test.jank.JankTestBase; import android.support.test.jank.JankType; +import android.support.test.uiautomator.By; +import android.support.test.uiautomator.Direction; import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.UiObjectNotFoundException; +import android.support.test.uiautomator.UiObject2; import android.support.test.uiautomator.UiScrollable; import android.support.test.uiautomator.UiSelector; @@ -47,17 +49,14 @@ import java.io.IOException; public class WebViewFlingTest extends JankTestBase { private static final long TEST_DELAY_TIME_MS = 2 * 1000; // 2 seconds - private static final long PAGE_LOAD_DELAY_TIMEOUT_MS = 10 * 1000; // 10 seconds private static final long PAGE_LOAD_DELAY_TIME_MS = 20 * 1000; // 20 seconds private static final int MIN_DATA_SIZE = 50; private static final long DEFAULT_ANIMATION_TIME = 2 * 1000; private static final String CHROMIUM_SHELL_APP = "com.android.webview.chromium.shell"; private static final String CHROMIUM_SHELL_ACTIVITY = CHROMIUM_SHELL_APP + ".JankActivity"; - private static final String AW_CONTAINER = "com.android.webview.chromium.shell:id/container"; + private static final String RES_PACKAGE = "com.android.webview.chromium.shell"; private UiDevice mDevice; - private UiScrollable mWebPageDisplay = null; - /** * {@inheritDoc} @@ -84,14 +83,19 @@ public class WebViewFlingTest extends JankTestBase { } @Override - public void beforeLoop() throws UiObjectNotFoundException { - getContainer().flingToBeginning(20); + public void beforeLoop() { + UiObject2 container = mDevice.findObject(By.res(RES_PACKAGE, "container")); + + // Fling to the top + while (container.fling(Direction.UP)) { + } + SystemClock.sleep(TEST_DELAY_TIME_MS); } @JankTest(type=JankType.CONTENT_FRAMES, expectedFrames=MIN_DATA_SIZE) - public void testBrowserPageFling() throws UiObjectNotFoundException, IOException { - getContainer().flingForward(); + public void testBrowserPageFling() throws IOException { + mDevice.findObject(By.res(RES_PACKAGE, "container")).fling(Direction.DOWN); SystemClock.sleep(DEFAULT_ANIMATION_TIME); } @@ -101,16 +105,7 @@ public class WebViewFlingTest extends JankTestBase { @Override protected void tearDown() throws Exception { mDevice.unfreezeRotation(); - super.tearDown(); - } - private UiScrollable getContainer() { - if (mWebPageDisplay == null) { - mWebPageDisplay = - new UiScrollable(new UiSelector().resourceId(AW_CONTAINER).instance(0)); - assertTrue("Failed to get web container", - mWebPageDisplay.waitForExists(PAGE_LOAD_DELAY_TIMEOUT_MS)); - } - return mWebPageDisplay; + super.tearDown(); } } |