summaryrefslogtreecommitdiffstats
path: root/tests/DumpRenderTree
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-08-19 18:46:34 +0100
committerSteve Block <steveblock@google.com>2009-08-19 22:52:25 +0100
commitdad347c8b83aeb49eafae68774b7bfb59c956977 (patch)
treeb7ce449b83e8f13949561e6c3c8f6d07a3724626 /tests/DumpRenderTree
parent77035a31dda76200b4096db49cb58a169ab54b2c (diff)
downloadframeworks_base-dad347c8b83aeb49eafae68774b7bfb59c956977.zip
frameworks_base-dad347c8b83aeb49eafae68774b7bfb59c956977.tar.gz
frameworks_base-dad347c8b83aeb49eafae68774b7bfb59c956977.tar.bz2
Adds the ability to set Geolocation permissions from DumpRenderTree on Android.
Diffstat (limited to 'tests/DumpRenderTree')
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java10
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java3
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java24
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
index b61b307..f33b01d 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java
@@ -61,6 +61,7 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
private static final int LAYOUT_WAIT_UNTIL_DONE = 40;
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;
CallbackProxy(EventSender eventSender,
LayoutTestController layoutTestController) {
@@ -202,6 +203,11 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
case LAYOUT_SET_CAN_OPEN_WINDOWS:
mLayoutTestController.setCanOpenWindows();
break;
+
+ case SET_GEOLOCATION_PERMISSION:
+ mLayoutTestController.setGeolocationPermission(
+ msg.arg1 == 1 ? true : false);
+ break;
}
}
@@ -364,4 +370,8 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
public void setMockGeolocationError(int code, String message) {
MockGeolocation.getInstance().setError(code, message);
}
+
+ public void setGeolocationPermission(boolean allow) {
+ obtainMessage(SET_GEOLOCATION_PERMISSION, allow ? 1 : 0, 0).sendToTarget();
+ }
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
index e1d802a..f535ed7 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestController.java
@@ -62,4 +62,7 @@ public interface LayoutTestController {
// For storage tests
public void dumpDatabaseCallbacks();
public void setCanOpenWindows();
+
+ // For Geolocation tests
+ public void setGeolocationPermission(boolean allow);
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index e060388..96b34b3 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -28,6 +28,7 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ViewGroup;
+import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
@@ -425,6 +426,14 @@ public class TestShellActivity extends Activity implements LayoutTestController
mCanOpenWindows = true;
}
+ /**
+ * Sets the Geolocation permission state to be used for all future requests.
+ */
+ public void setGeolocationPermission(boolean allow) {
+ mGeolocationPermissionSet = true;
+ mGeolocationPermission = allow;
+ }
+
private final WebViewClient mViewClient = new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
@@ -575,6 +584,18 @@ public class TestShellActivity extends Activity implements LayoutTestController
callback.updateQuota(currentQuota + 1024 * 1024 * 5);
}
+ /**
+ * Instructs the client to show a prompt to ask the user to set the
+ * Geolocation permission state for the specified origin.
+ */
+ @Override
+ public void onGeolocationPermissionsShowPrompt(String origin,
+ GeolocationPermissions.Callback callback) {
+ if (mGeolocationPermissionSet) {
+ callback.invoke(origin, mGeolocationPermission, false);
+ }
+ }
+
@Override
public void addMessageToConsole(String message, int lineNumber,
String sourceID) {
@@ -687,4 +708,7 @@ public class TestShellActivity extends Activity implements LayoutTestController
static final String RESULT_FILE = "ResultFile";
static final String TIMEOUT_IN_MILLIS = "TimeoutInMillis";
static final String UI_AUTO_TEST = "UiAutoTest";
+
+ private boolean mGeolocationPermissionSet;
+ private boolean mGeolocationPermission;
}