diff options
author | Marcin Kosiba <mkosiba@google.com> | 2014-09-09 16:57:12 +0100 |
---|---|---|
committer | Marcin Kosiba <mkosiba@google.com> | 2014-09-22 11:55:29 +0100 |
commit | 9e0d9ef46e124f0676d25989badb723b78fddbd6 (patch) | |
tree | 539b4f9dc5e22b4568253257f2c1449e918e8b89 | |
parent | 950c447e62ecb8aa7eb212f85076a384aa924627 (diff) | |
download | android_frameworks_webview-9e0d9ef46e124f0676d25989badb723b78fddbd6.tar.gz android_frameworks_webview-9e0d9ef46e124f0676d25989badb723b78fddbd6.tar.bz2 android_frameworks_webview-9e0d9ef46e124f0676d25989badb723b78fddbd6.zip |
Add startup time tests to the WebViewShell
BUG: 16870075
Change-Id: I3f5221accdf2e3ca9a05b1c030eb8d74a2ec12e2
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)); + } + +} + |