Add new tests for Script/ScriptC. 89% (442/498)

Change-Id: I66561f4ef70b7c191ac1b7db165aa500f775a1b8
diff --git a/tests/src/android/renderscript/cts/primitives.rs b/tests/src/android/renderscript/cts/primitives.rs
index 55710cd..c121ec4 100755
--- a/tests/src/android/renderscript/cts/primitives.rs
+++ b/tests/src/android/renderscript/cts/primitives.rs
@@ -1,3 +1,14 @@
+/*****************************************************************************
+ *****
+ *****
+ *****
+ ***** DANGER
+ ***** DO NOT ALTER THIS TEST WITHOUT VERIFYING ScriptTest.java STILL WORKS
+ ***** WE DEPEND ON VARIABLE ORDER FOR VERIFICATION
+ *****
+ *****
+ *****
+ *****************************************************************************/
 #include "shared.rsh"
 #include "structs.rsh"
 
@@ -9,6 +20,14 @@
 int intTest = -32;
 long longTest = 17179869184l; // 1 << 34
 long long longlongTest = 68719476736l; // 1 << 36
+bool boolTest = false;
+
+struct myStruct {
+    int i;
+} structTest;
+
+rs_allocation allocationTest;
+int *intPtrTest;
 
 uchar ucharTest = 8;
 ushort ushortTest = 16;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptCTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptCTest.java
new file mode 100644
index 0000000..7f4ba93
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptCTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript.cts;
+
+import android.content.res.Resources;
+
+import android.renderscript.RenderScript;
+import android.renderscript.ScriptC;
+
+import com.android.cts.stub.R;
+
+public class ScriptCTest extends RSBaseCompute {
+
+    class ScriptCHelper extends ScriptC {
+        public ScriptCHelper(int id, RenderScript rs) {
+            super(id, rs);
+        }
+
+        public ScriptCHelper(RenderScript rs,
+                             Resources resources,
+                             int resourceID) {
+            super(rs, resources, resourceID);
+        }
+    }
+
+    public void testScriptC() {
+        // Test basic constructor
+        ScriptCHelper h = new ScriptCHelper(0, mRS);
+
+        // Test actual constructor
+        h = new ScriptCHelper(mRS, mRes, R.raw.negate);
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
new file mode 100644
index 0000000..90b847a
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript.cts;
+
+import android.content.res.Resources;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.FieldPacker;
+import android.renderscript.RenderScript;
+import android.renderscript.Script;
+import android.renderscript.ScriptC;
+import android.renderscript.Type;
+
+import android.renderscript.cts.ScriptC_negate;
+
+import com.android.cts.stub.R;
+
+public class ScriptTest extends RSBaseCompute {
+
+    public void testScript() {
+        Script S = new ScriptC_primitives(mRS, mRes, R.raw.primitives);
+
+        S.setTimeZone("America/New_York");
+
+        S.setVar(4, 9.0f);  // floatTest
+        S.setVar(5, 9.0);  // doubleTest
+        S.setVar(6, 7);  // charTest
+        S.setVar(7, 300);  // shortTest
+        S.setVar(8, 20000);  // intTest
+        S.setVar(9, 20000000000l);  // longTest
+        S.setVar(11, true);  // boolTest
+
+        FieldPacker fp = new FieldPacker(4);
+        fp.addI32(3);
+        S.setVar(12, fp);  // structTest
+
+        Type.Builder tb = new Type.Builder(mRS, Element.I32(mRS));
+        Allocation a = Allocation.createTyped(mRS, tb.create());
+        S.setVar(13, a);  // allocationTest
+
+        S.bindAllocation(a, 14);  // intPtrTest
+    }
+}