Merge "resolved conflicts for merge of 2d9b17c1 to master"
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
index a0b4fa6..ead235e 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
@@ -42,13 +42,19 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
+ WebView webview = getActivity().getWebView();
+ if (webview != null) {
+ mOnUiThread = new WebViewOnUiThread(this, webview);
- mCookieManager = CookieManager.getInstance();
- assertNotNull(mCookieManager);
+ mCookieManager = CookieManager.getInstance();
+ assertNotNull(mCookieManager);
+ }
}
public void testGetInstance() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.cleanUp();
CookieManager c1 = CookieManager.getInstance();
CookieManager c2 = CookieManager.getInstance();
@@ -57,9 +63,15 @@
}
public void testClone() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
}
public void testAcceptCookie() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mCookieManager.removeAllCookie();
mCookieManager.setAcceptCookie(false);
assertFalse(mCookieManager.acceptCookie());
@@ -113,6 +125,9 @@
}
public void testCookieManager() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// enable cookie
mCookieManager.setAcceptCookie(true);
assertTrue(mCookieManager.acceptCookie());
@@ -146,6 +161,9 @@
@SuppressWarnings("deprecation")
public void testRemoveCookies() throws InterruptedException {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// enable cookie
mCookieManager.setAcceptCookie(true);
assertTrue(mCookieManager.acceptCookie());
@@ -212,6 +230,9 @@
}
public void testb3167208() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
String uri = "http://host.android.com/path/";
// note the space after the domain=
String problemCookie = "foo=bar; domain= .android.com; path=/";
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
index 67a77e7..e2112b7 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
@@ -33,6 +33,9 @@
}
public void testCookieSyncManager() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
CookieSyncManager csm1 = CookieSyncManager.createInstance(getActivity());
assertNotNull(csm1);
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieTest.java
index 0c0396a..704ae24 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieTest.java
@@ -16,22 +16,30 @@
package android.webkit.cts;
-import android.test.AndroidTestCase;
+import android.test.ActivityInstrumentationTestCase2;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
/**
* Original framework tests for CookieManager
*/
-public class CookieTest extends AndroidTestCase {
+public class CookieTest extends ActivityInstrumentationTestCase2<CookieSyncManagerStubActivity> {
private CookieManager mCookieManager;
private static final long WAIT_TIME = 50;
+ public CookieTest() {
+ super("com.android.cts.stub", CookieSyncManagerStubActivity.class);
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
- CookieSyncManager.createInstance(getContext());
+
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
mCookieManager = CookieManager.getInstance();
mCookieManager.removeAllCookie();
// cookies are removed asynchronously, wait a bit for cookies to be removed
@@ -48,6 +56,9 @@
}
public void testDomain() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
String url = "http://www.foo.com";
// basic
@@ -86,6 +97,9 @@
}
public void testSubDomain() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
String url_abcd = "http://a.b.c.d.com";
String url_bcd = "http://b.c.d.com";
String url_cd = "http://c.d.com";
@@ -127,6 +141,9 @@
}
public void testInvalidDomain() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
String url = "http://foo.bar.com";
mCookieManager.setCookie(url, "a=1; domain=.yo.foo.bar.com");
@@ -163,6 +180,9 @@
}
public void testPath() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
String url = "http://www.foo.com";
mCookieManager.setCookie(url, "a=b; path=/wee");
@@ -192,6 +212,9 @@
}
public void testEmptyValue() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
String url = "http://www.foobar.com";
mCookieManager.setCookie(url, "bar=");
diff --git a/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java b/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java
index 016d7c2..8ab9eb6 100644
--- a/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java
@@ -135,49 +135,58 @@
protected void setUp() throws Exception {
super.setUp();
- // Set up a WebView with JavaScript and Geolocation enabled
- final String GEO_DIR = "geo_test";
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
- mOnUiThread.getSettings().setJavaScriptEnabled(true);
- mOnUiThread.getSettings().setGeolocationEnabled(true);
- mOnUiThread.getSettings().setGeolocationDatabasePath(
- getActivity().getApplicationContext().getDir(GEO_DIR, 0).getPath());
+ WebView webview = getActivity().getWebView();
- // Add a JsInterface to report back to the test when a location is received
- mJavascriptStatusReceiver = new JavascriptStatusReceiver();
- mOnUiThread.addJavascriptInterface(mJavascriptStatusReceiver, JS_INTERFACE_NAME);
+ if (webview != null) {
+ // Set up a WebView with JavaScript and Geolocation enabled
+ final String GEO_DIR = "geo_test";
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ mOnUiThread.getSettings().setJavaScriptEnabled(true);
+ mOnUiThread.getSettings().setGeolocationEnabled(true);
+ mOnUiThread.getSettings().setGeolocationDatabasePath(
+ getActivity().getApplicationContext().getDir(GEO_DIR, 0).getPath());
- // Always intercept all loads with the same geolocation test page
- mOnUiThread.setWebViewClient(new InterceptClient(mOnUiThread));
- // Clear all permissions before each test
- GeolocationPermissions.getInstance().clearAll();
- // Cache this mostly because the lookup is two lines of code
- mLocationManager = (LocationManager)getActivity().getApplicationContext()
- .getSystemService(Context.LOCATION_SERVICE);
- // Add a test provider before each test to inject a location
- mProviders = mLocationManager.getAllProviders();
- for (String provider : mProviders) {
- // Can't mock passive provider.
- if (provider.equals(LocationManager.PASSIVE_PROVIDER)) {
- mProviders.remove(provider);
- break;
+ // Add a JsInterface to report back to the test when a location is received
+ mJavascriptStatusReceiver = new JavascriptStatusReceiver();
+ mOnUiThread.addJavascriptInterface(mJavascriptStatusReceiver, JS_INTERFACE_NAME);
+
+ // Always intercept all loads with the same geolocation test page
+ mOnUiThread.setWebViewClient(new InterceptClient(mOnUiThread));
+ // Clear all permissions before each test
+ GeolocationPermissions.getInstance().clearAll();
+ // Cache this mostly because the lookup is two lines of code
+ mLocationManager = (LocationManager)getActivity().getApplicationContext()
+ .getSystemService(Context.LOCATION_SERVICE);
+ // Add a test provider before each test to inject a location
+ mProviders = mLocationManager.getAllProviders();
+ for (String provider : mProviders) {
+ // Can't mock passive provider.
+ if (provider.equals(LocationManager.PASSIVE_PROVIDER)) {
+ mProviders.remove(provider);
+ break;
+ }
}
+ addTestProviders();
}
- addTestProviders();
}
@Override
protected void tearDown() throws Exception {
stopUpdateLocationThread();
- // Remove the test provider after each test
- for (String provider : mProviders) {
- try {
- // Work around b/11446702 by clearing the test provider before removing it
- mLocationManager.clearTestProviderEnabled(provider);
- mLocationManager.removeTestProvider(provider);
- } catch (IllegalArgumentException e) {} // Not much to do about this
+ if (mProviders != null) {
+ // Remove the test provider after each test
+ for (String provider : mProviders) {
+ try {
+ // Work around b/11446702 by clearing the test provider before removing it
+ mLocationManager.clearTestProviderEnabled(provider);
+ mLocationManager.removeTestProvider(provider);
+ } catch (IllegalArgumentException e) {} // Not much to do about this
+ }
}
- mOnUiThread.cleanUp();
+
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
// This will null all member and static variables
super.tearDown();
}
@@ -278,6 +287,9 @@
// Test loading a page and accepting the domain for one load
public void testSimpleGeolocationRequestAcceptOnce() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final TestSimpleGeolocationRequestWebChromeClient chromeClientAcceptOnce =
new TestSimpleGeolocationRequestWebChromeClient(mOnUiThread, true, false);
mOnUiThread.setWebChromeClient(chromeClientAcceptOnce);
@@ -368,6 +380,9 @@
// Test loading a page and retaining the domain forever
public void testSimpleGeolocationRequestAcceptAlways() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final TestSimpleGeolocationRequestWebChromeClient chromeClientAcceptAlways =
new TestSimpleGeolocationRequestWebChromeClient(mOnUiThread, true, true);
mOnUiThread.setWebChromeClient(chromeClientAcceptAlways);
@@ -424,6 +439,9 @@
// Test the GeolocationPermissions API
public void testGeolocationPermissions() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
Set<String> acceptedOrigins = new TreeSet<String>();
BooleanCheck falseCheck = new BooleanCheck(false);
GeolocationPermissions.getInstance().getAllowed(URL_2, falseCheck);
@@ -483,6 +501,9 @@
// Test loading pages and checks rejecting once and recjecting the domain forever
public void testSimpleGeolocationRequestReject() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final TestSimpleGeolocationRequestWebChromeClient chromeClientRejectOnce =
new TestSimpleGeolocationRequestWebChromeClient(mOnUiThread, false, false);
mOnUiThread.setWebChromeClient(chromeClientRejectOnce);
diff --git a/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java b/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java
index 52e9278..b078c7a 100644
--- a/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java
@@ -43,12 +43,18 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
+ WebView webview = getActivity().getWebView();
+ if (webview != null) {
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ }
}
@Override
protected void tearDown() throws Exception {
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
+
if (mWebServer != null) {
mWebServer.shutdown();
}
@@ -138,6 +144,9 @@
}
public void testProceed() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mWebServer = new CtsTestServer(getActivity());
String url = mWebServer.getAuthAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
@@ -147,6 +156,9 @@
}
public void testCancel() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mWebServer = new CtsTestServer(getActivity());
String url = mWebServer.getAuthAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
@@ -159,6 +171,9 @@
}
public void testUseHttpAuthUsernamePassword() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mWebServer = new CtsTestServer(getActivity());
String url = mWebServer.getAuthAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java b/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java
index 34dc697..71893f4 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java
@@ -20,6 +20,7 @@
import android.test.ActivityInstrumentationTestCase2;
import android.webkit.WebBackForwardList;
import android.webkit.WebHistoryItem;
+import android.webkit.WebView;
public class WebBackForwardListTest extends ActivityInstrumentationTestCase2<WebViewStubActivity> {
@@ -35,16 +36,24 @@
@Override
public void setUp() throws Exception {
super.setUp();
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
+ WebView webview = getActivity().getWebView();
+ if (webview != null) {
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ }
}
@Override
public void tearDown() throws Exception {
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
super.tearDown();
}
public void testGetCurrentItem() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebBackForwardList list = mOnUiThread.copyBackForwardList();
assertNull(list.getCurrentItem());
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index 344b568..fca14e2 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -44,13 +44,18 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
+ WebView webview = getActivity().getWebView();
+ if (webview != null) {
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ }
mWebServer = new CtsTestServer(getActivity());
}
@Override
protected void tearDown() throws Exception {
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
if (mWebServer != null) {
mWebServer.shutdown();
}
@@ -62,6 +67,9 @@
}
public void testOnProgressChanged() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -78,6 +86,9 @@
}
public void testOnReceivedTitle() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -96,6 +107,9 @@
}
public void testOnReceivedIcon() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -161,20 +175,32 @@
}
}
public void testWindows() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
runWindowTest(true);
}
public void testBlockWindowsSync() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mBlockWindowCreationSync = true;
runWindowTest(false);
}
public void testBlockWindowsAsync() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mBlockWindowCreationAsync = true;
runWindowTest(false);
}
public void testOnJsBeforeUnload() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -198,6 +224,9 @@
}
public void testOnJsAlert() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -220,6 +249,9 @@
}
public void testOnJsConfirm() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -242,6 +274,9 @@
}
public void testOnJsPrompt() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
index 468430f..7d276e9 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
@@ -54,12 +54,17 @@
protected void setUp() throws Exception {
super.setUp();
mWebServer = new CtsTestServer(getActivity());
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
+ WebView webview = getActivity().getWebView();
+ if (webview != null) {
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ }
}
@Override
protected void tearDown() throws Exception {
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
mWebServer.shutdown();
super.tearDown();
if (mIconDb != null) {
@@ -69,6 +74,9 @@
}
public void testWebHistoryItem() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final WaitForIconClient waitForIconClient = new WaitForIconClient(mOnUiThread);
mOnUiThread.setWebChromeClient(waitForIconClient);
runTestOnUiThread(new Runnable() {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index 291136f..c2104fe 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -65,8 +65,11 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mOnUiThread = new WebViewOnUiThread(this, getActivity().getWebView());
- mSettings = mOnUiThread.getSettings();
+ WebView webview = getActivity().getWebView();
+ if (webview != null) {
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ mSettings = mOnUiThread.getSettings();
+ }
mContext = getInstrumentation().getTargetContext();
}
@@ -75,7 +78,9 @@
if (mWebServer != null) {
mWebServer.shutdown();
}
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
super.tearDown();
}
@@ -90,6 +95,9 @@
* Safari/<major>.<minor>
*/
public void testUserAgentString_default() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final String actualUserAgentString = mSettings.getUserAgentString();
Log.i(LOG_TAG, String.format("Checking user agent string %s", actualUserAgentString));
final String patternString =
@@ -131,6 +139,9 @@
}
public void testAccessUserAgentString() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
startWebServer();
String url = mWebServer.getUserAgentUrl();
@@ -159,6 +170,9 @@
}
public void testAccessAllowFileAccess() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// This test is not compatible with 4.0.3
if ("4.0.3".equals(Build.VERSION.RELEASE)) {
return;
@@ -184,6 +198,9 @@
}
public void testAccessCacheMode() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
runTestOnUiThread(new Runnable() {
@Override
public void run() {
@@ -256,6 +273,9 @@
}
public void testAccessCursiveFontFamily() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getCursiveFontFamily());
String newCusiveFamily = "Apple Chancery";
@@ -264,6 +284,9 @@
}
public void testAccessFantasyFontFamily() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getFantasyFontFamily());
String newFantasyFamily = "Papyrus";
@@ -272,6 +295,9 @@
}
public void testAccessFixedFontFamily() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getFixedFontFamily());
String newFixedFamily = "Courier";
@@ -280,6 +306,9 @@
}
public void testAccessSansSerifFontFamily() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getSansSerifFontFamily());
String newFixedFamily = "Verdana";
@@ -288,6 +317,9 @@
}
public void testAccessSerifFontFamily() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getSerifFontFamily());
String newSerifFamily = "Times";
@@ -296,6 +328,9 @@
}
public void testAccessStandardFontFamily() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getStandardFontFamily());
String newStandardFamily = "Times";
@@ -304,6 +339,9 @@
}
public void testAccessDefaultFontSize() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
int defaultSize = mSettings.getDefaultFontSize();
assertTrue(defaultSize > 0);
@@ -322,6 +360,9 @@
}
public void testAccessDefaultFixedFontSize() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
int defaultSize = mSettings.getDefaultFixedFontSize();
assertTrue(defaultSize > 0);
@@ -340,6 +381,9 @@
}
public void testAccessDefaultTextEncodingName() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getDefaultTextEncodingName());
String newEncodingName = "iso-8859-1";
@@ -348,6 +392,9 @@
}
public void testAccessJavaScriptCanOpenWindowsAutomatically() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setJavaScriptEnabled(true);
mSettings.setJavaScriptCanOpenWindowsAutomatically(false);
@@ -372,6 +419,9 @@
}
public void testAccessJavaScriptEnabled() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setJavaScriptEnabled(true);
assertTrue(mSettings.getJavaScriptEnabled());
loadAssetUrl(TestHtmlConstants.JAVASCRIPT_URL);
@@ -395,6 +445,9 @@
}
public void testAccessLayoutAlgorithm() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertEquals(WebSettings.LayoutAlgorithm.NARROW_COLUMNS, mSettings.getLayoutAlgorithm());
mSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
@@ -405,6 +458,9 @@
}
public void testAccessMinimumFontSize() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertEquals(8, mSettings.getMinimumFontSize());
mSettings.setMinimumFontSize(100);
@@ -418,6 +474,9 @@
}
public void testAccessMinimumLogicalFontSize() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertEquals(8, mSettings.getMinimumLogicalFontSize());
mSettings.setMinimumLogicalFontSize(100);
@@ -431,6 +490,9 @@
}
public void testAccessPluginsEnabled() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.getPluginsEnabled());
mSettings.setPluginsEnabled(true);
@@ -438,6 +500,9 @@
}
public void testAccessPluginsPath() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(mSettings.getPluginsPath());
String pluginPath = "pluginPath";
@@ -447,6 +512,9 @@
}
public void testAccessSaveFormData() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertTrue(mSettings.getSaveFormData());
mSettings.setSaveFormData(false);
@@ -454,6 +522,9 @@
}
public void testAccessTextSize() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertEquals(TextSize.NORMAL, mSettings.getTextSize());
mSettings.setTextSize(TextSize.LARGER);
@@ -470,6 +541,9 @@
}
public void testAccessUseDoubleTree() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.getUseDoubleTree());
mSettings.setUseDoubleTree(true);
@@ -478,6 +552,9 @@
}
public void testAccessUseWideViewPort() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.getUseWideViewPort());
mSettings.setUseWideViewPort(true);
@@ -485,12 +562,18 @@
}
public void testSetNeedInitialFocus() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setNeedInitialFocus(false);
mSettings.setNeedInitialFocus(true);
}
public void testSetRenderPriority() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
mSettings.setRenderPriority(WebSettings.RenderPriority.LOW);
@@ -499,6 +582,9 @@
}
public void testAccessSupportMultipleWindows() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.supportMultipleWindows());
mSettings.setSupportMultipleWindows(true);
@@ -506,6 +592,9 @@
}
public void testAccessSupportZoom() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertTrue(mSettings.supportZoom());
runTestOnUiThread(new Runnable() {
@@ -518,6 +607,9 @@
}
public void testAccessBuiltInZoomControls() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.getBuiltInZoomControls());
runTestOnUiThread(new Runnable() {
@@ -530,6 +622,9 @@
}
public void testAppCacheDisabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Test that when AppCache is disabled, we don't get any AppCache
// callbacks.
startWebServer();
@@ -549,6 +644,9 @@
}
public void testAppCacheEnabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Note that the AppCache path can only be set once. This limits the
// amount of testing we can do, and means that we must test all aspects
// of setting the AppCache path in a single test to guarantee ordering.
@@ -594,6 +692,9 @@
// using a URL. Finally, it looks like enabling database requires creating a
// webChromeClient and listening to Quota callbacks, which is not documented.
public void testDatabaseDisabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Verify that websql database does not work when disabled.
startWebServer();
@@ -612,6 +713,9 @@
}
public void testLoadsImagesAutomatically() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertTrue(mSettings.getLoadsImagesAutomatically());
startWebServer();
@@ -644,6 +748,9 @@
}
public void testBlockNetworkImage() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.getBlockNetworkImage());
startWebServer();
@@ -673,6 +780,9 @@
}
public void testBlockNetworkLoads() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertFalse(mSettings.getBlockNetworkLoads());
startWebServer();
@@ -709,6 +819,9 @@
// Verify that an image in local file system can be loaded by an asset
public void testLocalImageLoads() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setJavaScriptEnabled(true);
// Check that local images are loaded without issues regardless of domain checkings
@@ -723,6 +836,9 @@
// Verify that javascript cross-domain request permissions matches file domain settings
// for iframes
public void testIframesWhenAccessFromFileURLsEnabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setJavaScriptEnabled(true);
// disable universal access from files
@@ -739,6 +855,9 @@
// Verify that javascript cross-domain request permissions matches file domain settings
// for iframes
public void testIframesWhenAccessFromFileURLsDisabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mSettings.setJavaScriptEnabled(true);
// disable universal access from files
@@ -757,11 +876,17 @@
// Verify that enabling file access from file URLs enable XmlHttpRequest (XHR) across files
public void testXHRWhenAccessFromFileURLsEnabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
verifyFileXHR(true);
}
// Verify that disabling file access from file URLs disable XmlHttpRequest (XHR) accross files
public void testXHRWhenAccessFromFileURLsDisabled() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final ChromeClient webChromeClient = new ChromeClient(mOnUiThread);
mOnUiThread.setWebChromeClient(webChromeClient);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 9aca8c7..5907d2f 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -47,18 +47,24 @@
protected void setUp() throws Exception {
super.setUp();
final WebViewStubActivity activity = getActivity();
- new PollingCheck(TEST_TIMEOUT) {
- @Override
- protected boolean check() {
- return activity.hasWindowFocus();
- }
- }.run();
- mOnUiThread = new WebViewOnUiThread(this, activity.getWebView());
+ WebView webview = activity.getWebView();
+ if (webview != null) {
+ new PollingCheck(TEST_TIMEOUT) {
+ @Override
+ protected boolean check() {
+ return activity.hasWindowFocus();
+ }
+ }.run();
+
+ mOnUiThread = new WebViewOnUiThread(this, webview);
+ }
}
@Override
protected void tearDown() throws Exception {
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
if (mWebServer != null) {
mWebServer.shutdown();
}
@@ -67,12 +73,18 @@
// Verify that the shouldoverrideurlloading is false by default
public void testShouldOverrideUrlLoadingDefault() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final WebViewClient webViewClient = new WebViewClient();
assertFalse(webViewClient.shouldOverrideUrlLoading(mOnUiThread.getWebView(), null));
}
// Verify shouldoverrideurlloading called on top level navigation
public void testShouldOverrideUrlLoading() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
mOnUiThread.getSettings().setJavaScriptEnabled(true);
@@ -87,6 +99,9 @@
// Verify shouldoverrideurlloading called on webview called via onCreateWindow
// TODO(sgurun) upstream this test to Aw.
public void testShouldOverrideUrlLoadingOnCreateWindow() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mWebServer = new CtsTestServer(getActivity());
// WebViewClient for main window
final MockWebViewClient mainWebViewClient = new MockWebViewClient();
@@ -152,6 +167,9 @@
}
public void testLoadPage() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
mWebServer = new CtsTestServer(getActivity());
@@ -185,6 +203,9 @@
}
public void testOnReceivedError() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
@@ -196,6 +217,9 @@
}
public void testOnFormResubmission() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
final WebSettings settings = mOnUiThread.getSettings();
@@ -221,6 +245,9 @@
}
public void testDoUpdateVisitedHistory() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
mWebServer = new CtsTestServer(getActivity());
@@ -239,6 +266,9 @@
}
public void testOnReceivedHttpAuthRequest() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
mWebServer = new CtsTestServer(getActivity());
@@ -250,6 +280,9 @@
}
public void testShouldOverrideKeyEvent() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
@@ -257,6 +290,9 @@
}
public void testOnUnhandledKeyEvent() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
requireLoadedPage();
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
@@ -276,6 +312,9 @@
}
public void testOnScaleChanged() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
mWebServer = new CtsTestServer(getActivity());
@@ -301,6 +340,9 @@
}
private void requireLoadedPage() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.loadUrlAndWaitForCompletion("about:blank");
}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewStartupTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewStartupTest.java
index b9cd0af..56f8f61 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewStartupTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewStartupTest.java
@@ -70,7 +70,7 @@
background.start();
background.join();
- if (h.shouldExitTestEarly(mActivity)) {
+ if (!h.isWebViewAvailable(mActivity)) {
return;
}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 4452861..fbefd97 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -131,23 +131,28 @@
protected void setUp() throws Exception {
super.setUp();
final WebViewStubActivity activity = getActivity();
- new PollingCheck() {
- @Override
- protected boolean check() {
- return activity.hasWindowFocus();
- }
- }.run();
mWebView = activity.getWebView();
- File f = activity.getFileStreamPath("snapshot");
- if (f.exists()) {
- f.delete();
+ if (mWebView != null) {
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return activity.hasWindowFocus();
+ }
+ }.run();
+ File f = activity.getFileStreamPath("snapshot");
+ if (f.exists()) {
+ f.delete();
+ }
+
+ mOnUiThread = new WebViewOnUiThread(this, mWebView);
}
- mOnUiThread = new WebViewOnUiThread(this, mWebView);
}
@Override
protected void tearDown() throws Exception {
- mOnUiThread.cleanUp();
+ if (mOnUiThread != null) {
+ mOnUiThread.cleanUp();
+ }
if (mWebServer != null) {
stopWebServer();
}
@@ -178,6 +183,10 @@
@UiThreadTest
public void testConstructor() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
new WebView(getActivity());
new WebView(getActivity(), null);
new WebView(getActivity(), null, 0);
@@ -185,12 +194,19 @@
@UiThreadTest
public void testCreatingWebViewCreatesCookieSyncManager() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
new WebView(getActivity());
assertNotNull(CookieSyncManager.getInstance());
}
@UiThreadTest
public void testFindAddress() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
/*
* Info about USPS
* http://en.wikipedia.org/wiki/Postal_address#United_States
@@ -206,19 +222,25 @@
@SuppressWarnings("deprecation")
@UiThreadTest
public void testGetZoomControls() {
- WebSettings settings = mWebView.getSettings();
- assertTrue(settings.supportZoom());
- View zoomControls = mWebView.getZoomControls();
- assertNotNull(zoomControls);
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+ WebSettings settings = mWebView.getSettings();
+ assertTrue(settings.supportZoom());
+ View zoomControls = mWebView.getZoomControls();
+ assertNotNull(zoomControls);
- // disable zoom support
- settings.setSupportZoom(false);
- assertFalse(settings.supportZoom());
- assertNull(mWebView.getZoomControls());
+ // disable zoom support
+ settings.setSupportZoom(false);
+ assertFalse(settings.supportZoom());
+ assertNull(mWebView.getZoomControls());
}
@UiThreadTest
public void testInvokeZoomPicker() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebSettings settings = mWebView.getSettings();
assertTrue(settings.supportZoom());
startWebServer(false);
@@ -228,6 +250,10 @@
}
public void testZoom() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
// Pinch zoom is not supported in wrap_content layouts.
mOnUiThread.setLayoutHeightToMatchParent();
@@ -314,6 +340,10 @@
@UiThreadTest
public void testSetScrollBarStyle() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
assertFalse(mWebView.overlayHorizontalScrollbar());
assertFalse(mWebView.overlayVerticalScrollbar());
@@ -333,6 +363,10 @@
@UiThreadTest
public void testScrollBarOverlay() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
mWebView.setHorizontalScrollbarOverlay(true);
mWebView.setVerticalScrollbarOverlay(false);
assertTrue(mWebView.overlayHorizontalScrollbar());
@@ -346,6 +380,10 @@
@UiThreadTest
public void testLoadUrl() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
assertNull(mWebView.getUrl());
assertNull(mWebView.getOriginalUrl());
assertEquals(INITIAL_PROGRESS, mWebView.getProgress());
@@ -399,6 +437,10 @@
@UiThreadTest
public void testLoadUrlDoesNotStripParamsWhenLoadingContentUrls() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
Uri.Builder uriBuilder = new Uri.Builder().scheme(
ContentResolver.SCHEME_CONTENT).authority(MockContentProvider.AUTHORITY);
uriBuilder.appendPath("foo.html").appendQueryParameter("param","bar");
@@ -411,6 +453,10 @@
@UiThreadTest
public void testAppInjectedXRequestedWithHeaderIsNotOverwritten() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
startWebServer(false);
String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
HashMap<String, String> map = new HashMap<String, String>();
@@ -430,6 +476,10 @@
@UiThreadTest
public void testAppCanInjectHeadersViaImmutableMap() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
startWebServer(false);
String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
HashMap<String, String> map = new HashMap<String, String>();
@@ -472,6 +522,10 @@
@SuppressWarnings("deprecation")
@UiThreadTest
public void testGetVisibleTitleHeight() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
startWebServer(false);
String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
mOnUiThread.loadUrlAndWaitForCompletion(url);
@@ -480,6 +534,10 @@
@UiThreadTest
public void testGetOriginalUrl() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
startWebServer(false);
final String finalUrl = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
final String redirectUrl =
@@ -500,6 +558,10 @@
}
public void testStopLoading() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
assertEquals(INITIAL_PROGRESS, mOnUiThread.getProgress());
startWebServer(false);
@@ -535,6 +597,10 @@
@UiThreadTest
public void testGoBackAndForward() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
assertGoBackOrForwardBySteps(false, -1);
assertGoBackOrForwardBySteps(false, 1);
@@ -581,6 +647,10 @@
@UiThreadTest
public void testAddJavascriptInterface() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
@@ -651,6 +721,10 @@
@UiThreadTest
public void testAddJavascriptInterfaceNullObject() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
String setTitleToPropertyTypeHtml = "<html><head></head>" +
@@ -683,6 +757,10 @@
@UiThreadTest
public void testRemoveJavascriptInterface() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
String setTitleToPropertyTypeHtml = "<html><head></head>" +
@@ -702,6 +780,10 @@
}
public void testUseRemovedJavascriptInterface() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
class RemovedObject {
@Override
@JavascriptInterface
@@ -846,6 +928,9 @@
}
public void testCapturePicture() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final TestPictureListener listener = new TestPictureListener();
startWebServer(false);
@@ -870,6 +955,9 @@
}
public void testSetPictureListener() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MyPictureListener implements PictureListener {
public int callCount;
public WebView webView;
@@ -913,6 +1001,9 @@
@UiThreadTest
public void testAccessHttpAuthUsernamePassword() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
try {
WebViewDatabase.getInstance(getActivity()).clearHttpAuthUsernamePassword();
@@ -974,6 +1065,9 @@
}
public void testLoadData() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final String HTML_CONTENT =
"<html><head><title>Hello,World!</title></head><body></body>" +
"</html>";
@@ -1002,6 +1096,9 @@
@UiThreadTest
public void testLoadDataWithBaseUrl() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNull(mWebView.getUrl());
String imgUrl = TestHtmlConstants.SMALL_IMG_URL; // relative
// Snippet of HTML that will prevent favicon requests to the test server.
@@ -1087,6 +1184,9 @@
}
public void testFindAll() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Make the page scrollable, so we can detect the scrolling to make sure the
// content fully loaded.
mOnUiThread.setInitialScale(100);
@@ -1111,6 +1211,9 @@
}
public void testFindNext() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Reset the scaling so that finding the next "all" text will require scrolling.
mOnUiThread.setInitialScale(100);
@@ -1167,6 +1270,9 @@
}
public void testDocumentHasImages() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class DocumentHasImageCheckHandler extends Handler {
private boolean mReceived;
private int mMsgArg1;
@@ -1216,6 +1322,9 @@
}
public void testPageScroll() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
DisplayMetrics metrics = mOnUiThread.getDisplayMetrics();
int dimension = 2 * Math.max(metrics.widthPixels, metrics.heightPixels);
String p = "<p style=\"height:" + dimension + "px;\">" +
@@ -1260,6 +1369,9 @@
}
public void testGetContentHeight() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.loadDataAndWaitForCompletion(
"<html><body></body></html>", "text/html", null);
new PollingCheck() {
@@ -1298,12 +1410,18 @@
@UiThreadTest
public void testPlatformNotifications() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebView.enablePlatformNotifications();
WebView.disablePlatformNotifications();
}
@UiThreadTest
public void testAccessPluginList() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
assertNotNull(WebView.getPluginList());
// can not find a way to install plugins
@@ -1312,12 +1430,18 @@
@UiThreadTest
public void testDestroy() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Create a new WebView, since we cannot call destroy() on a view in the hierarchy
WebView localWebView = new WebView(getActivity());
localWebView.destroy();
}
public void testFlingScroll() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
DisplayMetrics metrics = mOnUiThread.getDisplayMetrics();
final int dimension = 10 * Math.max(metrics.widthPixels, metrics.heightPixels);
String p = "<p style=\"height:" + dimension + "px;" +
@@ -1347,6 +1471,9 @@
}
public void testRequestFocusNodeHref() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
startWebServer(false);
String url1 = mWebServer.getAssetUrl(TestHtmlConstants.HTML_URL1);
String url2 = mWebServer.getAssetUrl(TestHtmlConstants.HTML_URL2);
@@ -1414,6 +1541,9 @@
}
public void testRequestImageRef() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class ImageLoaded {
public boolean mImageLoaded;
@@ -1494,10 +1624,16 @@
@UiThreadTest
public void testDebugDump() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mWebView.debugDump();
}
public void testGetHitTestResult() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final String anchor = "<p><a href=\"" + TestHtmlConstants.EXT_WEB_URL1
+ "\">normal anchor</a></p>";
final String blankAnchor = "<p><a href=\"\">blank anchor</a></p>";
@@ -1559,6 +1695,9 @@
}
public void testSetInitialScale() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final String p = "<p style=\"height:1000px;width:1000px\">Test setInitialScale.</p>";
final float defaultScale =
getInstrumentation().getTargetContext().getResources().getDisplayMetrics().density;
@@ -1610,6 +1749,9 @@
@UiThreadTest
public void testClearHistory() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
startWebServer(false);
String url1 = mWebServer.getAssetUrl(TestHtmlConstants.HTML_URL1);
String url2 = mWebServer.getAssetUrl(TestHtmlConstants.HTML_URL2);
@@ -1632,6 +1774,9 @@
@UiThreadTest
public void testSaveAndRestoreState() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// nothing to save
assertNull(mWebView.saveState(new Bundle()));
@@ -1694,6 +1839,9 @@
}
public void testSetWebViewClient() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final ScaleChangedWebViewClient webViewClient = new ScaleChangedWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
startWebServer(false);
@@ -1709,6 +1857,9 @@
@UiThreadTest
public void testInsecureSiteClearsCertificate() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1737,6 +1888,9 @@
@UiThreadTest
public void testSecureSiteSetsCertificate() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1765,6 +1919,9 @@
@UiThreadTest
public void testClearSslPreferences() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Load the first page. We expect a call to
// WebViewClient.onReceivedSslError().
final SslErrorWebViewClient webViewClient = new SslErrorWebViewClient();
@@ -1792,6 +1949,9 @@
}
public void testOnReceivedSslError() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
private String mErrorUrl;
private WebView mWebView;
@@ -1825,6 +1985,9 @@
}
public void testOnReceivedSslErrorProceed() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1843,6 +2006,9 @@
}
public void testOnReceivedSslErrorCancel() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1862,6 +2028,9 @@
}
public void testSslErrorProceedResponseReusedForSameHost() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Load the first page. We expect a call to
// WebViewClient.onReceivedSslError().
final SslErrorWebViewClient webViewClient = new SslErrorWebViewClient();
@@ -1882,6 +2051,9 @@
}
public void testSslErrorProceedResponseNotReusedForDifferentHost() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// Load the first page. We expect a call to
// WebViewClient.onReceivedSslError().
final SslErrorWebViewClient webViewClient = new SslErrorWebViewClient();
@@ -1934,6 +2106,9 @@
}
public void testRequestChildRectangleOnScreen() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
DisplayMetrics metrics = mOnUiThread.getDisplayMetrics();
final int dimension = 2 * Math.max(metrics.widthPixels, metrics.heightPixels);
String p = "<p style=\"height:" + dimension + "px;width:" + dimension + "px\"> </p>";
@@ -1957,6 +2132,10 @@
}
public void testSetDownloadListener() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
final CountDownLatch resultLatch = new CountDownLatch(1);
final class MyDownloadListener implements DownloadListener {
public String url;
@@ -2003,6 +2182,9 @@
@UiThreadTest
public void testSetLayoutParams() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(600, 800);
mWebView.setLayoutParams(params);
assertSame(params, mWebView.getLayoutParams());
@@ -2010,10 +2192,16 @@
@UiThreadTest
public void testSetMapTrackballToArrowKeys() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mWebView.setMapTrackballToArrowKeys(true);
}
public void testSetNetworkAvailable() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebSettings settings = mOnUiThread.getSettings();
settings.setJavaScriptEnabled(true);
startWebServer(false);
@@ -2044,6 +2232,9 @@
}
public void testSetWebChromeClient() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebChromeClient extends WaitForProgressClient {
private boolean mOnProgressChanged = false;
@@ -2081,6 +2272,9 @@
}
public void testPauseResumeTimers() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
class Monitor {
private boolean mIsUpdated;
@@ -2136,6 +2330,9 @@
// verify query parameters can be passed correctly to android asset files
public void testAndroidAssetQueryParam() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebSettings settings = mOnUiThread.getSettings();
settings.setJavaScriptEnabled(true);
@@ -2147,6 +2344,9 @@
// verify anchors work correctly for android asset files
public void testAndroidAssetAnchor() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebSettings settings = mOnUiThread.getSettings();
settings.setJavaScriptEnabled(true);
@@ -2157,6 +2357,9 @@
}
public void testEvaluateJavascript() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.getSettings().setJavaScriptEnabled(true);
mOnUiThread.loadUrlAndWaitForCompletion("about:blank");
@@ -2180,6 +2383,9 @@
// Verify Print feature can create a PDF file with a correct preamble.
public void testPrinting() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.loadDataAndWaitForCompletion("<html><head></head>" +
"<body>foo</body></html>",
"text/html", null);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java b/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java
index dd784be..cb72ef0 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java
@@ -31,6 +31,9 @@
@UiThreadTest
public void testAccessWebView() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebView webView = getActivity().getWebView();
WebViewTransport transport = webView.new WebViewTransport();