summaryrefslogtreecommitdiff
path: root/chromium/tools/WebViewShell
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/tools/WebViewShell')
-rw-r--r--chromium/tools/WebViewShell/AndroidManifest.xml23
-rw-r--r--chromium/tools/WebViewShell/res/values/strings.xml2
-rw-r--r--chromium/tools/WebViewShell/run_startup_time_test.sh28
-rw-r--r--chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/JankActivity.java57
-rw-r--r--chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/StartupTimeActivity.java44
5 files changed, 152 insertions, 2 deletions
diff --git a/chromium/tools/WebViewShell/AndroidManifest.xml b/chromium/tools/WebViewShell/AndroidManifest.xml
index 834bc58..77997cd 100644
--- a/chromium/tools/WebViewShell/AndroidManifest.xml
+++ b/chromium/tools/WebViewShell/AndroidManifest.xml
@@ -20,11 +20,12 @@
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="17"
- android:targetSdkVersion="17" />
+ android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
- <application
+ <application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light" >
@@ -36,5 +37,23 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".JankActivity"
+ android:label="@string/title_activity_jank"
+ android:noHistory="true">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".StartupTimeActivity"
+ android:label="@string/title_activity_startup_time"
+ android:noHistory="true">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/chromium/tools/WebViewShell/res/values/strings.xml b/chromium/tools/WebViewShell/res/values/strings.xml
index 4669508..f5df5b9 100644
--- a/chromium/tools/WebViewShell/res/values/strings.xml
+++ b/chromium/tools/WebViewShell/res/values/strings.xml
@@ -17,4 +17,6 @@
<resources>
<string name="app_name">WebView Telemetry</string>
<string name="title_activity_telemetry">WebView Telemetry</string>
+ <string name="title_activity_jank">WebView Jank Tester</string>
+ <string name="title_activity_startup_time">WebView Startup Time Tester</string>
</resources>
diff --git a/chromium/tools/WebViewShell/run_startup_time_test.sh b/chromium/tools/WebViewShell/run_startup_time_test.sh
new file mode 100644
index 0000000..7ddf83a
--- /dev/null
+++ b/chromium/tools/WebViewShell/run_startup_time_test.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+if ! which adb &> /dev/null; then
+ echo "adb is not in your path, did you run envsetup.sh?"
+ exit -1
+fi
+
+TMPFILE=$(tempfile)
+echo '<body><div>just some text</div></body>' > $TMPFILE
+adb push $TMPFILE /data/local/tmp/file.html
+rm $TMPFILE
+adb shell am start -n com.android.htmlviewer/.HTMLViewerActivity -d "file:///data/local/tmp/file.html" -a VIEW -t "text/html"
+
+sleep 3
+
+echo 'Running test, you should run `adb logcat | grep WebViewStartupTimeMillis=` in another shell to see results.'
+# Launch webview test shell 100 times
+for i in $(seq 1 100); do
+ if [[ $(($i % 10)) -eq 0 ]]; then
+ echo -n "..$i.."
+ fi
+ adb shell kill -9 `adb shell ps | grep com.android.webview.chromium.shell | tr -s " " " " | cut -d" " -f2`
+ adb shell am start -n com.android.webview.chromium.shell/.StartupTimeActivity -a VIEW > /dev/null
+ sleep 0.5
+done
+echo
+
+adb shell rm /data/local/tmp/file.html
diff --git a/chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/JankActivity.java b/chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/JankActivity.java
new file mode 100644
index 0000000..3694ce9
--- /dev/null
+++ b/chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/JankActivity.java
@@ -0,0 +1,57 @@
+/*
+ * 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.shell;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.webkit.CookieManager;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+/**
+ * This activity is designed for Android Jank testing of WebView. It takes a URL as an argument, and
+ * displays the page ready for the Jank tester to test scrolling etc.
+ */
+public class JankActivity extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setTitle(
+ getResources().getString(R.string.title_activity_jank));
+ setContentView(R.layout.activity_telemetry);
+
+ WebView webView = (WebView) findViewById(R.id.webview);
+ CookieManager.setAcceptFileSchemeCookies(true);
+
+ webView.setWebViewClient(new WebViewClient() {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView webView, String url) {
+ return false;
+ }
+ });
+
+ String url = getUrlFromIntent(getIntent());
+ webView.loadUrl(url);
+ }
+
+ private static String getUrlFromIntent(Intent intent) {
+ return intent != null ? intent.getDataString() : null;
+ }
+
+}
diff --git a/chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/StartupTimeActivity.java b/chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/StartupTimeActivity.java
new file mode 100644
index 0000000..aa805e6
--- /dev/null
+++ b/chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/StartupTimeActivity.java
@@ -0,0 +1,44 @@
+/*
+ * 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.shell;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.webkit.WebView;
+
+/**
+ * This activity is designed for startup time testing of the WebView.
+ */
+public class StartupTimeActivity extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setTitle(
+ getResources().getString(R.string.title_activity_startup_time));
+
+ long t1 = SystemClock.elapsedRealtime();
+ WebView webView = new WebView(this);
+ setContentView(webView);
+ long t2 = SystemClock.elapsedRealtime();
+ android.util.Log.i("WebViewShell", "WebViewStartupTimeMillis=" + (t2 - t1));
+ }
+
+}
+