CTS Tests to ensure WebDriver#get is blocking.
Bug: 3457555
Change-Id: I59f004ebb125a3e164530ce2358bb6eec02f22f3
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 9e6fae8..ea41723 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -653,6 +653,14 @@
</intent-filter>
</activity>
+ <activity android:name="android.webkit.cts.WebDriverStubActivity"
+ android:label="WebDriverStubActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+ </intent-filter>
+ </activity>
+
<activity android:name="android.app.cts.ChildActivity"
android:label="ChildActivity" />
diff --git a/tests/src/android/webkit/cts/WebDriverStubActivity.java b/tests/src/android/webkit/cts/WebDriverStubActivity.java
new file mode 100644
index 0000000..7ecb664
--- /dev/null
+++ b/tests/src/android/webkit/cts/WebDriverStubActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 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.cts;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.webdriver.WebDriver;
+
+/**
+ * A stub activity for WebDriver tests.
+ */
+public class WebDriverStubActivity extends Activity {
+ private WebDriver mDriver;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ WebView view = new WebView(this);
+
+ WebSettings settings = view.getSettings();
+ settings.setJavaScriptCanOpenWindowsAutomatically(true);
+ settings.setSupportMultipleWindows(true);
+ settings.setBuiltInZoomControls(true);
+ settings.setJavaScriptEnabled(true);
+ settings.setAppCacheEnabled(true);
+ settings.setDatabaseEnabled(true);
+ settings.setDomStorageEnabled(true);
+ settings.setGeolocationEnabled(true);
+ settings.setSaveFormData(true);
+
+ mDriver = new WebDriver(view);
+
+ setContentView(view);
+ }
+
+
+ public WebDriver getDriver() {
+ return mDriver;
+ }
+}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebDriverTest.java b/tests/tests/webkit/src/android/webkit/cts/WebDriverTest.java
new file mode 100644
index 0000000..cd40caf
--- /dev/null
+++ b/tests/tests/webkit/src/android/webkit/cts/WebDriverTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 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.cts;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.webkit.webdriver.WebDriver;
+
+import static android.webkit.cts.TestHtmlConstants.HELLO_WORLD_URL;
+
+/**
+ * Tests for {@link android.webkit.webdriver.WebDriver}.
+ */
+public class WebDriverTest extends
+ ActivityInstrumentationTestCase2<WebDriverStubActivity>{
+ private WebDriver mDriver;
+ private CtsTestServer mWebServer;
+
+ public WebDriverTest() {
+ super(WebDriverStubActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mDriver = getActivity().getDriver();
+ mWebServer = new CtsTestServer(getActivity(), false);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mWebServer.shutdown();
+ super.tearDown();
+ }
+
+ public void testGetIsBlocking() {
+ mDriver.get(mWebServer.getDelayedAssetUrl(HELLO_WORLD_URL));
+ assertTrue(mDriver.getPageSource().contains("hello world!"));
+ }
+}