summaryrefslogtreecommitdiffstats
path: root/libs/rs
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2010-09-21 11:54:15 -0700
committerStephen Hines <srhines@google.com>2010-09-21 11:59:15 -0700
commit065149f1628a2882a46af810ca9fc3913f7b0438 (patch)
tree7096bb5d3c259b43b2decda2ca1ff5c875e7e898 /libs/rs
parent6f1e9618e40f9290d9d21a9b1e09e51dba53faed (diff)
downloadframeworks_base-065149f1628a2882a46af810ca9fc3913f7b0438.zip
frameworks_base-065149f1628a2882a46af810ca9fc3913f7b0438.tar.gz
frameworks_base-065149f1628a2882a46af810ca9fc3913f7b0438.tar.bz2
Updated RSTest to test primitive type assignments.
Change-Id: I6c377cfdc647806d9362effc4c1715638dcf5bfb
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java26
-rw-r--r--libs/rs/java/tests/src/com/android/rs/test/primitives.rs42
-rw-r--r--libs/rs/java/tests/src/com/android/rs/test/shared.rsh10
3 files changed, 59 insertions, 19 deletions
diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java
index 6645372..cf9c6be 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java
@@ -38,33 +38,21 @@ public class RSTestCore {
return true;
}
- //private ScriptC_Fountain mScript;
+ private boolean rs_primitives_test() {
+ ScriptC_primitives s = new ScriptC_primitives(mRS, mRes, R.raw.primitives, true);
+ s.invoke_rs_primitives_test(0, 0);
+ return true;
+ }
+
public void init(RenderScriptGL rs, Resources res, int width, int height) {
mRS = rs;
mRes = res;
mRootScript = new ScriptC_test_root(mRS, mRes, R.raw.test_root, true);
+ rs_primitives_test();
fp_mad();
-
- /*
- ProgramFragment.Builder pfb = new ProgramFragment.Builder(rs);
- pfb.setVaryingColor(true);
- rs.contextBindProgramFragment(pfb.create());
-
- ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);
-
- Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
- smb.addVertexAllocation(points.getAllocation());
- smb.addIndexType(Primitive.POINT);
- Mesh sm = smb.create();
-
- mScript = new ScriptC_Fountain(mRS, mRes, R.raw.fountain, true);
- mScript.set_partMesh(sm);
- mScript.bind_point(points);
- mRS.contextBindRootScript(mScript);
- */
}
public void newTouchPosition(float x, float y, float pressure, int id) {
diff --git a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
new file mode 100644
index 0000000..b6148eff
--- /dev/null
+++ b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
@@ -0,0 +1,42 @@
+#include "shared.rsh"
+
+#pragma rs export_func(rs_primitives_test)
+
+// Testing primitive types
+static float floatTest = 1.0;
+static double doubleTest = 2.05;
+static char charTest = -8;
+static short shortTest = -16;
+static int intTest = -32;
+static uchar ucharTest = 8;
+static ushort ushortTest = 16;
+static uint uintTest = 32;
+
+static void test_primitive_types(uint32_t index) {
+ bool failed = false;
+ start();
+
+ _RS_ASSERT(floatTest == 1.0);
+ _RS_ASSERT(doubleTest == 2.05);
+ _RS_ASSERT(charTest == -8);
+ _RS_ASSERT(shortTest == -16);
+ _RS_ASSERT(intTest == -32);
+ _RS_ASSERT(ucharTest == 8);
+ _RS_ASSERT(ushortTest == 16);
+ _RS_ASSERT(uintTest == 32);
+
+ float time = end(index);
+ if (failed) {
+ rsDebug("test_primitives FAILED ", time);
+ }
+ else {
+ rsDebug("test_primitives PASSED ", time);
+ }
+}
+
+
+void rs_primitives_test(uint32_t index, int test_num) {
+ test_primitive_types(index);
+}
+
+
diff --git a/libs/rs/java/tests/src/com/android/rs/test/shared.rsh b/libs/rs/java/tests/src/com/android/rs/test/shared.rsh
index 1773e47..8c3e5f4 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/shared.rsh
+++ b/libs/rs/java/tests/src/com/android/rs/test/shared.rsh
@@ -23,3 +23,13 @@ static float end(uint32_t idx) {
return ((float)t) / 1000.f;
}
+#define _RS_ASSERT(b) \
+do { \
+ rsDebug("Checking " #b, ((int) (b))); \
+ if (!(b)) { \
+ failed = true; \
+ rsDebug(#b " FAILED", 0); \
+ } \
+\
+} while (0)
+