am a6e6d53b: camera2: Update cts to use Range<Integer> for some keys
* commit 'a6e6d53b82e90de1ff7a5f0849c52f65702816f3':
camera2: Update cts to use Range<Integer> for some keys
diff --git a/tests/res/drawable/vector_icon_clip_path_1.xml b/tests/res/drawable/vector_icon_clip_path_1.xml
new file mode 100644
index 0000000..5b4c4ab
--- /dev/null
+++ b/tests/res/drawable/vector_icon_clip_path_1.xml
@@ -0,0 +1,77 @@
+<!--
+ Copyright (C) 2014 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <size
+ android:height="64dp"
+ android:width="64dp" />
+
+ <viewport
+ android:viewportHeight="12.25"
+ android:viewportWidth="7.30625" />
+
+ <group
+ android:pivotX="3.65"
+ android:pivotY="6.125"
+ android:rotation="-30" >
+ <path
+ android:name="clip1"
+ android:clipToPath="true"
+ android:pathData="
+ M 0, 6.125
+ l 7.3, 0
+ l 0, 12.25
+ l -7.3, 0
+ z" />
+ </group>
+ <group>
+ <path
+ android:name="one"
+ android:fill="#ff88ff"
+ android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125
+ l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
+ l -5.046875,0.0 0.0,-1.0Z" />
+ </group>
+ <group
+ android:pivotX="3.65"
+ android:pivotY="6.125"
+ android:rotation="-30" >
+ <path
+ android:name="clip2"
+ android:clipToPath="true"
+ android:pathData="
+ M 0, 0
+ l 7.3, 0
+ l 0, 6.125
+ l -7.3, 0
+ z" />
+ </group>
+ <group>
+ <path
+ android:name="two"
+ android:fill="#ff88ff"
+ android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375
+ q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625
+ q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625
+ q -0.484375,-0.4375 -1.2656252,-0.4375 -0.5625,0.0 -1.1875,0.1875
+ q -0.609375,0.1875 -1.3125,0.59375l 0.0,-1.203125q 0.71875,-0.28125 1.328125,-0.421875
+ q 0.625,-0.15625 1.140625,-0.15625 1.3593752,0.0 2.1718752,0.6875
+ q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625
+ q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375
+ q -0.78125024,0.8125 -2.2187502,2.265625Z" />
+ </group>
+
+</vector>
\ No newline at end of file
diff --git a/tests/res/drawable/vector_icon_clip_path_1_golden.png b/tests/res/drawable/vector_icon_clip_path_1_golden.png
new file mode 100644
index 0000000..78dddaa
--- /dev/null
+++ b/tests/res/drawable/vector_icon_clip_path_1_golden.png
Binary files differ
diff --git a/tests/res/drawable/vector_icon_transformation_1.xml b/tests/res/drawable/vector_icon_transformation_1.xml
new file mode 100644
index 0000000..116d77e
--- /dev/null
+++ b/tests/res/drawable/vector_icon_transformation_1.xml
@@ -0,0 +1,41 @@
+<!--
+ Copyright (C) 2014 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <size
+ android:height="64dp"
+ android:width="64dp" />
+
+ <viewport
+ android:viewportHeight="500"
+ android:viewportWidth="800" />
+
+ <group
+ android:pivotX="90"
+ android:pivotY="100"
+ android:rotation="20">
+ <path
+ android:name="pie2"
+ android:pathData="M200,350 l 50,-25
+ a25,12 -30 0,1 100,-50 l 50,-25
+ a25,25 -30 0,1 100,-50 l 50,-25
+ a25,37 -30 0,1 100,-50 l 50,-25
+ a25,50 -30 0,1 100,-50 l 50,-25"
+ android:stroke="#FF00FF00"
+ android:strokeWidth="10" />
+ </group>
+
+</vector>
diff --git a/tests/res/drawable/vector_icon_transformation_1_golden.png b/tests/res/drawable/vector_icon_transformation_1_golden.png
new file mode 100644
index 0000000..6f659c3
--- /dev/null
+++ b/tests/res/drawable/vector_icon_transformation_1_golden.png
Binary files differ
diff --git a/tests/src/android/text/EmojiStubActivity.java b/tests/src/android/text/EmojiStubActivity.java
index 1587c94..8d09250 100644
--- a/tests/src/android/text/EmojiStubActivity.java
+++ b/tests/src/android/text/EmojiStubActivity.java
@@ -21,15 +21,20 @@
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
+import android.webkit.cts.NullWebViewUtils;
public class EmojiStubActivity extends Activity {
private WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.webview_layout);
- mWebView = (WebView) findViewById(R.id.web_page);
+ try {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.webview_layout);
+ mWebView = (WebView) findViewById(R.id.web_page);
+ } catch (Exception e) {
+ NullWebViewUtils.determineIfWebViewAvailable(this, e);
+ }
}
public WebView getWebView() {
@@ -38,7 +43,9 @@
@Override
public void onDestroy() {
- mWebView.destroy();
+ if (mWebView != null) {
+ mWebView.destroy();
+ }
super.onDestroy();
}
}
diff --git a/tests/src/android/webkit/cts/CookieSyncManagerStubActivity.java b/tests/src/android/webkit/cts/CookieSyncManagerStubActivity.java
index 3421ac6..a5ac6ec 100644
--- a/tests/src/android/webkit/cts/CookieSyncManagerStubActivity.java
+++ b/tests/src/android/webkit/cts/CookieSyncManagerStubActivity.java
@@ -27,22 +27,35 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- CookieSyncManager.createInstance(this);
- mWebView = new WebView(this);
- setContentView(mWebView);
+ try {
+ CookieSyncManager.createInstance(this);
+
+ mWebView = new WebView(this);
+ setContentView(mWebView);
+ } catch (Exception e) {
+ NullWebViewUtils.determineIfWebViewAvailable(this, e);
+ }
}
@Override
protected void onResume() {
super.onResume();
- CookieSyncManager.getInstance().startSync();
+ try {
+ CookieSyncManager.getInstance().startSync();
+ } catch (Exception e) {
+ // May throw on a device with no webview, OK to ignore at this point.
+ }
}
@Override
protected void onStop() {
super.onStop();
- CookieSyncManager.getInstance().stopSync();
+ try {
+ CookieSyncManager.getInstance().stopSync();
+ } catch (Exception e) {
+ // May throw on a device with no webview, OK to ignore at this point.
+ }
}
public WebView getWebView(){
diff --git a/tests/src/android/webkit/cts/NullWebViewUtils.java b/tests/src/android/webkit/cts/NullWebViewUtils.java
new file mode 100644
index 0000000..c52219f
--- /dev/null
+++ b/tests/src/android/webkit/cts/NullWebViewUtils.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 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.content.Context;
+import android.content.pm.PackageManager;
+
+/**
+ * Utilities to enable the android.webkit.* CTS tests (and others that rely on a functioning
+ * android.webkit.WebView implementation) to determine whether a functioning WebView is present
+ * on the device or not.
+ *
+ * Test cases that require android.webkit.* classes should wrap their first usage of WebView in a
+ * try catch block, and pass any exception that is thrown to
+ * NullWebViewUtils.determineIfWebViewAvailable. The return value of
+ * NullWebViewUtils.isWebViewAvailable will then determine if the test should expect to be able to
+ * use a WebView.
+ */
+public class NullWebViewUtils {
+
+ private static boolean sWebViewUnavailable;
+
+ /**
+ * @param context Current Activity context, used to query the PackageManager.
+ * @param t An exception thrown by trying to invoke android.webkit.* APIs.
+ */
+ public static void determineIfWebViewAvailable(Context context, Throwable t) {
+ sWebViewUnavailable = !hasWebViewFeature(context) && checkCauseWasUnsupportedOperation(t);
+ }
+
+ /**
+ * After calling determineIfWebViewAvailable, this returns whether a WebView is available on the
+ * device and wheter the test can rely on it.
+ * @return True iff. PackageManager determined that there is no WebView on the device and the
+ * exception thrown from android.webkit.* was UnsupportedOperationException.
+ */
+ public static boolean isWebViewAvailable() {
+ return !sWebViewUnavailable;
+ }
+
+ private static boolean hasWebViewFeature(Context context) {
+ // Query the system property that determins if there is a functional WebView on the device.
+ PackageManager pm = context.getPackageManager();
+ return pm.hasSystemFeature(PackageManager.FEATURE_WEBVIEW);
+ }
+
+ private static boolean checkCauseWasUnsupportedOperation(Throwable t) {
+ if (t == null) return false;
+ while (t.getCause() != null) {
+ t = t.getCause();
+ }
+ return t instanceof UnsupportedOperationException;
+ }
+
+ /**
+ * Some CTS tests (by design) first use android.webkit.* from a background thread. This helper
+ * allows the test to catch the UnsupportedOperationException from that background thread, and
+ * then query the result from the test main thread.
+ */
+ public static class NullWebViewFromThreadExceptionHandler
+ implements Thread.UncaughtExceptionHandler {
+ private Throwable mPendingException;
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ mPendingException = e;
+ }
+
+ public boolean isWebViewAvailable(Context context) {
+ return hasWebViewFeature(context) ||
+ !checkCauseWasUnsupportedOperation(mPendingException);
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/src/android/webkit/cts/WebViewStubActivity.java b/tests/src/android/webkit/cts/WebViewStubActivity.java
index 6a51bbe..62adc39 100644
--- a/tests/src/android/webkit/cts/WebViewStubActivity.java
+++ b/tests/src/android/webkit/cts/WebViewStubActivity.java
@@ -29,9 +29,13 @@
@Override
public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.webview_layout);
- mWebView = (WebView) findViewById(R.id.web_page);
+ try {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.webview_layout);
+ mWebView = (WebView) findViewById(R.id.web_page);
+ } catch (Exception e) {
+ NullWebViewUtils.determineIfWebViewAvailable(this, e);
+ }
}
public WebView getWebView() {
@@ -40,11 +44,13 @@
@Override
public void onDestroy() {
- ViewParent parent = mWebView.getParent();
- if (parent instanceof ViewGroup) {
- ((ViewGroup) parent).removeView(mWebView);
+ if (mWebView != null) {
+ ViewParent parent = mWebView.getParent();
+ if (parent instanceof ViewGroup) {
+ ((ViewGroup) parent).removeView(mWebView);
+ }
+ mWebView.destroy();
}
- mWebView.destroy();
super.onDestroy();
}
}
diff --git a/tests/src/android/widget/cts/RemoteViewsStubActivity.java b/tests/src/android/widget/cts/RemoteViewsStubActivity.java
index f1c0a72..f16ae13 100644
--- a/tests/src/android/widget/cts/RemoteViewsStubActivity.java
+++ b/tests/src/android/widget/cts/RemoteViewsStubActivity.java
@@ -20,6 +20,7 @@
import android.app.Activity;
import android.os.Bundle;
+import android.webkit.cts.NullWebViewUtils;
import android.widget.RemoteViews;
/**
@@ -28,7 +29,11 @@
public class RemoteViewsStubActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.remoteviews_host);
+ try {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.remoteviews_host);
+ } catch (Exception e) {
+ NullWebViewUtils.determineIfWebViewAvailable(this, e);
+ }
}
}
diff --git a/tests/tests/accessibilityservice/AndroidManifest.xml b/tests/tests/accessibilityservice/AndroidManifest.xml
index 7c22b96..4039193 100644
--- a/tests/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/tests/accessibilityservice/AndroidManifest.xml
@@ -22,8 +22,6 @@
<uses-sdk android:minSdkVersion="18"
android:targetSdkVersion="18" />
- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-
<application android:theme="@android:style/Theme.Holo.NoActionBar" >
<uses-library android:name="android.test.runner"/>
diff --git a/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml b/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml
index 351ea24..79f87dc 100644
--- a/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml
+++ b/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml
@@ -18,7 +18,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:gravity="center" android:orientation="vertical">
+ android:gravity="center"
+ android:orientation="vertical">
<ListView android:id="@+id/listview"
android:layout_width="fill_parent"
diff --git a/tests/tests/accessibilityservice/res/layout/query_window_test.xml b/tests/tests/accessibilityservice/res/layout/query_window_test.xml
index 88d4cc9..001b024 100644
--- a/tests/tests/accessibilityservice/res/layout/query_window_test.xml
+++ b/tests/tests/accessibilityservice/res/layout/query_window_test.xml
@@ -17,6 +17,7 @@
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/added_content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
index c7e4f4c..c121071 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
@@ -22,12 +22,13 @@
import android.test.ActivityInstrumentationTestCase2;
import android.view.accessibility.AccessibilityEvent;
+import java.util.concurrent.TimeoutException;
+
/**
* Base text case for testing accessibility APIs by instrumenting an Activity.
*/
public abstract class AccessibilityActivityTestCase<T extends Activity>
extends ActivityInstrumentationTestCase2<T> {
-
/**
* Timeout required for pending Binder calls or event processing to
* complete.
@@ -37,7 +38,7 @@
/**
* The timeout since the last accessibility event to consider the device idle.
*/
- public static final long TIMEOUT_ACCESSIBILITY_STATE_IDLE = 200;
+ public static final long TIMEOUT_ACCESSIBILITY_STATE_IDLE = 500;
/**
* @param activityClass
@@ -55,11 +56,20 @@
info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
getInstrumentation().getUiAutomation().setServiceInfo(info);
+ startActivityAndWaitForFirstEvent();
+
+ waitForIdle();
+ }
+
+ /**
+ * Waits for the UI do be idle.
+ *
+ * @throws TimeoutException if idle cannot be detected.
+ */
+ public void waitForIdle() throws TimeoutException {
getInstrumentation().getUiAutomation().waitForIdle(
TIMEOUT_ACCESSIBILITY_STATE_IDLE,
TIMEOUT_ASYNC_PROCESSING);
-
- startActivityAndWaitForFirstEvent();
}
/**
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndActivity.java
index 12bcd96..157a3dc 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndActivity.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndActivity.java
@@ -18,7 +18,6 @@
import com.android.cts.accessibilityservice.R;
-import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
@@ -28,11 +27,11 @@
import android.widget.TextView;
/**
- * This class is an {@link Activity} used to perform end-to-end
+ * This class is an {@link android.app.Activity} used to perform end-to-end
* testing of the accessibility feature by interaction with the
* UI widgets.
*/
-public class AccessibilityEndToEndActivity extends Activity {
+public class AccessibilityEndToEndActivity extends AccessibilityTestActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
index 81db5be..39b116a 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
@@ -366,7 +366,6 @@
&& first.getCurrentItemIndex() == second.getCurrentItemIndex()
&& first.isEnabled() == second.isEnabled()
&& first.getFromIndex() == second.getFromIndex()
- && first.isFullScreen() == second.isFullScreen()
&& first.getItemCount() == second.getItemCount()
&& first.isPassword() == second.isPassword()
&& first.getRemovedCount() == second.getRemovedCount()
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncActivity.java
index cdd2e42..46f04aa 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncActivity.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncActivity.java
@@ -14,7 +14,6 @@
package android.accessibilityservice.cts;
-import android.app.Activity;
import android.os.Bundle;
import com.android.cts.accessibilityservice.R;
@@ -26,7 +25,7 @@
* this activity is for verifying the the sync between accessibility
* and input focus.
*/
-public class AccessibilityFocusAndInputFocusSyncActivity extends Activity {
+public class AccessibilityFocusAndInputFocusSyncActivity extends AccessibilityTestActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTestActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTestActivity.java
new file mode 100644
index 0000000..4d9b97d
--- /dev/null
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTestActivity.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2014 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.accessibilityservice.cts;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.WindowManager;
+
+public abstract class AccessibilityTestActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+ }
+}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalActivity.java
index 7c9b45a..4a4a4ba 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalActivity.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalActivity.java
@@ -14,7 +14,6 @@
package android.accessibilityservice.cts;
-import android.app.Activity;
import android.os.Bundle;
import com.android.cts.accessibilityservice.R;
@@ -23,7 +22,7 @@
* Activity for testing the accessibility APIs for traversing the
* text content of a View at several granularities.
*/
-public class AccessibilityTextTraversalActivity extends Activity {
+public class AccessibilityTextTraversalActivity extends AccessibilityTestActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
index a53fdea..bdc0cd5 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
@@ -15,6 +15,7 @@
package android.accessibilityservice.cts;
import android.app.UiAutomation;
+import android.content.pm.PackageManager;
import android.os.Bundle;
import android.test.suitebuilder.annotation.MediumTest;
import android.text.Selection;
@@ -4486,6 +4487,11 @@
@MediumTest
public void testTextEditingActions() throws Exception {
+ if (!getActivity().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_INPUT_METHODS)) {
+ return;
+ }
+
final EditText editText = (EditText) getActivity().findViewById(R.id.edit);
final String textContent = getString(R.string.foo_bar_baz);
@@ -4513,7 +4519,7 @@
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
// Copy the selected text.
- text.performAction( AccessibilityNodeInfo.ACTION_COPY);
+ text.performAction(AccessibilityNodeInfo.ACTION_COPY);
// Set selection at the end.
final int textLength = editText.getText().length();
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingActivity.java
index 5aaa067..6aa4f44 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingActivity.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingActivity.java
@@ -14,7 +14,6 @@
package android.accessibilityservice.cts;
-import android.app.Activity;
import android.os.Bundle;
import com.android.cts.accessibilityservice.R;
@@ -26,7 +25,7 @@
* this activity is for verifying the hierarchical movement of the
* accessibility focus.
*/
-public class AccessibilityViewTreeReportingActivity extends Activity {
+public class AccessibilityViewTreeReportingActivity extends AccessibilityTestActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryActivity.java
index 698989c..aa66a45 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryActivity.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryActivity.java
@@ -14,7 +14,6 @@
package android.accessibilityservice.cts;
-import android.app.Activity;
import android.os.Bundle;
import android.view.View;
@@ -28,7 +27,7 @@
* requesting an action to be performed on a given view from an
* AccessibilityService.
*/
-public class AccessibilityWindowQueryActivity extends Activity {
+public class AccessibilityWindowQueryActivity extends AccessibilityTestActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index b8d543d..ded27ff 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -27,7 +27,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.UiAutomation;
import android.graphics.Rect;
-import android.os.SystemClock;
import android.test.suitebuilder.annotation.MediumTest;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -624,7 +623,7 @@
AccessibilityService.GLOBAL_ACTION_BACK));
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
}
@MediumTest
@@ -633,7 +632,7 @@
AccessibilityService.GLOBAL_ACTION_HOME));
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
}
@MediumTest
@@ -643,14 +642,14 @@
AccessibilityService.GLOBAL_ACTION_RECENTS));
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
// Clean up.
getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK);
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
}
@MediumTest
@@ -660,14 +659,14 @@
AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS));
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
// Clean up.
assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK));
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
}
@MediumTest
@@ -677,14 +676,14 @@
AccessibilityService.GLOBAL_ACTION_QUICK_SETTINGS));
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
// Clean up.
getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK);
// Sleep a bit so the UI is settles.
- SystemClock.sleep(3000);
+ waitForIdle();
}
@MediumTest
@@ -741,9 +740,6 @@
// make list of expected nodes
List<String> classNameAndTextList = new ArrayList<String>();
- classNameAndTextList.add("android.widget.FrameLayout");
- classNameAndTextList.add("android.widget.LinearLayout");
- classNameAndTextList.add("android.widget.FrameLayout");
classNameAndTextList.add("android.widget.LinearLayout");
classNameAndTextList.add("android.widget.LinearLayout");
classNameAndTextList.add("android.widget.LinearLayout");
@@ -758,6 +754,9 @@
classNameAndTextList.add("android.widget.ButtonB8");
classNameAndTextList.add("android.widget.ButtonB9");
+ String contentViewIdResName = "com.android.cts.accessibilityservice:id/added_content";
+ boolean verifyContent = false;
+
Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
fringe.add(root);
@@ -765,13 +764,20 @@
while (!fringe.isEmpty()) {
AccessibilityNodeInfo current = fringe.poll();
- CharSequence text = current.getText();
- String receivedClassNameAndText = current.getClassName().toString()
- + ((text != null) ? text.toString() : "");
- String expectedClassNameAndText = classNameAndTextList.remove(0);
+ if (!verifyContent
+ && contentViewIdResName.equals(current.getViewIdResourceName())) {
+ verifyContent = true;
+ }
- assertEquals("Did not get the expected node info",
- expectedClassNameAndText, receivedClassNameAndText);
+ if (verifyContent) {
+ CharSequence text = current.getText();
+ String receivedClassNameAndText = current.getClassName().toString()
+ + ((text != null) ? text.toString() : "");
+ String expectedClassNameAndText = classNameAndTextList.remove(0);
+
+ assertEquals("Did not get the expected node info",
+ expectedClassNameAndText, receivedClassNameAndText);
+ }
final int childCount = current.getChildCount();
for (int i = 0; i < childCount; i++) {
diff --git a/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java b/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
index fdf3cac..65f89f3 100644
--- a/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
@@ -33,26 +33,37 @@
mWallpaperManager = WallpaperManager.getInstance(mContext);
}
+ /**
+ * Suggesting desired dimensions is only a hint to the system that can be ignored.
+ *
+ * Test if the desired minimum width or height the WallpaperManager returns
+ * is greater than 0. If so, then we check whether that the size is at least the
+ * as big as the screen.
+ */
public void testSuggestDesiredDimensions() {
- Point min = getScreenSize();
- int w = min.x * 3;
- int h = min.y * 2;
+ final Point min = getScreenSize();
+ final int w = min.x * 3;
+ final int h = min.y * 2;
- mWallpaperManager.suggestDesiredDimensions(min.x / 2, min.y / 2);
- assertEquals(min.x, mWallpaperManager.getDesiredMinimumWidth());
- assertEquals(min.y, mWallpaperManager.getDesiredMinimumHeight());
+ assertDesiredMinimum(new Point(min.x / 2, min.y / 2), min);
- mWallpaperManager.suggestDesiredDimensions(w, h);
- assertEquals(w, mWallpaperManager.getDesiredMinimumWidth());
- assertEquals(h, mWallpaperManager.getDesiredMinimumHeight());
+ assertDesiredMinimum(new Point(w, h),
+ new Point(w, h));
- mWallpaperManager.suggestDesiredDimensions(min.x / 2, h);
- assertEquals(min.x, mWallpaperManager.getDesiredMinimumWidth());
- assertEquals(h, mWallpaperManager.getDesiredMinimumHeight());
+ assertDesiredMinimum(new Point(min.x / 2, h),
+ new Point(min.x, h));
- mWallpaperManager.suggestDesiredDimensions(w, min.y / 2);
- assertEquals(w, mWallpaperManager.getDesiredMinimumWidth());
- assertEquals(min.y, mWallpaperManager.getDesiredMinimumHeight());
+ assertDesiredMinimum(new Point(w, min.y / 2),
+ new Point(w, min.y));
+ }
+
+ private void assertDesiredMinimum(Point suggestedSize, Point expectedSize) {
+ mWallpaperManager.suggestDesiredDimensions(suggestedSize.x, suggestedSize.y);
+ Point actualSize = new Point(mWallpaperManager.getDesiredMinimumWidth(),
+ mWallpaperManager.getDesiredMinimumHeight());
+ if (actualSize.x > 0 || actualSize.y > 0) {
+ assertEquals(expectedSize, actualSize);
+ }
}
private Point getScreenSize() {
diff --git a/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java b/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java
index f452f50..f2f859a 100644
--- a/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java
+++ b/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java
@@ -29,6 +29,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
+import android.os.HandlerThread;
import android.os.SystemClock;
import android.test.AndroidTestCase;
import android.util.DisplayMetrics;
@@ -72,6 +73,8 @@
private ImageReader mImageReader;
private Surface mSurface;
private ImageListener mImageListener;
+ private HandlerThread mCheckThread;
+ private Handler mCheckHandler;
@Override
protected void setUp() throws Exception {
@@ -80,11 +83,15 @@
mDisplayManager = (DisplayManager)mContext.getSystemService(Context.DISPLAY_SERVICE);
mHandler = new Handler(Looper.getMainLooper());
mImageListener = new ImageListener();
+ // thread for image checking
+ mCheckThread = new HandlerThread("TestHandler");
+ mCheckThread.start();
+ mCheckHandler = new Handler(mCheckThread.getLooper());
mImageReaderLock.lock();
try {
mImageReader = ImageReader.newInstance(WIDTH, HEIGHT, PixelFormat.RGBA_8888, 2);
- mImageReader.setOnImageAvailableListener(mImageListener, mHandler);
+ mImageReader.setOnImageAvailableListener(mImageListener, mCheckHandler);
mSurface = mImageReader.getSurface();
} finally {
mImageReaderLock.unlock();
@@ -94,7 +101,6 @@
@Override
protected void tearDown() throws Exception {
super.tearDown();
-
mImageReaderLock.lock();
try {
mImageReader.close();
@@ -103,6 +109,7 @@
} finally {
mImageReaderLock.unlock();
}
+ mCheckThread.quit();
}
/**
diff --git a/tests/tests/drm/src/android/drm/cts/DRMTest.java b/tests/tests/drm/src/android/drm/cts/DRMTest.java
index e72fe83..bd4291d 100644
--- a/tests/tests/drm/src/android/drm/cts/DRMTest.java
+++ b/tests/tests/drm/src/android/drm/cts/DRMTest.java
@@ -49,14 +49,17 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mDrmManagerClient = new DrmManagerClient(getContext());
- String[] plugins = mDrmManagerClient.getAvailableDrmEngines();
- mConfigs.clear();
- for(String plugInName : plugins) {
- Config config = ConfigFactory.getConfig(plugInName);
- if (null != config) {
- mConfigs.add(config);
+ if (deviceSupportsDRM()) {
+ mDrmManagerClient = new DrmManagerClient(getContext());
+ String[] plugins = mDrmManagerClient.getAvailableDrmEngines();
+
+ mConfigs.clear();
+ for(String plugInName : plugins) {
+ Config config = ConfigFactory.getConfig(plugInName);
+ if (null != config) {
+ mConfigs.add(config);
+ }
}
}
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java
index 31dbf16..ee3ec7c 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java
@@ -107,4 +107,82 @@
// underline is under the text or at least at the bottom of it
assertTrue(rect.top >= TEXT_Y);
}
+
+ // Tests that FILTER_BITMAP_FLAG is handled properly.
+ public void testPaintFlagsDrawFilter2() {
+ // Create a bitmap with alternating black and white pixels.
+ int kWidth = 5;
+ int kHeight = 5;
+ int colors[] = new int [] { Color.WHITE, Color.BLACK };
+ int k = 0;
+ Bitmap grid = Bitmap.createBitmap(kWidth, kHeight, Config.ARGB_8888);
+ for (int i = 0; i < kWidth; ++i) {
+ for (int j = 0; j < kHeight; ++j) {
+ grid.setPixel(i, j, colors[k]);
+ k = (k + 1) % 2;
+ }
+ }
+
+ // Setup a scaled canvas for drawing the bitmap, with and without FILTER_BITMAP_FLAG set.
+ // When the flag is set, there will be gray pixels. When the flag is not set, all pixels
+ // will be either black or white.
+ int kScale = 5;
+ Bitmap dst = Bitmap.createBitmap(kWidth * kScale, kHeight * kScale, Config.ARGB_8888);
+ Canvas canvas = new Canvas(dst);
+ canvas.scale(kScale, kScale);
+
+ // Drawn without FILTER_BITMAP_FLAG, all pixels will be black or white.
+ Paint simplePaint = new Paint();
+ canvas.drawBitmap(grid, 0, 0, simplePaint);
+
+ assertContainsOnlyBlackAndWhite(dst);
+
+ // Drawn with FILTER_BITMAP_FLAG, some pixels will be somewhere in between.
+ Paint filterBitmapPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
+ canvas.drawBitmap(grid, 0, 0, filterBitmapPaint);
+
+ assertContainsNonBW(dst);
+
+ // Drawing with a paint that FILTER_BITMAP_FLAG set and a DrawFilter that removes
+ // FILTER_BITMAP_FLAG should remove the effect of the flag, resulting in all pixels being
+ // either black or white.
+ canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0));
+ canvas.drawBitmap(grid, 0, 0, filterBitmapPaint);
+
+ assertContainsOnlyBlackAndWhite(dst);
+
+ // Likewise, drawing with a DrawFilter that sets FILTER_BITMAP_FLAG should filter,
+ // resulting in gray pixels.
+ canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG));
+ canvas.drawBitmap(grid, 0, 0, simplePaint);
+
+ assertContainsNonBW(dst);
+ }
+
+ // Assert that at least one pixel is neither black nor white. This is used to verify that
+ // filtering was done, since the original bitmap only contained black and white pixels.
+ private void assertContainsNonBW(Bitmap bitmap) {
+ for (int i = 0; i < bitmap.getWidth(); ++i) {
+ for (int j = 0; j < bitmap.getHeight(); ++j) {
+ int color = bitmap.getPixel(i, j);
+ if (color != Color.BLACK && color != Color.WHITE) {
+ // Filtering must have been done.
+ return;
+ }
+ }
+ }
+ // Filtering did not happen.
+ assertTrue(false);
+ }
+
+ // Assert that every pixel is either black or white. Used to verify that no filtering was
+ // done, since the original bitmap contained only black and white pixels.
+ private void assertContainsOnlyBlackAndWhite(Bitmap bitmap) {
+ for (int i = 0; i < bitmap.getWidth(); ++i) {
+ for (int j = 0; j < bitmap.getHeight(); ++j) {
+ int color = bitmap.getPixel(i, j);
+ assertTrue(color == Color.BLACK || color == Color.WHITE);
+ }
+ }
+ }
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/PictureTest.java b/tests/tests/graphics/src/android/graphics/cts/PictureTest.java
index 81f053d..17e9b63 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PictureTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PictureTest.java
@@ -24,18 +24,88 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Picture;
+import android.graphics.Rect;
import android.graphics.Paint.Style;
-
+import android.graphics.Region.Op;
public class PictureTest extends TestCase {
private static final int TEST_WIDTH = 4; // must be >= 2
private static final int TEST_HEIGHT = 3; // must >= 2
- public void testPicture() throws Exception {
+ private final Rect mClipRect = new Rect(0, 0, 2, 2);
+ // This method tests out some edge cases w.r.t. Picture creation.
+ // In particular, this test verifies that, in the following situations,
+ // the created picture (effectively) has balanced saves and restores:
+ // - copy constructed picture from actively recording picture
+ // - writeToStream/createFromStream created picture from actively recording picture
+ // - actively recording picture after draw call
+ public void testSaveRestoreBalance() throws Exception {
+ Picture original = new Picture();
+ Canvas canvas = original.beginRecording(TEST_WIDTH, TEST_HEIGHT);
+ assertNotNull(canvas);
+ createImbalance(canvas);
+
+ int expectedSaveCount = canvas.getSaveCount();
+
+ Picture copy = new Picture(original);
+ checkBalance(copy);
+
+ assertEquals(expectedSaveCount, canvas.getSaveCount());
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ original.writeToStream(bout);
+
+ assertEquals(expectedSaveCount, canvas.getSaveCount());
+
+ Picture serialized = Picture.createFromStream(new ByteArrayInputStream(bout.toByteArray()));
+ // The serialization/deserialization process will balance the saves and restores
+ checkBalance(serialized);
+
+ assertEquals(expectedSaveCount, canvas.getSaveCount());
+
+ Bitmap bitmap = Bitmap.createBitmap(TEST_WIDTH, TEST_HEIGHT, Bitmap.Config.ARGB_8888);
+ Canvas drawDest = new Canvas(bitmap);
+ original.draw(drawDest);
+ checkBalance(original);
+ }
+
+ // Add an extra save with a transform and clip
+ private void createImbalance(Canvas canvas) {
+ canvas.save();
+ canvas.clipRect(mClipRect, Op.REPLACE);
+ canvas.translate(1.0f, 1.0f);
+ Paint paint = new Paint();
+ paint.setColor(Color.GREEN);
+ canvas.drawRect(0, 0, 10, 10, paint);
+ }
+
+ private void checkBalance(Picture picture) {
+ Bitmap bitmap = Bitmap.createBitmap(TEST_WIDTH, TEST_HEIGHT, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+
+ int beforeSaveCount = canvas.getSaveCount();
+
+ final Matrix beforeMatrix = canvas.getMatrix();
+
+ canvas.drawPicture(picture);
+
+ assertEquals(beforeSaveCount, canvas.getSaveCount());
+
+ assertTrue(beforeMatrix.equals(canvas.getMatrix()));
+
+ Rect afterClip = new Rect();
+
+ assertTrue(canvas.getClipBounds(afterClip));
+ assertEquals(TEST_WIDTH, afterClip.width());
+ assertEquals(TEST_HEIGHT, afterClip.height());
+ }
+
+ public void testPicture() throws Exception {
Picture picture = new Picture();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java
new file mode 100644
index 0000000..dc469c7
--- /dev/null
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2014 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.graphics.drawable.cts;
+
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.drawable.VectorDrawable;
+import android.test.AndroidTestCase;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.Xml;
+
+import com.android.cts.stub.R;
+
+import org.xmlpull.v1.XmlPullParser;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class VectorDrawableTest extends AndroidTestCase {
+ private static final String LOGTAG = VectorDrawableTest.class.getSimpleName();
+ private int[] mIconResIds = new int[] {
+ R.drawable.vector_icon_create,
+ R.drawable.vector_icon_delete,
+ R.drawable.vector_icon_heart,
+ R.drawable.vector_icon_schedule,
+ R.drawable.vector_icon_settings,
+ R.drawable.vector_icon_random_path_1,
+ R.drawable.vector_icon_random_path_2,
+ R.drawable.vector_icon_repeated_cq,
+ R.drawable.vector_icon_repeated_st,
+ R.drawable.vector_icon_repeated_a_1,
+ R.drawable.vector_icon_repeated_a_2,
+ R.drawable.vector_icon_clip_path_1,
+ R.drawable.vector_icon_transformation_1,
+ };
+
+ private int[] mGoldenImages = new int[] {
+ R.drawable.vector_icon_create_golden,
+ R.drawable.vector_icon_delete_golden,
+ R.drawable.vector_icon_heart_golden,
+ R.drawable.vector_icon_schedule_golden,
+ R.drawable.vector_icon_settings_golden,
+ R.drawable.vector_icon_random_path_1_golden,
+ R.drawable.vector_icon_random_path_2_golden,
+ R.drawable.vector_icon_repeated_cq_golden,
+ R.drawable.vector_icon_repeated_st_golden,
+ R.drawable.vector_icon_repeated_a_1_golden,
+ R.drawable.vector_icon_repeated_a_2_golden,
+ R.drawable.vector_icon_clip_path_1_golden,
+ R.drawable.vector_icon_transformation_1_golden,
+ };
+
+ private static final int IMAGE_WIDTH = 64;
+ private static final int IMAGE_HEIGHT = 64;
+ // A small value is actually making sure that the values are matching
+ // exactly with the golden image.
+ // We can increase the threshold if the Skia is drawing with some variance
+ // on different devices. So far, the tests show they are matching correctly.
+ private static final float PIXEL_ERROR_THRESHOLD = 0.00001f;
+
+ private static final boolean DBG_DUMP_PNG = false;
+
+ private Resources mResources;
+ private VectorDrawable mVectorDrawable;
+ private BitmapFactory.Options mOptions;
+ private Bitmap mBitmap;
+ private Canvas mCanvas;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ final int width = IMAGE_WIDTH;
+ final int height = IMAGE_HEIGHT;
+
+ mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ mCanvas = new Canvas(mBitmap);
+ mVectorDrawable = new VectorDrawable();
+ mVectorDrawable.setBounds(0, 0, width, height);
+
+ mResources = mContext.getResources();
+
+ mOptions = new BitmapFactory.Options();
+ mOptions.inScaled = false;
+ }
+
+ public void testSimpleVectorDrawables() throws Exception {
+ verifyVectorDrawables(mIconResIds, mGoldenImages, 0);
+ }
+
+ private void verifyVectorDrawables(int[] resIds, int[] goldenImages, float fraction) throws Exception {
+ for (int i = 0; i < resIds.length; i++) {
+ // Setup VectorDrawable from xml file and draw into the bitmap.
+ // TODO: use the VectorDrawable.create() function if it is
+ // publicized.
+ XmlPullParser xpp = mResources.getXml(resIds[i]);
+ AttributeSet attrs = Xml.asAttributeSet(xpp);
+
+ mVectorDrawable.inflate(mResources, xpp, attrs);
+
+ mBitmap.eraseColor(0);
+ mVectorDrawable.draw(mCanvas);
+
+ if (DBG_DUMP_PNG) {
+ saveVectorDrawableIntoPNG(mBitmap, resIds, i);
+ } else {
+ // Start to compare
+ Bitmap golden = BitmapFactory.decodeResource(mResources, goldenImages[i], mOptions);
+ compareImages(mBitmap, golden, mResources.getString(resIds[i]));
+ }
+ }
+ }
+
+ // This is only for debugging or golden image (re)generation purpose.
+ private void saveVectorDrawableIntoPNG(Bitmap bitmap, int[] resIds, int index) throws IOException {
+ // Save the image to the disk.
+ FileOutputStream out = null;
+ try {
+ String outputFolder = "/sdcard/temp/";
+ File folder = new File(outputFolder);
+ if (!folder.exists()) {
+ folder.mkdir();
+ }
+ String originalFilePath = mResources.getString(resIds[index]);
+ File originalFile = new File(originalFilePath);
+ String fileFullName = originalFile.getName();
+ String fileTitle = fileFullName.substring(0, fileFullName.lastIndexOf("."));
+ String outputFilename = outputFolder + fileTitle + "_golden.png";
+ File outputFile = new File(outputFilename);
+ if (!outputFile.exists()) {
+ outputFile.createNewFile();
+ }
+
+ out = new FileOutputStream(outputFile, false);
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
+ Log.v(LOGTAG, "Write test No." + index + " to file successfully.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private void compareImages(Bitmap ideal, Bitmap given, String filename) {
+ int idealWidth = ideal.getWidth();
+ int idealHeight = ideal.getHeight();
+
+ assertTrue(idealWidth == given.getWidth());
+ assertTrue(idealHeight == given.getHeight());
+
+ int totalDiffPixelCount = 0;
+ float totalPixelCount = idealWidth * idealHeight;
+ for (int x = 0; x < idealWidth; x++) {
+ for (int y = 0; y < idealHeight; y++) {
+ int idealColor = ideal.getPixel(x, y);
+ int givenColor = given.getPixel(x, y);
+ if (idealColor == givenColor)
+ continue;
+
+ float totalError = 0;
+ totalError += Math.abs(Color.red(idealColor) - Color.red(givenColor));
+ totalError += Math.abs(Color.green(idealColor) - Color.green(givenColor));
+ totalError += Math.abs(Color.blue(idealColor) - Color.blue(givenColor));
+ totalError += Math.abs(Color.alpha(idealColor) - Color.alpha(givenColor));
+
+ if ((totalError / 1024.0f) >= PIXEL_ERROR_THRESHOLD) {
+ fail((filename + ": totalError is " + totalError));
+ }
+
+ totalDiffPixelCount++;
+ }
+ }
+ if ((totalDiffPixelCount / totalPixelCount) >= PIXEL_ERROR_THRESHOLD) {
+ fail((filename +": totalDiffPixelCount is " + totalDiffPixelCount));
+ }
+
+ }
+}
diff --git a/tests/tests/hardware/src/android/hardware/consumerir/cts/ConsumerIrTest.java b/tests/tests/hardware/src/android/hardware/consumerir/cts/ConsumerIrTest.java
index 395a69b..e06adac 100644
--- a/tests/tests/hardware/src/android/hardware/consumerir/cts/ConsumerIrTest.java
+++ b/tests/tests/hardware/src/android/hardware/consumerir/cts/ConsumerIrTest.java
@@ -77,12 +77,12 @@
ConsumerIrManager.CarrierFrequencyRange[] freqs = mCIR.getCarrierFrequencies();
// Transmit two seconds for min and max for each frequency range
- int[] pattern = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999};
- long totalXmitTime = 0; // get the length of the pattern
+ int[] pattern = {11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999};
+ long totalXmitTimeNanos = 0; // get the length of the pattern
for (int slice : pattern) {
- totalXmitTime += slice;
+ totalXmitTimeNanos += slice * 1000; // add the time in nanoseconds
}
- double margin = 0.1; // max fraction xmit is allowed to be off timing
+ double margin = 0.5; // max fraction xmit is allowed to be off timing
for (ConsumerIrManager.CarrierFrequencyRange range : freqs) {
// test min freq
@@ -90,18 +90,18 @@
mCIR.transmit(range.getMinFrequency(), pattern);
long newTime = SystemClock.elapsedRealtimeNanos();
String msg = String.format("Pattern length pattern:%d, actual:%d",
- totalXmitTime, newTime - currentTime);
- assertTrue(msg, newTime - currentTime >= totalXmitTime * (1.0 - margin));
- assertTrue(msg, newTime - currentTime <= totalXmitTime * (1.0 + margin));
+ totalXmitTimeNanos, newTime - currentTime);
+ assertTrue(msg, newTime - currentTime >= totalXmitTimeNanos * (1.0 - margin));
+ assertTrue(msg, newTime - currentTime <= totalXmitTimeNanos * (1.0 + margin));
// test max freq
currentTime = SystemClock.elapsedRealtimeNanos();
mCIR.transmit(range.getMaxFrequency(), pattern);
newTime = SystemClock.elapsedRealtimeNanos();
msg = String.format("Pattern length pattern:%d, actual:%d",
- totalXmitTime, newTime - currentTime);
- assertTrue(msg, newTime - currentTime >= totalXmitTime * (1.0 - margin));
- assertTrue(msg, newTime - currentTime <= totalXmitTime * (1.0 + margin));
+ totalXmitTimeNanos, newTime - currentTime);
+ assertTrue(msg, newTime - currentTime >= totalXmitTimeNanos * (1.0 - margin));
+ assertTrue(msg, newTime - currentTime <= totalXmitTimeNanos * (1.0 + margin));
}
}
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index 34bc0e4..ab11b3c 100644
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -267,40 +267,66 @@
*/
public void testModeAndProviderApisConsistent() {
ContentResolver cr = mContext.getContentResolver();
+
+ // Find out what the settings say about which providers are enabled
int mode = Settings.Secure.getInt(
cr, Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
boolean gps = Settings.Secure.isLocationProviderEnabled(cr, LocationManager.GPS_PROVIDER);
boolean nlp = Settings.Secure.isLocationProviderEnabled(
cr, LocationManager.NETWORK_PROVIDER);
- // Assert that if there are no test providers enabled, LocationManager just returns the
- // values from Settings.Secure.
+ // Find out location manager's opinion on the matter, making sure we dont' get spurious
+ // results from test versions of the two providers.
forceRemoveTestProvider(LocationManager.GPS_PROVIDER);
forceRemoveTestProvider(LocationManager.NETWORK_PROVIDER);
boolean lmGps = mManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean lmNlp = mManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
- assertEquals("Inconsistent GPS values", gps, lmGps);
- assertEquals("Inconsistent NLP values", nlp, lmNlp);
- // Assert that isLocationProviderEnabled() values are consistent with the location mode
+ // Location Manager will report provider as off if it doesn't know about it
+ boolean expectedGps = gps && deviceHasProvider(LocationManager.GPS_PROVIDER);
+ boolean expectedNlp = nlp && deviceHasProvider(LocationManager.NETWORK_PROVIDER);
+
+ // Assert LocationManager returned the values from Settings.Secure (assuming the device has
+ // the appropriate hardware).
+ assertEquals("Inconsistent GPS values", expectedGps, lmGps);
+ assertEquals("Inconsistent NLP values", expectedNlp, lmNlp);
+
switch (mode) {
case Settings.Secure.LOCATION_MODE_OFF:
- assertFalse("Bad GPS for mode " + mode, gps);
- assertFalse("Bad NLP for mode " + mode, nlp);
+ expectedGps = false;
+ expectedNlp = false;
break;
case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
- assertEquals("Bad GPS for mode " + mode, hasGpsFeature(), gps);
- assertFalse("Bad NLP for mode " + mode, nlp);
+ expectedGps = true;
+ expectedNlp = false;
break;
case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
- assertFalse("Bad GPS for mode " + mode, gps);
- assertTrue("Bad NLP for mode " + mode, nlp);
+ expectedGps = false;
+ expectedNlp = true;
break;
case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
- assertEquals("Bad GPS for mode " + mode, hasGpsFeature(), gps);
- assertTrue("Bad NLP for mode " + mode, nlp);
+ expectedGps = true;
+ expectedNlp = true;
break;
}
+
+ // Assert that isLocationProviderEnabled() values are consistent with the location mode
+ assertEquals("Bad GPS for mode " + mode, expectedGps, gps);
+ assertEquals("Bad NLP for mode " + mode, expectedNlp, nlp);
+ }
+
+ /**
+ * Returns true if the {@link LocationManager} reports that the device includes this flavor
+ * of location provider.
+ */
+ private boolean deviceHasProvider(String provider) {
+ List<String> providers = mManager.getAllProviders();
+ for (String aProvider : providers) {
+ if (aProvider.equals(provider)) {
+ return true;
+ }
+ }
+ return false;
}
/**
diff --git a/tests/tests/media/libmediandkjni/native-media-jni.cpp b/tests/tests/media/libmediandkjni/native-media-jni.cpp
index abc73ae..9adc887 100644
--- a/tests/tests/media/libmediandkjni/native-media-jni.cpp
+++ b/tests/tests/media/libmediandkjni/native-media-jni.cpp
@@ -573,119 +573,6 @@
return true;
}
-void callback(AMediaCodec *codec, void *userdata) {
- sem_t *sem = (sem_t*) userdata;
- sem_post(sem);
-}
-
-extern "C" jboolean Java_android_media_cts_NativeDecoderTest_testPlaybackWithCallbackNative(
- JNIEnv *env,
- jclass /*clazz*/,
- jobject surface,
- int fd, jlong offset, jlong size) {
-
- ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
- ALOGI("@@@@ native window: %p", window);
-
- AMediaExtractor *ex = AMediaExtractor_new();
- int err = AMediaExtractor_setDataSourceFd(ex, fd, offset, size);
- if (err != 0) {
- ALOGE("setDataSource error: %d", err);
- return false;
- }
-
- int numtracks = AMediaExtractor_getTrackCount(ex);
-
- sem_t sem;
- sem_init(&sem, 0, 0);
-
- AMediaCodec *codec = NULL;
- AMediaFormat *format = NULL;
- bool sawInputEOS = false;
- bool sawOutputEOS = false;
-
- ALOGV("input has %d tracks", numtracks);
- for (int i = 0; i < numtracks; i++) {
- AMediaFormat *format = AMediaExtractor_getTrackFormat(ex, i);
- const char *s = AMediaFormat_toString(format);
- ALOGI("track %d format: %s", i, s);
- const char *mime;
- if (!AMediaFormat_getString(format, AMEDIAFORMAT_KEY_MIME, &mime)) {
- ALOGE("no mime type");
- return false;
- } else if (!strncmp(mime, "video/", 6)) {
- codec = AMediaCodec_createDecoderByType(mime);
- AMediaCodec_configure(codec, format, window, NULL, 0);
- AMediaCodec_setNotificationCallback(codec, callback, &sem);
- AMediaCodec_start(codec);
- AMediaExtractor_selectTrack(ex, i);
- }
- AMediaFormat_delete(format);
- }
-
- while (!sawOutputEOS) {
- // the callback will signal when a buffer is available
- if (sem_wait(&sem)) {
- ALOGI("sem_wait was interrupted");
- continue;
- }
- bool didwork = false;
- ssize_t bufidx = AMediaCodec_dequeueInputBuffer(codec, 0);
- ALOGV("input buffer %d", bufidx);
- if (bufidx >= 0) {
- didwork = true;
- size_t bufsize;
- uint8_t *buf = AMediaCodec_getInputBuffer(codec, bufidx, &bufsize);
- int sampleSize = AMediaExtractor_readSampleData(ex, buf, bufsize);
- ALOGV("read %d", sampleSize);
- if (sampleSize < 0) {
- sampleSize = 0;
- sawInputEOS = true;
- ALOGV("EOS");
- }
- int64_t presentationTimeUs = AMediaExtractor_getSampletime(ex);
-
- AMediaCodec_queueInputBuffer(codec, bufidx, 0, sampleSize, presentationTimeUs,
- sawInputEOS ? AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM : 0);
- AMediaExtractor_advance(ex);
- }
-
- AMediaCodecBufferInfo info;
- int status = AMediaCodec_dequeueOutputBuffer(codec, &info, 0);
- ALOGV("dequeueoutput returned: %d", status);
- if (status >= 0) {
- didwork = true;
- if (info.flags & AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM) {
- ALOGV("output EOS");
- sawOutputEOS = true;
- }
- ALOGV("got decoded buffer size %d", info.size);
- AMediaCodec_releaseOutputBuffer(codec, status, true);
- usleep(20000);
- } else if (status == AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED) {
- didwork = true;
- ALOGV("output buffers changed");
- } else if (status == AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED) {
- didwork = true;
- format = AMediaCodec_getOutputFormat(codec);
- ALOGV("format changed to: %s", AMediaFormat_toString(format));
- } else if (status == AMEDIACODEC_INFO_TRY_AGAIN_LATER) {
- ALOGV("no output buffer right now");
- } else {
- ALOGV("unexpected info code: %d", status);
- }
-
- if (!didwork) {
- ALOGE("called back for no reason");
- }
- }
-
- sem_destroy(&sem);
- AMediaCodec_stop(codec);
- AMediaCodec_delete(codec);
- AMediaExtractor_delete(ex);
- return true;
-}
extern "C" jboolean Java_android_media_cts_NativeDecoderTest_testPsshNative(JNIEnv * /*env*/,
jclass /*clazz*/, int fd, jlong offset, jlong size) {
diff --git a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
index e307bbd..1747afa 100644
--- a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
+++ b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
@@ -1275,13 +1275,11 @@
/* test if the explicitly named codec is present on the system */
if (explicitCodecName != null) {
- try {
- MediaCodec codec = MediaCodec.createByCodecName(explicitCodecName);
- if (codec != null) {
- codec.release();
- add(new Codec(explicitCodecName, null, mediaList));
- }
- } catch (IOException e) {}
+ MediaCodec codec = MediaCodec.createByCodecName(explicitCodecName);
+ if (codec != null) {
+ codec.release();
+ add(new Codec(explicitCodecName, null, mediaList));
+ }
}
} catch (Throwable t) {
Log.wtf("Constructor failed", t);
diff --git a/tests/tests/media/src/android/media/cts/NativeDecoderTest.java b/tests/tests/media/src/android/media/cts/NativeDecoderTest.java
index 2b255dd..fc27dfa 100644
--- a/tests/tests/media/src/android/media/cts/NativeDecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/NativeDecoderTest.java
@@ -453,25 +453,6 @@
private static native boolean testFormatNative();
- public void testVideoPlaybackWithCallback() throws Exception {
- testVideoPlaybackWithCallback(R.raw.video_1280x720_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz);
- testVideoPlaybackWithCallback(R.raw.video_1280x720_webm_vp8_333kbps_25fps_vorbis_stereo_128kbps_44100hz);
- testVideoPlaybackWithCallback(R.raw.video_1280x720_webm_vp9_309kbps_25fps_vorbis_stereo_128kbps_44100hz);
- testVideoPlaybackWithCallback(R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_mono_24kbps_11025hz);
- testVideoPlaybackWithCallback(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz);
- }
-
- private void testVideoPlaybackWithCallback(int res) throws Exception {
- AssetFileDescriptor fd = mResources.openRawResourceFd(res);
-
- boolean ret = testPlaybackWithCallbackNative(mActivity.getSurfaceHolder().getSurface(),
- fd.getParcelFileDescriptor().getFd(), fd.getStartOffset(), fd.getLength());
- assertTrue("native playback error", ret);
- }
-
- private static native boolean testPlaybackWithCallbackNative(Surface surface,
- int fd, long startOffset, long length);
-
public void testPssh() throws Exception {
testPssh(R.raw.psshtest);
}
diff --git a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
index 45e4009..58a61ab 100644
--- a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
+++ b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
@@ -277,6 +277,7 @@
} else {
params.timeoutDequeue = 0;
params.runInLooperThread = true;
+ continue; // FIXME add support for async
}
outputParameters.add(params);
}
@@ -680,7 +681,7 @@
* is configured to run in async mode the function will run in a looper thread.
* Encoded frame can be retrieved by calling getOutput() function.
*/
- protected class MediaEncoderAsync extends Thread implements MediaCodec.NotificationCallback {
+ protected class MediaEncoderAsync extends Thread /* FIXME implements MediaCodec.NotificationCallback */ {
private int mId;
private MediaCodec mCodec;
private MediaFormat mFormat;
@@ -708,7 +709,7 @@
private Handler mHandler;
private boolean mCallbackReceived;
- @Override
+ /* FIXME @Override */
public void onCodecNotify(MediaCodec codec) {
synchronized (mCallbackEvent) {
Log.v(TAG, "MediaEncoder " + mId + " Event Callback");
@@ -795,7 +796,7 @@
mCodec.configure(mFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
mCodec.start();
if (mAsync) {
- mCodec.setNotificationCallback(this);
+ /* FIXME mCodec.setNotificationCallback(this); */
}
mInputBuffers = mCodec.getInputBuffers();
mOutputBuffers = mCodec.getOutputBuffers();
diff --git a/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java b/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
index 19b4caa..7f51a64 100644
--- a/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
+++ b/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
@@ -111,7 +111,7 @@
* Checks the PSNR difference between the encoded and decoded output and reference yuv input
* does not change much for two different ways of the encoder call.
*/
- public void testAsyncEncoding() throws Exception {
+ public void FIXME_testAsyncEncoding() throws Exception {
int encodeSeconds = 9;
// First test the encoder running in a looper thread with buffer callbacks enabled.
diff --git a/tests/tests/text/src/android/text/cts/EmojiTest.java b/tests/tests/text/src/android/text/cts/EmojiTest.java
index f5f191f..4bcc0e1 100644
--- a/tests/tests/text/src/android/text/cts/EmojiTest.java
+++ b/tests/tests/text/src/android/text/cts/EmojiTest.java
@@ -25,6 +25,7 @@
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
+import android.webkit.cts.NullWebViewUtils;
import android.webkit.cts.WebViewOnUiThread;
import android.widget.TextView;
import android.widget.EditText;
@@ -58,7 +59,6 @@
*/
public void testEmojiGlyph() {
CaptureCanvas ccanvas = new CaptureCanvas(getInstrumentation().getContext());
- CaptureWebView cwebview = new CaptureWebView(getInstrumentation().getContext());
Bitmap mBitmapA, mBitmapB; // Emoji displayed Bitmaps to compare
@@ -92,11 +92,15 @@
assertFalse(mBitmapA.sameAs(mBitmapB));
- mBitmapA = cwebview.capture(Character.toChars(comparedCodePoints[i][0]));
- mBitmapB = cwebview.capture(Character.toChars(comparedCodePoints[i][1]));
-
- assertFalse(mBitmapA.sameAs(mBitmapB));
-
+ // Trigger activity bringup so we can determine if a WebView is available on this
+ // device.
+ EmojiStubActivity activity = getActivity();
+ if (NullWebViewUtils.isWebViewAvailable()) {
+ CaptureWebView cwebview = new CaptureWebView(getInstrumentation().getContext());
+ mBitmapA = cwebview.capture(Character.toChars(comparedCodePoints[i][0]));
+ mBitmapB = cwebview.capture(Character.toChars(comparedCodePoints[i][1]));
+ assertFalse(mBitmapA.sameAs(mBitmapB));
+ }
}
}
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 a7ee974..56f8f61 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewStartupTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewStartupTest.java
@@ -63,9 +63,17 @@
Log.i(TAG, "done setting cookie before creating webview");
}
});
+ NullWebViewUtils.NullWebViewFromThreadExceptionHandler h =
+ new NullWebViewUtils.NullWebViewFromThreadExceptionHandler();
+
+ background.setUncaughtExceptionHandler(h);
background.start();
background.join();
+ if (!h.isWebViewAvailable(mActivity)) {
+ return;
+ }
+
// Now create WebView and test that setting the cookie beforehand really worked.
mActivity.createAndAttachWebView();
WebViewOnUiThread onUiThread = new WebViewOnUiThread(this, mActivity.getWebView());
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index d8d9f12..982acfc 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
@@ -785,6 +867,34 @@
assertTrue(mJsInterfaceWasCalled.get());
}
+ public void testJavascriptInterfaceCustomPropertiesClearedOnReload() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ mOnUiThread.getSettings().setJavaScriptEnabled(true);
+
+ class DummyJavaScriptInterface {
+ }
+ final DummyJavaScriptInterface obj = new DummyJavaScriptInterface();
+ mOnUiThread.addJavascriptInterface(obj, "dummy");
+ mOnUiThread.loadUrlAndWaitForCompletion("about:blank");
+
+ EvaluateJsResultPollingCheck jsResult;
+ jsResult = new EvaluateJsResultPollingCheck("42");
+ mOnUiThread.evaluateJavascript("dummy.custom_property = 42", jsResult);
+ jsResult.run();
+ jsResult = new EvaluateJsResultPollingCheck("true");
+ mOnUiThread.evaluateJavascript("'custom_property' in dummy", jsResult);
+ jsResult.run();
+
+ mOnUiThread.reload();
+
+ jsResult = new EvaluateJsResultPollingCheck("false");
+ mOnUiThread.evaluateJavascript("'custom_property' in dummy", jsResult);
+ jsResult.run();
+ }
+
private final class TestPictureListener implements PictureListener {
public int callCount;
@@ -822,6 +932,9 @@
}
public void testCapturePicture() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final TestPictureListener listener = new TestPictureListener();
startWebServer(false);
@@ -846,6 +959,9 @@
}
public void testSetPictureListener() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MyPictureListener implements PictureListener {
public int callCount;
public WebView webView;
@@ -889,6 +1005,9 @@
@UiThreadTest
public void testAccessHttpAuthUsernamePassword() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
try {
WebViewDatabase.getInstance(getActivity()).clearHttpAuthUsernamePassword();
@@ -950,6 +1069,9 @@
}
public void testLoadData() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final String HTML_CONTENT =
"<html><head><title>Hello,World!</title></head><body></body>" +
"</html>";
@@ -978,6 +1100,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.
@@ -1063,6 +1188,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);
@@ -1087,6 +1215,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);
@@ -1143,6 +1274,9 @@
}
public void testDocumentHasImages() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class DocumentHasImageCheckHandler extends Handler {
private boolean mReceived;
private int mMsgArg1;
@@ -1192,6 +1326,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;\">" +
@@ -1236,6 +1373,9 @@
}
public void testGetContentHeight() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.loadDataAndWaitForCompletion(
"<html><body></body></html>", "text/html", null);
new PollingCheck() {
@@ -1274,12 +1414,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
@@ -1288,12 +1434,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;" +
@@ -1323,6 +1475,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);
@@ -1390,6 +1545,9 @@
}
public void testRequestImageRef() throws Exception, Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class ImageLoaded {
public boolean mImageLoaded;
@@ -1470,10 +1628,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>";
@@ -1535,6 +1699,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;
@@ -1586,6 +1753,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);
@@ -1608,6 +1778,9 @@
@UiThreadTest
public void testSaveAndRestoreState() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
// nothing to save
assertNull(mWebView.saveState(new Bundle()));
@@ -1670,6 +1843,9 @@
}
public void testSetWebViewClient() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final ScaleChangedWebViewClient webViewClient = new ScaleChangedWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
startWebServer(false);
@@ -1685,6 +1861,9 @@
@UiThreadTest
public void testInsecureSiteClearsCertificate() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1713,6 +1892,9 @@
@UiThreadTest
public void testSecureSiteSetsCertificate() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1741,6 +1923,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();
@@ -1768,6 +1953,9 @@
}
public void testOnReceivedSslError() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
private String mErrorUrl;
private WebView mWebView;
@@ -1801,6 +1989,9 @@
}
public void testOnReceivedSslErrorProceed() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1819,6 +2010,9 @@
}
public void testOnReceivedSslErrorCancel() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebViewClient extends WaitForLoadedClient {
public MockWebViewClient() {
super(mOnUiThread);
@@ -1838,6 +2032,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();
@@ -1858,6 +2055,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();
@@ -1910,6 +2110,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>";
@@ -1933,6 +2136,10 @@
}
public void testSetDownloadListener() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
final CountDownLatch resultLatch = new CountDownLatch(1);
final class MyDownloadListener implements DownloadListener {
public String url;
@@ -1979,6 +2186,9 @@
@UiThreadTest
public void testSetLayoutParams() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(600, 800);
mWebView.setLayoutParams(params);
assertSame(params, mWebView.getLayoutParams());
@@ -1986,10 +2196,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);
@@ -2020,6 +2236,9 @@
}
public void testSetWebChromeClient() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
final class MockWebChromeClient extends WaitForProgressClient {
private boolean mOnProgressChanged = false;
@@ -2057,6 +2276,9 @@
}
public void testPauseResumeTimers() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
class Monitor {
private boolean mIsUpdated;
@@ -2112,6 +2334,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);
@@ -2123,6 +2348,9 @@
// verify anchors work correctly for android asset files
public void testAndroidAssetAnchor() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
WebSettings settings = mOnUiThread.getSettings();
settings.setJavaScriptEnabled(true);
@@ -2133,6 +2361,9 @@
}
public void testEvaluateJavascript() {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
mOnUiThread.getSettings().setJavaScriptEnabled(true);
mOnUiThread.loadUrlAndWaitForCompletion("about:blank");
@@ -2156,6 +2387,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();
diff --git a/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java b/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java
index 758afd7..b3c0915 100644
--- a/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java
@@ -23,6 +23,7 @@
import android.view.InflateException;
import android.view.View;
import android.view.ViewGroup;
+import android.webkit.cts.NullWebViewUtils;
import android.widget.RemoteViews;
import com.android.cts.stub.R;
@@ -96,6 +97,9 @@
@MediumTest
public void testWebView() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
RemoteViews orig = new RemoteViews(PACKAGE_NAME, R.layout.remote_view_test_bad_2);
Parcel p = Parcel.obtain();
orig.writeToParcel(p, 0);
diff --git a/tools/tradefed-host/res/report/cts_result.xsl b/tools/tradefed-host/res/report/cts_result.xsl
index 2d8bb50..fe49308 100644
--- a/tools/tradefed-host/res/report/cts_result.xsl
+++ b/tools/tradefed-host/res/report/cts_result.xsl
@@ -538,15 +538,7 @@
<xsl:value-of select="@result"/>
</div>
</TD>
- <TD class="failuredetails">
- <div class="details">
- <ul>
- <xsl:for-each select="Details/ValueArray/Value">
- <li><xsl:value-of select="."/></li>
- </xsl:for-each>
- </ul>
- </div>
- </TD>
+ <TD class="failuredetails"/>
</xsl:if>
<xsl:if test="@result='fail'">