diff options
| author | Steve Block <steveblock@google.com> | 2012-05-16 12:41:18 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2012-05-22 12:07:55 +0100 |
| commit | f3f60d9328d8acfedf987a73631fc90c39bf5447 (patch) | |
| tree | 1df1425cd3c08ef1e29dee80877406332eafa873 /tests/DumpRenderTree2/src | |
| parent | 32a85291efb1b5ef0c3dbd7b581df27f1d03305a (diff) | |
| download | frameworks_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/DumpRenderTree2/src')
| -rw-r--r-- | tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java | 26 | ||||
| -rw-r--r-- | tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java | 52 |
2 files changed, 31 insertions, 47 deletions
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java index d0c59d3..bb3bf62 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java @@ -80,6 +80,21 @@ public class LayoutTestController { quota); } + public void setMockGeolocationPosition(double latitude, + double longitude, + double accuracy) { + Log.i(LOG_TAG, "setMockGeolocationPosition(): " + "latitude=" + latitude + + " longitude=" + longitude + " accuracy=" + accuracy); + mLayoutTestsExecutor.setMockGeolocationPosition(latitude, + longitude, + accuracy); + } + + public void setMockGeolocationError(int code, String message) { + Log.i(LOG_TAG, "setMockGeolocationError(): " + "code=" + code + " message=" + message); + mLayoutTestsExecutor.setMockGeolocationError(code, message); + } + public void setGeolocationPermission(boolean allow) { mLayoutTestsExecutor.setGeolocationPermission(allow); } @@ -95,17 +110,6 @@ public class LayoutTestController { canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); } - public void setMockGeolocationError(int code, String message) { - Log.i(LOG_TAG, "setMockGeolocationError(): " + "code=" + code + " message=" + message); - MockGeolocation.getInstance().setError(code, message); - } - - public void setMockGeolocationPosition(double latitude, double longitude, double accuracy) { - Log.i(LOG_TAG, "setMockGeolocationPosition(): " + "latitude=" + latitude + - " longitude=" + longitude + " accuracy=" + accuracy); - MockGeolocation.getInstance().setPosition(latitude, longitude, accuracy); - } - public void setXSSAuditorEnabled(boolean flag) { mLayoutTestsExecutor.setXSSAuditorEnabled(flag); } diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java index f958ade..b2fbfd5 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java @@ -109,9 +109,6 @@ public class LayoutTestsExecutor extends Activity { private LayoutTestController mLayoutTestController = new LayoutTestController(this); private boolean mCanOpenWindows; private boolean mDumpDatabaseCallbacks; - private boolean mIsGeolocationPermissionSet; - private boolean mGeolocationPermission; - private Map<GeolocationPermissions.Callback, String> mPendingGeolocationPermissionCallbacks; private EventSender mEventSender = new EventSender(); @@ -255,15 +252,8 @@ public class LayoutTestsExecutor extends Activity { @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."); } }; @@ -394,6 +384,7 @@ public class LayoutTestsExecutor extends Activity { webViewSettings.setPageCacheCapacity(0); // This is asynchronous, but it gets processed by WebCore before it starts loading pages. + WebViewClassic.fromWebView(mCurrentWebView).setUseMockGeolocation(); WebViewClassic.fromWebView(mCurrentWebView).setUseMockDeviceOrientation(); // Must do this after setting the AppCache path. @@ -573,9 +564,8 @@ public class LayoutTestsExecutor extends Activity { private static final int MSG_DUMP_CHILD_FRAMES_AS_TEXT = 3; private static final int MSG_SET_CAN_OPEN_WINDOWS = 4; private static final int MSG_DUMP_DATABASE_CALLBACKS = 5; - private static final int MSG_SET_GEOLOCATION_PERMISSION = 6; - private static final int MSG_OVERRIDE_PREFERENCE = 7; - private static final int MSG_SET_XSS_AUDITOR_ENABLED = 8; + private static final int MSG_OVERRIDE_PREFERENCE = 6; + private static final int MSG_SET_XSS_AUDITOR_ENABLED = 7; /** String constants for use with layoutTestController.overridePreference() */ private final String WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED = @@ -644,22 +634,6 @@ public class LayoutTestsExecutor extends Activity { mCanOpenWindows = true; break; - case MSG_SET_GEOLOCATION_PERMISSION: - mIsGeolocationPermissionSet = true; - mGeolocationPermission = msg.arg1 == 1; - - if (mPendingGeolocationPermissionCallbacks != null) { - Iterator<GeolocationPermissions.Callback> iter = - mPendingGeolocationPermissionCallbacks.keySet().iterator(); - while (iter.hasNext()) { - GeolocationPermissions.Callback callback = iter.next(); - String origin = mPendingGeolocationPermissionCallbacks.get(callback); - callback.invoke(origin, mGeolocationPermission, false); - } - mPendingGeolocationPermissionCallbacks = null; - } - break; - case MSG_SET_XSS_AUDITOR_ENABLED: WebViewClassic.fromWebView(mCurrentWebView).getSettings(). setXSSAuditorEnabled(msg.arg1 == 1); @@ -679,8 +653,6 @@ public class LayoutTestsExecutor extends Activity { private void resetLayoutTestController() { mCanOpenWindows = false; mDumpDatabaseCallbacks = false; - mIsGeolocationPermissionSet = false; - mPendingGeolocationPermissionCallbacks = null; } public void dumpAsText(boolean enablePixelTest) { @@ -721,12 +693,20 @@ public class LayoutTestsExecutor extends Activity { mLayoutTestControllerHandler.sendEmptyMessage(MSG_SET_CAN_OPEN_WINDOWS); } + public void setMockGeolocationPosition(double latitude, double longitude, double accuracy) { + WebViewClassic.fromWebView(mCurrentWebView).setMockGeolocationPosition(latitude, + longitude, + accuracy); + } + + public void setMockGeolocationError(int code, String message) { + WebViewClassic.fromWebView(mCurrentWebView).setMockGeolocationError(code, message); + } + public void setGeolocationPermission(boolean allow) { Log.i(LOG_TAG, mCurrentTestRelativePath + ": setGeolocationPermission(" + allow + ") called"); - Message msg = mLayoutTestControllerHandler.obtainMessage(MSG_SET_GEOLOCATION_PERMISSION); - msg.arg1 = allow ? 1 : 0; - msg.sendToTarget(); + WebViewClassic.fromWebView(mCurrentWebView).setMockGeolocationPermission(allow); } public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha, |
