diff options
9 files changed, 127 insertions, 3 deletions
diff --git a/core/java/android/webkit/DeviceOrientationManager.java b/core/java/android/webkit/DeviceOrientationManager.java new file mode 100644 index 0000000..778b043 --- /dev/null +++ b/core/java/android/webkit/DeviceOrientationManager.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 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 android.webkit; + +import android.util.Log; + +/** + * This class is simply a container for the methods used to configure WebKit's + * mock DeviceOrientationClient for use in LayoutTests. + * + * This could be part of WebViewCore, but have moved it to its own class to + * avoid bloat there. + * @hide + */ +public final class DeviceOrientationManager { + /** + * Sets whether the Page for the specified WebViewCore should use a mock DeviceOrientation + * client. + */ + public static void useMock(WebViewCore webViewCore) { + assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); + nativeUseMock(webViewCore); + } + + /** + * Set the position for the mock DeviceOrientation service for the supplied WebViewCore. + */ + public static void setMockOrientation(WebViewCore webViewCore, boolean canProvideAlpha, + double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma, + double gamma) { + assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); + nativeSetMockOrientation(webViewCore, canProvideAlpha, alpha, canProvideBeta, beta, + canProvideGamma, gamma); + } + + // Native functions + private static native void nativeUseMock(WebViewCore webViewCore); + private static native void nativeSetMockOrientation(WebViewCore webViewCore, + boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, + boolean canProvideGamma, double gamma); +} diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index d1b0902..44f036b 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -66,6 +66,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; +import android.webkit.DeviceOrientationManager; import android.webkit.WebTextView.AutoCompleteAdapter; import android.webkit.WebViewCore.EventHub; import android.webkit.WebViewCore.TouchEventData; @@ -3747,6 +3748,26 @@ public class WebView extends AbsoluteLayout } /** + * Called by DRT on UI thread, need to proxy to WebCore thread. + * + * @hide debug only + */ + public void useMockDeviceOrientation() { + mWebViewCore.sendMessage(EventHub.USE_MOCK_DEVICE_ORIENTATION); + } + + /** + * Called by DRT on WebCore thread. + * + * @hide debug only + */ + public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha, + boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) { + DeviceOrientationManager.setMockOrientation(mWebViewCore, canProvideAlpha, alpha, + canProvideBeta, beta, canProvideGamma, gamma); + } + + /** * Dump the V8 counters to standard output. * Note that you need a build with V8 and WEBCORE_INSTRUMENTATION set to * true. Otherwise, this will do nothing. diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 3c28c94..9ec97cd 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -33,6 +33,7 @@ import android.util.SparseBooleanArray; import android.view.KeyEvent; import android.view.SurfaceView; import android.view.View; +import android.webkit.DeviceOrientationManager; import java.util.ArrayList; import java.util.Collection; @@ -878,6 +879,8 @@ final class WebViewCore { // accessibility support static final int MODIFY_SELECTION = 190; + static final int USE_MOCK_DEVICE_ORIENTATION = 191; + // private message ids private static final int DESTROY = 200; @@ -1409,6 +1412,10 @@ final class WebViewCore { WebView.SET_TOUCH_HIGHLIGHT_RECTS, null) .sendToTarget(); break; + + case USE_MOCK_DEVICE_ORIENTATION: + useMockDeviceOrientation(); + break; } } }; @@ -2481,6 +2488,10 @@ final class WebViewCore { hMode, vMode).sendToTarget(); } + private void useMockDeviceOrientation() { + DeviceOrientationManager.useMock(this); + } + private native void nativePause(); private native void nativeResume(); private native void nativeFreeMemory(); diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java index b62db51..740f544 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java @@ -510,6 +510,14 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon obtainMessage(SET_GEOLOCATION_PERMISSION, allow ? 1 : 0, 0).sendToTarget(); } + 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); diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java index acc0ff2..9f580a3 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java @@ -73,7 +73,6 @@ public class FileFilter { static final String[] ignoreTestList = { "editing/selection/move-left-right.html", // Causes DumpRenderTree to hang - "fast/dom/DeviceOrientation/basic-operation.html", // Will cause crash until mock DeviceOrientationClient is hooked up. "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/regex/test1.html", // Causes DumpRenderTree to hang with V8 diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java index 15288b5..9be2f1c 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java @@ -71,4 +71,8 @@ public interface LayoutTestController { // For XSSAuditor tests public void setXSSAuditorEnabled(boolean flag); + + // 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 8c7254c..db076da 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java @@ -150,6 +150,9 @@ public class TestShellActivity extends Activity implements LayoutTestController if (intent != null) { executeIntent(intent); } + + // This is asynchronous, but it gets processed by WebCore before it starts loading pages. + mWebView.useMockDeviceOrientation(); } @Override @@ -494,6 +497,12 @@ public class TestShellActivity extends Activity implements LayoutTestController mGeolocationPermission = allow; } + public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha, + boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) { + mWebView.setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, + canProvideGamma, gamma); + } + 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 diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java index 8ff5e63..6db9571 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestController.java @@ -89,4 +89,12 @@ public class LayoutTestController { Log.w(LOG_TAG + "::setMockGeolocationError", "code: " + code + " message: " + message); MockGeolocation.getInstance().setError(code, message); } -}
\ No newline at end of file + + 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 LayoutTestsExecutor + // as we need access to the Webview. + mLayoutTestsExecutor.setMockDeviceOrientation( + canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); + } +} diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java index 047348d..8cc4921 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java @@ -308,6 +308,9 @@ public class LayoutTestsExecutor extends Activity { webViewSettings.setDomStorageEnabled(true); webViewSettings.setWorkersEnabled(false); webViewSettings.setXSSAuditorEnabled(false); + + // This is asynchronous, but it gets processed by WebCore before it starts loading pages. + mCurrentWebView.useMockDeviceOrientation(); } private void startTests() { @@ -569,4 +572,10 @@ public class LayoutTestsExecutor extends Activity { msg.arg1 = allow ? 1 : 0; msg.sendToTarget(); } -}
\ No newline at end of file + + public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha, + boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) { + mCurrentWebView.setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, + canProvideGamma, gamma); + } +} |
