summaryrefslogtreecommitdiff
path: root/chromium
diff options
context:
space:
mode:
authorMarcin Kosiba <mkosiba@google.com>2014-09-24 09:43:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-24 09:43:43 +0000
commitf9b947672c4b266df5b64dec0c9465c7f7bf215e (patch)
treebc6537f98e142d3e8294810eff6ff5c14beb0318 /chromium
parent3c1733e5798747813fe0e812cc02cb6ea1cea335 (diff)
parent9e0d9ef46e124f0676d25989badb723b78fddbd6 (diff)
downloadwebview-f9b947672c4b266df5b64dec0c9465c7f7bf215e.tar.gz
Merge "Add startup time tests to the WebViewShell" into master-chromium
Diffstat (limited to 'chromium')
-rw-r--r--chromium/tools/WebViewShell/AndroidManifest.xml9
-rw-r--r--chromium/tools/WebViewShell/res/values/strings.xml1
-rw-r--r--chromium/tools/WebViewShell/run_startup_time_test.sh28
-rw-r--r--chromium/tools/WebViewShell/src/com/android/webview/chromium/shell/StartupTimeActivity.java44
4 files changed, 82 insertions, 0 deletions
diff --git a/chromium/tools/WebViewShell/AndroidManifest.xml b/chromium/tools/WebViewShell/AndroidManifest.xml
index 575ab1c..77997cd 100644
--- a/chromium/tools/WebViewShell/AndroidManifest.xml
+++ b/chromium/tools/WebViewShell/AndroidManifest.xml
@@ -46,5 +46,14 @@
<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 5eed399..f5df5b9 100644
--- a/chromium/tools/WebViewShell/res/values/strings.xml
+++ b/chromium/tools/WebViewShell/res/values/strings.xml
@@ -18,4 +18,5 @@
<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/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));
+ }
+
+}
+