Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e689a74 authored by Maksymilian Osowski's avatar Maksymilian Osowski
Browse files

Added overridePreference() layoutTestsController function.

Change-Id: I99fbf7490c3c6eb063bf5ed0bbd2bced0f10a967
parent c54df24f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ public class LayoutTestController {
        mLayoutTestsExecutor.setGeolocationPermission(allow);
    }

    public void overridePreference(String key, boolean value) {
        mLayoutTestsExecutor.overridePreference(key, value);
    }

    public void setMockGeolocationPosition(double latitude, double longitude, double accuracy) {
        Log.i(LOG_TAG, "setMockGeolocationPosition(): " + "latitude=" + latitude +
                " longitude=" + longitude + " accuracy=" + accuracy);
+30 −0
Original line number Diff line number Diff line
@@ -507,6 +507,11 @@ public class LayoutTestsExecutor extends Activity {
    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;

    /** String constants for use with layoutTestController.overridePreference() */
    private final String WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED =
            "WebKitOfflineWebApplicationCacheEnabled";

    Handler mLayoutTestControllerHandler = new Handler() {
        @Override
@@ -570,6 +575,22 @@ public class LayoutTestsExecutor extends Activity {
                    }
                    break;

                case MSG_OVERRIDE_PREFERENCE:
                    /**
                     * 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 (msg.getData().getString("key").equals(
                            WEBKIT_OFFLINE_WEB_APPLICATION_CACHE_ENABLED)) {
                        mCurrentWebView.getSettings().setAppCacheEnabled(msg.getData().getBoolean(
                                "value"));
                    } else {
                        Log.w(LOG_TAG, "MSG_OVERRIDE_PREFERENCE: unsupported preference!");
                    }
                    break;

                default:
                    assert false : "msg.what=" + msg.what;
                    break;
@@ -626,6 +647,15 @@ public class LayoutTestsExecutor extends Activity {
        msg.sendToTarget();
    }

    public void overridePreference(String key, boolean value) {
        Log.i(LOG_TAG, mCurrentTestRelativePath + ": overridePreference(" + key + ", " + value +
        ") called");
        Message msg = mLayoutTestControllerHandler.obtainMessage(MSG_OVERRIDE_PREFERENCE);
        msg.getData().putString("key", key);
        msg.getData().putBoolean("value", value);
        msg.sendToTarget();
    }

    public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
            boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) {
        Log.i(LOG_TAG, mCurrentTestRelativePath + ": setMockDeviceOrientation(" + canProvideAlpha +