blob: 8d3fd1d722d03a6a2b0b540d1fe8ada7b528dbd2 [file] [log] [blame]
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.dumprendertree;
18
Guang Zhu6bf18ba2009-09-15 23:47:20 -070019import com.android.dumprendertree.forwarder.ForwardService;
20
Guang Zhu1871fe02009-04-29 14:49:03 -070021import android.app.Activity;
Guang Zhuf92bd422009-06-29 10:40:55 -070022import android.app.AlertDialog;
Andrei Popescu4950b2b2009-09-03 13:56:07 +010023import android.content.Context;
Guang Zhuf92bd422009-06-29 10:40:55 -070024import android.content.DialogInterface;
Guang Zhu1871fe02009-04-29 14:49:03 -070025import android.content.Intent;
Guang Zhuf92bd422009-06-29 10:40:55 -070026import android.content.DialogInterface.OnClickListener;
Guang Zhu1871fe02009-04-29 14:49:03 -070027import android.graphics.Bitmap;
Guang Zhu5dc4f212009-10-29 18:24:54 -070028import android.graphics.Canvas;
29import android.graphics.Bitmap.CompressFormat;
30import android.graphics.Bitmap.Config;
Guang Zhu1871fe02009-04-29 14:49:03 -070031import android.net.http.SslError;
32import android.os.Bundle;
Christian Mehlmauer8b85dce2010-07-19 20:11:27 +020033import android.os.Environment;
Guang Zhu1871fe02009-04-29 14:49:03 -070034import android.os.Handler;
35import android.os.Message;
36import android.util.Log;
37import android.view.ViewGroup;
Ben Murdoch9b815d02010-06-01 18:45:10 +010038import android.view.Window;
Kristian Monsen16d041c2010-12-06 13:43:51 +000039import android.webkit.CookieManager;
Guang Zhu6c15f602010-05-03 11:49:04 -070040import android.webkit.ConsoleMessage;
Ben Murdoch7e73ce92011-01-20 11:21:24 +000041import android.webkit.CookieManager;
Steve Blockdad347c2009-08-19 18:46:34 +010042import android.webkit.GeolocationPermissions;
Guang Zhu1871fe02009-04-29 14:49:03 -070043import android.webkit.HttpAuthHandler;
44import android.webkit.JsPromptResult;
45import android.webkit.JsResult;
46import android.webkit.SslErrorHandler;
47import android.webkit.WebChromeClient;
48import android.webkit.WebSettings;
Ben Murdoche6f3e452009-04-22 16:02:31 +010049import android.webkit.WebStorage;
Guang Zhu1871fe02009-04-29 14:49:03 -070050import android.webkit.WebView;
51import android.webkit.WebViewClient;
52import android.widget.LinearLayout;
53
Guang Zhuf92bd422009-06-29 10:40:55 -070054import java.io.BufferedReader;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070055import java.io.File;
56import java.io.FileOutputStream;
Guang Zhuf92bd422009-06-29 10:40:55 -070057import java.io.FileReader;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070058import java.io.IOException;
Ben Murdoche6f3e452009-04-22 16:02:31 +010059import java.net.MalformedURLException;
60import java.net.URL;
Andrei Popescu4950b2b2009-09-03 13:56:07 +010061import java.util.HashMap;
Steve Blockf0f30c62010-08-18 15:15:42 +010062import java.util.Iterator;
Andrei Popescu4950b2b2009-09-03 13:56:07 +010063import java.util.Map;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070064import java.util.Vector;
65
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070066public class TestShellActivity extends Activity implements LayoutTestController {
Guang Zhuf92bd422009-06-29 10:40:55 -070067
Guang Zhu1871fe02009-04-29 14:49:03 -070068 static enum DumpDataType {DUMP_AS_TEXT, EXT_REPR, NO_OP}
Guang Zhuf92bd422009-06-29 10:40:55 -070069
Steve Blockfb0de342010-03-19 18:48:35 +000070 // String constants for use with layoutTestController.overridePreferences
Steve Block5f37cc432010-10-13 18:44:31 +010071 private final String WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED =
72 "WebKitOfflineWebApplicationCacheEnabled";
73 private final String WEBKIT_USES_PAGE_CACHE_PREFERENCE_KEY = "WebKitUsesPageCachePreferenceKey";
Steve Blockfb0de342010-03-19 18:48:35 +000074
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070075 public class AsyncHandler extends Handler {
76 @Override
77 public void handleMessage(Message msg) {
78 if (msg.what == MSG_TIMEOUT) {
79 mTimedOut = true;
Guang Zhu4ce6e7c2011-01-14 16:17:20 -080080 mWebView.stopLoading();
Guang Zhu56a36932009-09-28 09:53:48 -070081 if (mCallback != null)
Guang Zhuf92bd422009-06-29 10:40:55 -070082 mCallback.timedOut(mWebView.getUrl());
Guang Zhu56a36932009-09-28 09:53:48 -070083 if (!mRequestedWebKitData) {
Guang Zhu72160472009-09-25 17:34:12 -070084 requestWebKitData();
85 } else {
86 // if timed out and webkit data has been dumped before
87 // finish directly
88 finished();
89 }
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070090 return;
91 } else if (msg.what == MSG_WEBKIT_DATA) {
Guang Zhuf2f7f562010-12-23 16:25:47 -080092 mHandler.removeMessages(MSG_DUMP_TIMEOUT);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070093 TestShellActivity.this.dump(mTimedOut, (String)msg.obj);
94 return;
Guang Zhuf37a5742010-12-23 14:37:31 -080095 } else if (msg.what == MSG_DUMP_TIMEOUT) {
96 throw new RuntimeException("WebView dump timeout, is it pegged?");
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070097 }
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070098 super.handleMessage(msg);
99 }
100 }
101
102 public void requestWebKitData() {
103 Message callback = mHandler.obtainMessage(MSG_WEBKIT_DATA);
Guang Zhuf92bd422009-06-29 10:40:55 -0700104
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700105 if (mRequestedWebKitData)
106 throw new AssertionError("Requested webkit data twice: " + mWebView.getUrl());
Guang Zhuf92bd422009-06-29 10:40:55 -0700107
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700108 mRequestedWebKitData = true;
Guang Zhu72160472009-09-25 17:34:12 -0700109 Log.v(LOGTAG, "message sent to WebView to dump text.");
Guang Zhu1871fe02009-04-29 14:49:03 -0700110 switch (mDumpDataType) {
111 case DUMP_AS_TEXT:
Shimeng (Simon) Wangad456862010-06-16 17:32:24 -0700112 callback.arg1 = mDumpTopFrameAsText ? 1 : 0;
113 callback.arg2 = mDumpChildFramesAsText ? 1 : 0;
Guang Zhuf37a5742010-12-23 14:37:31 -0800114 setDumpTimeout(DUMP_TIMEOUT_MS);
Guang Zhu1871fe02009-04-29 14:49:03 -0700115 mWebView.documentAsText(callback);
116 break;
117 case EXT_REPR:
118 mWebView.externalRepresentation(callback);
Guang Zhuf37a5742010-12-23 14:37:31 -0800119 setDumpTimeout(DUMP_TIMEOUT_MS);
Guang Zhu1871fe02009-04-29 14:49:03 -0700120 break;
121 default:
122 finished();
123 break;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700124 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700125 }
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700126
Guang Zhuf37a5742010-12-23 14:37:31 -0800127 private void setDumpTimeout(long timeout) {
128 Message msg = mHandler.obtainMessage(MSG_DUMP_TIMEOUT);
129 mHandler.sendMessageDelayed(msg, timeout);
130 }
131
Guang Zhu889181d2009-07-09 12:55:15 -0700132 public void clearCache() {
Guang Zhuf56e1a12009-07-20 11:16:28 -0700133 mWebView.freeMemory();
Guang Zhu889181d2009-07-09 12:55:15 -0700134 }
135
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700136 @Override
137 protected void onCreate(Bundle icicle) {
138 super.onCreate(icicle);
Ben Murdoch9b815d02010-06-01 18:45:10 +0100139 requestWindowFeature(Window.FEATURE_PROGRESS);
Guang Zhuf92bd422009-06-29 10:40:55 -0700140
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700141 LinearLayout contentView = new LinearLayout(this);
142 contentView.setOrientation(LinearLayout.VERTICAL);
143 setContentView(contentView);
144
Kristian Monsen16d041c2010-12-06 13:43:51 +0000145 CookieManager.setAcceptFileSchemeCookies(true);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700146 mWebView = new WebView(this);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700147 mEventSender = new WebViewEventSender(mWebView);
148 mCallbackProxy = new CallbackProxy(mEventSender, this);
149
Andrei Popescu4950b2b2009-09-03 13:56:07 +0100150 mWebView.addJavascriptInterface(mCallbackProxy, "layoutTestController");
151 mWebView.addJavascriptInterface(mCallbackProxy, "eventSender");
Ben Murdoche6f3e452009-04-22 16:02:31 +0100152 setupWebViewForLayoutTests(mWebView, mCallbackProxy);
153
Romain Guy980a9382010-01-08 15:06:28 -0800154 contentView.addView(mWebView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
Guang Zhuf92bd422009-06-29 10:40:55 -0700155
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700156 mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
Guang Zhuf92bd422009-06-29 10:40:55 -0700157
Feng Qian28909202009-08-13 14:54:56 -0700158 // Expose window.gc function to JavaScript. JSC build exposes
159 // this function by default, but V8 requires the flag to turn it on.
160 // WebView::setJsFlags is noop in JSC build.
161 mWebView.setJsFlags("--expose_gc");
162
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700163 mHandler = new AsyncHandler();
Guang Zhuf92bd422009-06-29 10:40:55 -0700164
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700165 Intent intent = getIntent();
166 if (intent != null) {
167 executeIntent(intent);
168 }
Steve Block68dede32010-08-04 10:28:46 +0100169
170 // This is asynchronous, but it gets processed by WebCore before it starts loading pages.
171 mWebView.useMockDeviceOrientation();
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700172 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700173
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700174 @Override
175 protected void onNewIntent(Intent intent) {
176 super.onNewIntent(intent);
177 executeIntent(intent);
178 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700179
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700180 private void executeIntent(Intent intent) {
181 resetTestStatus();
182 if (!Intent.ACTION_VIEW.equals(intent.getAction())) {
183 return;
184 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700185
Ben Murdoch9b815d02010-06-01 18:45:10 +0100186 mTotalTestCount = intent.getIntExtra(TOTAL_TEST_COUNT, mTotalTestCount);
187 mCurrentTestNumber = intent.getIntExtra(CURRENT_TEST_NUMBER, mCurrentTestNumber);
188
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700189 mTestUrl = intent.getStringExtra(TEST_URL);
Guang Zhuf92bd422009-06-29 10:40:55 -0700190 if (mTestUrl == null) {
191 mUiAutoTestPath = intent.getStringExtra(UI_AUTO_TEST);
192 if(mUiAutoTestPath != null) {
193 beginUiAutoTest();
194 }
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700195 return;
Guang Zhuf92bd422009-06-29 10:40:55 -0700196 }
197
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700198 mResultFile = intent.getStringExtra(RESULT_FILE);
199 mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 0);
Guang Zhu5dc4f212009-10-29 18:24:54 -0700200 mGetDrawtime = intent.getBooleanExtra(GET_DRAW_TIME, false);
201 mSaveImagePath = intent.getStringExtra(SAVE_IMAGE);
Guang Zhu5d53c192010-07-14 17:17:54 -0700202 mStopOnRefError = intent.getBooleanExtra(STOP_ON_REF_ERROR, false);
Ben Murdoch9b815d02010-06-01 18:45:10 +0100203 setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount);
204 float ratio = (float)mCurrentTestNumber / mTotalTestCount;
205 int progress = (int)(ratio * Window.PROGRESS_END);
206 getWindow().setFeatureInt(Window.FEATURE_PROGRESS, progress);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700207
208 Log.v(LOGTAG, " Loading " + mTestUrl);
209 mWebView.loadUrl(mTestUrl);
Guang Zhuf92bd422009-06-29 10:40:55 -0700210
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700211 if (mTimeoutInMillis > 0) {
212 // Create a timeout timer
213 Message m = mHandler.obtainMessage(MSG_TIMEOUT);
214 mHandler.sendMessageDelayed(m, mTimeoutInMillis);
215 }
216 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700217
218 private void beginUiAutoTest() {
219 try {
220 mTestListReader = new BufferedReader(
221 new FileReader(mUiAutoTestPath));
222 } catch (IOException ioe) {
223 Log.e(LOGTAG, "Failed to open test list for read.", ioe);
224 finishUiAutoTest();
225 return;
226 }
227 moveToNextTest();
228 }
229
230 private void finishUiAutoTest() {
231 try {
232 if(mTestListReader != null)
233 mTestListReader.close();
234 } catch (IOException ioe) {
235 Log.w(LOGTAG, "Failed to close test list file.", ioe);
236 }
Guang Zhu6bf18ba2009-09-15 23:47:20 -0700237 ForwardService.getForwardService().stopForwardService();
Guang Zhuf92bd422009-06-29 10:40:55 -0700238 finished();
239 }
240
241 private void moveToNextTest() {
242 String url = null;
243 try {
244 url = mTestListReader.readLine();
245 } catch (IOException ioe) {
246 Log.e(LOGTAG, "Failed to read next test.", ioe);
247 finishUiAutoTest();
248 return;
249 }
250 if (url == null) {
251 mUiAutoTestPath = null;
252 finishUiAutoTest();
253 AlertDialog.Builder builder = new AlertDialog.Builder(this);
254 builder.setMessage("All tests finished. Exit?")
255 .setCancelable(false)
256 .setPositiveButton("Yes", new OnClickListener(){
257 public void onClick(DialogInterface dialog, int which) {
258 TestShellActivity.this.finish();
259 }
260 })
261 .setNegativeButton("No", new OnClickListener(){
262 public void onClick(DialogInterface dialog, int which) {
263 dialog.cancel();
264 }
265 });
266 builder.create().show();
267 return;
268 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700269 Intent intent = new Intent(Intent.ACTION_VIEW);
270 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
Guang Zhu6bf18ba2009-09-15 23:47:20 -0700271 intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(url));
Ben Murdoch9b815d02010-06-01 18:45:10 +0100272 intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, ++mCurrentTestNumber);
Guang Zhuf92bd422009-06-29 10:40:55 -0700273 intent.putExtra(TIMEOUT_IN_MILLIS, 10000);
274 executeIntent(intent);
275 }
276
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700277 @Override
278 protected void onStop() {
279 super.onStop();
280 mWebView.stopLoading();
281 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700282
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700283 @Override
284 protected void onDestroy() {
285 super.onDestroy();
286 mWebView.destroy();
287 mWebView = null;
288 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700289
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700290 @Override
291 public void onLowMemory() {
292 super.onLowMemory();
Feng Qian0aeed6a2009-07-16 20:53:31 -0700293 Log.e(LOGTAG, "Low memory, clearing caches");
294 mWebView.freeMemory();
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700295 }
296
297 // Dump the page
298 public void dump(boolean timeout, String webkitData) {
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100299 mDumpWebKitData = true;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700300 if (mResultFile == null || mResultFile.length() == 0) {
301 finished();
302 return;
303 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700304
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700305 try {
306 File parentDir = new File(mResultFile).getParentFile();
307 if (!parentDir.exists()) {
308 parentDir.mkdirs();
309 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700310
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700311 FileOutputStream os = new FileOutputStream(mResultFile);
312 if (timeout) {
313 Log.w("Layout test: Timeout", mResultFile);
314 os.write(TIMEOUT_STR.getBytes());
315 os.write('\n');
316 }
317 if (mDumpTitleChanges)
318 os.write(mTitleChanges.toString().getBytes());
319 if (mDialogStrings != null)
320 os.write(mDialogStrings.toString().getBytes());
321 mDialogStrings = null;
Ben Murdoche6f3e452009-04-22 16:02:31 +0100322 if (mDatabaseCallbackStrings != null)
323 os.write(mDatabaseCallbackStrings.toString().getBytes());
324 mDatabaseCallbackStrings = null;
325 if (mConsoleMessages != null)
326 os.write(mConsoleMessages.toString().getBytes());
327 mConsoleMessages = null;
Feng Qianbe42388b2009-04-16 10:05:38 -0700328 if (webkitData != null)
329 os.write(webkitData.getBytes());
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700330 os.flush();
331 os.close();
332 } catch (IOException ex) {
Guang Zhuf92bd422009-06-29 10:40:55 -0700333 Log.e(LOGTAG, "Cannot write to " + mResultFile + ", " + ex.getMessage());
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700334 }
335
336 finished();
337 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700338
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700339 public void setCallback(TestShellCallback callback) {
340 mCallback = callback;
341 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700342
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100343 public boolean finished() {
344 if (canMoveToNextTest()) {
345 mHandler.removeMessages(MSG_TIMEOUT);
Ben Murdoch977f7692009-09-16 20:13:07 +0100346 if (mUiAutoTestPath != null) {
347 //don't really finish here
348 moveToNextTest();
349 } else {
350 if (mCallback != null) {
351 mCallback.finished();
352 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700353 }
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100354 return true;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700355 }
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100356 return false;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700357 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700358
Guang Zhu1871fe02009-04-29 14:49:03 -0700359 public void setDefaultDumpDataType(DumpDataType defaultDumpDataType) {
360 mDefaultDumpDataType = defaultDumpDataType;
361 }
362
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700363 // .......................................
364 // LayoutTestController Functions
Ben Murdoch357d2802010-07-23 16:18:58 +0100365 public void dumpAsText(boolean enablePixelTests) {
366 // Added after webkit update to r63859. See trac.webkit.org/changeset/63730.
367 if (enablePixelTests) {
368 Log.v(LOGTAG, "dumpAsText(enablePixelTests == true) not implemented on Android!");
369 }
370
Guang Zhu1871fe02009-04-29 14:49:03 -0700371 mDumpDataType = DumpDataType.DUMP_AS_TEXT;
Shimeng (Simon) Wangad456862010-06-16 17:32:24 -0700372 mDumpTopFrameAsText = true;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700373 if (mWebView != null) {
374 String url = mWebView.getUrl();
375 Log.v(LOGTAG, "dumpAsText called: "+url);
376 }
377 }
378
Shimeng (Simon) Wangad456862010-06-16 17:32:24 -0700379 public void dumpChildFramesAsText() {
380 mDumpDataType = DumpDataType.DUMP_AS_TEXT;
381 mDumpChildFramesAsText = true;
382 if (mWebView != null) {
383 String url = mWebView.getUrl();
384 Log.v(LOGTAG, "dumpChildFramesAsText called: "+url);
385 }
386 }
387
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700388 public void waitUntilDone() {
389 mWaitUntilDone = true;
390 String url = mWebView.getUrl();
391 Log.v(LOGTAG, "waitUntilDone called: " + url);
392 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700393
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700394 public void notifyDone() {
395 String url = mWebView.getUrl();
396 Log.v(LOGTAG, "notifyDone called: " + url);
397 if (mWaitUntilDone) {
398 mWaitUntilDone = false;
Ben Murdoch1620bcd2010-06-03 11:51:54 +0100399 if (!mRequestedWebKitData && !mTimedOut && !finished()) {
400 requestWebKitData();
401 }
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700402 }
403 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700404
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700405 public void display() {
406 mWebView.invalidate();
407 }
408
409 public void clearBackForwardList() {
410 mWebView.clearHistory();
411
412 }
413
414 public void dumpBackForwardList() {
415 //printf("\n============== Back Forward List ==============\n");
416 // mWebHistory
417 //printf("===============================================\n");
418
419 }
420
421 public void dumpChildFrameScrollPositions() {
422 // TODO Auto-generated method stub
423
424 }
425
426 public void dumpEditingCallbacks() {
427 // TODO Auto-generated method stub
428
429 }
430
431 public void dumpSelectionRect() {
432 // TODO Auto-generated method stub
433
434 }
435
436 public void dumpTitleChanges() {
437 if (!mDumpTitleChanges) {
438 mTitleChanges = new StringBuffer();
439 }
440 mDumpTitleChanges = true;
441 }
442
443 public void keepWebHistory() {
444 if (!mKeepWebHistory) {
445 mWebHistory = new Vector();
446 }
447 mKeepWebHistory = true;
448 }
449
450 public void queueBackNavigation(int howfar) {
451 // TODO Auto-generated method stub
452
453 }
454
455 public void queueForwardNavigation(int howfar) {
456 // TODO Auto-generated method stub
457
458 }
459
460 public void queueLoad(String Url, String frameTarget) {
461 // TODO Auto-generated method stub
462
463 }
464
465 public void queueReload() {
466 mWebView.reload();
467 }
468
469 public void queueScript(String scriptToRunInCurrentContext) {
Guang Zhuf92bd422009-06-29 10:40:55 -0700470 mWebView.loadUrl("javascript:"+scriptToRunInCurrentContext);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700471 }
472
473 public void repaintSweepHorizontally() {
474 // TODO Auto-generated method stub
475
476 }
477
478 public void setAcceptsEditing(boolean b) {
479 // TODO Auto-generated method stub
480
481 }
482
483 public void setMainFrameIsFirstResponder(boolean b) {
484 // TODO Auto-generated method stub
485
486 }
487
488 public void setWindowIsKey(boolean b) {
489 // This is meant to show/hide the window. The best I can find
490 // is setEnabled()
491 mWebView.setEnabled(b);
492 }
493
494 public void testRepaint() {
495 mWebView.invalidate();
496 }
Ben Murdoche6f3e452009-04-22 16:02:31 +0100497
498 public void dumpDatabaseCallbacks() {
499 Log.v(LOGTAG, "dumpDatabaseCallbacks called.");
500 mDumpDatabaseCallbacks = true;
501 }
502
503 public void setCanOpenWindows() {
504 Log.v(LOGTAG, "setCanOpenWindows called.");
505 mCanOpenWindows = true;
506 }
507
Steve Blockdad347c2009-08-19 18:46:34 +0100508 /**
509 * Sets the Geolocation permission state to be used for all future requests.
510 */
511 public void setGeolocationPermission(boolean allow) {
Steve Blockf0f30c62010-08-18 15:15:42 +0100512 mIsGeolocationPermissionSet = true;
Steve Blockdad347c2009-08-19 18:46:34 +0100513 mGeolocationPermission = allow;
Steve Blockf0f30c62010-08-18 15:15:42 +0100514
515 if (mPendingGeolocationPermissionCallbacks != null) {
516 Iterator iter = mPendingGeolocationPermissionCallbacks.keySet().iterator();
517 while (iter.hasNext()) {
518 GeolocationPermissions.Callback callback =
519 (GeolocationPermissions.Callback) iter.next();
520 String origin = (String) mPendingGeolocationPermissionCallbacks.get(callback);
521 callback.invoke(origin, mGeolocationPermission, false);
522 }
523 mPendingGeolocationPermissionCallbacks = null;
524 }
Steve Blockdad347c2009-08-19 18:46:34 +0100525 }
526
Steve Block68dede32010-08-04 10:28:46 +0100527 public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
528 boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) {
529 mWebView.setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta,
530 canProvideGamma, gamma);
531 }
532
Steve Blockfb0de342010-03-19 18:48:35 +0000533 public void overridePreference(String key, boolean value) {
534 // TODO: We should look up the correct WebView for the frame which
535 // called the layoutTestController method. Currently, we just use the
536 // WebView for the main frame. EventSender suffers from the same
537 // problem.
Steve Block5f37cc432010-10-13 18:44:31 +0100538 if (WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED.equals(key)) {
Steve Blockfb0de342010-03-19 18:48:35 +0000539 mWebView.getSettings().setAppCacheEnabled(value);
Steve Block5f37cc432010-10-13 18:44:31 +0100540 } else if (WEBKIT_USES_PAGE_CACHE_PREFERENCE_KEY.equals(key)) {
541 // Cache the maximum possible number of pages.
542 mWebView.getSettings().setPageCacheCapacity(Integer.MAX_VALUE);
543 } else {
544 Log.w(LOGTAG, "LayoutTestController.overridePreference(): " +
545 "Unsupported preference '" + key + "'");
Steve Blockfb0de342010-03-19 18:48:35 +0000546 }
547 }
548
Elliott Slaughter5dc0c822010-06-22 11:31:54 -0700549 public void setXSSAuditorEnabled (boolean flag) {
550 mWebView.getSettings().setXSSAuditorEnabled(flag);
551 }
552
Ben Murdoche6f3e452009-04-22 16:02:31 +0100553 private final WebViewClient mViewClient = new WebViewClient(){
554 @Override
555 public void onPageFinished(WebView view, String url) {
556 Log.v(LOGTAG, "onPageFinished, url=" + url);
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100557 mPageFinished = true;
Guang Zhu5dc4f212009-10-29 18:24:54 -0700558 // get page draw time
559 if (FsUtils.isTestPageUrl(url)) {
560 if (mGetDrawtime) {
561 long[] times = new long[DRAW_RUNS];
562 times = getDrawWebViewTime(mWebView, DRAW_RUNS);
563 FsUtils.writeDrawTime(DRAW_TIME_LOG, url, times);
564 }
565 if (mSaveImagePath != null) {
566 String name = FsUtils.getLastSegmentInPath(url);
567 drawPageToFile(mSaveImagePath + "/" + name + ".png", mWebView);
568 }
569 }
Ben Murdoch1620bcd2010-06-03 11:51:54 +0100570
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100571 // Calling finished() will check if we've met all the conditions for completing
Ben Murdoch1620bcd2010-06-03 11:51:54 +0100572 // this test and move to the next one if we are ready. Otherwise we ask WebCore to
573 // dump the page.
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100574 if (finished()) {
575 return;
576 }
Ben Murdoch1620bcd2010-06-03 11:51:54 +0100577
578 if (!mWaitUntilDone && !mRequestedWebKitData && !mTimedOut) {
579 requestWebKitData();
580 } else {
581 if (mWaitUntilDone) {
582 Log.v(LOGTAG, "page finished loading but waiting for notifyDone to be called: " + url);
583 }
584
585 if (mRequestedWebKitData) {
586 Log.v(LOGTAG, "page finished loading but webkit data has already been requested: " + url);
587 }
588
589 if (mTimedOut) {
590 Log.v(LOGTAG, "page finished loading but already timed out: " + url);
591 }
592 }
593
Ben Murdoche6f3e452009-04-22 16:02:31 +0100594 super.onPageFinished(view, url);
595 }
596
597 @Override
598 public void onPageStarted(WebView view, String url, Bitmap favicon) {
599 Log.v(LOGTAG, "onPageStarted, url=" + url);
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100600 mPageFinished = false;
Ben Murdoche6f3e452009-04-22 16:02:31 +0100601 super.onPageStarted(view, url, favicon);
602 }
603
604 @Override
605 public void onReceivedError(WebView view, int errorCode, String description,
606 String failingUrl) {
607 Log.v(LOGTAG, "onReceivedError, errorCode=" + errorCode
608 + ", desc=" + description + ", url=" + failingUrl);
609 super.onReceivedError(view, errorCode, description, failingUrl);
610 }
611
612 @Override
613 public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler,
614 String host, String realm) {
Steve Block2bb25532010-03-25 14:48:13 +0000615 if (handler.useHttpAuthUsernamePassword() && view != null) {
616 String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
617 if (credentials != null && credentials.length == 2) {
618 handler.proceed(credentials[0], credentials[1]);
619 return;
620 }
621 }
Ben Murdoche6f3e452009-04-22 16:02:31 +0100622 handler.cancel();
623 }
624
625 @Override
626 public void onReceivedSslError(WebView view, SslErrorHandler handler,
627 SslError error) {
628 handler.proceed();
629 }
630 };
631
632
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700633 private final WebChromeClient mChromeClient = new WebChromeClient() {
634 @Override
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700635 public void onReceivedTitle(WebView view, String title) {
Ben Murdoch9b815d02010-06-01 18:45:10 +0100636 setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount + ": "+ title);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700637 if (mDumpTitleChanges) {
638 mTitleChanges.append("TITLE CHANGED: ");
639 mTitleChanges.append(title);
640 mTitleChanges.append("\n");
641 }
642 }
643
644 @Override
645 public boolean onJsAlert(WebView view, String url, String message,
646 JsResult result) {
647 if (mDialogStrings == null) {
648 mDialogStrings = new StringBuffer();
649 }
650 mDialogStrings.append("ALERT: ");
651 mDialogStrings.append(message);
652 mDialogStrings.append('\n');
653 result.confirm();
654 return true;
655 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700656
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700657 @Override
658 public boolean onJsConfirm(WebView view, String url, String message,
659 JsResult result) {
660 if (mDialogStrings == null) {
661 mDialogStrings = new StringBuffer();
662 }
663 mDialogStrings.append("CONFIRM: ");
664 mDialogStrings.append(message);
665 mDialogStrings.append('\n');
666 result.confirm();
667 return true;
668 }
Guang Zhuf92bd422009-06-29 10:40:55 -0700669
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700670 @Override
671 public boolean onJsPrompt(WebView view, String url, String message,
672 String defaultValue, JsPromptResult result) {
673 if (mDialogStrings == null) {
674 mDialogStrings = new StringBuffer();
675 }
676 mDialogStrings.append("PROMPT: ");
677 mDialogStrings.append(message);
678 mDialogStrings.append(", default text: ");
679 mDialogStrings.append(defaultValue);
680 mDialogStrings.append('\n');
681 result.confirm();
682 return true;
683 }
Ben Murdoche6f3e452009-04-22 16:02:31 +0100684
685 @Override
Guang Zhuf4bf5522009-07-23 14:19:35 -0700686 public boolean onJsTimeout() {
687 Log.v(LOGTAG, "JavaScript timeout");
688 return false;
689 }
690
691 @Override
Ben Murdoche6f3e452009-04-22 16:02:31 +0100692 public void onExceededDatabaseQuota(String url_str,
Ben Murdochd497d872009-08-25 19:32:54 +0100693 String databaseIdentifier, long currentQuota,
694 long estimatedSize, long totalUsedQuota,
Ben Murdoche6f3e452009-04-22 16:02:31 +0100695 WebStorage.QuotaUpdater callback) {
696 if (mDumpDatabaseCallbacks) {
697 if (mDatabaseCallbackStrings == null) {
698 mDatabaseCallbackStrings = new StringBuffer();
699 }
700
701 String protocol = "";
702 String host = "";
703 int port = 0;
704
705 try {
706 URL url = new URL(url_str);
707 protocol = url.getProtocol();
708 host = url.getHost();
709 if (url.getPort() > -1) {
710 port = url.getPort();
711 }
712 } catch (MalformedURLException e) {}
713
714 String databaseCallbackString =
715 "UI DELEGATE DATABASE CALLBACK: " +
716 "exceededDatabaseQuotaForSecurityOrigin:{" + protocol +
717 ", " + host + ", " + port + "} database:" +
718 databaseIdentifier + "\n";
719 Log.v(LOGTAG, "LOG: "+databaseCallbackString);
720 mDatabaseCallbackStrings.append(databaseCallbackString);
721 }
722 // Give 5MB more quota.
723 callback.updateQuota(currentQuota + 1024 * 1024 * 5);
724 }
725
Steve Blockdad347c2009-08-19 18:46:34 +0100726 /**
727 * Instructs the client to show a prompt to ask the user to set the
728 * Geolocation permission state for the specified origin.
729 */
730 @Override
731 public void onGeolocationPermissionsShowPrompt(String origin,
732 GeolocationPermissions.Callback callback) {
Steve Blockf0f30c62010-08-18 15:15:42 +0100733 if (mIsGeolocationPermissionSet) {
Steve Blockdad347c2009-08-19 18:46:34 +0100734 callback.invoke(origin, mGeolocationPermission, false);
Steve Blockf0f30c62010-08-18 15:15:42 +0100735 return;
Steve Blockdad347c2009-08-19 18:46:34 +0100736 }
Steve Blockf0f30c62010-08-18 15:15:42 +0100737 if (mPendingGeolocationPermissionCallbacks == null) {
738 mPendingGeolocationPermissionCallbacks =
739 new HashMap<GeolocationPermissions.Callback, String>();
740 }
741 mPendingGeolocationPermissionCallbacks.put(callback, origin);
Steve Blockdad347c2009-08-19 18:46:34 +0100742 }
743
Ben Murdoche6f3e452009-04-22 16:02:31 +0100744 @Override
Guang Zhu6c15f602010-05-03 11:49:04 -0700745 public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
746 String msg = "CONSOLE MESSAGE: line " + consoleMessage.lineNumber() + ": "
747 + consoleMessage.message() + "\n";
Ben Murdoche6f3e452009-04-22 16:02:31 +0100748 if (mConsoleMessages == null) {
749 mConsoleMessages = new StringBuffer();
750 }
Guang Zhu6c15f602010-05-03 11:49:04 -0700751 mConsoleMessages.append(msg);
752 Log.v(LOGTAG, "LOG: " + msg);
753 // the rationale here is that if there's an error of either type, and the test was
754 // waiting for "notifyDone" signal to finish, then there's no point in waiting
755 // anymore because the JS execution is already terminated at this point and a
756 // "notifyDone" will never come out so it's just wasting time till timeout kicks in
Guang Zhu5d53c192010-07-14 17:17:54 -0700757 if ((msg.contains("Uncaught ReferenceError:") || msg.contains("Uncaught TypeError:"))
758 && mWaitUntilDone && mStopOnRefError) {
Guang Zhu6c15f602010-05-03 11:49:04 -0700759 Log.w(LOGTAG, "Terminating test case on uncaught ReferenceError or TypeError.");
760 mHandler.postDelayed(new Runnable() {
761 public void run() {
762 notifyDone();
763 }
764 }, 500);
765 }
766 return true;
Ben Murdoche6f3e452009-04-22 16:02:31 +0100767 }
768
769 @Override
770 public boolean onCreateWindow(WebView view, boolean dialog,
771 boolean userGesture, Message resultMsg) {
772 if (!mCanOpenWindows) {
Ben Murdochfc4a69e2010-02-04 16:35:10 +0000773 // We can't open windows, so just send null back.
774 WebView.WebViewTransport transport =
775 (WebView.WebViewTransport) resultMsg.obj;
776 transport.setWebView(null);
777 resultMsg.sendToTarget();
778 return true;
Ben Murdoche6f3e452009-04-22 16:02:31 +0100779 }
780
781 // We never display the new window, just create the view and
782 // allow it's content to execute and be recorded by the test
783 // runner.
784
Andrei Popescu4950b2b2009-09-03 13:56:07 +0100785 HashMap<String, Object> jsIfaces = new HashMap<String, Object>();
786 jsIfaces.put("layoutTestController", mCallbackProxy);
787 jsIfaces.put("eventSender", mCallbackProxy);
788 WebView newWindowView = new NewWindowWebView(TestShellActivity.this, jsIfaces);
Ben Murdoche6f3e452009-04-22 16:02:31 +0100789 setupWebViewForLayoutTests(newWindowView, mCallbackProxy);
790 WebView.WebViewTransport transport =
791 (WebView.WebViewTransport) resultMsg.obj;
792 transport.setWebView(newWindowView);
793 resultMsg.sendToTarget();
794 return true;
795 }
Ben Murdochfc4a69e2010-02-04 16:35:10 +0000796
797 @Override
798 public void onCloseWindow(WebView view) {
799 view.destroy();
800 }
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700801 };
Guang Zhuf92bd422009-06-29 10:40:55 -0700802
Andrei Popescu4950b2b2009-09-03 13:56:07 +0100803 private static class NewWindowWebView extends WebView {
804 public NewWindowWebView(Context context, Map<String, Object> jsIfaces) {
Elliott Slaughterf21d2e32010-07-14 18:08:54 -0700805 super(context, null, 0, jsIfaces, false);
Andrei Popescu4950b2b2009-09-03 13:56:07 +0100806 }
807 }
808
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700809 private void resetTestStatus() {
810 mWaitUntilDone = false;
Guang Zhu1871fe02009-04-29 14:49:03 -0700811 mDumpDataType = mDefaultDumpDataType;
Shimeng (Simon) Wangad456862010-06-16 17:32:24 -0700812 mDumpTopFrameAsText = false;
813 mDumpChildFramesAsText = false;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700814 mTimedOut = false;
815 mDumpTitleChanges = false;
816 mRequestedWebKitData = false;
Ben Murdoche6f3e452009-04-22 16:02:31 +0100817 mDumpDatabaseCallbacks = false;
818 mCanOpenWindows = false;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700819 mEventSender.resetMouse();
Ben Murdochecbc65c2010-01-13 10:54:56 +0000820 mEventSender.clearTouchPoints();
Ben Murdoch8a032a32010-02-02 18:20:11 +0000821 mEventSender.clearTouchMetaState();
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100822 mPageFinished = false;
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100823 mDumpWebKitData = false;
Guang Zhu5dc4f212009-10-29 18:24:54 -0700824 mGetDrawtime = false;
825 mSaveImagePath = null;
Ben Murdocha8b97682010-04-15 12:20:48 -0700826 setDefaultWebSettings(mWebView);
Steve Blockf0f30c62010-08-18 15:15:42 +0100827 mIsGeolocationPermissionSet = false;
828 mPendingGeolocationPermissionCallbacks = null;
Ben Murdoch7e73ce92011-01-20 11:21:24 +0000829 CookieManager.getInstance().removeAllCookie();
Guang Zhu5dc4f212009-10-29 18:24:54 -0700830 }
831
832 private long[] getDrawWebViewTime(WebView view, int count) {
833 if (count == 0)
834 return null;
835 long[] ret = new long[count];
836 long start;
837 Canvas canvas = new Canvas();
838 Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
839 canvas.setBitmap(bitmap);
840 for (int i = 0; i < count; i++) {
841 start = System.currentTimeMillis();
842 view.draw(canvas);
843 ret[i] = System.currentTimeMillis() - start;
844 }
845 return ret;
846 }
847
848 private void drawPageToFile(String fileName, WebView view) {
849 Canvas canvas = new Canvas();
850 Bitmap bitmap = Bitmap.createBitmap(view.getContentWidth(), view.getContentHeight(),
851 Config.ARGB_8888);
852 canvas.setBitmap(bitmap);
853 view.drawPage(canvas);
854 try {
855 FileOutputStream fos = new FileOutputStream(fileName);
856 if(!bitmap.compress(CompressFormat.PNG, 90, fos)) {
857 Log.w(LOGTAG, "Failed to compress and save image.");
858 }
859 } catch (IOException ioe) {
860 Log.e(LOGTAG, "", ioe);
861 }
862 bitmap.recycle();
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100863 }
864
865 private boolean canMoveToNextTest() {
Ben Murdoch1620bcd2010-06-03 11:51:54 +0100866 return (mDumpWebKitData && mPageFinished && !mWaitUntilDone) || mTimedOut;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700867 }
Ben Murdoche6f3e452009-04-22 16:02:31 +0100868
869 private void setupWebViewForLayoutTests(WebView webview, CallbackProxy callbackProxy) {
870 if (webview == null) {
871 return;
872 }
873
Ben Murdocha8b97682010-04-15 12:20:48 -0700874 setDefaultWebSettings(webview);
875
876 webview.setWebChromeClient(mChromeClient);
877 webview.setWebViewClient(mViewClient);
878 // Setting a touch interval of -1 effectively disables the optimisation in WebView
879 // that stops repeated touch events flooding WebCore. The Event Sender only sends a
880 // single event rather than a stream of events (like what would generally happen in
881 // a real use of touch events in a WebView) and so if the WebView drops the event,
882 // the test will fail as the test expects one callback for every touch it synthesizes.
883 webview.setTouchInterval(-1);
884 }
885
886 public void setDefaultWebSettings(WebView webview) {
Ben Murdoche6f3e452009-04-22 16:02:31 +0100887 WebSettings settings = webview.getSettings();
Guang Zhuf4bf5522009-07-23 14:19:35 -0700888 settings.setAppCacheEnabled(true);
889 settings.setAppCachePath(getApplicationContext().getCacheDir().getPath());
890 settings.setAppCacheMaxSize(Long.MAX_VALUE);
Ben Murdoche6f3e452009-04-22 16:02:31 +0100891 settings.setJavaScriptEnabled(true);
892 settings.setJavaScriptCanOpenWindowsAutomatically(true);
893 settings.setSupportMultipleWindows(true);
894 settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
895 settings.setDatabaseEnabled(true);
896 settings.setDatabasePath(getDir("databases",0).getAbsolutePath());
897 settings.setDomStorageEnabled(true);
Guang Zhub028f922009-08-11 14:27:32 -0700898 settings.setWorkersEnabled(false);
Elliott Slaughterbe1304f2010-06-23 11:29:02 -0700899 settings.setXSSAuditorEnabled(false);
Steve Block5f37cc432010-10-13 18:44:31 +0100900 settings.setPageCacheCapacity(0);
Ben Murdoche6f3e452009-04-22 16:02:31 +0100901 }
902
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700903 private WebView mWebView;
904 private WebViewEventSender mEventSender;
905 private AsyncHandler mHandler;
906 private TestShellCallback mCallback;
907
908 private CallbackProxy mCallbackProxy;
Guang Zhuf92bd422009-06-29 10:40:55 -0700909
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700910 private String mTestUrl;
911 private String mResultFile;
912 private int mTimeoutInMillis;
Guang Zhuf92bd422009-06-29 10:40:55 -0700913 private String mUiAutoTestPath;
Guang Zhu5dc4f212009-10-29 18:24:54 -0700914 private String mSaveImagePath;
Guang Zhuf92bd422009-06-29 10:40:55 -0700915 private BufferedReader mTestListReader;
Guang Zhu5dc4f212009-10-29 18:24:54 -0700916 private boolean mGetDrawtime;
Ben Murdoch9b815d02010-06-01 18:45:10 +0100917 private int mTotalTestCount;
918 private int mCurrentTestNumber;
Guang Zhu5d53c192010-07-14 17:17:54 -0700919 private boolean mStopOnRefError;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700920
921 // States
922 private boolean mTimedOut;
923 private boolean mRequestedWebKitData;
924 private boolean mFinishedRunning;
925
926 // Layout test controller variables.
Guang Zhu1871fe02009-04-29 14:49:03 -0700927 private DumpDataType mDumpDataType;
928 private DumpDataType mDefaultDumpDataType = DumpDataType.EXT_REPR;
Shimeng (Simon) Wangad456862010-06-16 17:32:24 -0700929 private boolean mDumpTopFrameAsText;
930 private boolean mDumpChildFramesAsText;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700931 private boolean mWaitUntilDone;
932 private boolean mDumpTitleChanges;
933 private StringBuffer mTitleChanges;
934 private StringBuffer mDialogStrings;
935 private boolean mKeepWebHistory;
936 private Vector mWebHistory;
Ben Murdoche6f3e452009-04-22 16:02:31 +0100937 private boolean mDumpDatabaseCallbacks;
938 private StringBuffer mDatabaseCallbackStrings;
939 private StringBuffer mConsoleMessages;
940 private boolean mCanOpenWindows;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700941
Ben Murdoch2eea5f32009-09-23 15:28:57 +0100942 private boolean mPageFinished = false;
943 private boolean mDumpWebKitData = false;
Ben Murdoch977f7692009-09-16 20:13:07 +0100944
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700945 static final String TIMEOUT_STR = "**Test timeout";
Steve Block8e8cf732011-02-10 10:51:45 -0800946 static final long DUMP_TIMEOUT_MS = 100000; // 100s timeout for dumping webview content
Guang Zhuf92bd422009-06-29 10:40:55 -0700947
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700948 static final int MSG_TIMEOUT = 0;
949 static final int MSG_WEBKIT_DATA = 1;
Guang Zhuf37a5742010-12-23 14:37:31 -0800950 static final int MSG_DUMP_TIMEOUT = 2;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700951
952 static final String LOGTAG="TestShell";
Guang Zhuf92bd422009-06-29 10:40:55 -0700953
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700954 static final String TEST_URL = "TestUrl";
955 static final String RESULT_FILE = "ResultFile";
956 static final String TIMEOUT_IN_MILLIS = "TimeoutInMillis";
Guang Zhuf92bd422009-06-29 10:40:55 -0700957 static final String UI_AUTO_TEST = "UiAutoTest";
Guang Zhu5dc4f212009-10-29 18:24:54 -0700958 static final String GET_DRAW_TIME = "GetDrawTime";
959 static final String SAVE_IMAGE = "SaveImage";
Ben Murdoch9b815d02010-06-01 18:45:10 +0100960 static final String TOTAL_TEST_COUNT = "TestCount";
961 static final String CURRENT_TEST_NUMBER = "TestNumber";
Guang Zhu5d53c192010-07-14 17:17:54 -0700962 static final String STOP_ON_REF_ERROR = "StopOnReferenceError";
Guang Zhu5dc4f212009-10-29 18:24:54 -0700963
964 static final int DRAW_RUNS = 5;
Christian Mehlmauer8b85dce2010-07-19 20:11:27 +0200965 static final String DRAW_TIME_LOG = Environment.getExternalStorageDirectory() +
966 "/android/page_draw_time.txt";
Steve Blockdad347c2009-08-19 18:46:34 +0100967
Steve Blockf0f30c62010-08-18 15:15:42 +0100968 private boolean mIsGeolocationPermissionSet;
Steve Blockdad347c2009-08-19 18:46:34 +0100969 private boolean mGeolocationPermission;
Steve Blockf0f30c62010-08-18 15:15:42 +0100970 private Map mPendingGeolocationPermissionCallbacks;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700971}