summaryrefslogtreecommitdiffstats
path: root/tests/DumpRenderTree
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-05-16 12:41:18 +0100
committerSteve Block <steveblock@google.com>2012-05-22 12:07:55 +0100
commitf3f60d9328d8acfedf987a73631fc90c39bf5447 (patch)
tree1df1425cd3c08ef1e29dee80877406332eafa873 /tests/DumpRenderTree
parent32a85291efb1b5ef0c3dbd7b581df27f1d03305a (diff)
downloadframeworks_base-f3f60d9328d8acfedf987a73631fc90c39bf5447.zip
frameworks_base-f3f60d9328d8acfedf987a73631fc90c39bf5447.tar.gz
frameworks_base-f3f60d9328d8acfedf987a73631fc90c39bf5447.tar.bz2
Switch Geolocation DRT methods to control client-based mock
Note that we plumb DRT Geolocation mock calls via WebView. This is required because the WebCore client-based mock is not a static but is tied to the Page. See WebKit change Ib74a3c05991593e75c3138415d4ac0bf0c9aefa9. Bug: 6511338 Change-Id: I6d88d5dce5c2148812b191a5b452718bf0854aeb
Diffstat (limited to 'tests/DumpRenderTree')
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java30
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java4
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java52
3 files changed, 35 insertions, 51 deletions
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
index d74f5f7..9d621d6 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
@@ -19,7 +19,6 @@ package com.android.dumprendertree;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.webkit.MockGeolocation;
import android.webkit.WebStorage;
import java.util.HashMap;
@@ -48,7 +47,6 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
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;
@@ -72,10 +70,9 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
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 SET_GEOLOCATION_PERMISSION = 43;
- private static final int OVERRIDE_PREFERENCE = 44;
- private static final int LAYOUT_DUMP_CHILD_FRAMES_TEXT = 45;
- private static final int SET_XSS_AUDITOR_ENABLED = 46;
+ 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) {
@@ -269,11 +266,6 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
mLayoutTestController.setCanOpenWindows();
break;
- case SET_GEOLOCATION_PERMISSION:
- mLayoutTestController.setGeolocationPermission(
- msg.arg1 == 1 ? true : false);
- break;
-
case OVERRIDE_PREFERENCE:
String key = msg.getData().getString("key");
boolean value = msg.getData().getBoolean("value");
@@ -497,17 +489,23 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
public void setMockGeolocationPosition(double latitude,
double longitude,
double accuracy) {
- MockGeolocation.getInstance().setPosition(latitude,
- longitude,
- 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) {
- MockGeolocation.getInstance().setError(code, 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) {
- obtainMessage(SET_GEOLOCATION_PERMISSION, allow ? 1 : 0, 0).sendToTarget();
+ // 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,
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
index 9be2f1c..c936a6c 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
@@ -72,6 +72,10 @@ public interface LayoutTestController {
// 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/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index bbfbfc4..2b58f14 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -539,24 +539,22 @@ public class TestShellActivity extends Activity implements LayoutTestController
mCanOpenWindows = true;
}
- /**
- * Sets the Geolocation permission state to be used for all future requests.
- */
+ @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) {
- mIsGeolocationPermissionSet = true;
- mGeolocationPermission = allow;
-
- if (mPendingGeolocationPermissionCallbacks != null) {
- Iterator iter = mPendingGeolocationPermissionCallbacks.keySet().iterator();
- while (iter.hasNext()) {
- GeolocationPermissions.Callback callback =
- (GeolocationPermissions.Callback) iter.next();
- String origin = (String) mPendingGeolocationPermissionCallbacks.get(callback);
- callback.invoke(origin, mGeolocationPermission, false);
- }
- mPendingGeolocationPermissionCallbacks = null;
- }
+ Log.v(LOGTAG, "setGeolocationPermission() allow=" + allow);
+ WebViewClassic.fromWebView(mWebView).setMockGeolocationPermission(allow);
}
@Override
@@ -749,22 +747,11 @@ public class TestShellActivity extends Activity implements LayoutTestController
callback.updateQuota(currentQuota + 1024 * 1024 * 5);
}
- /**
- * Instructs the client to show a prompt to ask the user to set the
- * Geolocation permission state for the specified origin.
- */
@Override
public void onGeolocationPermissionsShowPrompt(String origin,
GeolocationPermissions.Callback callback) {
- if (mIsGeolocationPermissionSet) {
- callback.invoke(origin, mGeolocationPermission, false);
- return;
- }
- if (mPendingGeolocationPermissionCallbacks == null) {
- mPendingGeolocationPermissionCallbacks =
- new HashMap<GeolocationPermissions.Callback, String>();
- }
- mPendingGeolocationPermissionCallbacks.put(callback, origin);
+ throw new RuntimeException(
+ "The WebCore mock used by DRT should bypass the usual permissions flow.");
}
@Override
@@ -849,9 +836,8 @@ public class TestShellActivity extends Activity implements LayoutTestController
mPageFinished = false;
mDumpWebKitData = false;
setDefaultWebSettings(mWebView);
- mIsGeolocationPermissionSet = false;
- mPendingGeolocationPermissionCallbacks = null;
CookieManager.getInstance().removeAllCookie();
+ mWebViewClassic.setUseMockGeolocation();
}
private boolean canMoveToNextTest() {
@@ -958,8 +944,4 @@ public class TestShellActivity extends Activity implements LayoutTestController
static final int DRAW_RUNS = 5;
static final String DRAW_TIME_LOG = Environment.getExternalStorageDirectory() +
"/android/page_draw_time.txt";
-
- private boolean mIsGeolocationPermissionSet;
- private boolean mGeolocationPermission;
- private Map mPendingGeolocationPermissionCallbacks;
}