summaryrefslogtreecommitdiffstats
path: root/tests/DumpRenderTree/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/DumpRenderTree/src')
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java529
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/EventSender.java39
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java229
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java196
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java225
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostApp.java33
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java82
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java80
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java494
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java298
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java90
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java308
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java946
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java23
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java413
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/AdbUtils.java127
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardServer.java133
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java117
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java109
19 files changed, 0 insertions, 4471 deletions
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
deleted file mode 100644
index 9d621d6..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.webkit.WebStorage;
-
-import java.util.HashMap;
-
-public class CallbackProxy extends Handler implements EventSender, LayoutTestController {
-
- private EventSender mEventSender;
- private LayoutTestController mLayoutTestController;
-
- private static final int EVENT_DOM_LOG = 1;
- private static final int EVENT_FIRE_KBD = 2;
- private static final int EVENT_KEY_DOWN_1 = 3;
- private static final int EVENT_KEY_DOWN_2 = 4;
- private static final int EVENT_LEAP = 5;
- private static final int EVENT_MOUSE_CLICK = 6;
- private static final int EVENT_MOUSE_DOWN = 7;
- private static final int EVENT_MOUSE_MOVE = 8;
- private static final int EVENT_MOUSE_UP = 9;
- private static final int EVENT_TOUCH_START = 10;
- private static final int EVENT_TOUCH_MOVE = 11;
- private static final int EVENT_TOUCH_END = 12;
- private static final int EVENT_TOUCH_CANCEL = 13;
- private static final int EVENT_ADD_TOUCH_POINT = 14;
- private static final int EVENT_UPDATE_TOUCH_POINT = 15;
- private static final int EVENT_RELEASE_TOUCH_POINT = 16;
- private static final int EVENT_CLEAR_TOUCH_POINTS = 17;
- private static final int EVENT_CANCEL_TOUCH_POINT = 18;
- private static final int EVENT_SET_TOUCH_MODIFIER = 19;
- private static final int LAYOUT_CLEAR_LIST = 20;
- private static final int LAYOUT_DISPLAY = 21;
- private static final int LAYOUT_DUMP_TEXT = 22;
- private static final int LAYOUT_DUMP_HISTORY = 23;
- private static final int LAYOUT_DUMP_CHILD_SCROLL = 24;
- private static final int LAYOUT_DUMP_EDIT_CB = 25;
- private static final int LAYOUT_DUMP_SEL_RECT = 26;
- private static final int LAYOUT_DUMP_TITLE_CHANGES = 27;
- private static final int LAYOUT_KEEP_WEB_HISTORY = 28;
- private static final int LAYOUT_NOTIFY_DONE = 29;
- private static final int LAYOUT_QUEUE_BACK_NAV = 30;
- private static final int LAYOUT_QUEUE_FWD_NAV = 31;
- private static final int LAYOUT_QUEUE_LOAD = 32;
- private static final int LAYOUT_QUEUE_RELOAD = 33;
- private static final int LAYOUT_QUEUE_SCRIPT = 34;
- private static final int LAYOUT_REPAINT_HORZ = 35;
- private static final int LAYOUT_SET_ACCEPT_EDIT = 36;
- private static final int LAYOUT_MAIN_FIRST_RESP = 37;
- private static final int LAYOUT_SET_WINDOW_KEY = 38;
- private static final int LAYOUT_TEST_REPAINT = 39;
- private static final int LAYOUT_WAIT_UNTIL_DONE = 40;
- private static final int LAYOUT_DUMP_DATABASE_CALLBACKS = 41;
- private static final int LAYOUT_SET_CAN_OPEN_WINDOWS = 42;
- private static final int OVERRIDE_PREFERENCE = 43;
- private static final int LAYOUT_DUMP_CHILD_FRAMES_TEXT = 44;
- private static final int SET_XSS_AUDITOR_ENABLED = 45;
-
- CallbackProxy(EventSender eventSender,
- LayoutTestController layoutTestController) {
- mEventSender = eventSender;
- mLayoutTestController = layoutTestController;
- }
-
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case EVENT_DOM_LOG:
- mEventSender.enableDOMUIEventLogging(msg.arg1);
- break;
- case EVENT_FIRE_KBD:
- mEventSender.fireKeyboardEventsToElement(msg.arg1);
- break;
- case EVENT_KEY_DOWN_1:
- HashMap map = (HashMap) msg.obj;
- mEventSender.keyDown((String) map.get("character"),
- (String[]) map.get("withModifiers"));
- break;
-
- case EVENT_KEY_DOWN_2:
- mEventSender.keyDown((String)msg.obj);
- break;
-
- case EVENT_LEAP:
- mEventSender.leapForward(msg.arg1);
- break;
-
- case EVENT_MOUSE_CLICK:
- mEventSender.mouseClick();
- break;
-
- case EVENT_MOUSE_DOWN:
- mEventSender.mouseDown();
- break;
-
- case EVENT_MOUSE_MOVE:
- mEventSender.mouseMoveTo(msg.arg1, msg.arg2);
- break;
-
- case EVENT_MOUSE_UP:
- mEventSender.mouseUp();
- break;
-
- case EVENT_TOUCH_START:
- mEventSender.touchStart();
- break;
-
- case EVENT_TOUCH_MOVE:
- mEventSender.touchMove();
- break;
-
- case EVENT_TOUCH_END:
- mEventSender.touchEnd();
- break;
-
- case EVENT_TOUCH_CANCEL:
- mEventSender.touchCancel();
- break;
-
- case EVENT_ADD_TOUCH_POINT:
- mEventSender.addTouchPoint(msg.arg1, msg.arg2);
- break;
-
- case EVENT_UPDATE_TOUCH_POINT:
- Bundle args = (Bundle) msg.obj;
- int x = args.getInt("x");
- int y = args.getInt("y");
- int id = args.getInt("id");
- mEventSender.updateTouchPoint(id, x, y);
- break;
-
- case EVENT_SET_TOUCH_MODIFIER:
- Bundle modifierArgs = (Bundle) msg.obj;
- String modifier = modifierArgs.getString("modifier");
- boolean enabled = modifierArgs.getBoolean("enabled");
- mEventSender.setTouchModifier(modifier, enabled);
- break;
-
- case EVENT_RELEASE_TOUCH_POINT:
- mEventSender.releaseTouchPoint(msg.arg1);
- break;
-
- case EVENT_CLEAR_TOUCH_POINTS:
- mEventSender.clearTouchPoints();
- break;
-
- case EVENT_CANCEL_TOUCH_POINT:
- mEventSender.cancelTouchPoint(msg.arg1);
- break;
-
- case LAYOUT_CLEAR_LIST:
- mLayoutTestController.clearBackForwardList();
- break;
-
- case LAYOUT_DISPLAY:
- mLayoutTestController.display();
- break;
-
- case LAYOUT_DUMP_TEXT:
- mLayoutTestController.dumpAsText(msg.arg1 == 1);
- break;
-
- case LAYOUT_DUMP_CHILD_FRAMES_TEXT:
- mLayoutTestController.dumpChildFramesAsText();
- break;
-
- case LAYOUT_DUMP_HISTORY:
- mLayoutTestController.dumpBackForwardList();
- break;
-
- case LAYOUT_DUMP_CHILD_SCROLL:
- mLayoutTestController.dumpChildFrameScrollPositions();
- break;
-
- case LAYOUT_DUMP_EDIT_CB:
- mLayoutTestController.dumpEditingCallbacks();
- break;
-
- case LAYOUT_DUMP_SEL_RECT:
- mLayoutTestController.dumpSelectionRect();
- break;
-
- case LAYOUT_DUMP_TITLE_CHANGES:
- mLayoutTestController.dumpTitleChanges();
- break;
-
- case LAYOUT_KEEP_WEB_HISTORY:
- mLayoutTestController.keepWebHistory();
- break;
-
- case LAYOUT_NOTIFY_DONE:
- mLayoutTestController.notifyDone();
- break;
-
- case LAYOUT_QUEUE_BACK_NAV:
- mLayoutTestController.queueBackNavigation(msg.arg1);
- break;
-
- case LAYOUT_QUEUE_FWD_NAV:
- mLayoutTestController.queueForwardNavigation(msg.arg1);
- break;
-
- case LAYOUT_QUEUE_LOAD:
- HashMap<String, String> loadMap =
- (HashMap<String, String>) msg.obj;
- mLayoutTestController.queueLoad(loadMap.get("Url"),
- loadMap.get("frameTarget"));
- break;
-
- case LAYOUT_QUEUE_RELOAD:
- mLayoutTestController.queueReload();
- break;
-
- case LAYOUT_QUEUE_SCRIPT:
- mLayoutTestController.queueScript((String)msg.obj);
- break;
-
- case LAYOUT_REPAINT_HORZ:
- mLayoutTestController.repaintSweepHorizontally();
- break;
-
- case LAYOUT_SET_ACCEPT_EDIT:
- mLayoutTestController.setAcceptsEditing(
- msg.arg1 == 1 ? true : false);
- break;
- case LAYOUT_MAIN_FIRST_RESP:
- mLayoutTestController.setMainFrameIsFirstResponder(
- msg.arg1 == 1 ? true : false);
- break;
-
- case LAYOUT_SET_WINDOW_KEY:
- mLayoutTestController.setWindowIsKey(
- msg.arg1 == 1 ? true : false);
- break;
-
- case LAYOUT_TEST_REPAINT:
- mLayoutTestController.testRepaint();
- break;
-
- case LAYOUT_WAIT_UNTIL_DONE:
- mLayoutTestController.waitUntilDone();
- break;
-
- case LAYOUT_DUMP_DATABASE_CALLBACKS:
- mLayoutTestController.dumpDatabaseCallbacks();
- break;
-
- case LAYOUT_SET_CAN_OPEN_WINDOWS:
- mLayoutTestController.setCanOpenWindows();
- break;
-
- case OVERRIDE_PREFERENCE:
- String key = msg.getData().getString("key");
- boolean value = msg.getData().getBoolean("value");
- mLayoutTestController.overridePreference(key, value);
- break;
-
- case SET_XSS_AUDITOR_ENABLED:
- mLayoutTestController.setXSSAuditorEnabled(msg.arg1 == 1);
- break;
- }
- }
-
- // EventSender Methods
-
- public void enableDOMUIEventLogging(int DOMNode) {
- obtainMessage(EVENT_DOM_LOG, DOMNode, 0).sendToTarget();
- }
-
- public void fireKeyboardEventsToElement(int DOMNode) {
- obtainMessage(EVENT_FIRE_KBD, DOMNode, 0).sendToTarget();
- }
-
- public void keyDown(String character, String[] withModifiers) {
- // TODO Auto-generated method stub
- HashMap map = new HashMap();
- map.put("character", character);
- map.put("withModifiers", withModifiers);
- obtainMessage(EVENT_KEY_DOWN_1, map).sendToTarget();
- }
-
- public void keyDown(String character) {
- obtainMessage(EVENT_KEY_DOWN_2, character).sendToTarget();
- }
-
- public void leapForward(int milliseconds) {
- obtainMessage(EVENT_LEAP, milliseconds, 0).sendToTarget();
- }
-
- public void mouseClick() {
- obtainMessage(EVENT_MOUSE_CLICK).sendToTarget();
- }
-
- public void mouseDown() {
- obtainMessage(EVENT_MOUSE_DOWN).sendToTarget();
- }
-
- public void mouseMoveTo(int X, int Y) {
- obtainMessage(EVENT_MOUSE_MOVE, X, Y).sendToTarget();
- }
-
- public void mouseUp() {
- obtainMessage(EVENT_MOUSE_UP).sendToTarget();
- }
-
- public void touchStart() {
- obtainMessage(EVENT_TOUCH_START).sendToTarget();
- }
-
- public void addTouchPoint(int x, int y) {
- obtainMessage(EVENT_ADD_TOUCH_POINT, x, y).sendToTarget();
- }
-
- public void updateTouchPoint(int id, int x, int y) {
- Bundle map = new Bundle();
- map.putInt("x", x);
- map.putInt("y", y);
- map.putInt("id", id);
- obtainMessage(EVENT_UPDATE_TOUCH_POINT, map).sendToTarget();
- }
-
- public void setTouchModifier(String modifier, boolean enabled) {
- Bundle map = new Bundle();
- map.putString("modifier", modifier);
- map.putBoolean("enabled", enabled);
- obtainMessage(EVENT_SET_TOUCH_MODIFIER, map).sendToTarget();
- }
-
- public void touchMove() {
- obtainMessage(EVENT_TOUCH_MOVE).sendToTarget();
- }
-
- public void releaseTouchPoint(int id) {
- obtainMessage(EVENT_RELEASE_TOUCH_POINT, id, 0).sendToTarget();
- }
-
- public void touchEnd() {
- obtainMessage(EVENT_TOUCH_END).sendToTarget();
- }
-
- public void touchCancel() {
- obtainMessage(EVENT_TOUCH_CANCEL).sendToTarget();
- }
-
-
- public void clearTouchPoints() {
- obtainMessage(EVENT_CLEAR_TOUCH_POINTS).sendToTarget();
- }
-
- public void cancelTouchPoint(int id) {
- obtainMessage(EVENT_CANCEL_TOUCH_POINT, id, 0).sendToTarget();
- }
-
- // LayoutTestController Methods
-
- public void clearBackForwardList() {
- obtainMessage(LAYOUT_CLEAR_LIST).sendToTarget();
- }
-
- public void display() {
- obtainMessage(LAYOUT_DISPLAY).sendToTarget();
- }
-
- public void dumpAsText() {
- obtainMessage(LAYOUT_DUMP_TEXT, 0).sendToTarget();
- }
-
- public void dumpAsText(boolean enablePixelTests) {
- obtainMessage(LAYOUT_DUMP_TEXT, enablePixelTests ? 1 : 0).sendToTarget();
- }
-
- public void dumpChildFramesAsText() {
- obtainMessage(LAYOUT_DUMP_CHILD_FRAMES_TEXT).sendToTarget();
- }
-
- public void dumpBackForwardList() {
- obtainMessage(LAYOUT_DUMP_HISTORY).sendToTarget();
- }
-
- public void dumpChildFrameScrollPositions() {
- obtainMessage(LAYOUT_DUMP_CHILD_SCROLL).sendToTarget();
- }
-
- public void dumpEditingCallbacks() {
- obtainMessage(LAYOUT_DUMP_EDIT_CB).sendToTarget();
- }
-
- public void dumpSelectionRect() {
- obtainMessage(LAYOUT_DUMP_SEL_RECT).sendToTarget();
- }
-
- public void dumpTitleChanges() {
- obtainMessage(LAYOUT_DUMP_TITLE_CHANGES).sendToTarget();
- }
-
- public void keepWebHistory() {
- obtainMessage(LAYOUT_KEEP_WEB_HISTORY).sendToTarget();
- }
-
- public void notifyDone() {
- obtainMessage(LAYOUT_NOTIFY_DONE).sendToTarget();
- }
-
- public void queueBackNavigation(int howfar) {
- obtainMessage(LAYOUT_QUEUE_BACK_NAV, howfar, 0).sendToTarget();
- }
-
- public void queueForwardNavigation(int howfar) {
- obtainMessage(LAYOUT_QUEUE_FWD_NAV, howfar, 0).sendToTarget();
- }
-
- public void queueLoad(String Url, String frameTarget) {
- HashMap <String, String>map = new HashMap<String, String>();
- map.put("Url", Url);
- map.put("frameTarget", frameTarget);
- obtainMessage(LAYOUT_QUEUE_LOAD, map).sendToTarget();
- }
-
- public void queueReload() {
- obtainMessage(LAYOUT_QUEUE_RELOAD).sendToTarget();
- }
-
- public void queueScript(String scriptToRunInCurrentContext) {
- obtainMessage(LAYOUT_QUEUE_SCRIPT,
- scriptToRunInCurrentContext).sendToTarget();
- }
-
- public void repaintSweepHorizontally() {
- obtainMessage(LAYOUT_REPAINT_HORZ).sendToTarget();
- }
-
- public void setAcceptsEditing(boolean b) {
- obtainMessage(LAYOUT_SET_ACCEPT_EDIT, b ? 1 : 0, 0).sendToTarget();
- }
-
- public void setMainFrameIsFirstResponder(boolean b) {
- obtainMessage(LAYOUT_MAIN_FIRST_RESP, b ? 1 : 0, 0).sendToTarget();
- }
-
- public void setWindowIsKey(boolean b) {
- obtainMessage(LAYOUT_SET_WINDOW_KEY, b ? 1 : 0, 0).sendToTarget();
- }
-
- public void testRepaint() {
- obtainMessage(LAYOUT_TEST_REPAINT).sendToTarget();
- }
-
- public void waitUntilDone() {
- obtainMessage(LAYOUT_WAIT_UNTIL_DONE).sendToTarget();
- }
-
- public void dumpDatabaseCallbacks() {
- obtainMessage(LAYOUT_DUMP_DATABASE_CALLBACKS).sendToTarget();
- }
-
- public void clearAllDatabases() {
- WebStorage.getInstance().deleteAllData();
- }
-
- public void setDatabaseQuota(long quota) {
- WebStorage.getInstance().setQuotaForOrigin("file://", quota);
- }
-
- public void setAppCacheMaximumSize(long size) {
- android.webkit.WebStorageClassic.getInstance().setAppCacheMaximumSize(size);
- }
-
- public void setCanOpenWindows() {
- obtainMessage(LAYOUT_SET_CAN_OPEN_WINDOWS).sendToTarget();
- }
-
- public void setMockGeolocationPosition(double latitude,
- double longitude,
- double accuracy) {
- // Configuration is in WebKit, so stay on WebCore thread, but go via the TestShellActivity
- // as we need access to the Webview.
- mLayoutTestController.setMockGeolocationPosition(latitude,
- longitude,
- accuracy);
- }
-
- public void setMockGeolocationError(int code, String message) {
- // Configuration is in WebKit, so stay on WebCore thread, but go via the TestShellActivity
- // as we need access to the Webview.
- mLayoutTestController.setMockGeolocationError(code, message);
- }
-
- public void setGeolocationPermission(boolean allow) {
- // Configuration is in WebKit, so stay on WebCore thread, but go via the TestShellActivity
- // as we need access to the Webview.
- mLayoutTestController.setGeolocationPermission(allow);
- }
-
- public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
- boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) {
- // Configuration is in WebKit, so stay on WebCore thread, but go via the TestShellActivity
- // as we need access to the Webview.
- mLayoutTestController.setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta,
- canProvideGamma, gamma);
- }
-
- public void overridePreference(String key, boolean value) {
- Message message = obtainMessage(OVERRIDE_PREFERENCE);
- message.getData().putString("key", key);
- message.getData().putBoolean("value", value);
- message.sendToTarget();
- }
-
- public void setXSSAuditorEnabled(boolean flag) {
- obtainMessage(SET_XSS_AUDITOR_ENABLED, flag ? 1 : 0, 0).sendToTarget();
- }
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/EventSender.java b/tests/DumpRenderTree/src/com/android/dumprendertree/EventSender.java
deleted file mode 100644
index 23cc8f5..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/EventSender.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-public interface EventSender {
- public void mouseDown();
- public void mouseUp();
- public void mouseClick();
- public void mouseMoveTo(int X, int Y);
- public void leapForward(int milliseconds);
- public void keyDown (String character, String[] withModifiers);
- public void keyDown (String character);
- public void enableDOMUIEventLogging(int DOMNode);
- public void fireKeyboardEventsToElement(int DOMNode);
- public void touchStart();
- public void touchMove();
- public void touchEnd();
- public void touchCancel();
- public void addTouchPoint(int x, int y);
- public void updateTouchPoint(int id, int x, int y);
- public void setTouchModifier(String modifier, boolean enabled);
- public void releaseTouchPoint(int id);
- public void clearTouchPoints();
- public void cancelTouchPoint(int id);
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
deleted file mode 100644
index d373d8d..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import java.util.Vector;
-import android.util.*;
-
-public class FileFilter {
-
- private static final String LOGTAG = "FileFilter";
-
- // Returns whether we should ignore this test and skip running it.
- // Currently we use this only for tests that crash or hang DumpRenderTree.
- // TODO: Fix these and eliminate this method.
- public static boolean ignoreTest(String file) {
- for (int i = 0; i < ignoreTestList.length; i++) {
- if (file.endsWith(ignoreTestList[i])) {
- Log.v(LOGTAG, "File path in list of ignored tests: " + file);
- return true;
- }
- }
- return false;
- }
-
- // Returns whether a directory does not contain layout tests and so can be
- // ignored.
- public static boolean isNonTestDir(String file) {
- for (int i = 0; i < nonTestDirs.length; i++) {
- if (file.endsWith(nonTestDirs[i])) {
- return true;
- }
- }
- return false;
- }
-
- // Returns whether we should ignore the result of this test.
- public static boolean ignoreResult(String file) {
- for (int i = 0; i < ignoreResultList.size(); i++) {
- if (file.endsWith(ignoreResultList.get(i))) {
- Log.v(LOGTAG, "File path in list of ignored results: " + file);
- return true;
- }
- }
- return false;
- }
-
- final static Vector<String> ignoreResultList = new Vector<String>();
-
- static {
- fillIgnoreResultList();
- }
-
- static final String[] nonTestDirs = {
- ".", // ignore hidden directories and files
- "resources", // ignore resource directories
- ".svn", // don't run anything under .svn folder
- "platform" // No-Android specific tests
- };
-
- static final String[] ignoreTestList = {
- "canvas/philip/tests/2d.drawImage.broken.html", // blocks test, http://b/2982500
- "editing/selection/move-left-right.html", // Causes DumpRenderTree to hang
- "fast/js/excessive-comma-usage.html", // Tests huge initializer list, causes OOM.
- "fast/js/regexp-charclass-crash.html", // RegExp is too large, causing OOM
- "fast/js/regexp-overflow.html", // Result is too large, causing OOM when reading by DRT, http://b/2697589
- "fast/regex/test1.html", // Causes DumpRenderTree to hang with V8
- "fast/regex/slow.html", // Causes DumpRenderTree to hang with V8
- };
-
- static void fillIgnoreResultList() {
- // This first block of tests are for features for which Android
- // should pass all tests. They are skipped only temporarily.
- // TODO: Fix these failing tests and remove them from this list.
- ignoreResultList.add("fast/dom/HTMLKeygenElement/keygen.html"); // Missing layoutTestController.shadowRoot()
- ignoreResultList.add("fast/dom/Geolocation/window-close-crash.html"); // Missing layoutTestContoller.setCloseRemainingWindowsWhenComplete()
- ignoreResultList.add("fast/dom/Geolocation/page-reload-cancel-permission-requests.html"); // Missing layoutTestController.numberOfPendingGeolocationPermissionRequests()
- ignoreResultList.add("fast/dom/HTMLLinkElement/link-and-subresource-test.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
- ignoreResultList.add("fast/dom/HTMLLinkElement/prefetch.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
- ignoreResultList.add("fast/dom/HTMLLinkElement/subresource.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
- ignoreResultList.add("fast/encoding/char-decoding.html"); // fails in Java HTTP stack, see http://b/issue?id=3047156
- ignoreResultList.add("fast/encoding/hanarei-blog32-fc2-com.html"); // fails in Java HTTP stack, see http://b/issue?id=3046986
- ignoreResultList.add("fast/encoding/mailto-always-utf-8.html"); // Requires waitForPolicyDelegate(), see http://b/issue?id=3043468
- ignoreResultList.add("fast/encoding/percent-escaping.html"); // fails in Java HTTP stack, see http://b/issue?id=3046984
- ignoreResultList.add("http/tests/appcache/empty-manifest.html"); // flaky
- ignoreResultList.add("http/tests/appcache/fallback.html"); // http://b/issue?id=2713004
- ignoreResultList.add("http/tests/appcache/foreign-fallback.html"); // Flaky, may be due to DRT, see http://b/3285647
- ignoreResultList.add("http/tests/appcache/foreign-iframe-main.html"); // flaky - skips states
- ignoreResultList.add("http/tests/appcache/manifest-with-empty-file.html"); // flaky
- ignoreResultList.add("http/tests/appcache/origin-quota.html"); // needs clearAllApplicationCaches(), see http://b/issue?id=2944196
- ignoreResultList.add("storage/database-lock-after-reload.html"); // Succeeds but DumpRenderTree does not read result correctly
- ignoreResultList.add("storage/hash-change-with-xhr.html"); // Succeeds but DumpRenderTree does not read result correctly
- ignoreResultList.add("storage/open-database-creation-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
- ignoreResultList.add("storage/statement-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
- ignoreResultList.add("storage/statement-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
- ignoreResultList.add("storage/storageinfo-query-usage.html"); // Need window.webkitStorageInfo
- ignoreResultList.add("storage/transaction-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
- ignoreResultList.add("storage/transaction-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
- ignoreResultList.add("storage/transaction-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
- ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-1-prepare.html"); // Missing layoutTestController.originsWithLocalStorage()
- ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-2-create.html"); // Missing layoutTestController.originsWithLocalStorage()
- ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-3-delete-all.html"); // Missing layoutTestController.originsWithLocalStorage()
- ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-4-create.html"); // Missing layoutTestController.originsWithLocalStorage()
- ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-5-delete-one.html"); // Missing layoutTestController.originsWithLocalStorage()
-
-
- // Expected failures due to unsupported features or tests unsuitable for Android.
- ignoreResultList.add("fast/encoding/char-decoding-mac.html"); // Mac-specific encodings (also marked Won't Fix in Chromium, bug 7388)
- ignoreResultList.add("fast/encoding/char-encoding-mac.html"); // Mac-specific encodings (also marked Won't Fix in Chromium, bug 7388)
- ignoreResultList.add("fast/encoding/idn-security.html"); // Mac-specific IDN checks (also marked Won't Fix in Chromium, bug 21814)
- ignoreResultList.add("fast/events/touch/basic-multi-touch-events.html"); // Requires multi-touch gestures not supported by Android system
- ignoreResultList.add("fast/events/touch/touch-coords-in-zoom-and-scroll.html"); // Requires eventSender.zoomPageIn(),zoomPageOut()
- ignoreResultList.add("fast/events/touch/touch-target.html"); // Requires multi-touch gestures not supported by Android system
- ignoreResultList.add("fast/workers"); // workers not supported
- ignoreResultList.add("http/tests/cookies/third-party-cookie-relaxing.html"); // We don't support conditional acceptance of third-party cookies
- ignoreResultList.add("http/tests/eventsource/workers"); // workers not supported
- ignoreResultList.add("http/tests/workers"); // workers not supported
- ignoreResultList.add("http/tests/xmlhttprequest/workers"); // workers not supported
- ignoreResultList.add("storage/domstorage/localstorage/private-browsing-affects-storage.html"); // private browsing not supported
- ignoreResultList.add("storage/domstorage/sessionstorage/private-browsing-affects-storage.html"); // private browsing not supported
- ignoreResultList.add("storage/indexeddb"); // indexeddb not supported
- ignoreResultList.add("storage/private-browsing-noread-nowrite.html"); // private browsing not supported
- ignoreResultList.add("storage/private-browsing-readonly.html"); // private browsing not supported
- ignoreResultList.add("websocket/tests/workers"); // workers not supported
- ignoreResultList.add("dom/xhtml/level2/html/htmldocument04.xhtml"); // /mnt/sdcard on SR uses lowercase filesystem, this test checks filename and is case senstive.
- ignoreResultList.add("dom/html/level2/html/htmldocument04.html"); // ditto
-
- // Expected failures due to missing expected results
- ignoreResultList.add("dom/xhtml/level3/core/canonicalform08.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/canonicalform09.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/documentgetinputencoding03.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/entitygetinputencoding02.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/entitygetxmlversion02.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri05.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri07.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri09.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri10.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri11.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri15.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri17.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri18.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodelookupnamespaceuri01.xhtml");
- ignoreResultList.add("dom/xhtml/level3/core/nodelookupprefix19.xhtml");
-
- // TODO: These need to be triaged
- ignoreResultList.add("fast/css/case-transform.html"); // will not fix #619707
- ignoreResultList.add("fast/dom/Element/offsetLeft-offsetTop-body-quirk.html"); // different screen size result in extra spaces in Apple compared to us
- ignoreResultList.add("fast/dom/Window/Plug-ins.html"); // need test plugin
- ignoreResultList.add("fast/dom/Window/window-screen-properties.html"); // pixel depth
- ignoreResultList.add("fast/dom/Window/window-xy-properties.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/dom/attribute-namespaces-get-set.html"); // http://b/733229
- ignoreResultList.add("fast/dom/object-embed-plugin-scripting.html"); // dynamic plugins not supported
- ignoreResultList.add("fast/dom/tabindex-clamp.html"); // there is extra spacing in the file due to multiple input boxes fitting on one line on Apple, ours are wrapped. Space at line ends are stripped.
- ignoreResultList.add("fast/events/anchor-image-scrolled-x-y.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/arrow-navigation.html"); // http://b/735233
- ignoreResultList.add("fast/events/capture-on-target.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/dblclick-addEventListener.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/drag-in-frames.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/drag-outside-window.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/event-view-toString.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/frame-click-focus.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/frame-tab-focus.html"); // http://b/734308
- ignoreResultList.add("fast/events/iframe-object-onload.html"); // there is extra spacing in the file due to multiple frame boxes fitting on one line on Apple, ours are wrapped. Space at line ends are stripped.
- ignoreResultList.add("fast/events/input-image-scrolled-x-y.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/mouseclick-target-and-positioning.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/mouseover-mouseout.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/mouseover-mouseout2.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/mouseup-outside-button.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/mouseup-outside-document.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/onclick-list-marker.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/ondragenter.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/onload-webkit-before-webcore.html"); // missing space in textrun, ok as text is wrapped. ignore. #714933
- ignoreResultList.add("fast/events/option-tab.html"); // http://b/734308
- ignoreResultList.add("fast/events/window-events-bubble.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/window-events-bubble2.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/events/window-events-capture.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/forms/drag-into-textarea.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/forms/focus-control-to-page.html"); // http://b/716638
- ignoreResultList.add("fast/forms/focus2.html"); // http://b/735111
- ignoreResultList.add("fast/forms/form-data-encoding-2.html"); // charset convert. #516936 ignore, won't fix
- ignoreResultList.add("fast/forms/form-data-encoding.html"); // charset convert. #516936 ignore, won't fix
- ignoreResultList.add("fast/forms/input-appearance-maxlength.html"); // execCommand "insertText" not supported
- ignoreResultList.add("fast/forms/input-select-on-click.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/forms/listbox-onchange.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/forms/listbox-selection.html"); // http://b/735116
- ignoreResultList.add("fast/forms/onselect-textarea.html"); // requires eventSender.mouseMoveTo, mouseDown & mouseUp and abs. position of mouse to select a word. ignore, won't fix #716583
- ignoreResultList.add("fast/forms/onselect-textfield.html"); // requires eventSender.mouseMoveTo, mouseDown & mouseUp and abs. position of mouse to select a word. ignore, won't fix #716583
- ignoreResultList.add("fast/forms/plaintext-mode-1.html"); // not implemented queryCommandEnabled:BackColor, Undo & Redo
- ignoreResultList.add("fast/forms/search-cancel-button-mouseup.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/forms/search-event-delay.html"); // http://b/735120
- ignoreResultList.add("fast/forms/select-empty-list.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/forms/select-type-ahead-non-latin.html"); // http://b/735244
- ignoreResultList.add("fast/forms/selected-index-assert.html"); // not capturing the console messages
- ignoreResultList.add("fast/forms/selection-functions.html"); // there is extra spacing as the text areas and input boxes fit next to each other on Apple, but are wrapped on our screen.
- ignoreResultList.add("fast/forms/textarea-appearance-wrap.html"); // Our text areas are a little thinner than Apples. Also RTL test failes
- ignoreResultList.add("fast/forms/textarea-initial-caret-position.html"); // Text selection done differently on our platform. When a inputbox gets focus, the entire block is selected.
- ignoreResultList.add("fast/forms/textarea-no-scroll-on-blur.html"); // Text selection done differently on our platform. When a inputbox gets focus, the entire block is selected.
- ignoreResultList.add("fast/forms/textarea-paste-newline.html"); // Copy&Paste commands not supported
- ignoreResultList.add("fast/forms/textarea-scrolled-endline-caret.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/frames/iframe-window-focus.html"); // http://b/735140
- ignoreResultList.add("fast/frames/frameElement-widthheight.html"); // screen width&height are different
- ignoreResultList.add("fast/frames/frame-js-url-clientWidth.html"); // screen width&height are different
- ignoreResultList.add("fast/html/tab-order.html"); // http://b/719289
- ignoreResultList.add("fast/js/navigator-mimeTypes-length.html"); // dynamic plugins not supported
- ignoreResultList.add("fast/js/string-capitalization.html"); // http://b/516936
- ignoreResultList.add("fast/loader/local-JavaScript-from-local.html"); // Requires LayoutTests to exist at /tmp/LayoutTests
- ignoreResultList.add("fast/loader/local-iFrame-source-from-local.html"); // Requires LayoutTests to exist at /tmp/LayoutTests
- ignoreResultList.add("fast/loader/opaque-base-url.html"); // extra spacing because iFrames rendered next to each other on Apple
- ignoreResultList.add("fast/overflow/scroll-vertical-not-horizontal.html"); // http://b/735196
- ignoreResultList.add("fast/parser/script-tag-with-trailing-slash.html"); // not capturing the console messages
- ignoreResultList.add("fast/replaced/image-map.html"); // requires eventSender.mouseDown(),mouseUp()
- ignoreResultList.add("fast/text/plain-text-line-breaks.html"); // extra spacing because iFrames rendered next to each other on Apple
- ignoreResultList.add("profiler"); // profiler is not supported
- }
-
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
deleted file mode 100644
index 4a47a0e..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.io.File;
-
-import android.app.AlertDialog;
-import android.app.ListActivity;
-import android.content.DialogInterface;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.os.Bundle;
-import android.os.Environment;
-
-
-public abstract class FileList extends ListActivity
-{
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode)
- {
- case KeyEvent.KEYCODE_DPAD_LEFT:
- if (mPath.length() > mBaseLength) {
- File f = new File(mPath);
- mFocusFile = f.getName();
- mFocusIndex = 0;
- f = f.getParentFile();
- mPath = f.getPath();
- updateList();
- return true;
- }
- break;
-
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- {
- Map map = (Map) getListView().getItemAtPosition(getListView().getSelectedItemPosition());
- String path = (String)map.get("path");
- if ((new File(path)).isDirectory()) {
- mPath = path;
- mFocusFile = null;
- updateList();
- } else {
- processFile(path, false);
- }
- return true;
- }
-
- default:
- break;
- }
- return super.onKeyDown(keyCode, event);
- }
-
- public void onCreate(Bundle icicle)
- {
- super.onCreate(icicle);
- setupPath();
- updateList();
- }
-
- protected List getData()
- {
- List myData = new ArrayList<HashMap>();
-
- File f = new File(mPath);
- if (!f.exists()) {
- addItem(myData, "!LayoutTests path missing!", "");
- return myData;
- }
- String[] files = f.list();
- Arrays.sort(files);
-
- for (int i = 0; i < files.length; i++) {
- StringBuilder sb = new StringBuilder(mPath);
- sb.append(File.separatorChar);
- sb.append(files[i]);
- String path = sb.toString();
- File c = new File(path);
- if (fileFilter(c)) {
- if (c.isDirectory()) {
- addItem(myData, "<"+files[i]+">", path);
- if (mFocusFile != null && mFocusFile.equals(files[i]))
- mFocusIndex = myData.size()-1;
- }
- else
- addItem(myData, files[i], path);
- }
- }
-
- return myData;
- }
-
- protected void addItem(List<Map> data, String name, String path)
- {
- HashMap temp = new HashMap();
- temp.put("title", name);
- temp.put("path", path);
- data.add(temp);
- }
-
- protected void onListItemClick(ListView l, View v, int position, long id)
- {
- Map map = (Map) l.getItemAtPosition(position);
- final String path = (String)map.get("path");
-
- if ((new File(path)).isDirectory()) {
- final CharSequence[] items = {"Open", "Run"};
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Select an Action");
- builder.setSingleChoiceItems(items, -1,
- new DialogInterface.OnClickListener(){
- public void onClick(DialogInterface dialog, int which) {
- switch (which) {
- case OPEN_DIRECTORY:
- dialog.dismiss();
- mPath = path;
- mFocusFile = null;
- updateList();
- break;
- case RUN_TESTS:
- dialog.dismiss();
- processDirectory(path, false);
- break;
- }
- }
- });
- builder.create().show();
- } else {
- processFile(path, false);
- }
- }
-
- /*
- * This function is called when the user has selected a directory in the
- * list and wants to perform an action on it instead of navigating into
- * the directory.
- */
- abstract void processDirectory(String path, boolean selection);
- /*
- * This function is called when the user has selected a file in the
- * file list. The selected file could be a file or a directory.
- * The flag indicates if this was from a selection or not.
- */
- abstract void processFile(String filename, boolean selection);
-
- /*
- * This function is called when the file list is being built. Return
- * true if the file is to be added to the file list.
- */
- abstract boolean fileFilter(File f);
-
- protected void updateList() {
- setListAdapter(new SimpleAdapter(this,
- getData(),
- android.R.layout.simple_list_item_1,
- new String[] {"title"},
- new int[] {android.R.id.text1}));
- String title = mPath; //.substring(mBaseLength-11); // show the word LayoutTests
- setTitle(title);
- getListView().setSelection(mFocusIndex);
- }
-
- protected void setupPath() {
- mPath = Environment.getExternalStorageDirectory() + "/webkit/layout_tests";
- mBaseLength = mPath.length();
- }
-
- protected String mPath;
- protected int mBaseLength;
- protected String mFocusFile;
- protected int mFocusIndex;
-
- private final static int OPEN_DIRECTORY = 0;
- private final static int RUN_TESTS = 1;
-
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
deleted file mode 100644
index b7d2c26..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2009 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.dumprendertree;
-
-import com.android.dumprendertree.forwarder.ForwardService;
-
-import android.os.Environment;
-import android.util.Log;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.regex.Pattern;
-
-public class FsUtils {
-
- private static final String LOGTAG = "FsUtils";
- static final String EXTERNAL_DIR = Environment.getExternalStorageDirectory().toString();
- static final String HTTP_TESTS_PREFIX =
- EXTERNAL_DIR + "/webkit/layout_tests/http/tests/";
- static final String HTTPS_TESTS_PREFIX =
- EXTERNAL_DIR + "/webkit/layout_tests/http/tests/ssl/";
- static final String HTTP_LOCAL_TESTS_PREFIX =
- EXTERNAL_DIR + "/webkit/layout_tests/http/tests/local/";
- static final String HTTP_MEDIA_TESTS_PREFIX =
- EXTERNAL_DIR + "/webkit/layout_tests/http/tests/media/";
- static final String HTTP_WML_TESTS_PREFIX =
- EXTERNAL_DIR + "/webkit/layout_tests/http/tests/wml/";
-
- private FsUtils() {
- //no creation of instances
- }
-
- /**
- * @return the number of tests in the list.
- */
- public static int writeLayoutTestListRecursively(BufferedOutputStream bos,
- String dir, boolean ignoreResultsInDir) throws IOException {
-
- int testCount = 0;
- Log.v(LOGTAG, "Searching tests under " + dir);
-
- File d = new File(dir);
- if (!d.isDirectory()) {
- throw new AssertionError("A directory expected, but got " + dir);
- }
- ignoreResultsInDir |= FileFilter.ignoreResult(dir);
-
- String[] files = d.list();
- for (int i = 0; i < files.length; i++) {
- String s = dir + "/" + files[i];
-
- File f = new File(s);
- if (f.isDirectory()) {
- // If this is not a test directory, we don't recurse into it.
- if (!FileFilter.isNonTestDir(s)) {
- Log.v(LOGTAG, "Recursing on " + s);
- testCount += writeLayoutTestListRecursively(bos, s, ignoreResultsInDir);
- }
- continue;
- }
-
- // If this test should be ignored, we skip it completely.
- if (FileFilter.ignoreTest(s)) {
- Log.v(LOGTAG, "Ignoring: " + s);
- continue;
- }
-
- if ((s.toLowerCase().endsWith(".html")
- || s.toLowerCase().endsWith(".xml")
- || s.toLowerCase().endsWith(".xhtml"))
- && !s.endsWith("TEMPLATE.html")) {
- Log.v(LOGTAG, "Recording " + s);
- bos.write(s.getBytes());
- // If the result of this test should be ignored, we still run the test.
- if (ignoreResultsInDir || FileFilter.ignoreResult(s)) {
- bos.write((" IGNORE_RESULT").getBytes());
- }
- bos.write('\n');
- testCount++;
- }
- }
- return testCount;
- }
-
- public static void updateTestStatus(String statusFile, String s) {
- try {
- BufferedOutputStream bos = new BufferedOutputStream(
- new FileOutputStream(statusFile));
- bos.write(s.getBytes());
- bos.close();
- } catch (Exception e) {
- Log.e(LOGTAG, "Cannot update file " + statusFile);
- }
- }
-
- public static String readTestStatus(String statusFile) {
- // read out the test name it stopped last time.
- String status = null;
- File testStatusFile = new File(statusFile);
- if(testStatusFile.exists()) {
- try {
- BufferedReader inReader = new BufferedReader(
- new FileReader(testStatusFile));
- status = inReader.readLine();
- inReader.close();
- } catch (IOException e) {
- Log.e(LOGTAG, "Error reading test status.", e);
- }
- }
- return status;
- }
-
- public static String getTestUrl(String path) {
- String url = null;
- if (!path.startsWith(HTTP_TESTS_PREFIX)) {
- url = "file://" + path;
- } else {
- ForwardService.getForwardService().startForwardService();
- if (path.startsWith(HTTPS_TESTS_PREFIX)) {
- // still cut the URL after "http/tests/"
- url = "https://127.0.0.1:8443/" + path.substring(HTTP_TESTS_PREFIX.length());
- } else if (!path.startsWith(HTTP_LOCAL_TESTS_PREFIX)
- && !path.startsWith(HTTP_MEDIA_TESTS_PREFIX)
- && !path.startsWith(HTTP_WML_TESTS_PREFIX)) {
- url = "http://127.0.0.1:8000/" + path.substring(HTTP_TESTS_PREFIX.length());
- } else {
- url = "file://" + path;
- }
- }
- return url;
- }
-
- public static boolean diffIgnoreSpaces(String file1, String file2) throws IOException {
- BufferedReader br1 = new BufferedReader(new FileReader(file1));
- BufferedReader br2 = new BufferedReader(new FileReader(file2));
- boolean same = true;
- Pattern trailingSpace = Pattern.compile("\\s+$");
-
- while(true) {
- String line1 = br1.readLine();
- String line2 = br2.readLine();
-
- if (line1 == null && line2 == null)
- break;
- if (line1 != null) {
- line1 = trailingSpace.matcher(line1).replaceAll("");
- } else {
- line1 = "";
- }
- if (line2 != null) {
- line2 = trailingSpace.matcher(line2).replaceAll("");
- } else {
- line2 = "";
- }
- if(!line1.equals(line2)) {
- same = false;
- break;
- }
- }
-
- br1.close();
- br2.close();
-
- return same;
- }
-
- public static boolean isTestPageUrl(String url) {
- int qmPostion = url.indexOf('?');
- int slashPostion = url.lastIndexOf('/');
- if (slashPostion < qmPostion) {
- String fileName = url.substring(slashPostion + 1, qmPostion);
- if ("index.html".equals(fileName)) {
- return true;
- }
- }
- return false;
- }
-
- public static String getLastSegmentInPath(String path) {
- int endPos = path.lastIndexOf('/');
- path = path.substring(0, endPos);
- endPos = path.lastIndexOf('/');
- return path.substring(endPos + 1);
- }
-
- public static void writeDrawTime(String fileName, String url, long[] times) {
- StringBuffer lineBuffer = new StringBuffer();
- // grab the last segment of path in url
- lineBuffer.append(getLastSegmentInPath(url));
- for (long time : times) {
- lineBuffer.append('\t');
- lineBuffer.append(time);
- }
- lineBuffer.append('\n');
- String line = lineBuffer.toString();
- Log.v(LOGTAG, "logging draw times: " + line);
- try {
- FileWriter fw = new FileWriter(fileName, true);
- fw.write(line);
- fw.close();
- } catch (IOException ioe) {
- Log.e(LOGTAG, "Failed to log draw times", ioe);
- }
- }
-
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostApp.java b/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostApp.java
deleted file mode 100644
index f610f5a..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostApp.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import android.app.Application;
-
-public class HTMLHostApp extends Application {
-
- public HTMLHostApp() {
- }
-
- public void onCreate() {
- }
-
- public void onTerminate() {
- }
-
-}
-
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
deleted file mode 100644
index c936a6c..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-public interface LayoutTestController {
-
- public void dumpAsText(boolean enablePixelTests);
- public void dumpChildFramesAsText();
- public void waitUntilDone();
- public void notifyDone();
-
- // Force a redraw of the page
- public void display();
- // Used with pixel dumps of content
- public void testRepaint();
-
- // If the page title changes, add the information to the output.
- public void dumpTitleChanges();
- public void dumpBackForwardList();
- public void dumpChildFrameScrollPositions();
- public void dumpEditingCallbacks();
-
- // Show/Hide window for window.onBlur() testing
- public void setWindowIsKey(boolean b);
- // Mac function, used to disable events going to the window
- public void setMainFrameIsFirstResponder(boolean b);
-
- public void dumpSelectionRect();
-
- // invalidate and draw one line at a time of the web view.
- public void repaintSweepHorizontally();
-
- // History testing functions
- public void keepWebHistory();
- public void clearBackForwardList();
- // navigate after page load has finished
- public void queueBackNavigation(int howfar);
- public void queueForwardNavigation(int howfar);
-
- // Reload when the page load has finished
- public void queueReload();
- // Execute the provided script in current context when page load has finished.
- public void queueScript(String scriptToRunInCurrentContext);
- // Load the provided URL into the provided frame
- public void queueLoad(String Url, String frameTarget);
-
- public void setAcceptsEditing(boolean b);
-
- // For storage tests
- public void dumpDatabaseCallbacks();
- public void setCanOpenWindows();
-
- // For Geolocation tests
- public void setGeolocationPermission(boolean allow);
-
- public void overridePreference(String key, boolean value);
-
- // For XSSAuditor tests
- public void setXSSAuditorEnabled(boolean flag);
-
- // For Geolocation tests
- public void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
- public void setMockGeolocationError(int code, String message);
-
- // For DeviceOrientation tests
- public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
- boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma);
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java
deleted file mode 100644
index fb2a1f4..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2008 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.dumprendertree;
-
-import android.os.Bundle;
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-
-import junit.framework.TestSuite;
-
-
-/**
- * Instrumentation Test Runner for all DumpRenderTree tests.
- *
- * Running all tests:
- *
- * adb shell am instrument \
- * -w com.android.dumprendertree.LayoutTestsAutoRunner
- */
-
-public class LayoutTestsAutoRunner extends InstrumentationTestRunner {
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(LayoutTestsAutoTest.class);
- suite.addTestSuite(LoadTestsAutoTest.class);
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return LayoutTestsAutoRunner.class.getClassLoader();
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- this.mTestPath = (String) icicle.get("path");
- String timeout_str = (String) icicle.get("timeout");
- if (timeout_str != null) {
- try {
- this.mTimeoutInMillis = Integer.parseInt(timeout_str);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- String r = icicle.getString("rebaseline");
- this.mRebaseline = (r != null && r.toLowerCase().equals("true"));
-
- mJsEngine = icicle.getString("jsengine");
-
- mPageCyclerSuite = icicle.getString("suite");
- mPageCyclerForwardHost = icicle.getString("forward");
- mPageCyclerIteration = icicle.getString("iteration", "5");
-
- super.onCreate(icicle);
- }
-
- String mPageCyclerSuite;
- String mPageCyclerForwardHost;
- String mPageCyclerIteration;
- String mTestPath;
- int mTimeoutInMillis = 0;
- boolean mRebaseline;
- String mJsEngine;
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
deleted file mode 100644
index 3fe4e70..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * Copyright (C) 2008 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.dumprendertree;
-
-import com.android.dumprendertree.TestShellActivity.DumpDataType;
-import com.android.dumprendertree.forwarder.AdbUtils;
-import com.android.dumprendertree.forwarder.ForwardService;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Environment;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Vector;
-
-// TestRecorder creates four files ...
-// - passing tests
-// - failing tests
-// - tests for which results are ignored
-// - tests with no text results available
-// TestRecorder does not have the ability to clear the results.
-class MyTestRecorder {
- private BufferedOutputStream mBufferedOutputPassedStream;
- private BufferedOutputStream mBufferedOutputFailedStream;
- private BufferedOutputStream mBufferedOutputIgnoreResultStream;
- private BufferedOutputStream mBufferedOutputNoResultStream;
-
- public void passed(String layout_file) {
- try {
- mBufferedOutputPassedStream.write(layout_file.getBytes());
- mBufferedOutputPassedStream.write('\n');
- mBufferedOutputPassedStream.flush();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- public void failed(String layout_file) {
- try {
- mBufferedOutputFailedStream.write(layout_file.getBytes());
- mBufferedOutputFailedStream.write('\n');
- mBufferedOutputFailedStream.flush();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- public void ignoreResult(String layout_file) {
- try {
- mBufferedOutputIgnoreResultStream.write(layout_file.getBytes());
- mBufferedOutputIgnoreResultStream.write('\n');
- mBufferedOutputIgnoreResultStream.flush();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- public void noResult(String layout_file) {
- try {
- mBufferedOutputNoResultStream.write(layout_file.getBytes());
- mBufferedOutputNoResultStream.write('\n');
- mBufferedOutputNoResultStream.flush();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- public MyTestRecorder(boolean resume) {
- try {
- File externalDir = Environment.getExternalStorageDirectory();
- File resultsPassedFile = new File(externalDir, "layout_tests_passed.txt");
- File resultsFailedFile = new File(externalDir, "layout_tests_failed.txt");
- File resultsIgnoreResultFile = new File(externalDir, "layout_tests_ignored.txt");
- File noExpectedResultFile = new File(externalDir, "layout_tests_nontext.txt");
-
- mBufferedOutputPassedStream =
- new BufferedOutputStream(new FileOutputStream(resultsPassedFile, resume));
- mBufferedOutputFailedStream =
- new BufferedOutputStream(new FileOutputStream(resultsFailedFile, resume));
- mBufferedOutputIgnoreResultStream =
- new BufferedOutputStream(new FileOutputStream(resultsIgnoreResultFile, resume));
- mBufferedOutputNoResultStream =
- new BufferedOutputStream(new FileOutputStream(noExpectedResultFile, resume));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void close() {
- try {
- mBufferedOutputPassedStream.close();
- mBufferedOutputFailedStream.close();
- mBufferedOutputIgnoreResultStream.close();
- mBufferedOutputNoResultStream.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
-
-
-public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestShellActivity> {
-
- private static final String LOGTAG = "LayoutTests";
- static final int DEFAULT_TIMEOUT_IN_MILLIS = 5000;
-
- static final String EXTERNAL_DIR = Environment.getExternalStorageDirectory().toString();
- static final String LAYOUT_TESTS_ROOT = EXTERNAL_DIR + "/webkit/layout_tests/";
- static final String LAYOUT_TESTS_RESULT_DIR = EXTERNAL_DIR + "/webkit/layout_tests_results/";
- static final String ANDROID_EXPECTED_RESULT_DIR = EXTERNAL_DIR + "/webkit/expected_results/";
- static final String LAYOUT_TESTS_LIST_FILE = EXTERNAL_DIR + "/webkit/layout_tests_list.txt";
- static final String TEST_STATUS_FILE = EXTERNAL_DIR + "/webkit/running_test.txt";
- static final String LAYOUT_TESTS_RESULTS_REFERENCE_FILES[] = {
- "results/layout_tests_passed.txt",
- "results/layout_tests_failed.txt",
- "results/layout_tests_nontext.txt",
- "results/layout_tests_crashed.txt",
- "run_layout_tests.py"
- };
-
- static final String LAYOUT_RESULTS_FAILED_RESULT_FILE = "results/layout_tests_failed.txt";
- static final String LAYOUT_RESULTS_NONTEXT_RESULT_FILE = "results/layout_tests_nontext.txt";
- static final String LAYOUT_RESULTS_CRASHED_RESULT_FILE = "results/layout_tests_crashed.txt";
- static final String LAYOUT_TESTS_RUNNER = "run_layout_tests.py";
-
- private MyTestRecorder mResultRecorder;
- private Vector<String> mTestList;
- // Whether we should ignore the result for the corresponding test. Ordered same as mTestList.
- private Vector<Boolean> mTestListIgnoreResult;
- private boolean mRebaselineResults;
- // The JavaScript engine currently in use. This determines which set of Android-specific
- // expected test results we use.
- private String mJsEngine;
- private String mTestPathPrefix;
- private boolean mFinished;
- private int mTestCount;
- private int mResumeIndex;
-
- public LayoutTestsAutoTest() {
- super(TestShellActivity.class);
- }
-
- private void getTestList() {
- // Read test list.
- try {
- BufferedReader inReader = new BufferedReader(new FileReader(LAYOUT_TESTS_LIST_FILE));
- String line = inReader.readLine();
- while (line != null) {
- if (line.startsWith(mTestPathPrefix)) {
- String[] components = line.split(" ");
- mTestList.add(components[0]);
- mTestListIgnoreResult.add(components.length > 1 && components[1].equals("IGNORE_RESULT"));
- }
- line = inReader.readLine();
- }
- inReader.close();
- Log.v(LOGTAG, "Test list has " + mTestList.size() + " test(s).");
- } catch (Exception e) {
- Log.e(LOGTAG, "Error while reading test list : " + e.getMessage());
- }
- mTestCount = mTestList.size();
- }
-
- private void resumeTestList() {
- // read out the test name it stoped last time.
- try {
- String line = FsUtils.readTestStatus(TEST_STATUS_FILE);
- for (int i = 0; i < mTestList.size(); i++) {
- if (mTestList.elementAt(i).equals(line)) {
- mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.size()));
- mTestListIgnoreResult = new Vector<Boolean>(mTestListIgnoreResult.subList(i+1, mTestListIgnoreResult.size()));
- mResumeIndex = i + 1;
- break;
- }
- }
- } catch (Exception e) {
- Log.e(LOGTAG, "Error reading " + TEST_STATUS_FILE);
- }
- }
-
- private void clearTestStatus() {
- // Delete TEST_STATUS_FILE
- try {
- File f = new File(TEST_STATUS_FILE);
- if (f.delete())
- Log.v(LOGTAG, "Deleted " + TEST_STATUS_FILE);
- else
- Log.e(LOGTAG, "Fail to delete " + TEST_STATUS_FILE);
- } catch (Exception e) {
- Log.e(LOGTAG, "Fail to delete " + TEST_STATUS_FILE + " : " + e.getMessage());
- }
- }
-
- private String getResultFile(String test) {
- String shortName = test.substring(0, test.lastIndexOf('.'));
- // Write actual results to result directory.
- return shortName.replaceFirst(LAYOUT_TESTS_ROOT, LAYOUT_TESTS_RESULT_DIR) + "-result.txt";
- }
-
- // Gets the file which contains WebKit's expected results for this test.
- private String getExpectedResultFile(String test) {
- // The generic result is at <path>/<name>-expected.txt
- // First try the Android-specific result at
- // platform/android-<js-engine>/<path>/<name>-expected.txt
- // then
- // platform/android/<path>/<name>-expected.txt
- int pos = test.lastIndexOf('.');
- if (pos == -1)
- return null;
- String genericExpectedResult = test.substring(0, pos) + "-expected.txt";
- String androidExpectedResultsDir = "platform/android-" + mJsEngine + "/";
- String androidExpectedResult = genericExpectedResult.replaceFirst(LAYOUT_TESTS_ROOT,
- LAYOUT_TESTS_ROOT + androidExpectedResultsDir);
- File f = new File(androidExpectedResult);
- if (f.exists())
- return androidExpectedResult;
- androidExpectedResultsDir = "platform/android/";
- androidExpectedResult = genericExpectedResult.replaceFirst(LAYOUT_TESTS_ROOT,
- LAYOUT_TESTS_ROOT + androidExpectedResultsDir);
- f = new File(androidExpectedResult);
- return f.exists() ? androidExpectedResult : genericExpectedResult;
- }
-
- // Gets the file which contains the actual results of running the test on
- // Android, generated by a previous run which set a new baseline.
- private String getAndroidExpectedResultFile(String expectedResultFile) {
- return expectedResultFile.replaceFirst(LAYOUT_TESTS_ROOT, ANDROID_EXPECTED_RESULT_DIR);
- }
-
- // Wrap up
- private void failedCase(String file) {
- Log.w("Layout test: ", file + " failed");
- mResultRecorder.failed(file);
- }
-
- private void passedCase(String file) {
- Log.v("Layout test:", file + " passed");
- mResultRecorder.passed(file);
- }
-
- private void ignoreResultCase(String file) {
- Log.v("Layout test:", file + " ignore result");
- mResultRecorder.ignoreResult(file);
- }
-
- private void noResultCase(String file) {
- Log.v("Layout test:", file + " no expected result");
- mResultRecorder.noResult(file);
- }
-
- private void processResult(String testFile, String actualResultFile, String expectedResultFile, boolean ignoreResult) {
- Log.v(LOGTAG, " Processing result: " + testFile);
-
- if (ignoreResult) {
- ignoreResultCase(testFile);
- return;
- }
-
- File actual = new File(actualResultFile);
- File expected = new File(expectedResultFile);
- if (actual.exists() && expected.exists()) {
- try {
- if (FsUtils.diffIgnoreSpaces(actualResultFile, expectedResultFile)) {
- passedCase(testFile);
- } else {
- failedCase(testFile);
- }
- } catch (FileNotFoundException ex) {
- Log.e(LOGTAG, "File not found : " + ex.getMessage());
- } catch (IOException ex) {
- Log.e(LOGTAG, "IO Error : " + ex.getMessage());
- }
- return;
- }
-
- if (!expected.exists()) {
- noResultCase(testFile);
- }
- }
-
- private void runTestAndWaitUntilDone(TestShellActivity activity, String test, int timeout, boolean ignoreResult, int testNumber) {
- activity.setCallback(new TestShellCallback() {
- public void finished() {
- synchronized (LayoutTestsAutoTest.this) {
- mFinished = true;
- LayoutTestsAutoTest.this.notifyAll();
- }
- }
-
- public void timedOut(String url) {
- Log.v(LOGTAG, "layout timeout: " + url);
- }
-
- @Override
- public void dumpResult(String webViewDump) {
- }
- });
-
- String resultFile = getResultFile(test);
- if (resultFile == null) {
- // Simply ignore this test.
- return;
- }
- if (mRebaselineResults) {
- String expectedResultFile = getExpectedResultFile(test);
- File f = new File(expectedResultFile);
- if (f.exists()) {
- return; // don't run test and don't overwrite default tests.
- }
-
- resultFile = getAndroidExpectedResultFile(expectedResultFile);
- }
-
- mFinished = false;
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(activity, TestShellActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(test));
- intent.putExtra(TestShellActivity.RESULT_FILE, resultFile);
- intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout);
- intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, mTestCount);
- intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, testNumber);
- intent.putExtra(TestShellActivity.STOP_ON_REF_ERROR, true);
- activity.startActivity(intent);
-
- // Wait until done.
- synchronized (this) {
- while(!mFinished){
- try {
- this.wait();
- } catch (InterruptedException e) { }
- }
- }
-
- if (!mRebaselineResults) {
- String expectedResultFile = getExpectedResultFile(test);
- File f = new File(expectedResultFile);
- if (!f.exists()) {
- expectedResultFile = getAndroidExpectedResultFile(expectedResultFile);
- }
-
- processResult(test, resultFile, expectedResultFile, ignoreResult);
- }
- }
-
- // Invokes running of layout tests
- // and waits till it has finished running.
- public void executeLayoutTests(boolean resume) {
- LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation();
- // A convenient method to be called by another activity.
-
- if (runner.mTestPath == null) {
- Log.e(LOGTAG, "No test specified");
- return;
- }
-
- this.mTestList = new Vector<String>();
- this.mTestListIgnoreResult = new Vector<Boolean>();
-
- // Read settings
- mTestPathPrefix = (new File(LAYOUT_TESTS_ROOT + runner.mTestPath)).getAbsolutePath();
- mRebaselineResults = runner.mRebaseline;
- // V8 is the default JavaScript engine.
- mJsEngine = runner.mJsEngine == null ? "v8" : runner.mJsEngine;
-
- int timeout = runner.mTimeoutInMillis;
- if (timeout <= 0) {
- timeout = DEFAULT_TIMEOUT_IN_MILLIS;
- }
-
- this.mResultRecorder = new MyTestRecorder(resume);
-
- if (!resume)
- clearTestStatus();
-
- getTestList();
- if (resume)
- resumeTestList();
-
- TestShellActivity activity = getActivity();
- activity.setDefaultDumpDataType(DumpDataType.EXT_REPR);
-
- // Run tests.
- for (int i = 0; i < mTestList.size(); i++) {
- String s = mTestList.elementAt(i);
- boolean ignoreResult = mTestListIgnoreResult.elementAt(i);
- FsUtils.updateTestStatus(TEST_STATUS_FILE, s);
- // Run tests
- // i is 0 based, but test count is 1 based so add 1 to i here.
- runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis, ignoreResult,
- i + 1 + mResumeIndex);
- }
-
- FsUtils.updateTestStatus(TEST_STATUS_FILE, "#DONE");
- ForwardService.getForwardService().stopForwardService();
- activity.finish();
- }
-
- private String getTestPath() {
- LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation();
-
- String test_path = LAYOUT_TESTS_ROOT;
- if (runner.mTestPath != null) {
- test_path += runner.mTestPath;
- }
- test_path = new File(test_path).getAbsolutePath();
- Log.v("LayoutTestsAutoTest", " Test path : " + test_path);
-
- return test_path;
- }
-
- public void generateTestList() {
- try {
- File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
- FsUtils.writeLayoutTestListRecursively(bos, getTestPath(), false); // Don't ignore results
- bos.flush();
- bos.close();
- } catch (Exception e) {
- Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());
- }
- }
-
- // Running all the layout tests at once sometimes
- // causes the dumprendertree to run out of memory.
- // So, additional tests are added to run the tests
- // in chunks.
- public void startLayoutTests() {
- try {
- File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
- if (!tests_list.exists())
- generateTestList();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- executeLayoutTests(false);
- }
-
- public void resumeLayoutTests() {
- executeLayoutTests(true);
- }
-
- public void copyResultsAndRunnerAssetsToCache() {
- try {
- Context targetContext = getInstrumentation().getTargetContext();
- File cacheDir = targetContext.getCacheDir();
-
- for( int i=0; i< LAYOUT_TESTS_RESULTS_REFERENCE_FILES.length; i++) {
- InputStream in = targetContext.getAssets().open(
- LAYOUT_TESTS_RESULTS_REFERENCE_FILES[i]);
- OutputStream out = new FileOutputStream(new File(cacheDir,
- LAYOUT_TESTS_RESULTS_REFERENCE_FILES[i]));
-
- byte[] buf = new byte[2048];
- int len;
-
- while ((len = in.read(buf)) >= 0 ) {
- out.write(buf, 0, len);
- }
- out.close();
- in.close();
- }
- }catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
deleted file mode 100644
index 4b86a0b..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (C) 2008 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.dumprendertree;
-
-import com.android.dumprendertree.forwarder.AdbUtils;
-import com.android.dumprendertree.forwarder.ForwardServer;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Debug;
-import android.os.Environment;
-import android.os.Process;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShellActivity> {
-
- private final static String LOGTAG = "LoadTest";
- private final static String LOAD_TEST_RESULT =
- Environment.getExternalStorageDirectory() + "/load_test_result.txt";
- private final static int MAX_GC_WAIT_SEC = 10;
- private final static int LOCAL_PORT = 17171;
- private boolean mFinished;
- static final String LOAD_TEST_RUNNER_FILES[] = {
- "run_page_cycler.py"
- };
- private ForwardServer mForwardServer;
-
- public LoadTestsAutoTest() {
- super(TestShellActivity.class);
- }
-
- // This function writes the result of the layout test to
- // Am status so that it can be picked up from a script.
- public void passOrFailCallback(String file, boolean result) {
- Instrumentation inst = getInstrumentation();
- Bundle bundle = new Bundle();
- bundle.putBoolean(file, result);
- inst.sendStatus(0, bundle);
- }
-
- private String setUpForwarding(String forwardInfo, String suite, String iteration) throws IOException {
- // read forwarding information first
- Pattern forwardPattern = Pattern.compile("(.*):(\\d+)/(.*)/");
- Matcher matcher = forwardPattern.matcher(forwardInfo);
- if (!matcher.matches()) {
- throw new RuntimeException("Invalid forward information");
- }
- String host = matcher.group(1);
- int port = Integer.parseInt(matcher.group(2));
- mForwardServer = new ForwardServer(LOCAL_PORT, AdbUtils.resolve(host), port);
- mForwardServer.start();
- return String.format("http://127.0.0.1:%d/%s/%s/start.html?auto=1&iterations=%s",
- LOCAL_PORT, matcher.group(3), suite, iteration);
- }
-
- // Invokes running of layout tests
- // and waits till it has finished running.
- public void runPageCyclerTest() throws IOException {
- LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation();
-
- if (runner.mPageCyclerSuite != null) {
- // start forwarder to use page cycler suites hosted on external web server
- if (runner.mPageCyclerForwardHost == null) {
- throw new RuntimeException("no forwarder information provided");
- }
- runner.mTestPath = setUpForwarding(runner.mPageCyclerForwardHost,
- runner.mPageCyclerSuite, runner.mPageCyclerIteration);
- Log.d(LOGTAG, "using path: " + runner.mTestPath);
- }
-
- if (runner.mTestPath == null) {
- throw new RuntimeException("No test specified");
- }
-
- final TestShellActivity activity = (TestShellActivity) getActivity();
-
- Log.v(LOGTAG, "About to run tests, calling gc first...");
- freeMem();
-
- // Run tests
- runTestAndWaitUntilDone(activity, runner.mTestPath, runner.mTimeoutInMillis);
-
- getInstrumentation().runOnMainSync(new Runnable() {
-
- @Override
- public void run() {
- activity.clearCache();
- }
- });
- if (mForwardServer != null) {
- mForwardServer.stop();
- mForwardServer = null;
- }
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- }
- dumpMemoryInfo();
-
- // Kill activity
- activity.finish();
- }
-
- private void freeMem() {
- Log.v(LOGTAG, "freeMem: calling gc...");
- final CountDownLatch latch = new CountDownLatch(1);
- @SuppressWarnings("unused")
- Object dummy = new Object() {
- // this object instance is used to track gc
- @Override
- protected void finalize() throws Throwable {
- latch.countDown();
- super.finalize();
- }
- };
- dummy = null;
- System.gc();
- try {
- if (!latch.await(MAX_GC_WAIT_SEC, TimeUnit.SECONDS)) {
- Log.w(LOGTAG, "gc did not happen in 10s");
- }
- } catch (InterruptedException e) {
- //ignore
- }
- }
-
- private void printRow(PrintStream ps, String format, Object...objs) {
- ps.println(String.format(format, objs));
- }
-
- private void dumpMemoryInfo() {
- try {
- freeMem();
- Log.v(LOGTAG, "Dumping memory information.");
-
- FileOutputStream out = new FileOutputStream(LOAD_TEST_RESULT, true);
- PrintStream ps = new PrintStream(out);
-
- ps.print("\n\n\n");
- ps.println("** MEMINFO in pid " + Process.myPid()
- + " [com.android.dumprendertree] **");
- String formatString = "%17s %8s %8s %8s %8s";
-
- long nativeMax = Debug.getNativeHeapSize() / 1024;
- long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024;
- long nativeFree = Debug.getNativeHeapFreeSize() / 1024;
- Runtime runtime = Runtime.getRuntime();
- long dalvikMax = runtime.totalMemory() / 1024;
- long dalvikFree = runtime.freeMemory() / 1024;
- long dalvikAllocated = dalvikMax - dalvikFree;
-
-
- Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
- Debug.getMemoryInfo(memInfo);
-
- final int nativeShared = memInfo.nativeSharedDirty;
- final int dalvikShared = memInfo.dalvikSharedDirty;
- final int otherShared = memInfo.otherSharedDirty;
-
- final int nativePrivate = memInfo.nativePrivateDirty;
- final int dalvikPrivate = memInfo.dalvikPrivateDirty;
- final int otherPrivate = memInfo.otherPrivateDirty;
-
- printRow(ps, formatString, "", "native", "dalvik", "other", "total");
- printRow(ps, formatString, "size:", nativeMax, dalvikMax, "N/A", nativeMax + dalvikMax);
- printRow(ps, formatString, "allocated:", nativeAllocated, dalvikAllocated, "N/A",
- nativeAllocated + dalvikAllocated);
- printRow(ps, formatString, "free:", nativeFree, dalvikFree, "N/A",
- nativeFree + dalvikFree);
-
- printRow(ps, formatString, "(Pss):", memInfo.nativePss, memInfo.dalvikPss,
- memInfo.otherPss, memInfo.nativePss + memInfo.dalvikPss + memInfo.otherPss);
-
- printRow(ps, formatString, "(shared dirty):", nativeShared, dalvikShared, otherShared,
- nativeShared + dalvikShared + otherShared);
- printRow(ps, formatString, "(priv dirty):", nativePrivate, dalvikPrivate, otherPrivate,
- nativePrivate + dalvikPrivate + otherPrivate);
- ps.print("\n\n\n");
- ps.flush();
- ps.close();
- out.flush();
- out.close();
- } catch (IOException e) {
- Log.e(LOGTAG, e.getMessage());
- }
- }
-
- // A convenient method to be called by another activity.
- private void runTestAndWaitUntilDone(TestShellActivity activity, String url, int timeout) {
- activity.setCallback(new TestShellCallback() {
- @Override
- public void finished() {
- synchronized (LoadTestsAutoTest.this) {
- mFinished = true;
- LoadTestsAutoTest.this.notifyAll();
- }
- }
-
- @Override
- public void timedOut(String url) {
- }
-
- @Override
- public void dumpResult(String webViewDump) {
- String lines[] = webViewDump.split("\\r?\\n");
- for (String line : lines) {
- line = line.trim();
- // parse for a line like this:
- // totals: 9620.00 11947.00 10099.75 380.38
- // and return the 3rd number, which is mean
- if (line.startsWith("totals:")) {
- line = line.substring(7).trim(); // strip "totals:"
- String[] numbers = line.split("\\s+");
- if (numbers.length == 4) {
- Bundle b = new Bundle();
- b.putString("mean", numbers[2]);
- getInstrumentation().sendStatus(Activity.RESULT_FIRST_USER, b);
- }
- }
- }
- }
- });
-
- mFinished = false;
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(activity, TestShellActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(TestShellActivity.TEST_URL, url);
- intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout);
- intent.putExtra(TestShellActivity.RESULT_FILE, LOAD_TEST_RESULT);
- activity.startActivity(intent);
-
- // Wait until done.
- synchronized (this) {
- while(!mFinished) {
- try {
- this.wait();
- } catch (InterruptedException e) { }
- }
- }
- }
-
- public void copyRunnerAssetsToCache() {
- try {
- Context targetContext = getInstrumentation().getTargetContext();
- File cacheDir = targetContext.getCacheDir();
-
- for( int i=0; i< LOAD_TEST_RUNNER_FILES.length; i++) {
- InputStream in = targetContext.getAssets().open(
- LOAD_TEST_RUNNER_FILES[i]);
- OutputStream out = new FileOutputStream(
- new File(cacheDir, LOAD_TEST_RUNNER_FILES[i]));
-
- byte[] buf = new byte[2048];
- int len;
-
- while ((len = in.read(buf)) >= 0 ) {
- out.write(buf, 0, len);
- }
- out.close();
- in.close();
- }
- }catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
deleted file mode 100644
index 0b00d65..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Environment;
-import android.util.Log;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-
-public class Menu extends FileList {
-
- private static final int MENU_START = 0x01;
- private static String LOGTAG = "MenuActivity";
- static final String LAYOUT_TESTS_LIST_FILE =
- Environment.getExternalStorageDirectory() + "/android/layout_tests_list.txt";
-
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- }
-
- boolean fileFilter(File f) {
- if (f.getName().startsWith("."))
- return false;
- if (f.getName().equalsIgnoreCase("resources"))
- return false;
- if (f.isDirectory())
- return true;
- if (f.getPath().toLowerCase().endsWith("ml"))
- return true;
- return false;
- }
-
- void processFile(String filename, boolean selection) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(this, TestShellActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename);
- intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, 1);
- intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 1);
- startActivity(intent);
- }
-
- @Override
- void processDirectory(String path, boolean selection) {
- int testCount = generateTestList(path);
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(this, TestShellActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE);
- intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, testCount);
- // TestShellActivity will process this intent once and increment the test index
- // before running the first test, so pass 0 here to allow for that.
- intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 0);
- startActivity(intent);
- }
-
- private int generateTestList(String path) {
- int testCount = 0;
- try {
- File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
- testCount = FsUtils.writeLayoutTestListRecursively(
- bos, path, false); // Don't ignore results
- bos.flush();
- bos.close();
- } catch (Exception e) {
- Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());
- }
- return testCount;
- }
-
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java
deleted file mode 100644
index 22b587f..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (C) 2009 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.dumprendertree;
-
-import android.app.Activity;
-import android.app.ActivityThread;
-import android.graphics.Bitmap;
-import android.net.http.SslError;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-import android.view.ViewGroup;
-import android.webkit.HttpAuthHandler;
-import android.webkit.JsPromptResult;
-import android.webkit.JsResult;
-import android.webkit.SslErrorHandler;
-import android.webkit.WebChromeClient;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-import android.webkit.WebSettings.LayoutAlgorithm;
-import android.widget.LinearLayout;
-import android.widget.LinearLayout.LayoutParams;
-
-public class ReliabilityTestActivity extends Activity {
-
- public static final String TEST_URL_ACTION = "com.andrdoid.dumprendertree.TestUrlAction";
- public static final String PARAM_URL = "URL";
- public static final String PARAM_TIMEOUT = "Timeout";
- public static final int RESULT_TIMEOUT = 0xDEAD;
- public static final int MSG_TIMEOUT = 0xC001;
- public static final int MSG_NAVIGATE = 0xC002;
- public static final String MSG_NAV_URL = "url";
- public static final String MSG_NAV_LOGTIME = "logtime";
-
- private static final String LOGTAG = "ReliabilityTestActivity";
-
- private WebView webView;
- private SimpleWebViewClient webViewClient;
- private SimpleChromeClient chromeClient;
- private Handler handler;
- private boolean timeoutFlag;
- private boolean logTime;
- private boolean pageDone;
- private Object pageDoneLock;
- private int pageStartCount;
- private int manualDelay;
- private long startTime;
- private long pageLoadTime;
- private PageDoneRunner pageDoneRunner = new PageDoneRunner();
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
-
- LinearLayout contentView = new LinearLayout(this);
- contentView.setOrientation(LinearLayout.VERTICAL);
- setContentView(contentView);
- setTitle("Idle");
-
- webView = new WebView(this);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
- webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
-
- webViewClient = new SimpleWebViewClient();
- chromeClient = new SimpleChromeClient();
- webView.setWebViewClient(webViewClient);
- webView.setWebChromeClient(chromeClient);
-
- contentView.addView(webView, new LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
-
- handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_TIMEOUT:
- handleTimeout();
- return;
- case MSG_NAVIGATE:
- manualDelay = msg.arg2;
- navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
- logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
- return;
- }
- }
- };
-
- pageDoneLock = new Object();
- }
-
- public void reset() {
- synchronized (pageDoneLock) {
- pageDone = false;
- }
- timeoutFlag = false;
- pageStartCount = 0;
- chromeClient.resetJsTimeout();
- }
-
- private void navigate(String url, int timeout) {
- if(url == null) {
- Log.v(LOGTAG, "URL is null, cancelling...");
- finish();
- }
- webView.stopLoading();
- if(logTime) {
- webView.clearCache(true);
- }
- startTime = System.currentTimeMillis();
- Log.v(LOGTAG, "Navigating to URL: " + url);
- webView.loadUrl(url);
-
- if(timeout != 0) {
- //set a timer with specified timeout (in ms)
- handler.sendMessageDelayed(handler.obtainMessage(MSG_TIMEOUT),
- timeout);
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- Log.v(LOGTAG, "onDestroy, inst=" + Integer.toHexString(hashCode()));
- webView.clearCache(true);
- webView.destroy();
- }
-
- private boolean isPageDone() {
- synchronized (pageDoneLock) {
- return pageDone;
- }
- }
-
- private void setPageDone(boolean pageDone) {
- synchronized (pageDoneLock) {
- this.pageDone = pageDone;
- pageDoneLock.notifyAll();
- }
- }
-
- private void handleTimeout() {
- int progress = webView.getProgress();
- webView.stopLoading();
- Log.v(LOGTAG, "Page timeout triggered, progress = " + progress);
- timeoutFlag = true;
- handler.postDelayed(pageDoneRunner, manualDelay);
- }
-
- public boolean waitUntilDone() {
- validateNotAppThread();
- synchronized (pageDoneLock) {
- while(!isPageDone()) {
- try {
- pageDoneLock.wait();
- } catch (InterruptedException ie) {
- //no-op
- }
- }
- }
- return timeoutFlag;
- }
-
- public Handler getHandler() {
- return handler;
- }
-
- private final void validateNotAppThread() {
- if (Looper.myLooper() == Looper.getMainLooper()) {
- throw new RuntimeException(
- "This method can not be called from the main application thread");
- }
- }
-
- public long getPageLoadTime() {
- return pageLoadTime;
- }
-
- class SimpleWebViewClient extends WebViewClient {
-
- @Override
- public void onReceivedError(WebView view, int errorCode, String description,
- String failingUrl) {
- Log.v(LOGTAG, "Received WebCore error: code=" + errorCode
- + ", description=" + description
- + ", url=" + failingUrl);
- }
-
- @Override
- public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
- //ignore certificate error
- Log.v(LOGTAG, "Received SSL error: " + error.toString());
- handler.proceed();
- }
-
- @Override
- public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host,
- String realm) {
- // cancel http auth request
- handler.cancel();
- }
-
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- pageStartCount++;
- Log.v(LOGTAG, "onPageStarted: " + url);
- }
-
- @Override
- public void onPageFinished(WebView view, String url) {
- Log.v(LOGTAG, "onPageFinished: " + url);
- // let handleTimeout take care of finishing the page
- if(!timeoutFlag)
- handler.postDelayed(new WebViewStatusChecker(), 500);
- }
- }
-
- class SimpleChromeClient extends WebChromeClient {
-
- private int timeoutCounter = 0;
-
- @Override
- public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
- JsPromptResult result) {
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsTimeout() {
- timeoutCounter++;
- Log.v(LOGTAG, "JavaScript timeout, count=" + timeoutCounter);
- return timeoutCounter > 2;
- }
-
- public void resetJsTimeout() {
- timeoutCounter = 0;
- }
-
- @Override
- public void onReceivedTitle(WebView view, String title) {
- ReliabilityTestActivity.this.setTitle(title);
- }
- }
-
- class WebViewStatusChecker implements Runnable {
-
- private int initialStartCount;
-
- public WebViewStatusChecker() {
- initialStartCount = pageStartCount;
- }
-
- public void run() {
- if (initialStartCount == pageStartCount && !isPageDone()) {
- handler.removeMessages(MSG_TIMEOUT);
- webView.stopLoading();
- handler.postDelayed(pageDoneRunner, manualDelay);
- }
- }
- }
-
- class PageDoneRunner implements Runnable {
-
- public void run() {
- Log.v(LOGTAG, "Finishing URL: " + webView.getUrl());
- pageLoadTime = System.currentTimeMillis() - startTime;
- setPageDone(true);
- }
- }
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
deleted file mode 100644
index 42d6457..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ /dev/null
@@ -1,946 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import com.android.dumprendertree.forwarder.ForwardService;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.net.http.SslError;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.webkit.ConsoleMessage;
-import android.webkit.CookieManager;
-import android.webkit.GeolocationPermissions;
-import android.webkit.HttpAuthHandler;
-import android.webkit.JsPromptResult;
-import android.webkit.JsResult;
-import android.webkit.SslErrorHandler;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
-import android.webkit.WebSettingsClassic;
-import android.webkit.WebStorage;
-import android.webkit.WebView;
-import android.webkit.WebViewClassic;
-import android.webkit.WebViewClient;
-import android.widget.LinearLayout;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-public class TestShellActivity extends Activity implements LayoutTestController {
-
- static enum DumpDataType {DUMP_AS_TEXT, EXT_REPR, NO_OP}
-
- // String constants for use with layoutTestController.overridePreferences
- private final String WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED =
- "WebKitOfflineWebApplicationCacheEnabled";
- private final String WEBKIT_USES_PAGE_CACHE_PREFERENCE_KEY = "WebKitUsesPageCachePreferenceKey";
-
- public class AsyncHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == MSG_TIMEOUT) {
- mTimedOut = true;
- mWebView.stopLoading();
- if (mCallback != null)
- mCallback.timedOut(mWebView.getUrl());
- if (!mRequestedWebKitData) {
- requestWebKitData();
- } else {
- // if timed out and webkit data has been dumped before
- // finish directly
- finished();
- }
- return;
- } else if (msg.what == MSG_WEBKIT_DATA) {
- Log.v(LOGTAG, "Received WebView dump data");
- mHandler.removeMessages(MSG_DUMP_TIMEOUT);
- TestShellActivity.this.dump(mTimedOut, (String)msg.obj);
- return;
- } else if (msg.what == MSG_DUMP_TIMEOUT) {
- throw new RuntimeException("WebView dump timeout, is it pegged?");
- }
- super.handleMessage(msg);
- }
- }
-
- public void requestWebKitData() {
- setDumpTimeout(DUMP_TIMEOUT_MS);
- Message callback = mHandler.obtainMessage(MSG_WEBKIT_DATA);
-
- if (mRequestedWebKitData)
- throw new AssertionError("Requested webkit data twice: " + mWebView.getUrl());
-
- mRequestedWebKitData = true;
- Log.v(LOGTAG, "message sent to WebView to dump text.");
- switch (mDumpDataType) {
- case DUMP_AS_TEXT:
- callback.arg1 = mDumpTopFrameAsText ? 1 : 0;
- callback.arg2 = mDumpChildFramesAsText ? 1 : 0;
- mWebViewClassic.documentAsText(callback);
- break;
- case EXT_REPR:
- mWebViewClassic.externalRepresentation(callback);
- break;
- default:
- finished();
- break;
- }
- }
-
- private void setDumpTimeout(long timeout) {
- Log.v(LOGTAG, "setting dump timeout at " + timeout);
- Message msg = mHandler.obtainMessage(MSG_DUMP_TIMEOUT);
- mHandler.sendMessageDelayed(msg, timeout);
- }
-
- public void clearCache() {
- mWebView.freeMemory();
- }
-
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- requestWindowFeature(Window.FEATURE_PROGRESS);
-
- LinearLayout contentView = new LinearLayout(this);
- contentView.setOrientation(LinearLayout.VERTICAL);
- setContentView(contentView);
-
- CookieManager.setAcceptFileSchemeCookies(true);
- mWebView = new WebView(this);
- mWebViewClassic = WebViewClassic.fromWebView(mWebView);
- mEventSender = new WebViewEventSender(mWebView);
- mCallbackProxy = new CallbackProxy(mEventSender, this);
-
- mWebView.addJavascriptInterface(mCallbackProxy, "layoutTestController");
- mWebView.addJavascriptInterface(mCallbackProxy, "eventSender");
- setupWebViewForLayoutTests(mWebView, mCallbackProxy);
-
- contentView.addView(mWebView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
-
- mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
-
- // Expose window.gc function to JavaScript. JSC build exposes
- // this function by default, but V8 requires the flag to turn it on.
- // WebView::setJsFlags is noop in JSC build.
- mWebViewClassic.setJsFlags("--expose_gc");
-
- mHandler = new AsyncHandler();
-
- Intent intent = getIntent();
- if (intent != null) {
- executeIntent(intent);
- }
-
- // This is asynchronous, but it gets processed by WebCore before it starts loading pages.
- mWebViewClassic.setUseMockDeviceOrientation();
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- executeIntent(intent);
- }
-
- private void executeIntent(Intent intent) {
- resetTestStatus();
- if (!Intent.ACTION_VIEW.equals(intent.getAction())) {
- return;
- }
-
- mTotalTestCount = intent.getIntExtra(TOTAL_TEST_COUNT, mTotalTestCount);
- mCurrentTestNumber = intent.getIntExtra(CURRENT_TEST_NUMBER, mCurrentTestNumber);
-
- mTestUrl = intent.getStringExtra(TEST_URL);
- if (mTestUrl == null) {
- mUiAutoTestPath = intent.getStringExtra(UI_AUTO_TEST);
- if(mUiAutoTestPath != null) {
- beginUiAutoTest();
- }
- return;
- }
-
- mResultFile = intent.getStringExtra(RESULT_FILE);
- mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 0);
- mStopOnRefError = intent.getBooleanExtra(STOP_ON_REF_ERROR, false);
- setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount);
- float ratio = (float)mCurrentTestNumber / mTotalTestCount;
- int progress = (int)(ratio * Window.PROGRESS_END);
- getWindow().setFeatureInt(Window.FEATURE_PROGRESS, progress);
-
- Log.v(LOGTAG, " Loading " + mTestUrl);
-
- if (mTestUrl.contains("/dumpAsText/")) {
- dumpAsText(false);
- }
-
- mWebView.loadUrl(mTestUrl);
-
- if (mTimeoutInMillis > 0) {
- // Create a timeout timer
- Message m = mHandler.obtainMessage(MSG_TIMEOUT);
- mHandler.sendMessageDelayed(m, mTimeoutInMillis);
- }
- }
-
- private void beginUiAutoTest() {
- try {
- mTestListReader = new BufferedReader(
- new FileReader(mUiAutoTestPath));
- } catch (IOException ioe) {
- Log.e(LOGTAG, "Failed to open test list for read.", ioe);
- finishUiAutoTest();
- return;
- }
- moveToNextTest();
- }
-
- private void finishUiAutoTest() {
- try {
- if(mTestListReader != null)
- mTestListReader.close();
- } catch (IOException ioe) {
- Log.w(LOGTAG, "Failed to close test list file.", ioe);
- }
- ForwardService.getForwardService().stopForwardService();
- finished();
- }
-
- private void moveToNextTest() {
- String url = null;
- try {
- url = mTestListReader.readLine();
- } catch (IOException ioe) {
- Log.e(LOGTAG, "Failed to read next test.", ioe);
- finishUiAutoTest();
- return;
- }
- if (url == null) {
- mUiAutoTestPath = null;
- finishUiAutoTest();
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage("All tests finished. Exit?")
- .setCancelable(false)
- .setPositiveButton("Yes", new OnClickListener(){
- @Override
- public void onClick(DialogInterface dialog, int which) {
- TestShellActivity.this.finish();
- }
- })
- .setNegativeButton("No", new OnClickListener(){
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
- builder.create().show();
- return;
- }
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(url));
- intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, ++mCurrentTestNumber);
- intent.putExtra(TIMEOUT_IN_MILLIS, 10000);
- executeIntent(intent);
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mWebView.stopLoading();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mWebView.destroy();
- mWebView = null;
- mWebViewClassic = null;
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- Log.e(LOGTAG, "Low memory, clearing caches");
- mWebView.freeMemory();
- }
-
- // Dump the page
- public void dump(boolean timeout, String webkitData) {
- mDumpWebKitData = true;
- if (mResultFile == null || mResultFile.length() == 0) {
- finished();
- return;
- }
-
- if (mCallback != null) {
- mCallback.dumpResult(webkitData);
- }
-
- try {
- File parentDir = new File(mResultFile).getParentFile();
- if (!parentDir.exists()) {
- parentDir.mkdirs();
- }
-
- FileOutputStream os = new FileOutputStream(mResultFile);
- if (timeout) {
- Log.w("Layout test: Timeout", mResultFile);
- os.write(TIMEOUT_STR.getBytes());
- os.write('\n');
- }
- if (mDumpTitleChanges)
- os.write(mTitleChanges.toString().getBytes());
- if (mDialogStrings != null)
- os.write(mDialogStrings.toString().getBytes());
- mDialogStrings = null;
- if (mDatabaseCallbackStrings != null)
- os.write(mDatabaseCallbackStrings.toString().getBytes());
- mDatabaseCallbackStrings = null;
- if (mConsoleMessages != null)
- os.write(mConsoleMessages.toString().getBytes());
- mConsoleMessages = null;
- if (webkitData != null)
- os.write(webkitData.getBytes());
- os.flush();
- os.close();
- } catch (IOException ex) {
- Log.e(LOGTAG, "Cannot write to " + mResultFile + ", " + ex.getMessage());
- }
-
- finished();
- }
-
- public void setCallback(TestShellCallback callback) {
- mCallback = callback;
- }
-
- public boolean finished() {
- if (canMoveToNextTest()) {
- mHandler.removeMessages(MSG_TIMEOUT);
- if (mUiAutoTestPath != null) {
- //don't really finish here
- moveToNextTest();
- } else {
- if (mCallback != null) {
- mCallback.finished();
- }
- }
- return true;
- }
- return false;
- }
-
- public void setDefaultDumpDataType(DumpDataType defaultDumpDataType) {
- mDefaultDumpDataType = defaultDumpDataType;
- }
-
- // .......................................
- // LayoutTestController Functions
- @Override
- public void dumpAsText(boolean enablePixelTests) {
- // Added after webkit update to r63859. See trac.webkit.org/changeset/63730.
- if (enablePixelTests) {
- Log.v(LOGTAG, "dumpAsText(enablePixelTests == true) not implemented on Android!");
- }
-
- mDumpDataType = DumpDataType.DUMP_AS_TEXT;
- mDumpTopFrameAsText = true;
- if (mWebView != null) {
- String url = mWebView.getUrl();
- Log.v(LOGTAG, "dumpAsText called: "+url);
- }
- }
-
- @Override
- public void dumpChildFramesAsText() {
- mDumpDataType = DumpDataType.DUMP_AS_TEXT;
- mDumpChildFramesAsText = true;
- if (mWebView != null) {
- String url = mWebView.getUrl();
- Log.v(LOGTAG, "dumpChildFramesAsText called: "+url);
- }
- }
-
- @Override
- public void waitUntilDone() {
- mWaitUntilDone = true;
- String url = mWebView.getUrl();
- Log.v(LOGTAG, "waitUntilDone called: " + url);
- }
-
- @Override
- public void notifyDone() {
- String url = mWebView.getUrl();
- Log.v(LOGTAG, "notifyDone called: " + url);
- if (mWaitUntilDone) {
- mWaitUntilDone = false;
- if (!mRequestedWebKitData && !mTimedOut && !finished()) {
- requestWebKitData();
- }
- }
- }
-
- @Override
- public void display() {
- mWebView.invalidate();
- }
-
- @Override
- public void clearBackForwardList() {
- mWebView.clearHistory();
-
- }
-
- @Override
- public void dumpBackForwardList() {
- //printf("\n============== Back Forward List ==============\n");
- // mWebHistory
- //printf("===============================================\n");
-
- }
-
- @Override
- public void dumpChildFrameScrollPositions() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void dumpEditingCallbacks() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void dumpSelectionRect() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void dumpTitleChanges() {
- if (!mDumpTitleChanges) {
- mTitleChanges = new StringBuffer();
- }
- mDumpTitleChanges = true;
- }
-
- @Override
- public void keepWebHistory() {
- if (!mKeepWebHistory) {
- mWebHistory = new Vector();
- }
- mKeepWebHistory = true;
- }
-
- @Override
- public void queueBackNavigation(int howfar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void queueForwardNavigation(int howfar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void queueLoad(String Url, String frameTarget) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void queueReload() {
- mWebView.reload();
- }
-
- @Override
- public void queueScript(String scriptToRunInCurrentContext) {
- mWebView.loadUrl("javascript:"+scriptToRunInCurrentContext);
- }
-
- @Override
- public void repaintSweepHorizontally() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setAcceptsEditing(boolean b) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setMainFrameIsFirstResponder(boolean b) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setWindowIsKey(boolean b) {
- // This is meant to show/hide the window. The best I can find
- // is setEnabled()
- mWebView.setEnabled(b);
- }
-
- @Override
- public void testRepaint() {
- mWebView.invalidate();
- }
-
- @Override
- public void dumpDatabaseCallbacks() {
- Log.v(LOGTAG, "dumpDatabaseCallbacks called.");
- mDumpDatabaseCallbacks = true;
- }
-
- @Override
- public void setCanOpenWindows() {
- Log.v(LOGTAG, "setCanOpenWindows called.");
- mCanOpenWindows = true;
- }
-
- @Override
- public void setMockGeolocationPosition(double latitude, double longitude, double accuracy) {
- WebViewClassic.fromWebView(mWebView).setMockGeolocationPosition(latitude, longitude,
- accuracy);
- }
-
- @Override
- public void setMockGeolocationError(int code, String message) {
- WebViewClassic.fromWebView(mWebView).setMockGeolocationError(code, message);
- }
-
- @Override
- public void setGeolocationPermission(boolean allow) {
- Log.v(LOGTAG, "setGeolocationPermission() allow=" + allow);
- WebViewClassic.fromWebView(mWebView).setMockGeolocationPermission(allow);
- }
-
- @Override
- public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
- boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) {
- WebViewClassic.fromWebView(mWebView).setMockDeviceOrientation(canProvideAlpha, alpha,
- canProvideBeta, beta, canProvideGamma, gamma);
- }
-
- @Override
- public void overridePreference(String key, boolean value) {
- // TODO: We should look up the correct WebView for the frame which
- // called the layoutTestController method. Currently, we just use the
- // WebView for the main frame. EventSender suffers from the same
- // problem.
- if (WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED.equals(key)) {
- mWebViewClassic.getSettings().setAppCacheEnabled(value);
- } else if (WEBKIT_USES_PAGE_CACHE_PREFERENCE_KEY.equals(key)) {
- // Cache the maximum possible number of pages.
- mWebViewClassic.getSettings().setPageCacheCapacity(Integer.MAX_VALUE);
- } else {
- Log.w(LOGTAG, "LayoutTestController.overridePreference(): " +
- "Unsupported preference '" + key + "'");
- }
- }
-
- @Override
- public void setXSSAuditorEnabled (boolean flag) {
- mWebViewClassic.getSettings().setXSSAuditorEnabled(flag);
- }
-
- private final WebViewClient mViewClient = new WebViewClient(){
- @Override
- public void onPageFinished(WebView view, String url) {
- Log.v(LOGTAG, "onPageFinished, url=" + url);
- mPageFinished = true;
-
- // Calling finished() will check if we've met all the conditions for completing
- // this test and move to the next one if we are ready. Otherwise we ask WebCore to
- // dump the page.
- if (finished()) {
- return;
- }
-
- if (!mWaitUntilDone && !mRequestedWebKitData && !mTimedOut) {
- requestWebKitData();
- } else {
- if (mWaitUntilDone) {
- Log.v(LOGTAG, "page finished loading but waiting for notifyDone to be called: " + url);
- }
-
- if (mRequestedWebKitData) {
- Log.v(LOGTAG, "page finished loading but webkit data has already been requested: " + url);
- }
-
- if (mTimedOut) {
- Log.v(LOGTAG, "page finished loading but already timed out: " + url);
- }
- }
-
- super.onPageFinished(view, url);
- }
-
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- Log.v(LOGTAG, "onPageStarted, url=" + url);
- mPageFinished = false;
- super.onPageStarted(view, url, favicon);
- }
-
- @Override
- public void onReceivedError(WebView view, int errorCode, String description,
- String failingUrl) {
- Log.v(LOGTAG, "onReceivedError, errorCode=" + errorCode
- + ", desc=" + description + ", url=" + failingUrl);
- super.onReceivedError(view, errorCode, description, failingUrl);
- }
-
- @Override
- public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler,
- String host, String realm) {
- if (handler.useHttpAuthUsernamePassword() && view != null) {
- String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
- if (credentials != null && credentials.length == 2) {
- handler.proceed(credentials[0], credentials[1]);
- return;
- }
- }
- handler.cancel();
- }
-
- @Override
- public void onReceivedSslError(WebView view, SslErrorHandler handler,
- SslError error) {
- handler.proceed();
- }
- };
-
-
- private final WebChromeClient mChromeClient = new WebChromeClient() {
- @Override
- public void onReceivedTitle(WebView view, String title) {
- setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount + ": "+ title);
- if (mDumpTitleChanges) {
- mTitleChanges.append("TITLE CHANGED: ");
- mTitleChanges.append(title);
- mTitleChanges.append("\n");
- }
- }
-
- @Override
- public boolean onJsAlert(WebView view, String url, String message,
- JsResult result) {
- if (mDialogStrings == null) {
- mDialogStrings = new StringBuffer();
- }
- mDialogStrings.append("ALERT: ");
- mDialogStrings.append(message);
- mDialogStrings.append('\n');
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsConfirm(WebView view, String url, String message,
- JsResult result) {
- if (mDialogStrings == null) {
- mDialogStrings = new StringBuffer();
- }
- mDialogStrings.append("CONFIRM: ");
- mDialogStrings.append(message);
- mDialogStrings.append('\n');
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsPrompt(WebView view, String url, String message,
- String defaultValue, JsPromptResult result) {
- if (mDialogStrings == null) {
- mDialogStrings = new StringBuffer();
- }
- mDialogStrings.append("PROMPT: ");
- mDialogStrings.append(message);
- mDialogStrings.append(", default text: ");
- mDialogStrings.append(defaultValue);
- mDialogStrings.append('\n');
- result.confirm();
- return true;
- }
-
- @Override
- public boolean onJsTimeout() {
- Log.v(LOGTAG, "JavaScript timeout");
- return false;
- }
-
- @Override
- public void onExceededDatabaseQuota(String url_str,
- String databaseIdentifier, long currentQuota,
- long estimatedSize, long totalUsedQuota,
- WebStorage.QuotaUpdater callback) {
- if (mDumpDatabaseCallbacks) {
- if (mDatabaseCallbackStrings == null) {
- mDatabaseCallbackStrings = new StringBuffer();
- }
-
- String protocol = "";
- String host = "";
- int port = 0;
-
- try {
- URL url = new URL(url_str);
- protocol = url.getProtocol();
- host = url.getHost();
- if (url.getPort() > -1) {
- port = url.getPort();
- }
- } catch (MalformedURLException e) {}
-
- String databaseCallbackString =
- "UI DELEGATE DATABASE CALLBACK: " +
- "exceededDatabaseQuotaForSecurityOrigin:{" + protocol +
- ", " + host + ", " + port + "} database:" +
- databaseIdentifier + "\n";
- Log.v(LOGTAG, "LOG: "+databaseCallbackString);
- mDatabaseCallbackStrings.append(databaseCallbackString);
- }
- // Give 5MB more quota.
- callback.updateQuota(currentQuota + 1024 * 1024 * 5);
- }
-
- @Override
- public void onGeolocationPermissionsShowPrompt(String origin,
- GeolocationPermissions.Callback callback) {
- throw new RuntimeException(
- "The WebCore mock used by DRT should bypass the usual permissions flow.");
- }
-
- @Override
- public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
- String msg = "CONSOLE MESSAGE: line " + consoleMessage.lineNumber() + ": "
- + consoleMessage.message() + "\n";
- if (mConsoleMessages == null) {
- mConsoleMessages = new StringBuffer();
- }
- mConsoleMessages.append(msg);
- Log.v(LOGTAG, "LOG: " + msg);
- // the rationale here is that if there's an error of either type, and the test was
- // waiting for "notifyDone" signal to finish, then there's no point in waiting
- // anymore because the JS execution is already terminated at this point and a
- // "notifyDone" will never come out so it's just wasting time till timeout kicks in
- if ((msg.contains("Uncaught ReferenceError:") || msg.contains("Uncaught TypeError:"))
- && mWaitUntilDone && mStopOnRefError) {
- Log.w(LOGTAG, "Terminating test case on uncaught ReferenceError or TypeError.");
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- notifyDone();
- }
- }, 500);
- }
- return true;
- }
-
- @Override
- public boolean onCreateWindow(WebView view, boolean dialog,
- boolean userGesture, Message resultMsg) {
- if (!mCanOpenWindows) {
- // We can't open windows, so just send null back.
- WebView.WebViewTransport transport =
- (WebView.WebViewTransport) resultMsg.obj;
- transport.setWebView(null);
- resultMsg.sendToTarget();
- return true;
- }
-
- // We never display the new window, just create the view and
- // allow it's content to execute and be recorded by the test
- // runner.
-
- HashMap<String, Object> jsIfaces = new HashMap<String, Object>();
- jsIfaces.put("layoutTestController", mCallbackProxy);
- jsIfaces.put("eventSender", mCallbackProxy);
- WebView newWindowView = new NewWindowWebView(TestShellActivity.this, jsIfaces);
- setupWebViewForLayoutTests(newWindowView, mCallbackProxy);
- WebView.WebViewTransport transport =
- (WebView.WebViewTransport) resultMsg.obj;
- transport.setWebView(newWindowView);
- resultMsg.sendToTarget();
- return true;
- }
-
- @Override
- public void onCloseWindow(WebView view) {
- view.destroy();
- }
- };
-
- private static class NewWindowWebView extends WebView {
- public NewWindowWebView(Context context, Map<String, Object> jsIfaces) {
- super(context, null, 0, jsIfaces, false);
- }
- }
-
- private void resetTestStatus() {
- mWaitUntilDone = false;
- mDumpDataType = mDefaultDumpDataType;
- mDumpTopFrameAsText = false;
- mDumpChildFramesAsText = false;
- mTimedOut = false;
- mDumpTitleChanges = false;
- mRequestedWebKitData = false;
- mDumpDatabaseCallbacks = false;
- mCanOpenWindows = false;
- mEventSender.resetMouse();
- mEventSender.clearTouchPoints();
- mEventSender.clearTouchMetaState();
- mPageFinished = false;
- mDumpWebKitData = false;
- setDefaultWebSettings(mWebView);
- CookieManager.getInstance().removeAllCookie();
- mWebViewClassic.setUseMockGeolocation();
- }
-
- private boolean canMoveToNextTest() {
- return (mDumpWebKitData && mPageFinished && !mWaitUntilDone) || mTimedOut;
- }
-
- private void setupWebViewForLayoutTests(WebView webview, CallbackProxy callbackProxy) {
- if (webview == null) {
- return;
- }
-
- setDefaultWebSettings(webview);
-
- webview.setWebChromeClient(mChromeClient);
- webview.setWebViewClient(mViewClient);
- // Setting a touch interval of -1 effectively disables the optimisation in WebView
- // that stops repeated touch events flooding WebCore. The Event Sender only sends a
- // single event rather than a stream of events (like what would generally happen in
- // a real use of touch events in a WebView) and so if the WebView drops the event,
- // the test will fail as the test expects one callback for every touch it synthesizes.
- WebViewClassic.fromWebView(webview).setTouchInterval(-1);
- }
-
- public void setDefaultWebSettings(WebView webview) {
- WebSettingsClassic settings = WebViewClassic.fromWebView(webview).getSettings();
- settings.setAppCacheEnabled(true);
- settings.setAppCachePath(getApplicationContext().getCacheDir().getPath());
- settings.setAppCacheMaxSize(Long.MAX_VALUE);
- settings.setJavaScriptEnabled(true);
- settings.setJavaScriptCanOpenWindowsAutomatically(true);
- settings.setSupportMultipleWindows(true);
- settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
- settings.setDatabaseEnabled(true);
- settings.setDatabasePath(getDir("databases",0).getAbsolutePath());
- settings.setDomStorageEnabled(true);
- settings.setWorkersEnabled(false);
- settings.setXSSAuditorEnabled(false);
- settings.setPageCacheCapacity(0);
- settings.setProperty("use_minimal_memory", "false");
- settings.setAllowUniversalAccessFromFileURLs(true);
- settings.setAllowFileAccessFromFileURLs(true);
- }
-
- private WebViewClassic mWebViewClassic;
- private WebView mWebView;
- private WebViewEventSender mEventSender;
- private AsyncHandler mHandler;
- private TestShellCallback mCallback;
-
- private CallbackProxy mCallbackProxy;
-
- private String mTestUrl;
- private String mResultFile;
- private int mTimeoutInMillis;
- private String mUiAutoTestPath;
- private BufferedReader mTestListReader;
- private int mTotalTestCount;
- private int mCurrentTestNumber;
- private boolean mStopOnRefError;
-
- // States
- private boolean mTimedOut;
- private boolean mRequestedWebKitData;
- private boolean mFinishedRunning;
-
- // Layout test controller variables.
- private DumpDataType mDumpDataType;
- private DumpDataType mDefaultDumpDataType = DumpDataType.EXT_REPR;
- private boolean mDumpTopFrameAsText;
- private boolean mDumpChildFramesAsText;
- private boolean mWaitUntilDone;
- private boolean mDumpTitleChanges;
- private StringBuffer mTitleChanges;
- private StringBuffer mDialogStrings;
- private boolean mKeepWebHistory;
- private Vector mWebHistory;
- private boolean mDumpDatabaseCallbacks;
- private StringBuffer mDatabaseCallbackStrings;
- private StringBuffer mConsoleMessages;
- private boolean mCanOpenWindows;
-
- private boolean mPageFinished = false;
- private boolean mDumpWebKitData = false;
-
- static final String TIMEOUT_STR = "**Test timeout";
- static final long DUMP_TIMEOUT_MS = 100000; // 100s timeout for dumping webview content
-
- static final int MSG_TIMEOUT = 0;
- static final int MSG_WEBKIT_DATA = 1;
- static final int MSG_DUMP_TIMEOUT = 2;
-
- static final String LOGTAG="TestShell";
-
- static final String TEST_URL = "TestUrl";
- static final String RESULT_FILE = "ResultFile";
- static final String TIMEOUT_IN_MILLIS = "TimeoutInMillis";
- static final String UI_AUTO_TEST = "UiAutoTest";
- static final String GET_DRAW_TIME = "GetDrawTime";
- static final String SAVE_IMAGE = "SaveImage";
- static final String TOTAL_TEST_COUNT = "TestCount";
- static final String CURRENT_TEST_NUMBER = "TestNumber";
- static final String STOP_ON_REF_ERROR = "StopOnReferenceError";
-
- static final int DRAW_RUNS = 5;
- static final String DRAW_TIME_LOG = Environment.getExternalStorageDirectory() +
- "/android/page_draw_time.txt";
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java
deleted file mode 100644
index 5220d57..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-public interface TestShellCallback {
- public void finished();
- public void dumpResult(String webViewDump);
- public void timedOut(String url);
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java b/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java
deleted file mode 100644
index 17345ae..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (C) 2007 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.dumprendertree;
-
-import android.os.SystemClock;
-import android.util.*;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.webkit.WebView;
-
-import java.util.Arrays;
-import java.util.Vector;
-
-public class WebViewEventSender implements EventSender {
-
- private static final String LOGTAG = "WebViewEventSender";
-
- WebViewEventSender(WebView webView) {
- mWebView = webView;
- mWebView.getSettings().setBuiltInZoomControls(true);
- mTouchPoints = new Vector<TouchPoint>();
- }
-
- public void resetMouse() {
- mouseX = mouseY = 0;
- }
-
- public void enableDOMUIEventLogging(int DOMNode) {
- // TODO Auto-generated method stub
-
- }
-
- public void fireKeyboardEventsToElement(int DOMNode) {
- // TODO Auto-generated method stub
-
- }
-
- public void keyDown(String character, String[] withModifiers) {
- Log.e("EventSender", "KeyDown: " + character + "("
- + character.getBytes()[0] + ") Modifiers: "
- + Arrays.toString(withModifiers));
- KeyEvent modifier = null;
- if (withModifiers != null && withModifiers.length > 0) {
- for (int i = 0; i < withModifiers.length; i++) {
- int keyCode = modifierMapper(withModifiers[i]);
- modifier = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
- mWebView.onKeyDown(modifier.getKeyCode(), modifier);
- }
- }
- int keyCode = keyMapper(character.toLowerCase().toCharArray()[0]);
- KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
- mWebView.onKeyDown(event.getKeyCode(), event);
-
- }
-
- public void keyDown(String character) {
- keyDown(character, null);
- }
-
- public void leapForward(int milliseconds) {
- // TODO Auto-generated method stub
-
- }
-
- public void mouseClick() {
- mouseDown();
- mouseUp();
- }
-
- public void mouseDown() {
- long ts = SystemClock.uptimeMillis();
- MotionEvent event = MotionEvent.obtain(ts, ts, MotionEvent.ACTION_DOWN, mouseX, mouseY, 0);
- mWebView.onTouchEvent(event);
- }
-
- public void mouseMoveTo(int X, int Y) {
- mouseX= X;
- mouseY= Y;
- }
-
- public void mouseUp() {
- long ts = SystemClock.uptimeMillis();
- MotionEvent event = MotionEvent.obtain(ts, ts, MotionEvent.ACTION_UP, mouseX, mouseY, 0);
- mWebView.onTouchEvent(event);
- }
-
- // Assumes lowercase chars, case needs to be
- // handled by calling function.
- static int keyMapper(char c) {
- // handle numbers
- if (c >= '0' && c<= '9') {
- int offset = c - '0';
- return KeyEvent.KEYCODE_0 + offset;
- }
-
- // handle characters
- if (c >= 'a' && c <= 'z') {
- int offset = c - 'a';
- return KeyEvent.KEYCODE_A + offset;
- }
-
- // handle all others
- switch (c) {
- case '*':
- return KeyEvent.KEYCODE_STAR;
- case '#':
- return KeyEvent.KEYCODE_POUND;
- case ',':
- return KeyEvent.KEYCODE_COMMA;
- case '.':
- return KeyEvent.KEYCODE_PERIOD;
- case '\t':
- return KeyEvent.KEYCODE_TAB;
- case ' ':
- return KeyEvent.KEYCODE_SPACE;
- case '\n':
- return KeyEvent.KEYCODE_ENTER;
- case '\b':
- case 0x7F:
- return KeyEvent.KEYCODE_DEL;
- case '~':
- return KeyEvent.KEYCODE_GRAVE;
- case '-':
- return KeyEvent.KEYCODE_MINUS;
- case '=':
- return KeyEvent.KEYCODE_EQUALS;
- case '(':
- return KeyEvent.KEYCODE_LEFT_BRACKET;
- case ')':
- return KeyEvent.KEYCODE_RIGHT_BRACKET;
- case '\\':
- return KeyEvent.KEYCODE_BACKSLASH;
- case ';':
- return KeyEvent.KEYCODE_SEMICOLON;
- case '\'':
- return KeyEvent.KEYCODE_APOSTROPHE;
- case '/':
- return KeyEvent.KEYCODE_SLASH;
- default:
- break;
- }
-
- return c;
- }
-
- static int modifierMapper(String modifier) {
- if (modifier.equals("ctrlKey")) {
- return KeyEvent.KEYCODE_ALT_LEFT;
- } else if (modifier.equals("shiftKey")) {
- return KeyEvent.KEYCODE_SHIFT_LEFT;
- } else if (modifier.equals("altKey")) {
- return KeyEvent.KEYCODE_SYM;
- } else if (modifier.equals("metaKey")) {
- return KeyEvent.KEYCODE_UNKNOWN;
- }
- return KeyEvent.KEYCODE_UNKNOWN;
- }
-
- public void touchStart() {
- final int numPoints = mTouchPoints.size();
- if (numPoints == 0) {
- return;
- }
-
- int[] pointerIds = new int[numPoints];
- MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[numPoints];
- long downTime = SystemClock.uptimeMillis();
-
- for (int i = 0; i < numPoints; ++i) {
- pointerIds[i] = mTouchPoints.get(i).getId();
- pointerCoords[i] = new MotionEvent.PointerCoords();
- pointerCoords[i].x = mTouchPoints.get(i).getX();
- pointerCoords[i].y = mTouchPoints.get(i).getY();
- mTouchPoints.get(i).setDownTime(downTime);
- }
-
- MotionEvent event = MotionEvent.obtain(downTime, downTime,
- MotionEvent.ACTION_DOWN, numPoints, pointerIds, pointerCoords,
- mTouchMetaState, 1.0f, 1.0f, 0, 0, 0, 0);
-
- mWebView.onTouchEvent(event);
- }
-
- public void touchMove() {
- final int numPoints = mTouchPoints.size();
- if (numPoints == 0) {
- return;
- }
-
- int[] pointerIds = new int[numPoints];
- MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[numPoints];
- int numMovedPoints = 0;
- for (int i = 0; i < numPoints; ++i) {
- TouchPoint tp = mTouchPoints.get(i);
- if (tp.hasMoved()) {
- pointerIds[numMovedPoints] = mTouchPoints.get(i).getId();
- pointerCoords[i] = new MotionEvent.PointerCoords();
- pointerCoords[numMovedPoints].x = mTouchPoints.get(i).getX();
- pointerCoords[numMovedPoints].y = mTouchPoints.get(i).getY();
- ++numMovedPoints;
- tp.setMoved(false);
- }
- }
-
- if (numMovedPoints == 0) {
- return;
- }
-
- MotionEvent event = MotionEvent.obtain(mTouchPoints.get(0).downTime(),
- SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE,
- numMovedPoints, pointerIds, pointerCoords,
- mTouchMetaState, 1.0f, 1.0f, 0, 0, 0, 0);
- mWebView.onTouchEvent(event);
- }
-
- public void touchEnd() {
- final int numPoints = mTouchPoints.size();
- if (numPoints == 0) {
- return;
- }
-
- int[] pointerIds = new int[numPoints];
- MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[numPoints];
-
- for (int i = 0; i < numPoints; ++i) {
- pointerIds[i] = mTouchPoints.get(i).getId();
- pointerCoords[i] = new MotionEvent.PointerCoords();
- pointerCoords[i].x = mTouchPoints.get(i).getX();
- pointerCoords[i].y = mTouchPoints.get(i).getY();
- }
-
- MotionEvent event = MotionEvent.obtain(mTouchPoints.get(0).downTime(),
- SystemClock.uptimeMillis(), MotionEvent.ACTION_UP,
- numPoints, pointerIds, pointerCoords,
- mTouchMetaState, 1.0f, 1.0f, 0, 0, 0, 0);
- mWebView.onTouchEvent(event);
-
- for (int i = numPoints - 1; i >= 0; --i) { // remove released points.
- TouchPoint tp = mTouchPoints.get(i);
- if (tp.isReleased()) {
- mTouchPoints.remove(i);
- }
- }
- }
-
- public void touchCancel() {
- final int numPoints = mTouchPoints.size();
- if (numPoints == 0) {
- return;
- }
-
- int[] pointerIds = new int[numPoints];
- MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[numPoints];
- long cancelTime = SystemClock.uptimeMillis();
- int numCanceledPoints = 0;
-
- for (int i = 0; i < numPoints; ++i) {
- TouchPoint tp = mTouchPoints.get(i);
- if (tp.cancelled()) {
- pointerIds[numCanceledPoints] = mTouchPoints.get(i).getId();
- pointerCoords[numCanceledPoints] = new MotionEvent.PointerCoords();
- pointerCoords[numCanceledPoints].x = mTouchPoints.get(i).getX();
- pointerCoords[numCanceledPoints].y = mTouchPoints.get(i).getY();
- ++numCanceledPoints;
- }
- }
-
- if (numCanceledPoints == 0) {
- return;
- }
-
- MotionEvent event = MotionEvent.obtain(mTouchPoints.get(0).downTime(),
- SystemClock.uptimeMillis(), MotionEvent.ACTION_CANCEL,
- numCanceledPoints, pointerIds, pointerCoords,
- mTouchMetaState, 1.0f, 1.0f, 0, 0, 0, 0);
-
- mWebView.onTouchEvent(event);
- }
-
- public void cancelTouchPoint(int id) {
- TouchPoint tp = mTouchPoints.get(id);
- if (tp == null) {
- return;
- }
-
- tp.cancel();
- }
-
- public void addTouchPoint(int x, int y) {
- final int numPoints = mTouchPoints.size();
- int id;
- if (numPoints == 0) {
- id = 0;
- } else {
- id = mTouchPoints.get(numPoints - 1).getId() + 1;
- }
-
- mTouchPoints.add(new TouchPoint(id, contentsToWindowX(x), contentsToWindowY(y)));
- }
-
- public void updateTouchPoint(int i, int x, int y) {
- TouchPoint tp = mTouchPoints.get(i);
- if (tp == null) {
- return;
- }
-
- tp.update(contentsToWindowX(x), contentsToWindowY(y));
- tp.setMoved(true);
- }
-
- public void setTouchModifier(String modifier, boolean enabled) {
- int mask = 0;
- if ("alt".equals(modifier.toLowerCase())) {
- mask = KeyEvent.META_ALT_ON;
- } else if ("shift".equals(modifier.toLowerCase())) {
- mask = KeyEvent.META_SHIFT_ON;
- } else if ("ctrl".equals(modifier.toLowerCase())) {
- mask = KeyEvent.META_SYM_ON;
- }
-
- if (enabled) {
- mTouchMetaState |= mask;
- } else {
- mTouchMetaState &= ~mask;
- }
- }
-
- public void releaseTouchPoint(int id) {
- TouchPoint tp = mTouchPoints.get(id);
- if (tp == null) {
- return;
- }
-
- tp.release();
- }
-
- public void clearTouchPoints() {
- mTouchPoints.clear();
- }
-
- public void clearTouchMetaState() {
- mTouchMetaState = 0;
- }
-
- private int contentsToWindowX(int x) {
- return Math.round(x * mWebView.getScale()) - mWebView.getScrollX();
- }
-
- private int contentsToWindowY(int y) {
- return Math.round(y * mWebView.getScale()) - mWebView.getScrollY();
- }
-
- private WebView mWebView = null;
- private int mouseX;
- private int mouseY;
-
- private class TouchPoint {
- private int mId;
- private int mX;
- private int mY;
- private long mDownTime;
- private boolean mReleased;
- private boolean mMoved;
- private boolean mCancelled;
-
- public TouchPoint(int id, int x, int y) {
- mId = id;
- mX = x;
- mY = y;
- mReleased = false;
- mMoved = false;
- mCancelled = false;
- }
-
- public void setDownTime(long downTime) { mDownTime = downTime; }
- public long downTime() { return mDownTime; }
- public void cancel() { mCancelled = true; }
-
- public boolean cancelled() { return mCancelled; }
-
- public void release() { mReleased = true; }
- public boolean isReleased() { return mReleased; }
-
- public void setMoved(boolean moved) { mMoved = moved; }
- public boolean hasMoved() { return mMoved; }
-
- public int getId() { return mId; }
- public int getX() { return mX; }
- public int getY() { return mY; }
-
- public void update(int x, int y) {
- mX = x;
- mY = y;
- }
- }
-
- private Vector<TouchPoint> mTouchPoints;
- private int mTouchMetaState;
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/AdbUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/AdbUtils.java
deleted file mode 100644
index c2ecf3a..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/AdbUtils.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2009 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.dumprendertree.forwarder;
-
-import android.util.Log;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-public class AdbUtils {
-
- private static final String ADB_OK = "OKAY";
- private static final int ADB_PORT = 5037;
- private static final String ADB_HOST = "127.0.0.1";
- private static final int ADB_RESPONSE_SIZE = 4;
-
- private static final String LOGTAG = "AdbUtils";
-
- /**
- *
- * Convert integer format IP into xxx.xxx.xxx.xxx format
- *
- * @param host IP address in integer format
- * @return human readable format
- */
- public static String convert(int host) {
- return ((host >> 24) & 0xFF) + "."
- + ((host >> 16) & 0xFF) + "."
- + ((host >> 8) & 0xFF) + "."
- + (host & 0xFF);
- }
-
- /**
- *
- * Resolve DNS name into IP address
- *
- * @param host DNS name
- * @return IP address in integer format
- * @throws IOException
- */
- public static int resolve(String host) throws IOException {
- Socket localSocket = new Socket(ADB_HOST, ADB_PORT);
- DataInputStream dis = new DataInputStream(localSocket.getInputStream());
- OutputStream os = localSocket.getOutputStream();
- int count_read = 0;
-
- if (localSocket == null || dis == null || os == null)
- return -1;
- String cmd = "dns:" + host;
-
- if(!sendAdbCmd(dis, os, cmd))
- return -1;
-
- count_read = dis.readInt();
- localSocket.close();
- return count_read;
- }
-
- /**
- *
- * Send an ADB command using existing socket connection
- *
- * the streams provided must be from a socket connected to adbd already
- *
- * @param is input stream of the socket connection
- * @param os output stream of the socket
- * @param cmd the adb command to send
- * @return if adb gave a success response
- * @throws IOException
- */
- public static boolean sendAdbCmd(InputStream is, OutputStream os,
- String cmd) throws IOException {
- byte[] buf = new byte[ADB_RESPONSE_SIZE];
-
- cmd = String.format("%04X", cmd.length()) + cmd;
- os.write(cmd.getBytes());
- int read = is.read(buf);
- if(read != ADB_RESPONSE_SIZE || !ADB_OK.equals(new String(buf))) {
- Log.w(LOGTAG, "adb cmd faild.");
- return false;
- }
- return true;
- }
-
- /**
- *
- * Get a tcp socket connection to specified IP address and port proxied by adb
- *
- * The proxying is transparent, e.g. if a socket is returned, then it can be written to and
- * read from as if it is directly connected to the target
- *
- * @param remoteAddress IP address of the host to connect to
- * @param remotePort port of the host to connect to
- * @return a valid Socket instance if successful, null otherwise
- */
- public static Socket getForwardedSocket(int remoteAddress, int remotePort) {
- try {
- Socket socket = new Socket(ADB_HOST, ADB_PORT);
- String cmd = "tcp:" + remotePort + ":" + convert(remoteAddress);
- if(!sendAdbCmd(socket.getInputStream(), socket.getOutputStream(), cmd)) {
- socket.close();
- return null;
- }
- return socket;
- } catch (IOException ioe) {
- Log.w(LOGTAG, "error creating adb socket", ioe);
- return null;
- }
- }
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardServer.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardServer.java
deleted file mode 100644
index 14f8fbe..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardServer.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2009 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.dumprendertree.forwarder;
-
-import android.util.Log;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- *
- * A port forwarding server. Listens at specified local port and forward the tcp communications to
- * external host/port via adb networking proxy.
- *
- */
-public class ForwardServer {
-
- private static final String LOGTAG = "ForwardServer";
-
- private int remotePort;
- private int remoteAddress;
- private int localPort;
- private ServerSocket serverSocket;
- private boolean started;
-
- private Set<Forwarder> forwarders;
-
- public ForwardServer(int localPort, int remoteAddress, int remotePort) {
- this.localPort = localPort;
- this.remoteAddress = remoteAddress;
- this.remotePort = remotePort;
- started = false;
- forwarders = new HashSet<Forwarder>();
- }
-
- public synchronized void start() throws IOException {
- if(!started) {
- serverSocket = new ServerSocket(localPort);
- Thread serverThread = new Thread(new ServerRunner(serverSocket));
- serverThread.setName(LOGTAG);
- serverThread.start();
- started = true;
- }
- }
-
- public synchronized void stop() {
- if(started) {
- synchronized (forwarders) {
- for(Forwarder forwarder : forwarders)
- forwarder.stop();
- forwarders.clear();
- }
- try {
- serverSocket.close();
- } catch (IOException ioe) {
- Log.v(LOGTAG, "exception while closing", ioe);
- } finally {
- started = false;
- }
- }
- }
-
- public synchronized boolean isRunning() {
- return started;
- }
-
- private class ServerRunner implements Runnable {
-
- private ServerSocket socket;
-
- public ServerRunner(ServerSocket socket) {
- this.socket = socket;
- }
-
- public void run() {
- try {
- while (true) {
- Socket localSocket = socket.accept();
- Socket remoteSocket = AdbUtils.getForwardedSocket(remoteAddress, remotePort);
- if(remoteSocket == null) {
- try {
- localSocket.close();
- } catch (IOException ioe) {
- Log.w(LOGTAG, "error while closing socket", ioe);
- } finally {
- Log.w(LOGTAG, "failed to start forwarding from " + localSocket);
- }
- } else {
- Forwarder forwarder = new Forwarder(localSocket, remoteSocket,
- ForwardServer.this);
- forwarder.start();
- }
- }
- } catch (IOException ioe) {
- return;
- }
- }
- }
-
- public void register(Forwarder forwarder) {
- synchronized (forwarders) {
- if(!forwarders.contains(forwarder)) {
- forwarders.add(forwarder);
- }
- }
- }
-
- public void unregister(Forwarder recyclable) {
- synchronized (forwarders) {
- if(forwarders.contains(recyclable)) {
- recyclable.stop();
- forwarders.remove(recyclable);
- }
- }
- }
-} \ No newline at end of file
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
deleted file mode 100644
index 25dd04fd..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009 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.dumprendertree.forwarder;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-import android.os.Environment;
-import android.util.Log;
-
-public class ForwardService {
-
- private ForwardServer fs8000, fs8080, fs8443;
-
- private static ForwardService inst;
-
- private static final String LOGTAG = "ForwardService";
-
- private static final String DEFAULT_TEST_HOST = "android-browser-test.mtv.corp.google.com";
-
- private static final String FORWARD_HOST_CONF =
- Environment.getExternalStorageDirectory() + "/drt_forward_host.txt";
-
- private ForwardService() {
- int addr = getForwardHostAddr();
- if (addr != -1) {
- fs8000 = new ForwardServer(8000, addr, 8000);
- fs8080 = new ForwardServer(8080, addr, 8080);
- fs8443 = new ForwardServer(8443, addr, 8443);
- }
- }
-
- public static ForwardService getForwardService() {
- if (inst == null) {
- inst = new ForwardService();
- }
- return inst;
- }
-
- public void startForwardService() {
- try {
- if (fs8000 != null)
- fs8000.start();
- if (fs8080 != null)
- fs8080.start();
- if (fs8443 != null)
- fs8443.start();
- } catch (IOException ioe) {
- Log.w(LOGTAG, "failed to start forwarder. http tests will fail.", ioe);
- return;
- }
- }
-
- public void stopForwardService() {
- if (fs8000 != null) {
- fs8000.stop();
- fs8000 = null;
- }
- if (fs8080 != null) {
- fs8080.stop();
- fs8080 = null;
- }
- if (fs8443 != null) {
- fs8443.stop();
- fs8443 = null;
- }
- Log.v(LOGTAG, "forwarders stopped.");
- }
-
- private static int getForwardHostAddr() {
- int addr = -1;
- String host = null;
- File forwardHostConf = new File(FORWARD_HOST_CONF);
- if (forwardHostConf.isFile()) {
- BufferedReader hostReader = null;
- try {
- hostReader = new BufferedReader(new FileReader(forwardHostConf));
- host = hostReader.readLine();
- Log.v(LOGTAG, "read forward host from file: " + host);
- } catch (IOException ioe) {
- Log.v(LOGTAG, "cannot read forward host from file", ioe);
- } finally {
- if (hostReader != null) {
- try {
- hostReader.close();
- } catch (IOException ioe) {
- // burn!!!
- }
- }
- }
- }
- if (host == null || host.length() == 0)
- host = DEFAULT_TEST_HOST;
- try {
- addr = AdbUtils.resolve(host);
- } catch (IOException ioe) {
- Log.e(LOGTAG, "failed to resolve server address", ioe);
- }
- return addr;
- }
-}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java
deleted file mode 100644
index a971e7b..0000000
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2009 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.dumprendertree.forwarder;
-
-import android.util.Log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-/**
- *
- * Worker class for {@link ForwardServer}. A Forwarder will be created once the ForwardServer
- * accepts an incoming connection, and it will then forward the incoming/outgoing streams to a
- * connection already proxied by adb networking (see also {@link AdbUtils}).
- *
- */
-public class Forwarder {
-
- private ForwardServer server;
- private Socket from, to;
-
- private static final String LOGTAG = "Forwarder";
- private static final int BUFFER_SIZE = 16384;
-
- public Forwarder (Socket from, Socket to, ForwardServer server) {
- this.server = server;
- this.from = from;
- this.to = to;
- server.register(this);
- }
-
- public void start() {
- Thread outgoing = new Thread(new SocketPipe(from, to));
- Thread incoming = new Thread(new SocketPipe(to, from));
- outgoing.setName(LOGTAG);
- incoming.setName(LOGTAG);
- outgoing.start();
- incoming.start();
- }
-
- public void stop() {
- shutdown(from);
- shutdown(to);
- }
-
- private void shutdown(Socket socket) {
- try {
- socket.shutdownInput();
- } catch (IOException e) {
- Log.v(LOGTAG, "Socket#shutdownInput", e);
- }
- try {
- socket.shutdownOutput();
- } catch (IOException e) {
- Log.v(LOGTAG, "Socket#shutdownOutput", e);
- }
- try {
- socket.close();
- } catch (IOException e) {
- Log.v(LOGTAG, "Socket#close", e);
- }
- }
-
- private class SocketPipe implements Runnable {
-
- private Socket in, out;
-
- public SocketPipe(Socket in, Socket out) {
- this.in = in;
- this.out = out;
- }
-
- public void run() {
- try {
- int length;
- InputStream is = in.getInputStream();
- OutputStream os = out.getOutputStream();
- byte[] buffer = new byte[BUFFER_SIZE];
- while ((length = is.read(buffer)) > 0) {
- os.write(buffer, 0, length);
- }
- } catch (IOException ioe) {
- } finally {
- server.unregister(Forwarder.this);
- }
- }
-
- @Override
- public String toString() {
- return "SocketPipe{" + in + "=>" + out + "}";
- }
- }
-}