Added geolocation layoutTestController functions.
Change-Id: Ie9558e873ff589b9e2358623433838f0718ea3b4
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.dumprendertree2;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.webkit.MockGeolocation;
|
||||
import android.webkit.WebStorage;
|
||||
|
||||
import java.io.File;
|
||||
@@ -73,4 +74,19 @@ public class LayoutTestController {
|
||||
WebStorage.getInstance().setQuotaForOrigin(Uri.fromFile(new File("")).toString(),
|
||||
quota);
|
||||
}
|
||||
|
||||
public void setGeolocationPermission(boolean allow) {
|
||||
mLayoutTestsExecutor.setGeolocationPermission(allow);
|
||||
}
|
||||
|
||||
public void setMockGeolocationPosition(double latitude, double longitude, double accuracy) {
|
||||
Log.w(LOG_TAG + "::setMockGeolocationPosition", "latitude: " + latitude +
|
||||
" longitude: " + longitude + " accuracy: " + accuracy);
|
||||
MockGeolocation.getInstance().setPosition(latitude, longitude, accuracy);
|
||||
}
|
||||
|
||||
public void setMockGeolocationError(int code, String message) {
|
||||
Log.w(LOG_TAG + "::setMockGeolocationError", "code: " + code + " message: " + message);
|
||||
MockGeolocation.getInstance().setError(code, message);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.webkit.GeolocationPermissions.Callback;
|
||||
import android.webkit.WebStorage.QuotaUpdater;
|
||||
|
||||
import java.io.File;
|
||||
@@ -104,6 +105,8 @@ public class LayoutTestsExecutor extends Activity {
|
||||
private LayoutTestController mLayoutTestController = new LayoutTestController(this);
|
||||
private boolean mCanOpenWindows;
|
||||
private boolean mDumpDatabaseCallbacks;
|
||||
private boolean mSetGeolocationPermissionCalled;
|
||||
private boolean mGeolocationPermission;
|
||||
|
||||
private WakeLock mScreenDimLock;
|
||||
|
||||
@@ -221,6 +224,13 @@ public class LayoutTestsExecutor extends Activity {
|
||||
resultMsg.sendToTarget();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
|
||||
if (mSetGeolocationPermissionCalled) {
|
||||
callback.invoke(origin, mGeolocationPermission, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** IMPLEMENTATION */
|
||||
@@ -420,6 +430,7 @@ 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_PREMISSION = 6;
|
||||
|
||||
Handler mLayoutTestControllerHandler = new Handler() {
|
||||
@Override
|
||||
@@ -468,6 +479,11 @@ public class LayoutTestsExecutor extends Activity {
|
||||
mDumpDatabaseCallbacks = true;
|
||||
break;
|
||||
|
||||
case MSG_SET_GEOLOCATION_PREMISSION:
|
||||
mSetGeolocationPermissionCalled = true;
|
||||
mGeolocationPermission = msg.arg1 == 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.w(LOG_TAG + "::handleMessage", "Message code does not exist: " + msg.what);
|
||||
break;
|
||||
@@ -478,6 +494,8 @@ public class LayoutTestsExecutor extends Activity {
|
||||
private void resetLayoutTestController() {
|
||||
mCanOpenWindows = false;
|
||||
mDumpDatabaseCallbacks = false;
|
||||
mSetGeolocationPermissionCalled = false;
|
||||
mGeolocationPermission = false;
|
||||
}
|
||||
|
||||
public void waitUntilDone() {
|
||||
@@ -513,4 +531,11 @@ public class LayoutTestsExecutor extends Activity {
|
||||
Log.w(LOG_TAG + "::dumpDatabaseCallbacks:", "called");
|
||||
mLayoutTestControllerHandler.sendEmptyMessage(MSG_DUMP_DATABASE_CALLBACKS);
|
||||
}
|
||||
|
||||
public void setGeolocationPermission(boolean allow) {
|
||||
Log.w(LOG_TAG + "::setGeolocationPermission", "called");
|
||||
Message msg = mLayoutTestControllerHandler.obtainMessage(MSG_SET_GEOLOCATION_PREMISSION);
|
||||
msg.arg1 = allow ? 1 : 0;
|
||||
msg.sendToTarget();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user