summaryrefslogtreecommitdiff
path: root/chromium/tests/UbWebViewJankTests
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/tests/UbWebViewJankTests')
-rw-r--r--chromium/tests/UbWebViewJankTests/Android.mk26
-rw-r--r--chromium/tests/UbWebViewJankTests/AndroidManifest.xml29
-rw-r--r--chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java116
3 files changed, 171 insertions, 0 deletions
diff --git a/chromium/tests/UbWebViewJankTests/Android.mk b/chromium/tests/UbWebViewJankTests/Android.mk
new file mode 100644
index 0000000..0c2d128
--- /dev/null
+++ b/chromium/tests/UbWebViewJankTests/Android.mk
@@ -0,0 +1,26 @@
+# Copyright 2014 Google Inc. All Rights Reserved.
+#
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := UbWebViewJankTests
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator ub-janktesthelper
+
+LOCAK_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/chromium/tests/UbWebViewJankTests/AndroidManifest.xml b/chromium/tests/UbWebViewJankTests/AndroidManifest.xml
new file mode 100644
index 0000000..cf1adb6
--- /dev/null
+++ b/chromium/tests/UbWebViewJankTests/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.webview.chromium.tests.jank">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.android.webview.chromium.tests.jank"
+ android:label="Chromium Jank Tests" />
+
+</manifest>
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
new file mode 100644
index 0000000..efd9f27
--- /dev/null
+++ b/chromium/tests/UbWebViewJankTests/src/com/android/webview/chromium/tests/jank/WebViewFlingTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 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.webview.chromium.tests.jank;
+
+import android.content.Intent;
+import android.net.Uri;
+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.UiDevice;
+import android.support.test.uiautomator.UiObjectNotFoundException;
+import android.support.test.uiautomator.UiScrollable;
+import android.support.test.uiautomator.UiSelector;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Jank test for Android Webview.
+ *
+ * To run
+ * 1) Install the test application (com.android.webview.chromium.shell)
+ * 2) Place a directories containing the test pages on the test device in
+ * $EXTERNAL_STORAGE/AwJankPages. Each directory should contain an index.html
+ * file as the main file of the test page.
+ * 3) Build this test and install the resulting apk file
+ * 4) Run the test using the command:
+ * adb shell am instrument -e Url URL -w \
+ * com.android.webview.chromium.tests.jank/android.test.InstrumentationTestRunner
+ *
+ */
+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 UiDevice mDevice;
+ private UiScrollable mWebPageDisplay = null;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mDevice.setOrientationNatural();
+
+ // Get the URL argument
+ String url = getArguments().getString("Url");
+ File webpage = new File(url);
+ assertNotNull("No test pages", webpage);
+
+ // Launch the chromium shell
+ Intent intent = new Intent(Intent.ACTION_DEFAULT,
+ Uri.parse("file://" + webpage.getAbsolutePath()));
+ intent.setClassName(CHROMIUM_SHELL_APP, CHROMIUM_SHELL_ACTIVITY);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getInstrumentation().getContext().startActivity(intent);
+ SystemClock.sleep(PAGE_LOAD_DELAY_TIME_MS);
+ }
+
+ @Override
+ public void beforeLoop() throws UiObjectNotFoundException {
+ getContainer().flingToBeginning(20);
+ SystemClock.sleep(TEST_DELAY_TIME_MS);
+ }
+
+ @JankTest(type=JankType.CONTENT_FRAMES, expectedFrames=MIN_DATA_SIZE)
+ public void testBrowserPageFling() throws UiObjectNotFoundException, IOException {
+ getContainer().flingForward();
+ SystemClock.sleep(DEFAULT_ANIMATION_TIME);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @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;
+ }
+}