Merge "Fix testHtmlEncode"
diff --git a/tests/src/android/renderscript/cts/fe_all.rs b/tests/src/android/renderscript/cts/fe_all.rs
new file mode 100644
index 0000000..419d3d5
--- /dev/null
+++ b/tests/src/android/renderscript/cts/fe_all.rs
@@ -0,0 +1,174 @@
+#pragma version(1)
+#pragma rs java_package_name(android.renderscript.cts)
+
+void test_i8(const char *ain, uchar *aout) {
+    aout[0] = ain[0] + 1;
+    return;
+}
+
+void test_i8_2(const char2 *ain, uchar2 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    return;
+}
+
+void test_i8_3(const char3 *ain, uchar3 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    return;
+}
+
+void test_i8_4(const char4 *ain, uchar4 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    aout[0].w = ain[0].w + 1;
+    return;
+}
+
+void test_i16(const short *ain, ushort *aout) {
+    aout[0] = ain[0] + 1;
+    return;
+}
+
+void test_i16_2(const short2 *ain, ushort2 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    return;
+}
+
+void test_i16_3(const short3 *ain, ushort3 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    return;
+}
+
+void test_i16_4(const short4 *ain, ushort4 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    aout[0].w = ain[0].w + 1;
+    return;
+}
+
+void test_i32(const int *ain, uint *aout) {
+    aout[0] = ain[0] + 1;
+    return;
+}
+
+void test_i32_2(const int2 *ain, uint2 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    return;
+}
+
+void test_i32_3(const int3 *ain, uint3 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    return;
+}
+
+void test_i32_4(const int4 *ain, uint4 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    aout[0].w = ain[0].w + 1;
+    return;
+}
+
+void test_i64(const long *ain, ulong *aout) {
+    aout[0] = ain[0] + 1;
+    return;
+}
+
+void test_i64_2(const long2 *ain, ulong2 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    return;
+}
+
+void test_i64_3(const long3 *ain, ulong3 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    return;
+}
+
+void test_i64_4(const long4 *ain, ulong4 *aout) {
+    aout[0].x = ain[0].x + 1;
+    aout[0].y = ain[0].y + 1;
+    aout[0].z = ain[0].z + 1;
+    aout[0].w = ain[0].w + 1;
+    return;
+}
+
+void test_f32(const float *ain, float *aout) {
+    aout[0] = ain[0] + 1.0f;
+    return;
+}
+
+void test_f32_2(const float2 *ain, float2 *aout) {
+    aout[0].x = ain[0].x + 1.0f;
+    aout[0].y = ain[0].y + 1.0f;
+    return;
+}
+
+void test_f32_3(const float3 *ain, float3 *aout) {
+    aout[0].x = ain[0].x + 1.0f;
+    aout[0].y = ain[0].y + 1.0f;
+    aout[0].z = ain[0].z + 1.0f;
+    return;
+}
+
+void test_f32_4(const float4 *ain, float4 *aout) {
+    aout[0].x = ain[0].x + 1.0f;
+    aout[0].y = ain[0].y + 1.0f;
+    aout[0].z = ain[0].z + 1.0f;
+    aout[0].w = ain[0].w + 1.0f;
+    return;
+}
+
+void test_f64(const double *ain, double *aout) {
+    aout[0] = ain[0] + 1.0;
+    return;
+}
+
+void test_f64_2(const double2 *ain, double2 *aout) {
+    aout[0].x = ain[0].x + 1.0;
+    aout[0].y = ain[0].y + 1.0;
+    return;
+}
+
+void test_f64_3(const double3 *ain, double3 *aout) {
+    aout[0].x = ain[0].x + 1.0;
+    aout[0].y = ain[0].y + 1.0;
+    aout[0].z = ain[0].z + 1.0;
+    return;
+}
+
+void test_f64_4(const double4 *ain, double4 *aout) {
+    aout[0].x = ain[0].x + 1.0;
+    aout[0].y = ain[0].y + 1.0;
+    aout[0].z = ain[0].z + 1.0;
+    aout[0].w = ain[0].w + 1.0;
+    return;
+}
+
+struct fe_test {
+    int i;
+    float f;
+};
+
+void test_struct(const struct fe_test *ain, struct fe_test *aout) {
+    aout[0].i = ain[0].i + 1;
+    aout[0].f = ain[0].f + 1.0f;
+    return;
+}
+
+void test_bool(const bool *ain, bool *aout) {
+    aout[0] = !ain[0];
+    return;
+}
diff --git a/tests/src/android/renderscript/cts/fe_bool.rs b/tests/src/android/renderscript/cts/fe_bool.rs
deleted file mode 100644
index 727635a..0000000
--- a/tests/src/android/renderscript/cts/fe_bool.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const bool *ain, bool *aout) {
-    aout[0] = !ain[0];
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f32.rs b/tests/src/android/renderscript/cts/fe_f32.rs
deleted file mode 100644
index 3c649e2..0000000
--- a/tests/src/android/renderscript/cts/fe_f32.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const float *ain, float *aout) {
-    aout[0] = ain[0] + 1.0f;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f32_2.rs b/tests/src/android/renderscript/cts/fe_f32_2.rs
deleted file mode 100644
index 571100b..0000000
--- a/tests/src/android/renderscript/cts/fe_f32_2.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const float2 *ain, float2 *aout) {
-    aout[0].x = ain[0].x + 1.0f;
-    aout[0].y = ain[0].y + 1.0f;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f32_3.rs b/tests/src/android/renderscript/cts/fe_f32_3.rs
deleted file mode 100644
index 1df67a7..0000000
--- a/tests/src/android/renderscript/cts/fe_f32_3.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const float3 *ain, float3 *aout) {
-    aout[0].x = ain[0].x + 1.0f;
-    aout[0].y = ain[0].y + 1.0f;
-    aout[0].z = ain[0].z + 1.0f;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f32_4.rs b/tests/src/android/renderscript/cts/fe_f32_4.rs
deleted file mode 100644
index 50a50ec..0000000
--- a/tests/src/android/renderscript/cts/fe_f32_4.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const float4 *ain, float4 *aout) {
-    aout[0].x = ain[0].x + 1.0f;
-    aout[0].y = ain[0].y + 1.0f;
-    aout[0].z = ain[0].z + 1.0f;
-    aout[0].w = ain[0].w + 1.0f;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f64.rs b/tests/src/android/renderscript/cts/fe_f64.rs
deleted file mode 100644
index b609a08..0000000
--- a/tests/src/android/renderscript/cts/fe_f64.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const double *ain, double *aout) {
-    aout[0] = ain[0] + 1.0;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f64_2.rs b/tests/src/android/renderscript/cts/fe_f64_2.rs
deleted file mode 100644
index a97628b..0000000
--- a/tests/src/android/renderscript/cts/fe_f64_2.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const double2 *ain, double2 *aout) {
-    aout[0].x = ain[0].x + 1.0;
-    aout[0].y = ain[0].y + 1.0;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f64_3.rs b/tests/src/android/renderscript/cts/fe_f64_3.rs
deleted file mode 100644
index b6e97b8..0000000
--- a/tests/src/android/renderscript/cts/fe_f64_3.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const double3 *ain, double3 *aout) {
-    aout[0].x = ain[0].x + 1.0;
-    aout[0].y = ain[0].y + 1.0;
-    aout[0].z = ain[0].z + 1.0;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_f64_4.rs b/tests/src/android/renderscript/cts/fe_f64_4.rs
deleted file mode 100644
index 959c30b..0000000
--- a/tests/src/android/renderscript/cts/fe_f64_4.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const double4 *ain, double4 *aout) {
-    aout[0].x = ain[0].x + 1.0;
-    aout[0].y = ain[0].y + 1.0;
-    aout[0].z = ain[0].z + 1.0;
-    aout[0].w = ain[0].w + 1.0;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i16.rs b/tests/src/android/renderscript/cts/fe_i16.rs
deleted file mode 100644
index e45a0a8..0000000
--- a/tests/src/android/renderscript/cts/fe_i16.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const short *ain, ushort *aout) {
-    aout[0] = ain[0] + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i16_2.rs b/tests/src/android/renderscript/cts/fe_i16_2.rs
deleted file mode 100644
index 8eb8245..0000000
--- a/tests/src/android/renderscript/cts/fe_i16_2.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const short2 *ain, ushort2 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i16_3.rs b/tests/src/android/renderscript/cts/fe_i16_3.rs
deleted file mode 100644
index 09113a5..0000000
--- a/tests/src/android/renderscript/cts/fe_i16_3.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const short3 *ain, ushort3 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i16_4.rs b/tests/src/android/renderscript/cts/fe_i16_4.rs
deleted file mode 100644
index 4a5ca2c..0000000
--- a/tests/src/android/renderscript/cts/fe_i16_4.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const short4 *ain, ushort4 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    aout[0].w = ain[0].w + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i32.rs b/tests/src/android/renderscript/cts/fe_i32.rs
deleted file mode 100644
index 402a1f7..0000000
--- a/tests/src/android/renderscript/cts/fe_i32.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const int *ain, uint *aout) {
-    aout[0] = ain[0] + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i32_2.rs b/tests/src/android/renderscript/cts/fe_i32_2.rs
deleted file mode 100644
index bff5460..0000000
--- a/tests/src/android/renderscript/cts/fe_i32_2.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const int2 *ain, uint2 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i32_3.rs b/tests/src/android/renderscript/cts/fe_i32_3.rs
deleted file mode 100644
index ce666c0..0000000
--- a/tests/src/android/renderscript/cts/fe_i32_3.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const int3 *ain, uint3 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i32_4.rs b/tests/src/android/renderscript/cts/fe_i32_4.rs
deleted file mode 100644
index ab66082..0000000
--- a/tests/src/android/renderscript/cts/fe_i32_4.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const int4 *ain, uint4 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    aout[0].w = ain[0].w + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i64.rs b/tests/src/android/renderscript/cts/fe_i64.rs
deleted file mode 100644
index 352a48e..0000000
--- a/tests/src/android/renderscript/cts/fe_i64.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const long *ain, ulong *aout) {
-    aout[0] = ain[0] + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i64_2.rs b/tests/src/android/renderscript/cts/fe_i64_2.rs
deleted file mode 100644
index f39531d..0000000
--- a/tests/src/android/renderscript/cts/fe_i64_2.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const long2 *ain, ulong2 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i64_3.rs b/tests/src/android/renderscript/cts/fe_i64_3.rs
deleted file mode 100644
index 1229137..0000000
--- a/tests/src/android/renderscript/cts/fe_i64_3.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const long3 *ain, ulong3 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i64_4.rs b/tests/src/android/renderscript/cts/fe_i64_4.rs
deleted file mode 100644
index 5e2b2ae..0000000
--- a/tests/src/android/renderscript/cts/fe_i64_4.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const long4 *ain, ulong4 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    aout[0].w = ain[0].w + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i8.rs b/tests/src/android/renderscript/cts/fe_i8.rs
deleted file mode 100644
index 067ef50..0000000
--- a/tests/src/android/renderscript/cts/fe_i8.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const char *ain, uchar *aout) {
-    aout[0] = ain[0] + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i8_2.rs b/tests/src/android/renderscript/cts/fe_i8_2.rs
deleted file mode 100644
index cec1f57..0000000
--- a/tests/src/android/renderscript/cts/fe_i8_2.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const char2 *ain, uchar2 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i8_3.rs b/tests/src/android/renderscript/cts/fe_i8_3.rs
deleted file mode 100644
index 9254ba5..0000000
--- a/tests/src/android/renderscript/cts/fe_i8_3.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const char3 *ain, uchar3 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_i8_4.rs b/tests/src/android/renderscript/cts/fe_i8_4.rs
deleted file mode 100644
index 0c1fd1d..0000000
--- a/tests/src/android/renderscript/cts/fe_i8_4.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-void root(const char4 *ain, uchar4 *aout) {
-    aout[0].x = ain[0].x + 1;
-    aout[0].y = ain[0].y + 1;
-    aout[0].z = ain[0].z + 1;
-    aout[0].w = ain[0].w + 1;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/fe_struct.rs b/tests/src/android/renderscript/cts/fe_struct.rs
deleted file mode 100644
index b22604d..0000000
--- a/tests/src/android/renderscript/cts/fe_struct.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscript.cts)
-
-struct fe_test {
-    int i;
-    float f;
-};
-
-void root(const struct fe_test *ain, struct fe_test *aout) {
-    aout[0].i = ain[0].i + 1;
-    aout[0].f = ain[0].f + 1.0f;
-    return;
-}
diff --git a/tests/src/android/renderscript/cts/foreach.rs b/tests/src/android/renderscript/cts/foreach.rs
new file mode 100644
index 0000000..ac527b5
--- /dev/null
+++ b/tests/src/android/renderscript/cts/foreach.rs
@@ -0,0 +1,74 @@
+#include "shared.rsh"
+
+int *a;
+int dimX;
+int dimY;
+static bool failed = false;
+
+void root(int *out, uint32_t x, uint32_t y) {
+    *out = x + y * dimX;
+}
+
+void foo(const int *in, int *out, uint32_t x, uint32_t y) {
+    _RS_ASSERT(*in == (x + y * dimX));
+    *out = 99 + x + y * dimX;
+    _RS_ASSERT(*out == (99 + x + y * dimX));
+}
+
+static bool test_root_output() {
+    bool failed = false;
+    int i, j;
+
+    for (j = 0; j < dimY; j++) {
+        for (i = 0; i < dimX; i++) {
+            _RS_ASSERT(a[i + j * dimX] == (i + j * dimX));
+        }
+    }
+
+    if (failed) {
+        rsDebug("test_root_output FAILED", 0);
+    }
+    else {
+        rsDebug("test_root_output PASSED", 0);
+    }
+
+    return failed;
+}
+
+static bool test_foo_output() {
+    bool failed = false;
+    int i, j;
+
+    for (j = 0; j < dimY; j++) {
+        for (i = 0; i < dimX; i++) {
+            _RS_ASSERT(a[i + j * dimX] == (99 + i + j * dimX));
+        }
+    }
+
+    if (failed) {
+        rsDebug("test_foo_output FAILED", 0);
+    }
+    else {
+        rsDebug("test_foo_output PASSED", 0);
+    }
+
+    return failed;
+}
+
+void verify_root() {
+    failed |= test_root_output();
+}
+
+void verify_foo() {
+    failed |= test_foo_output();
+}
+
+void foreach_test() {
+    if (failed) {
+        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+    }
+    else {
+        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+    }
+}
+
diff --git a/tests/src/android/renderscript/cts/noroot.rs b/tests/src/android/renderscript/cts/noroot.rs
new file mode 100644
index 0000000..33944aa
--- /dev/null
+++ b/tests/src/android/renderscript/cts/noroot.rs
@@ -0,0 +1,44 @@
+#include "shared.rsh"
+
+int *a;
+int dimX;
+int dimY;
+static bool failed = false;
+
+void foo(const int *in, int *out, uint32_t x, uint32_t y) {
+    *out = 99 + x + y * dimX;
+}
+
+static bool test_foo_output() {
+    bool failed = false;
+    int i, j;
+
+    for (j = 0; j < dimY; j++) {
+        for (i = 0; i < dimX; i++) {
+            _RS_ASSERT(a[i + j * dimX] == (99 + i + j * dimX));
+        }
+    }
+
+    if (failed) {
+        rsDebug("test_foo_output FAILED", 0);
+    }
+    else {
+        rsDebug("test_foo_output PASSED", 0);
+    }
+
+    return failed;
+}
+
+void verify_foo() {
+    failed |= test_foo_output();
+}
+
+void noroot_test() {
+    if (failed) {
+        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+    }
+    else {
+        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+    }
+}
+
diff --git a/tests/tests/drm/src/android/drm/cts/DrmEventTest.java b/tests/tests/drm/src/android/drm/cts/DrmEventTest.java
new file mode 100644
index 0000000..f5b13dd
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/DrmEventTest.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2012 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.drm.cts;
+
+import java.util.HashMap;
+import android.util.Log;
+import android.test.AndroidTestCase;
+import android.drm.DrmEvent;
+import android.drm.DrmInfoEvent;
+import android.drm.DrmErrorEvent;
+
+public class DrmEventTest extends AndroidTestCase {
+    private static String TAG = "CtsDrmEventTest";
+
+    public static void testGetAttribute() throws Exception {
+        HashMap<String, Object> attributes = new HashMap<String, Object>(3);
+        attributes.put("Hello World", attributes);
+        attributes.put("Hello", "World");
+        attributes.put("World", "");
+        checkGetAttribute(null, "NotNull");
+        checkGetAttribute(null, null);
+        checkGetAttribute(attributes, null);
+        checkGetAttribute(attributes, "");
+        checkGetAttribute(attributes, "Hello");
+        checkGetAttribute(attributes, "World");
+        checkGetAttribute(attributes, "Hello World");
+    }
+
+    public static void testGetMessage() throws Exception {
+        checkGetMessage(null);
+        checkGetMessage("");
+        checkGetMessage("Hello World");
+    }
+
+    public static void testGetUniqueId() throws Exception {
+        checkGetUniqueId(-1);
+        checkGetUniqueId(0);
+        checkGetUniqueId(1);
+    }
+
+    public static void testValidErrorEventTypes() throws Exception {
+        checkValidErrorType(DrmErrorEvent.TYPE_RIGHTS_NOT_INSTALLED);
+
+        checkValidErrorType(
+                DrmErrorEvent.TYPE_RIGHTS_RENEWAL_NOT_ALLOWED);
+
+        checkValidErrorType(DrmErrorEvent.TYPE_NOT_SUPPORTED);
+        checkValidErrorType(DrmErrorEvent.TYPE_OUT_OF_MEMORY);
+        checkValidErrorType(DrmErrorEvent.TYPE_NO_INTERNET_CONNECTION);
+        checkValidErrorType(DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED);
+        checkValidErrorType(DrmErrorEvent.TYPE_REMOVE_ALL_RIGHTS_FAILED);
+        checkValidErrorType(DrmErrorEvent.TYPE_ACQUIRE_DRM_INFO_FAILED);
+    }
+
+    public static void testValidInfoEventTypes() throws Exception {
+        checkValidInfoType(
+                DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT);
+
+        checkValidInfoType(DrmInfoEvent.TYPE_REMOVE_RIGHTS);
+        checkValidInfoType(DrmInfoEvent.TYPE_RIGHTS_INSTALLED);
+        checkValidInfoType(DrmInfoEvent.TYPE_WAIT_FOR_RIGHTS);
+
+        checkValidInfoType(
+                DrmInfoEvent.TYPE_ACCOUNT_ALREADY_REGISTERED);
+
+        checkValidInfoType(DrmInfoEvent.TYPE_RIGHTS_REMOVED);
+
+
+        // DrmEvent should be just DrmInfoEvent
+        checkValidInfoType(DrmEvent.TYPE_ALL_RIGHTS_REMOVED);
+        checkValidInfoType(DrmEvent.TYPE_DRM_INFO_PROCESSED);
+
+    }
+
+    public static void testInvalidErrorEventTypes() throws Exception {
+        checkInfoTypeInErrorEvent(
+                DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT);
+
+        checkInfoTypeInErrorEvent(DrmInfoEvent.TYPE_REMOVE_RIGHTS);
+        checkInfoTypeInErrorEvent(DrmInfoEvent.TYPE_RIGHTS_INSTALLED);
+        checkInfoTypeInErrorEvent(DrmInfoEvent.TYPE_WAIT_FOR_RIGHTS);
+
+        checkInfoTypeInErrorEvent(
+                DrmInfoEvent.TYPE_ACCOUNT_ALREADY_REGISTERED);
+
+        checkInfoTypeInErrorEvent(DrmInfoEvent.TYPE_RIGHTS_REMOVED);
+
+
+        // DrmEvent should be just DrmInfoEvent
+        checkInfoTypeInErrorEvent(DrmEvent.TYPE_ALL_RIGHTS_REMOVED);
+        checkInfoTypeInErrorEvent(DrmEvent.TYPE_DRM_INFO_PROCESSED);
+    }
+
+    public static void testInvalidInfoEventTypes() throws Exception {
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_RIGHTS_NOT_INSTALLED);
+
+        checkErrorTypeInInfoEvent(
+                DrmErrorEvent.TYPE_RIGHTS_RENEWAL_NOT_ALLOWED);
+
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_NOT_SUPPORTED);
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_OUT_OF_MEMORY);
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_NO_INTERNET_CONNECTION);
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED);
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_REMOVE_ALL_RIGHTS_FAILED);
+        checkErrorTypeInInfoEvent(DrmErrorEvent.TYPE_ACQUIRE_DRM_INFO_FAILED);
+    }
+
+    private static void checkGetAttribute(
+        HashMap<String, Object> attributes, String key) throws Exception {
+        DrmInfoEvent infoEvent = new DrmInfoEvent(
+                0, DrmInfoEvent.TYPE_RIGHTS_INSTALLED, "", attributes);
+
+        if (attributes == null) {
+            assertNull(infoEvent.getAttribute(key));
+        } else {
+            assertEquals(infoEvent.getAttribute(key), attributes.get(key));
+        }
+    }
+
+    private static void checkGetUniqueId(int id) throws Exception {
+        DrmInfoEvent infoEvent = new DrmInfoEvent(
+                id, DrmInfoEvent.TYPE_RIGHTS_INSTALLED, "");
+
+        assertEquals(infoEvent.getUniqueId(), id);
+    }
+
+    private static void checkGetMessage(String msg) throws Exception {
+        DrmInfoEvent infoEvent = new DrmInfoEvent(0,
+                DrmInfoEvent.TYPE_RIGHTS_INSTALLED, msg);
+
+        if (msg == null) {
+            assertNotNull(infoEvent.getMessage());
+        } else {
+            assertEquals(infoEvent.getMessage(), msg);
+        }
+    }
+
+    private static void checkValidInfoType(int type) throws Exception {
+        DrmInfoEvent infoEvent = new DrmInfoEvent(0, type, "");
+        assertEquals(infoEvent.getType(), type);
+    }
+
+    private static void checkValidErrorType(int type) throws Exception {
+        DrmErrorEvent errEvent = new DrmErrorEvent(0, type, "");
+        assertEquals(errEvent.getType(), type);
+    }
+
+    private static void checkInfoTypeInErrorEvent(int type) throws Exception {
+        try {
+            DrmErrorEvent errEvent = new DrmErrorEvent(0, type, "");
+            fail("Info type accepted for DrmErrorEvent: " + type);
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored
+        }
+
+        try {
+            DrmErrorEvent errEvent = new DrmErrorEvent(0, type, "", null);
+            fail("Info type accepted for DrmErrorEvent: " + type);
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored
+        }
+    }
+
+    private static void checkErrorTypeInInfoEvent(int type) throws Exception {
+        try {
+            DrmInfoEvent infoEvent = new DrmInfoEvent(0, type, "");
+            fail("Error type accepted for DrmInfoEvent: " + type);
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored
+        }
+
+        try {
+            DrmInfoEvent infoEvent = new DrmInfoEvent(0, type, "", null);
+            fail("Error type accepted for DrmInfoEvent: " + type);
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored
+        }
+
+        /*
+         * We could not do the following because the existing
+         * public API has design flaws.
+         *
+        try {
+            DrmEvent event = new DrmEvent(id, type, msg);
+            fail("Error type accepted for DrmEvent: " + type);
+        } catch(IllegalArgumentException iae) {
+            // intentionally ignored
+        }
+
+        */
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/DrmInfoRequestTest.java b/tests/tests/drm/src/android/drm/cts/DrmInfoRequestTest.java
new file mode 100644
index 0000000..0ec8d49
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/DrmInfoRequestTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2012 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.drm.cts;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import android.util.Log;
+import android.test.AndroidTestCase;
+import android.drm.DrmInfoRequest;
+
+public class DrmInfoRequestTest extends AndroidTestCase {
+    private static final String TAG = "CtsDrmInfoRequestTest";
+    private static final String DEFAULT_MIME = "video/";
+    private static final int DEFAULT_TYPE =
+            DrmInfoRequest.TYPE_REGISTRATION_INFO;
+
+    public static void testInvalidInfoTypes() throws Exception {
+        checkInvalidInfoType(DrmInfoRequest.TYPE_REGISTRATION_INFO - 1);
+        checkInvalidInfoType(
+                DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO + 1);
+    }
+
+    public static void testValidInfoTypes() throws Exception {
+        checkValidInfoType(DrmInfoRequest.TYPE_REGISTRATION_INFO);
+        checkValidInfoType(DrmInfoRequest.TYPE_UNREGISTRATION_INFO);
+        checkValidInfoType(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO);
+        checkValidInfoType(
+                DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO);
+    }
+
+    public static void testGetInfoType() throws Exception {
+        checkGetInfoType(DrmInfoRequest.TYPE_REGISTRATION_INFO);
+        checkGetInfoType(DrmInfoRequest.TYPE_UNREGISTRATION_INFO);
+        checkGetInfoType(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO);
+        checkGetInfoType(
+                DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO);
+    }
+
+    public static void testInvalidMimeTypes() throws Exception {
+        checkInvalidMimeType("");
+        checkInvalidMimeType(null);
+    }
+
+    public static void testGetMimeType() throws Exception {
+        checkGetMimeType("Hello");
+        checkGetMimeType("World");
+        checkGetMimeType("Hello World");
+    }
+
+    public static void testPutAndGetKeys() throws Exception {
+        HashMap<String, Object> attributes = new HashMap<String, Object>(3);
+        attributes.put("Hello", "");
+        attributes.put("World", null);
+        attributes.put("Hello World", "Hello World");
+
+        // Store all the attributes in DrmInfoRequest object request.
+        DrmInfoRequest request = new DrmInfoRequest(DEFAULT_TYPE, DEFAULT_MIME);
+        Iterator<String> keys = attributes.keySet().iterator();
+        while (keys.hasNext()) {
+            final String key = (String) keys.next();
+            request.put(key, attributes.get(key));
+        }
+
+        // Request object must have all the keys that attributes does.
+        Iterator<String> infoKeys = request.keyIterator();
+        while (keys.hasNext()) {
+            final String key = (String) keys.next();
+            assertEquals(request.get(key), attributes.get(key));
+        }
+
+        // Attributes object must have all the keys that request does.
+        while (infoKeys.hasNext()) {
+            final String key = (String) infoKeys.next();
+            assertEquals(request.get(key), attributes.get(key));
+        }
+    }
+
+    private static void checkInvalidMimeType(String mimeType) throws Exception {
+        try {
+            DrmInfoRequest request = new DrmInfoRequest(DEFAULT_TYPE, mimeType);
+            fail("Mime type " + mimeType + " was accepted for DrmInfoRequest");
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored.
+        }
+    }
+
+    private static void checkGetMimeType(String mimeType) throws Exception {
+        DrmInfoRequest request = new DrmInfoRequest(DEFAULT_TYPE, mimeType);
+        assertEquals(request.getMimeType(),  mimeType);
+    }
+
+    private static void checkGetInfoType(int type) throws Exception {
+        DrmInfoRequest request = new DrmInfoRequest(type, DEFAULT_MIME);
+        assertEquals(request.getInfoType(), type);
+    }
+
+    private static void checkInvalidInfoType(int type) throws Exception {
+        try {
+            DrmInfoRequest request = new DrmInfoRequest(type, DEFAULT_MIME);
+            fail("Info type " + type + " was accepted for DrmInfoRequest");
+        } catch(IllegalArgumentException e) {
+            // Expected, and thus intentionally ignored.
+        }
+    }
+
+    private static void checkValidInfoType(int type) throws Exception {
+        DrmInfoRequest request = new DrmInfoRequest(type, DEFAULT_MIME);
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java b/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java
new file mode 100644
index 0000000..ab0d4a5
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2012 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.drm.cts;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import android.util.Log;
+import android.test.AndroidTestCase;
+import android.drm.DrmInfo;
+import android.drm.DrmInfoRequest;
+
+public class DrmInfoTest extends AndroidTestCase {
+    private static final String TAG = "CtsDrmInfoTest";
+    private static final byte[] DEFAULT_DATA = new byte[1];
+    private static final String DEFAULT_MIME = "video/";
+    private static final int DEFAULT_TYPE =
+            DrmInfoRequest.TYPE_REGISTRATION_INFO;
+
+    public static void testInvalidInfoTypes() throws Exception {
+        checkInvalidInfoType(DrmInfoRequest.TYPE_REGISTRATION_INFO - 1);
+        checkInvalidInfoType(
+                DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO + 1);
+    }
+
+    public static void testValidInfoTypes() throws Exception {
+        checkValidInfoType(DrmInfoRequest.TYPE_REGISTRATION_INFO);
+        checkValidInfoType(DrmInfoRequest.TYPE_UNREGISTRATION_INFO);
+        checkValidInfoType(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO);
+        checkValidInfoType(
+                DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO);
+    }
+
+    public static void testGetInfoType() throws Exception {
+        checkGetInfoType(DrmInfoRequest.TYPE_REGISTRATION_INFO);
+        checkGetInfoType(DrmInfoRequest.TYPE_UNREGISTRATION_INFO);
+        checkGetInfoType(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO);
+        checkGetInfoType(
+                DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO);
+    }
+
+    public static void testInvalidMimeTypes() throws Exception {
+        checkInvalidMimeType("");
+        checkInvalidMimeType(null);
+    }
+
+    public static void testGetMimeType() throws Exception {
+        checkGetMimeType("Hello");
+        checkGetMimeType("World");
+        checkGetMimeType("Hello World");
+    }
+
+    public static void testInvalidData() throws Exception {
+        checkInvalidData(null);
+    }
+
+    public static void testGetData() throws Exception {
+        checkGetData(DEFAULT_DATA);
+    }
+
+    public static void testPutAndGetKeys() throws Exception {
+        HashMap<String, Object> attributes = new HashMap<String, Object>(3);
+        attributes.put("Hello", "");
+        attributes.put("World", null);
+        attributes.put("Hello World", "Hello World");
+
+        // Store all the attributes in DrmInfo object info.
+        DrmInfo info = new DrmInfo(DEFAULT_TYPE, DEFAULT_DATA, DEFAULT_MIME);
+        Iterator<String> keys = attributes.keySet().iterator();
+        while (keys.hasNext()) {
+            final String key = (String) keys.next();
+            info.put(key, attributes.get(key));
+        }
+
+        // info object must have all the keys that attributes does.
+        Iterator<String> infoKeys = info.keyIterator();
+        while (keys.hasNext()) {
+            final String key = (String) keys.next();
+            assertEquals(info.get(key), attributes.get(key));
+        }
+
+        // Attributes object must have all the keys that info does.
+        while (infoKeys.hasNext()) {
+            final String key = (String) infoKeys.next();
+            assertEquals(info.get(key), attributes.get(key));
+        }
+    }
+
+    private static void checkInvalidData(byte[] data) throws Exception {
+        try {
+            DrmInfo info = new DrmInfo(DEFAULT_TYPE, data, DEFAULT_MIME);
+            fail("Data " + data + " was accepted for DrmInfo");
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored.
+        }
+    }
+
+    private static void checkInvalidMimeType(String mimeType) throws Exception {
+        try {
+            DrmInfo info = new DrmInfo(DEFAULT_TYPE, DEFAULT_DATA, mimeType);
+            fail("Mime type " + mimeType + " was accepted for DrmInfo");
+        } catch(IllegalArgumentException e) {
+            // Expected and thus intentionally ignored.
+        }
+    }
+
+    private static void checkGetData(byte[] data) throws Exception {
+        DrmInfo info = new DrmInfo(DEFAULT_TYPE, data, DEFAULT_MIME);
+        assertEquals(info.getData(), data);
+    }
+
+    private static void checkGetMimeType(String mimeType) throws Exception {
+        DrmInfo info = new DrmInfo(DEFAULT_TYPE, DEFAULT_DATA, mimeType);
+        assertEquals(info.getMimeType(), mimeType);
+    }
+
+    private static void checkGetInfoType(int type) throws Exception {
+        DrmInfo info = new DrmInfo(type, DEFAULT_DATA, DEFAULT_MIME);
+        assertEquals(info.getInfoType(), type);
+    }
+
+    private static void checkInvalidInfoType(int type) throws Exception {
+        try {
+            DrmInfo info = new DrmInfo(type, DEFAULT_DATA, DEFAULT_MIME);
+            fail("Info type " + type + " was accepted for DrmInfo");
+        } catch(IllegalArgumentException e) {
+            // Expected, and thus intentionally ignored.
+        }
+    }
+
+    private static void checkValidInfoType(int type) throws Exception {
+        DrmInfo info = new DrmInfo(type, DEFAULT_DATA, DEFAULT_MIME);
+    }
+}
diff --git a/tests/tests/preference2/src/android/preference2/cts/PreferenceFromCodeActivity.java b/tests/tests/preference2/src/android/preference2/cts/PreferenceFromCodeActivity.java
index ee0dde1..94be86f 100755
--- a/tests/tests/preference2/src/android/preference2/cts/PreferenceFromCodeActivity.java
+++ b/tests/tests/preference2/src/android/preference2/cts/PreferenceFromCodeActivity.java
@@ -49,6 +49,7 @@
         //CheckBox Preference
         CheckBoxPreference checkboxPref = new CheckBoxPreference(this);
         checkboxPref.setKey("checkbox_preference");
+        checkboxPref.setIcon(R.drawable.ic_launcher);
         checkboxPref.setTitle(R.string.title_checkbox_preference);
         checkboxPref.setSummary(R.string.summary_checkbox_preference);
         checkboxPref.setSummaryOn(R.string.summary_on_checkbox_preference);
diff --git a/tests/tests/preference2/src/android/preference2/cts/PreferenceTest.java b/tests/tests/preference2/src/android/preference2/cts/PreferenceTest.java
new file mode 100755
index 0000000..ae3ef0a
--- /dev/null
+++ b/tests/tests/preference2/src/android/preference2/cts/PreferenceTest.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2012 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.preference2.cts;
+
+import android.graphics.drawable.Drawable;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.test.ActivityInstrumentationTestCase2;
+
+import com.android.cts.preference2.R;
+
+public class PreferenceTest
+        extends ActivityInstrumentationTestCase2<PreferenceFromCodeActivity> {
+
+    private PreferenceFromCodeActivity mActivity;
+    private Preference mPreference;
+
+    public PreferenceTest() {
+        super(PreferenceFromCodeActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mActivity = getActivity();
+        mPreference = (CheckBoxPreference) mActivity.findPreference(
+                "checkbox_preference");
+    }
+
+    public void testNotNull() {
+        assertNotNull(mPreference);
+    }
+
+    public void testGetSummary() {
+        String summary = (String) mPreference.getSummary();
+        String summaryExp = mActivity.getResources().getString(
+                R.string.summary_checkbox_preference);
+        assertEquals(summaryExp, summary);
+    }
+
+    public void testSetSummary() throws Throwable {
+        final String summary = "New Summary";
+        this.runTestOnUiThread(new Runnable() {
+            public void run() {
+                mPreference.setSummary(summary);
+            }
+        });
+        assertEquals(summary, mPreference.getSummary());
+    }
+
+    public void testIsEnabled() {
+        assertTrue(mPreference.isEnabled());
+    }
+
+    public void testSetEnabled() throws Throwable {
+        this.runTestOnUiThread(new Runnable() {
+            public void run() {
+                mPreference.setEnabled(false);
+            }
+        });
+        assertFalse(mPreference.isEnabled());
+    }
+
+    public void testIsPersistent() {
+        assertTrue(mPreference.isPersistent());
+    }
+
+    public void testIsSelectable() {
+        assertTrue(mPreference.isSelectable());
+    }
+
+    public void testGetTitle() {
+        CharSequence title= mPreference.getTitle();
+        String titleExp = mActivity.getResources().getString(
+                R.string.title_checkbox_preference);
+        assertEquals(titleExp, title);
+    }
+
+    public void testSetTitle() throws Throwable {
+        this.runTestOnUiThread(new Runnable() {
+            public void run() {
+                mPreference.setTitle(R.string.title_my_preference);
+            }
+        });
+        String titleExp = mActivity.getResources().getString(
+                R.string.title_my_preference);
+        String title = (String) mPreference.getTitle();
+        assertEquals(titleExp, title);
+    }
+
+    public void testHasKey() {
+        assertTrue(mPreference.hasKey());
+    }
+
+    public void testGetKey() {
+        String key = mPreference.getKey();
+        String keyExp = "checkbox_preference";
+        assertEquals(keyExp, key);
+    }
+
+    public void testSetKey() throws Throwable {
+        final String key = "key1";
+        this.runTestOnUiThread(new Runnable() {
+            public void run() {
+                mPreference.setKey(key);
+            }
+        });
+        assertEquals(key, mPreference.getKey());
+    }
+
+     public void testGetPreferenceManager() {
+        assertNotNull(mPreference.getPreferenceManager());
+    }
+
+    public void testGetSharedPreferences() {
+        assertNotNull(mPreference.getSharedPreferences());
+    }
+
+    public void testSetTitle_CharSequence() throws Throwable {
+        final CharSequence titleExp = "Test Title";
+        this.runTestOnUiThread(new Runnable() {
+            public void run() {
+                mPreference.setTitle(titleExp);
+            }
+        });
+
+        assertEquals(titleExp, mPreference.getTitle());
+    }
+
+    public void testGetContext() {
+        assertNotNull(mPreference.getContext());
+    }
+
+    public void testGetOrder() throws Throwable {
+        int order = mPreference.getOrder();
+        assertEquals(0, order);
+    }
+
+    public void testSetOrder() throws Throwable {
+        int orderExp = 1;
+        mPreference.setOrder(orderExp);
+        int order = mPreference.getOrder();
+        assertEquals(orderExp, order);
+    }
+
+    public void testGetIcon() {
+        Drawable iconExp = mActivity.getResources().getDrawable(R.drawable.ic_launcher);
+        Drawable icon = mPreference.getIcon();
+        assertEquals(iconExp.getIntrinsicHeight(), icon.getIntrinsicHeight());
+        assertEquals(iconExp.getIntrinsicWidth(), icon.getIntrinsicWidth());
+        assertEquals(iconExp.getOpacity(), icon.getOpacity());
+    }
+
+    public void testgetShouldDisableView() {
+        assertTrue(mPreference.getShouldDisableView());
+    }
+
+    public void testSetShouldDisableView() throws Throwable {
+        this.runTestOnUiThread(new Runnable() {
+            public void run() {
+                mPreference.setShouldDisableView(false);
+            }
+        });
+        assertFalse(mPreference.getShouldDisableView());
+    }
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
index a64d1d9..f633168 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 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.
@@ -61,418 +61,356 @@
         Type t = new Type.Builder(mRS, Element.I8(mRS)).setX(x).create();
         Allocation badOut = Allocation.createTyped(mRS, t);
 
+        ScriptC_fe_all fe_all = new ScriptC_fe_all(mRS, mRes, R.raw.fe_all);
+
         // I8
-        ScriptC_fe_i8 fe_i8 = new ScriptC_fe_i8(mRS, mRes, R.raw.fe_i8);
         Allocation in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U8(mRS)).setX(x).create();
         Allocation out = Allocation.createTyped(mRS, t);
-        fe_i8.forEach_root(in, out);
+        fe_all.forEach_test_i8(in, out);
         mRS.finish();
         try {
-            fe_i8.forEach_root(in, badOut);
+            fe_all.forEach_test_i8(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I8_2
-        ScriptC_fe_i8_2 fe_i8_2 = new ScriptC_fe_i8_2(mRS,
-                                                      mRes,
-                                                      R.raw.fe_i8_2);
         t = new Type.Builder(mRS, Element.I8_2(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U8_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i8_2.forEach_root(in, out);
+        fe_all.forEach_test_i8_2(in, out);
         mRS.finish();
         try {
-            fe_i8_2.forEach_root(in, badOut);
+            fe_all.forEach_test_i8_2(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I8_3
-        ScriptC_fe_i8_3 fe_i8_3 = new ScriptC_fe_i8_3(mRS,
-                                                      mRes,
-                                                      R.raw.fe_i8_3);
         t = new Type.Builder(mRS, Element.I8_3(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U8_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i8_3.forEach_root(in, out);
+        fe_all.forEach_test_i8_3(in, out);
         mRS.finish();
         try {
-            fe_i8_3.forEach_root(in, badOut);
+            fe_all.forEach_test_i8_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I8_4
-        ScriptC_fe_i8_4 fe_i8_4 = new ScriptC_fe_i8_4(mRS,
-                                                      mRes,
-                                                      R.raw.fe_i8_4);
         t = new Type.Builder(mRS, Element.I8_4(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U8_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i8_4.forEach_root(in, out);
+        fe_all.forEach_test_i8_4(in, out);
         mRS.finish();
         try {
-            fe_i8_4.forEach_root(in, badOut);
+            fe_all.forEach_test_i8_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I16
-        ScriptC_fe_i16 fe_i16 = new ScriptC_fe_i16(mRS, mRes, R.raw.fe_i16);
         t = new Type.Builder(mRS, Element.I16(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U16(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i16.forEach_root(in, out);
+        fe_all.forEach_test_i16(in, out);
         mRS.finish();
         try {
-            fe_i16.forEach_root(in, badOut);
+            fe_all.forEach_test_i16(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I16_2
-        ScriptC_fe_i16_2 fe_i16_2 = new ScriptC_fe_i16_2(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i16_2);
         t = new Type.Builder(mRS, Element.I16_2(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U16_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i16_2.forEach_root(in, out);
+        fe_all.forEach_test_i16_2(in, out);
         mRS.finish();
         try {
-            fe_i16_2.forEach_root(in, badOut);
+            fe_all.forEach_test_i16_2(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I16_3
-        ScriptC_fe_i16_3 fe_i16_3 = new ScriptC_fe_i16_3(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i16_3);
         t = new Type.Builder(mRS, Element.I16_3(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U16_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i16_3.forEach_root(in, out);
+        fe_all.forEach_test_i16_3(in, out);
         mRS.finish();
         try {
-            fe_i16_3.forEach_root(in, badOut);
+            fe_all.forEach_test_i16_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I16_4
-        ScriptC_fe_i16_4 fe_i16_4 = new ScriptC_fe_i16_4(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i16_4);
         t = new Type.Builder(mRS, Element.I16_4(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U16_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i16_4.forEach_root(in, out);
+        fe_all.forEach_test_i16_4(in, out);
         mRS.finish();
         try {
-            fe_i16_4.forEach_root(in, badOut);
+            fe_all.forEach_test_i16_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I32
-        ScriptC_fe_i32 fe_i32 = new ScriptC_fe_i32(mRS, mRes, R.raw.fe_i32);
         t = new Type.Builder(mRS, Element.I32(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U32(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i32.forEach_root(in, out);
+        fe_all.forEach_test_i32(in, out);
         mRS.finish();
         try {
-            fe_i32.forEach_root(in, badOut);
+            fe_all.forEach_test_i32(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I32_2
-        ScriptC_fe_i32_2 fe_i32_2 = new ScriptC_fe_i32_2(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i32_2);
         t = new Type.Builder(mRS, Element.I32_2(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U32_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i32_2.forEach_root(in, out);
+        fe_all.forEach_test_i32_2(in, out);
         mRS.finish();
         try {
-            fe_i32_2.forEach_root(in, badOut);
+            fe_all.forEach_test_i32_2(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I32_3
-        ScriptC_fe_i32_3 fe_i32_3 = new ScriptC_fe_i32_3(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i32_3);
         t = new Type.Builder(mRS, Element.I32_3(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U32_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i32_3.forEach_root(in, out);
+        fe_all.forEach_test_i32_3(in, out);
         mRS.finish();
         try {
-            fe_i32_3.forEach_root(in, badOut);
+            fe_all.forEach_test_i32_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I32_4
-        ScriptC_fe_i32_4 fe_i32_4 = new ScriptC_fe_i32_4(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i32_4);
         t = new Type.Builder(mRS, Element.I32_4(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U32_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i32_4.forEach_root(in, out);
+        fe_all.forEach_test_i32_4(in, out);
         mRS.finish();
         try {
-            fe_i32_4.forEach_root(in, badOut);
+            fe_all.forEach_test_i32_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I64
-        ScriptC_fe_i64 fe_i64 = new ScriptC_fe_i64(mRS, mRes, R.raw.fe_i64);
         t = new Type.Builder(mRS, Element.I64(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U64(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i64.forEach_root(in, out);
+        fe_all.forEach_test_i64(in, out);
         mRS.finish();
         try {
-            fe_i64.forEach_root(in, badOut);
+            fe_all.forEach_test_i64(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I64_2
-        ScriptC_fe_i64_2 fe_i64_2 = new ScriptC_fe_i64_2(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i64_2);
         t = new Type.Builder(mRS, Element.I64_2(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U64_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i64_2.forEach_root(in, out);
+        fe_all.forEach_test_i64_2(in, out);
         mRS.finish();
         try {
-            fe_i64_2.forEach_root(in, badOut);
+            fe_all.forEach_test_i64_2(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I64_3
-        ScriptC_fe_i64_3 fe_i64_3 = new ScriptC_fe_i64_3(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i64_3);
         t = new Type.Builder(mRS, Element.I64_3(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U64_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i64_3.forEach_root(in, out);
+        fe_all.forEach_test_i64_3(in, out);
         mRS.finish();
         try {
-            fe_i64_3.forEach_root(in, badOut);
+            fe_all.forEach_test_i64_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // I64_4
-        ScriptC_fe_i64_4 fe_i64_4 = new ScriptC_fe_i64_4(mRS,
-                                                         mRes,
-                                                         R.raw.fe_i64_4);
         t = new Type.Builder(mRS, Element.I64_4(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.U64_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i64_4.forEach_root(in, out);
+        fe_all.forEach_test_i64_4(in, out);
         mRS.finish();
         try {
-            fe_i64_4.forEach_root(in, badOut);
+            fe_all.forEach_test_i64_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F32
-        ScriptC_fe_f32 fe_f32 = new ScriptC_fe_f32(mRS, mRes, R.raw.fe_f32);
         t = new Type.Builder(mRS, Element.F32(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f32.forEach_root(in, out);
+        fe_all.forEach_test_f32(in, out);
         mRS.finish();
         try {
-            fe_f32.forEach_root(in, badOut);
+            fe_all.forEach_test_f32(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F32_2
-        ScriptC_fe_f32_2 fe_f32_2 = new ScriptC_fe_f32_2(mRS,
-                                                         mRes,
-                                                         R.raw.fe_f32_2);
         t = new Type.Builder(mRS, Element.F32_2(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.F32_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_f32_2.forEach_root(in, out);
+        fe_all.forEach_test_f32_2(in, out);
         mRS.finish();
         try {
-            fe_f32_2.forEach_root(in, badOut);
+            fe_all.forEach_test_f32_2(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F32_3
-        ScriptC_fe_f32_3 fe_f32_3 = new ScriptC_fe_f32_3(mRS,
-                                                         mRes,
-                                                         R.raw.fe_f32_3);
         t = new Type.Builder(mRS, Element.F32_3(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f32_3.forEach_root(in, out);
+        fe_all.forEach_test_f32_3(in, out);
         mRS.finish();
         try {
-            fe_f32_3.forEach_root(in, badOut);
+            fe_all.forEach_test_f32_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F32_4
-        ScriptC_fe_f32_4 fe_f32_4 = new ScriptC_fe_f32_4(mRS,
-                                                         mRes,
-                                                         R.raw.fe_f32_4);
         t = new Type.Builder(mRS, Element.F32_4(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f32_4.forEach_root(in, out);
+        fe_all.forEach_test_f32_4(in, out);
         mRS.finish();
         try {
-            fe_f32_4.forEach_root(in, badOut);
+            fe_all.forEach_test_f32_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F64
-        ScriptC_fe_f64 fe_f64 = new ScriptC_fe_f64(mRS, mRes, R.raw.fe_f64);
         t = new Type.Builder(mRS, Element.F64(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f64.forEach_root(in, out);
+        fe_all.forEach_test_f64(in, out);
         mRS.finish();
         try {
-            fe_f64.forEach_root(in, badOut);
+            fe_all.forEach_test_f64(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F64_2
-        ScriptC_fe_f64_2 fe_f64_2 = new ScriptC_fe_f64_2(mRS,
-                                                         mRes,
-                                                         R.raw.fe_f64_2);
         t = new Type.Builder(mRS, Element.F64_2(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f64_2.forEach_root(in, out);
+        fe_all.forEach_test_f64_2(in, out);
         mRS.finish();
         try {
-            fe_f64_2.forEach_root(in, badOut);
+            fe_all.forEach_test_f64_2(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F64_3
-        ScriptC_fe_f64_3 fe_f64_3 = new ScriptC_fe_f64_3(mRS,
-                                                         mRes,
-                                                         R.raw.fe_f64_3);
         t = new Type.Builder(mRS, Element.F64_3(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f64_3.forEach_root(in, out);
+        fe_all.forEach_test_f64_3(in, out);
         mRS.finish();
         try {
-            fe_f64_3.forEach_root(in, badOut);
+            fe_all.forEach_test_f64_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // F64_4
-        ScriptC_fe_f64_4 fe_f64_4 = new ScriptC_fe_f64_4(mRS,
-                                                         mRes,
-                                                         R.raw.fe_f64_4);
         t = new Type.Builder(mRS, Element.F64_4(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_f64_4.forEach_root(in, out);
+        fe_all.forEach_test_f64_4(in, out);
         mRS.finish();
         try {
-            fe_f64_4.forEach_root(in, badOut);
+            fe_all.forEach_test_f64_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // fe_test (struct)
-        ScriptC_fe_struct fe_struct = new ScriptC_fe_struct(mRS,
-                                                            mRes,
-                                                            R.raw.fe_struct);
         in = new ScriptField_fe_test(mRS, x).getAllocation();
         out = new ScriptField_fe_test(mRS, x).getAllocation();
-        fe_struct.forEach_root(in, out);
+        fe_all.forEach_test_struct(in, out);
         mRS.finish();
         try {
-            fe_struct.forEach_root(in, badOut);
+            fe_all.forEach_test_struct(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
 
         // BOOLEAN
-        ScriptC_fe_bool fe_bool = new ScriptC_fe_bool(mRS, mRes, R.raw.fe_bool);
         t = new Type.Builder(mRS, Element.BOOLEAN(mRS)).setX(x).create();
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
-        fe_bool.forEach_root(in, out);
+        fe_all.forEach_test_bool(in, out);
         mRS.finish();
         try {
-            fe_bool.forEach_root(in, badOut);
+            fe_all.forEach_test_bool(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
@@ -483,10 +421,10 @@
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.A_8(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i8.forEach_root(in, out);
+        fe_all.forEach_test_i8(in, out);
         mRS.finish();
         try {
-            fe_i8.forEach_root(in, badOut);
+            fe_all.forEach_test_i8(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
@@ -497,10 +435,10 @@
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.RGBA_8888(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i8_4.forEach_root(in, out);
+        fe_all.forEach_test_i8_4(in, out);
         mRS.finish();
         try {
-            fe_i8_4.forEach_root(in, badOut);
+            fe_all.forEach_test_i8_4(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
@@ -511,13 +449,53 @@
         in = Allocation.createTyped(mRS, t);
         t = new Type.Builder(mRS, Element.RGB_888(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
-        fe_i8_3.forEach_root(in, out);
+        fe_all.forEach_test_i8_3(in, out);
         mRS.finish();
         try {
-            fe_i8_3.forEach_root(in, badOut);
+            fe_all.forEach_test_i8_3(in, badOut);
             mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
     }
+
+
+    public void testMultipleForEach() {
+        ScriptC_foreach s = new ScriptC_foreach(mRS, mRes, R.raw.foreach);
+        Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
+
+        int X = 5;
+        int Y = 7;
+        s.set_dimX(X);
+        s.set_dimY(Y);
+        typeBuilder.setX(X).setY(Y);
+        Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
+        s.bind_a(A);
+        s.forEach_root(A);
+        s.invoke_verify_root();
+        s.forEach_foo(A, A);
+        s.invoke_verify_foo();
+        s.invoke_foreach_test();
+        mRS.finish();
+        waitForMessage();
+    }
+
+    public void testNoRoot() {
+        ScriptC_noroot s = new ScriptC_noroot(mRS, mRes, R.raw.noroot);
+        Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
+
+        int X = 5;
+        int Y = 7;
+        s.set_dimX(X);
+        s.set_dimY(Y);
+        typeBuilder.setX(X).setY(Y);
+        Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
+        s.bind_a(A);
+        s.forEach_foo(A, A);
+        s.invoke_verify_foo();
+        s.invoke_noroot_test();
+        mRS.finish();
+        checkForErrors();
+        waitForMessage();
+    }
 }
diff --git a/tools/cts-java-scanner-doclet/Android.mk b/tools/cts-java-scanner-doclet/Android.mk
index 51b141e..d647537 100644
--- a/tools/cts-java-scanner-doclet/Android.mk
+++ b/tools/cts-java-scanner-doclet/Android.mk
@@ -21,6 +21,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR) cts/tools/utils/lib/junit.jar
+LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+LOCAL_JAVA_LIBRARIES := junit
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/utils/Android.mk b/tools/utils/Android.mk
index ddb06c8..36081ca 100644
--- a/tools/utils/Android.mk
+++ b/tools/utils/Android.mk
@@ -22,8 +22,9 @@
 
 LOCAL_SRC_FILES := CollectAllTests.java DescriptionGenerator.java VogarUtils.java
 
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR) $(LOCAL_PATH)/lib/junit.jar
+LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
 
+LOCAL_JAVA_LIBRARIES := junit
 LOCAL_STATIC_JAVA_LIBRARIES := vogarexpectlib
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/utils/lib/junit.jar b/tools/utils/lib/junit.jar
deleted file mode 100644
index 674d71e..0000000
--- a/tools/utils/lib/junit.jar
+++ /dev/null
Binary files differ