Merge "Move accessibility CTS tests to UiAutomation and fixing all broken ones." into jb-mr2-dev
diff --git a/tests/res/values-v18/strings.xml b/tests/res/values-v18/strings.xml
index 0b84d5e..d03c5cb 100644
--- a/tests/res/values-v18/strings.xml
+++ b/tests/res/values-v18/strings.xml
@@ -16,5 +16,4 @@
 
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="version_cur">v18cur</string>
-   <string name="version_old">v18old</string>
 </resources>
diff --git a/tests/res/values-v19/strings.xml b/tests/res/values-v19/strings.xml
new file mode 100644
index 0000000..833ca08
--- /dev/null
+++ b/tests/res/values-v19/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+   <string name="version_cur">v19cur</string>
+</resources>
diff --git a/tests/res/values-v20/strings.xml b/tests/res/values-v20/strings.xml
new file mode 100644
index 0000000..f47207a
--- /dev/null
+++ b/tests/res/values-v20/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+   <string name="version_cur">v20cur</string>
+</resources>
diff --git a/tests/res/values-v21/strings.xml b/tests/res/values-v21/strings.xml
new file mode 100644
index 0000000..ac8f8a7
--- /dev/null
+++ b/tests/res/values-v21/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+   <string name="version_cur">v21cur</string>
+</resources>
diff --git a/tests/res/values-v22/strings.xml b/tests/res/values-v22/strings.xml
new file mode 100644
index 0000000..6b51a01
--- /dev/null
+++ b/tests/res/values-v22/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+   <string name="version_cur">v22cur</string>
+</resources>
diff --git a/tests/src/android/renderscript/cts/global_sync.rs b/tests/src/android/renderscript/cts/global_sync.rs
index c947fa2..e384143 100644
--- a/tests/src/android/renderscript/cts/global_sync.rs
+++ b/tests/src/android/renderscript/cts/global_sync.rs
@@ -6,18 +6,26 @@
 
 rs_allocation aFailed;
 
-void test_global(int expected) {
+void test_read_global(int expected) {
     if (gInt != expected) {
         rsSetElementAt_uchar(aFailed, 1, 0);
     }
 }
 
-void test_static_global(int expected) {
+void test_read_static_global(int expected) {
     if (sInt != expected) {
         rsSetElementAt_uchar(aFailed, 1, 0);
     }
 }
 
+void test_write_global(int i) {
+    gInt = i;
+}
+
+void test_write_static_global(int i) {
+    sInt = i;
+}
+
 void __attribute__((kernel)) write_global(int ain, uint32_t x) {
     if (x == 0) {
         gInt = ain;
@@ -30,3 +38,16 @@
     }
 }
 
+int __attribute__((kernel)) read_global(int ain, uint32_t x) {
+    if (gInt != ain) {
+        return 1;
+    }
+    return 0;
+}
+
+int __attribute__((kernel)) read_static_global(int ain, uint32_t x) {
+    if (sInt != ain) {
+        return 1;
+    }
+    return 0;
+}
diff --git a/tests/src/android/renderscript/cts/sample.rs b/tests/src/android/renderscript/cts/sample.rs
index 3fecf3c..7a8d5bb 100644
--- a/tests/src/android/renderscript/cts/sample.rs
+++ b/tests/src/android/renderscript/cts/sample.rs
@@ -73,7 +73,7 @@
 
     result = rsSample(alloc1D, gMipLinear, location, lod);
     _RS_ASSERT(compare(expected3, result));
-    return failed;
+    return !failed;
 }
 
 static bool sub_test_RGBA_2D(rs_allocation alloc2D, float2 location, float lod,
@@ -90,17 +90,17 @@
 
     result = rsSample(alloc2D, gMipLinear, location, lod);
     _RS_ASSERT(compare(expected3, result));
-    return failed;
+    return !failed;
 }
 
 void test_RGBA(rs_allocation alloc1D, rs_allocation alloc2D) {
     bool failed = false;
     float4 result;
 
-    float4 fLOD0 = convert_float4(lod0Color);
-    float4 fLOD1 = convert_float4(lod1Color);
-    float4 fLOD2 = convert_float4(lod2Color);
-    float4 fLOD3 = convert_float4(lod3Color);
+    float4 fLOD0 = rsUnpackColor8888(lod0Color);
+    float4 fLOD1 = rsUnpackColor8888(lod1Color);
+    float4 fLOD2 = rsUnpackColor8888(lod2Color);
+    float4 fLOD3 = rsUnpackColor8888(lod3Color);
 
     float4 fLOD04 = fLOD0*0.6f + fLOD1*0.4f;
     float4 fLOD06 = fLOD0*0.4f + fLOD1*0.6f;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
index f895661..c446ba1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
@@ -40,20 +40,19 @@
         int [] In = new int [1];
         In[0] = v;
         AIn.copyFrom(In);
-
     }
 
     /**
      * Test whether we are properly synchronizing extern global data
-     * when dealing with mixed kernels/invokables.
+     * when going from kernel to invokable.
      */
-    public void testGlobalSync() {
+    public void testKIGlobalSync() {
         ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
 
         int v = 7;
         setupGlobalSync(mRS, gs, v);
         gs.forEach_write_global(AIn);
-        gs.invoke_test_global(v);
+        gs.invoke_test_read_global(v);
 
         AFailed.copyTo(Failed);
         if (Failed[0] != 0) {
@@ -66,15 +65,57 @@
 
     /**
      * Test whether we are properly synchronizing static global data
-     * when dealing with mixed kernels/invokables.
+     * when going from invokable to kernel.
      */
-    public void testStaticGlobalSync() {
+    public void testKIStaticGlobalSync() {
         ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
 
         int v = 9;
         setupGlobalSync(mRS, gs, v);
         gs.forEach_write_static_global(AIn);
-        gs.invoke_test_static_global(v);
+        gs.invoke_test_read_static_global(v);
+
+        AFailed.copyTo(Failed);
+        if (Failed[0] != 0) {
+            FoundError = true;
+        }
+
+        gs.destroy();
+        checkForErrors();
+    }
+
+    /**
+     * Test whether we are properly synchronizing extern global data
+     * when going from invokable to kernel.
+     */
+    public void testIKGlobalSync() {
+        ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
+
+        int v = 7;
+        setupGlobalSync(mRS, gs, v);
+        gs.invoke_test_write_global(v);
+        gs.forEach_read_global(AIn, AFailed);
+
+        AFailed.copyTo(Failed);
+        if (Failed[0] != 0) {
+            FoundError = true;
+        }
+
+        gs.destroy();
+        checkForErrors();
+    }
+
+    /**
+     * Test whether we are properly synchronizing static global data
+     * when going from kernel to invokable.
+     */
+    public void testIKStaticGlobalSync() {
+        ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
+
+        int v = 9;
+        setupGlobalSync(mRS, gs, v);
+        gs.invoke_test_write_static_global(v);
+        gs.forEach_read_static_global(AIn, AFailed);
 
         AFailed.copyTo(Failed);
         if (Failed[0] != 0) {
@@ -85,4 +126,3 @@
         checkForErrors();
     }
 }
-
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
index 75fc599..3c8650d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
@@ -71,6 +71,9 @@
 
     public void testNearest() {
         mScript.invoke_test_RGBA(mAlloc_RGBA_1D, mAlloc_RGBA_2D);
+        mRS.finish();
+        checkForErrors();
+        waitForMessage();
     }
 }
 
diff --git a/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java b/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java
index 1dafd3b..820bc79 100644
--- a/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/GeolocationTest.java
@@ -64,7 +64,7 @@
 
     private static final String JS_INTERFACE_NAME = "Android";
     private static final int POLLING_TIMEOUT = 60 * 1000;
-    private static final String PROVIDER_NAME = "WebKitGeolocationTestLocationProvider";
+    private static final String PROVIDER_NAME = LocationManager.NETWORK_PROVIDER;
 
     // static HTML page always injected instead of the url loaded
     private static final String RAW_HTML =