Implements layoutTestController.overridePreference()
This change provides the infrastructure for
layoutTestController.overridePreference(). Currently, we only provide an
implementation for the preference 'WebKitOfflineWebApplicationCacheEnabled',
which is required by the layout test http/tests/appcache/disabled.html.
Change-Id: I8552f2f4e23b982db2d067ffa20c052e56d8fb7f
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
index 9a6fc27..5780c43 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
@@ -73,6 +73,7 @@
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;
CallbackProxy(EventSender eventSender,
LayoutTestController layoutTestController) {
@@ -266,6 +267,12 @@
mLayoutTestController.setGeolocationPermission(
msg.arg1 == 1 ? true : false);
break;
+
+ case OVERRIDE_PREFERENCE:
+ String key = msg.getData().getString("key");
+ boolean value = msg.getData().getBoolean("value");
+ mLayoutTestController.overridePreference(key, value);
+ break;
}
}
@@ -484,4 +491,11 @@
public void setGeolocationPermission(boolean allow) {
obtainMessage(SET_GEOLOCATION_PERMISSION, allow ? 1 : 0, 0).sendToTarget();
}
+
+ public void overridePreference(String key, boolean value) {
+ Message message = obtainMessage(OVERRIDE_PREFERENCE);
+ message.getData().putString("key", key);
+ message.getData().putBoolean("value", value);
+ message.sendToTarget();
+ }
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
index b33f2a4..d10e382 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
@@ -83,7 +83,6 @@
// should pass all tests. They are skipped only temporarily.
// TODO: Fix these failing tests and remove them from this list.
ignoreResultList.add("http/tests/appcache/auth.html"); // DumpRenderTree throws exception when authentication fails
- ignoreResultList.add("http/tests/appcache/disabled.html"); // Missing layoutTestController.overridePreference
ignoreResultList.add("http/tests/appcache/empty-manifest.html"); // flaky
ignoreResultList.add("http/tests/appcache/foreign-iframe-main.html"); // flaky - skips states
ignoreResultList.add("http/tests/appcache/manifest-with-empty-file.html"); // flaky
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
index f535ed7..9236345 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
@@ -65,4 +65,6 @@
// For Geolocation tests
public void setGeolocationPermission(boolean allow);
+
+ public void overridePreference(String key, boolean value);
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index 02a7046..24f58b2 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -61,6 +61,9 @@
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";
+
public class AsyncHandler extends Handler {
@Override
public void handleMessage(Message msg) {
@@ -459,6 +462,16 @@
mGeolocationPermission = allow;
}
+ 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 (key.equals(WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED)) {
+ mWebView.getSettings().setAppCacheEnabled(value);
+ }
+ }
+
private final WebViewClient mViewClient = new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {