summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2011-10-20 13:54:37 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-20 13:54:37 -0700
commit79235d2a93086538817391c847a8063442e1e1f0 (patch)
treebc25b09dcb8b113c58ce92ebc179b9140f51218e /tests
parent5b6f23868aff6a7317d2249224ea29d5e14113c9 (diff)
parent7d5f5e7c8943e043a422ad51c85d4e1684c37e28 (diff)
downloadframeworks_base-79235d2a93086538817391c847a8063442e1e1f0.zip
frameworks_base-79235d2a93086538817391c847a8063442e1e1f0.tar.gz
frameworks_base-79235d2a93086538817391c847a8063442e1e1f0.tar.bz2
Merge "adding getters to Sampler ProgramRaster, ProgramStore, Element. Element adds ability to get subelement info. Tests for new stuff."
Diffstat (limited to 'tests')
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java34
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java116
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java91
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java36
4 files changed, 238 insertions, 39 deletions
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java
index 1fbf97a..2bfb6b1 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java
@@ -25,6 +25,9 @@ import android.renderscript.ProgramRaster.CullMode;
public class UT_program_raster extends UnitTest {
private Resources mRes;
+ ProgramRaster pointSpriteEnabled;
+ ProgramRaster cullMode;
+
protected UT_program_raster(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "ProgramRaster", ctx);
mRes = res;
@@ -39,20 +42,41 @@ public class UT_program_raster extends UnitTest {
private void initializeGlobals(RenderScript RS, ScriptC_program_raster s) {
ProgramRaster.Builder b = getDefaultBuilder(RS);
- s.set_pointSpriteEnabled(b.setPointSpriteEnabled(true).create());
+ pointSpriteEnabled = b.setPointSpriteEnabled(true).create();
b = getDefaultBuilder(RS);
- s.set_cullMode(b.setCullMode(CullMode.FRONT).create());
- return;
+ cullMode = b.setCullMode(CullMode.FRONT).create();
+
+ s.set_pointSpriteEnabled(pointSpriteEnabled);
+ s.set_cullMode(cullMode);
}
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
+ private void testScriptSide(RenderScript pRS) {
ScriptC_program_raster s = new ScriptC_program_raster(pRS, mRes, R.raw.program_raster);
pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s);
s.invoke_program_raster_test();
pRS.finish();
waitForMessage();
+ }
+
+ private void testJavaSide(RenderScript RS) {
+ _RS_ASSERT("pointSpriteEnabled.getPointSpriteEnabled() == true",
+ pointSpriteEnabled.getPointSpriteEnabled() == true);
+ _RS_ASSERT("pointSpriteEnabled.getCullMode() == ProgramRaster.CullMode.BACK",
+ pointSpriteEnabled.getCullMode() == ProgramRaster.CullMode.BACK);
+
+ _RS_ASSERT("cullMode.getPointSpriteEnabled() == false",
+ cullMode.getPointSpriteEnabled() == false);
+ _RS_ASSERT("cullMode.getCullMode() == ProgramRaster.CullMode.FRONT",
+ cullMode.getCullMode() == ProgramRaster.CullMode.FRONT);
+
+ updateUI();
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ testScriptSide(pRS);
+ testJavaSide(pRS);
pRS.destroy();
}
}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java
index e06112c..72a401d 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java
@@ -27,6 +27,16 @@ import android.renderscript.ProgramStore.DepthFunc;
public class UT_program_store extends UnitTest {
private Resources mRes;
+ ProgramStore ditherEnable;
+ ProgramStore colorRWriteEnable;
+ ProgramStore colorGWriteEnable;
+ ProgramStore colorBWriteEnable;
+ ProgramStore colorAWriteEnable;
+ ProgramStore blendSrc;
+ ProgramStore blendDst;
+ ProgramStore depthWriteEnable;
+ ProgramStore depthFunc;
+
protected UT_program_store(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "ProgramStore", ctx);
mRes = res;
@@ -44,44 +54,122 @@ public class UT_program_store extends UnitTest {
private void initializeGlobals(RenderScript RS, ScriptC_program_store s) {
ProgramStore.Builder b = getDefaultBuilder(RS);
- s.set_ditherEnable(b.setDitherEnabled(true).create());
+ ditherEnable = b.setDitherEnabled(true).create();
b = getDefaultBuilder(RS);
- s.set_colorRWriteEnable(b.setColorMaskEnabled(true, false, false, false).create());
+ colorRWriteEnable = b.setColorMaskEnabled(true, false, false, false).create();
b = getDefaultBuilder(RS);
- s.set_colorGWriteEnable(b.setColorMaskEnabled(false, true, false, false).create());
+ colorGWriteEnable = b.setColorMaskEnabled(false, true, false, false).create();
b = getDefaultBuilder(RS);
- s.set_colorBWriteEnable(b.setColorMaskEnabled(false, false, true, false).create());
+ colorBWriteEnable = b.setColorMaskEnabled(false, false, true, false).create();
b = getDefaultBuilder(RS);
- s.set_colorAWriteEnable(b.setColorMaskEnabled(false, false, false, true).create());
+ colorAWriteEnable = b.setColorMaskEnabled(false, false, false, true).create();
b = getDefaultBuilder(RS);
- s.set_blendSrc(b.setBlendFunc(ProgramStore.BlendSrcFunc.DST_COLOR,
- ProgramStore.BlendDstFunc.ZERO).create());
+ blendSrc = b.setBlendFunc(ProgramStore.BlendSrcFunc.DST_COLOR,
+ ProgramStore.BlendDstFunc.ZERO).create();
b = getDefaultBuilder(RS);
- s.set_blendDst(b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO,
- ProgramStore.BlendDstFunc.DST_ALPHA).create());
+ blendDst = b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO,
+ ProgramStore.BlendDstFunc.DST_ALPHA).create();
b = getDefaultBuilder(RS);
- s.set_depthWriteEnable(b.setDepthMaskEnabled(true).create());
+ depthWriteEnable = b.setDepthMaskEnabled(true).create();
b = getDefaultBuilder(RS);
- s.set_depthFunc(b.setDepthFunc(ProgramStore.DepthFunc.GREATER).create());
- return;
+ depthFunc = b.setDepthFunc(ProgramStore.DepthFunc.GREATER).create();
+
+ s.set_ditherEnable(ditherEnable);
+ s.set_colorRWriteEnable(colorRWriteEnable);
+ s.set_colorGWriteEnable(colorGWriteEnable);
+ s.set_colorBWriteEnable(colorBWriteEnable);
+ s.set_colorAWriteEnable(colorAWriteEnable);
+ s.set_blendSrc(blendSrc);
+ s.set_blendDst(blendDst);
+ s.set_depthWriteEnable(depthWriteEnable);
+ s.set_depthFunc(depthFunc);
}
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
+ private void testScriptSide(RenderScript pRS) {
ScriptC_program_store s = new ScriptC_program_store(pRS, mRes, R.raw.program_store);
pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s);
s.invoke_program_store_test();
pRS.finish();
waitForMessage();
+ }
+
+ void checkObject(ProgramStore ps,
+ boolean depthMask,
+ DepthFunc df,
+ BlendSrcFunc bsf,
+ BlendDstFunc bdf,
+ boolean R,
+ boolean G,
+ boolean B,
+ boolean A,
+ boolean dither) {
+ _RS_ASSERT("ps.getDepthMaskEnabled() == depthMask", ps.getDepthMaskEnabled() == depthMask);
+ _RS_ASSERT("ps.getDepthFunc() == df", ps.getDepthFunc() == df);
+ _RS_ASSERT("ps.getBlendSrcFunc() == bsf", ps.getBlendSrcFunc() == bsf);
+ _RS_ASSERT("ps.getBlendDstFunc() == bdf", ps.getBlendDstFunc() == bdf);
+ _RS_ASSERT("ps.getColorMaskREnabled() == R", ps.getColorMaskREnabled() == R);
+ _RS_ASSERT("ps.getColorMaskGEnabled() == G", ps.getColorMaskGEnabled() == G);
+ _RS_ASSERT("ps.getColorMaskBEnabled() == B", ps.getColorMaskBEnabled() == B);
+ _RS_ASSERT("ps.getColorMaskAEnabled() == A", ps.getColorMaskAEnabled() == A);
+ _RS_ASSERT("ps.getDitherEnabled() == dither", ps.getDitherEnabled() == dither);
+ }
+
+ void varyBuilderColorAndDither(ProgramStore.Builder pb,
+ boolean depthMask,
+ DepthFunc df,
+ BlendSrcFunc bsf,
+ BlendDstFunc bdf) {
+ for (int r = 0; r <= 1; r++) {
+ boolean isR = (r == 1);
+ for (int g = 0; g <= 1; g++) {
+ boolean isG = (g == 1);
+ for (int b = 0; b <= 1; b++) {
+ boolean isB = (b == 1);
+ for (int a = 0; a <= 1; a++) {
+ boolean isA = (a == 1);
+ for (int dither = 0; dither <= 1; dither++) {
+ boolean isDither = (dither == 1);
+ pb.setDitherEnabled(isDither);
+ pb.setColorMaskEnabled(isR, isG, isB, isA);
+ ProgramStore ps = pb.create();
+ checkObject(ps, depthMask, df, bsf, bdf, isR, isG, isB, isA, isDither);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void testJavaSide(RenderScript RS) {
+ for (int depth = 0; depth <= 1; depth++) {
+ boolean depthMask = (depth == 1);
+ for (DepthFunc df : DepthFunc.values()) {
+ for (BlendSrcFunc bsf : BlendSrcFunc.values()) {
+ for (BlendDstFunc bdf : BlendDstFunc.values()) {
+ ProgramStore.Builder b = new ProgramStore.Builder(RS);
+ b.setDepthFunc(df);
+ b.setDepthMaskEnabled(depthMask);
+ b.setBlendFunc(bsf, bdf);
+ varyBuilderColorAndDither(b, depthMask, df, bsf, bdf);
+ }
+ }
+ }
+ }
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ testJavaSide(pRS);
+ testScriptSide(pRS);
pRS.destroy();
}
}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java
index b0ccf9d..030b3ff 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java
@@ -25,6 +25,12 @@ import android.renderscript.Sampler.Value;
public class UT_sampler extends UnitTest {
private Resources mRes;
+ Sampler minification;
+ Sampler magnification;
+ Sampler wrapS;
+ Sampler wrapT;
+ Sampler anisotropy;
+
protected UT_sampler(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "Sampler", ctx);
mRes = res;
@@ -43,34 +49,103 @@ public class UT_sampler extends UnitTest {
private void initializeGlobals(RenderScript RS, ScriptC_sampler s) {
Sampler.Builder b = getDefaultBuilder(RS);
b.setMinification(Value.LINEAR_MIP_LINEAR);
- s.set_minification(b.create());
+ minification = b.create();
b = getDefaultBuilder(RS);
b.setMagnification(Value.LINEAR);
- s.set_magnification(b.create());
+ magnification = b.create();
b = getDefaultBuilder(RS);
b.setWrapS(Value.WRAP);
- s.set_wrapS(b.create());
+ wrapS = b.create();
b = getDefaultBuilder(RS);
b.setWrapT(Value.WRAP);
- s.set_wrapT(b.create());
+ wrapT = b.create();
b = getDefaultBuilder(RS);
b.setAnisotropy(8.0f);
- s.set_anisotropy(b.create());
- return;
+ anisotropy = b.create();
+
+ s.set_minification(minification);
+ s.set_magnification(magnification);
+ s.set_wrapS(wrapS);
+ s.set_wrapT(wrapT);
+ s.set_anisotropy(anisotropy);
}
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
+ private void testScriptSide(RenderScript pRS) {
ScriptC_sampler s = new ScriptC_sampler(pRS, mRes, R.raw.sampler);
pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s);
s.invoke_sampler_test();
pRS.finish();
waitForMessage();
+ }
+
+ private void testJavaSide(RenderScript RS) {
+ _RS_ASSERT("minification.getMagnification() == Sampler.Value.NEAREST",
+ minification.getMagnification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("minification.getMinification() == Sampler.Value.LINEAR_MIP_LINEAR",
+ minification.getMinification() == Sampler.Value.LINEAR_MIP_LINEAR);
+ _RS_ASSERT("minification.getWrapS() == Sampler.Value.CLAMP",
+ minification.getWrapS() == Sampler.Value.CLAMP);
+ _RS_ASSERT("minification.getWrapT() == Sampler.Value.CLAMP",
+ minification.getWrapT() == Sampler.Value.CLAMP);
+ _RS_ASSERT("minification.getAnisotropy() == 1.0f",
+ minification.getAnisotropy() == 1.0f);
+
+ _RS_ASSERT("magnification.getMagnification() == Sampler.Value.LINEAR",
+ magnification.getMagnification() == Sampler.Value.LINEAR);
+ _RS_ASSERT("magnification.getMinification() == Sampler.Value.NEAREST",
+ magnification.getMinification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("magnification.getWrapS() == Sampler.Value.CLAMP",
+ magnification.getWrapS() == Sampler.Value.CLAMP);
+ _RS_ASSERT("magnification.getWrapT() == Sampler.Value.CLAMP",
+ magnification.getWrapT() == Sampler.Value.CLAMP);
+ _RS_ASSERT("magnification.getAnisotropy() == 1.0f",
+ magnification.getAnisotropy() == 1.0f);
+
+ _RS_ASSERT("wrapS.getMagnification() == Sampler.Value.NEAREST",
+ wrapS.getMagnification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("wrapS.getMinification() == Sampler.Value.NEAREST",
+ wrapS.getMinification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("wrapS.getWrapS() == Sampler.Value.WRAP",
+ wrapS.getWrapS() == Sampler.Value.WRAP);
+ _RS_ASSERT("wrapS.getWrapT() == Sampler.Value.CLAMP",
+ wrapS.getWrapT() == Sampler.Value.CLAMP);
+ _RS_ASSERT("wrapS.getAnisotropy() == 1.0f",
+ wrapS.getAnisotropy() == 1.0f);
+
+ _RS_ASSERT("wrapT.getMagnification() == Sampler.Value.NEAREST",
+ wrapT.getMagnification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("wrapT.getMinification() == Sampler.Value.NEAREST",
+ wrapT.getMinification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("wrapT.getWrapS() == Sampler.Value.CLAMP",
+ wrapT.getWrapS() == Sampler.Value.CLAMP);
+ _RS_ASSERT("wrapT.getWrapT() == Sampler.Value.WRAP",
+ wrapT.getWrapT() == Sampler.Value.WRAP);
+ _RS_ASSERT("wrapT.getAnisotropy() == 1.0f",
+ wrapT.getAnisotropy() == 1.0f);
+
+ _RS_ASSERT("anisotropy.getMagnification() == Sampler.Value.NEAREST",
+ anisotropy.getMagnification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("anisotropy.getMinification() == Sampler.Value.NEAREST",
+ anisotropy.getMinification() == Sampler.Value.NEAREST);
+ _RS_ASSERT("anisotropy.getWrapS() == Sampler.Value.CLAMP",
+ anisotropy.getWrapS() == Sampler.Value.CLAMP);
+ _RS_ASSERT("anisotropy.getWrapT() == Sampler.Value.CLAMP",
+ anisotropy.getWrapT() == Sampler.Value.CLAMP);
+ _RS_ASSERT("anisotropy.getAnisotropy() == 1.0f",
+ anisotropy.getAnisotropy() == 8.0f);
+
+ updateUI();
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ testScriptSide(pRS);
+ testJavaSide(pRS);
pRS.destroy();
}
}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java
index 6151431..a97ffa7 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java
@@ -16,6 +16,7 @@
package com.android.rs.test;
import android.content.Context;
+import android.util.Log;
import android.renderscript.RenderScript.RSMessageHandler;
public class UnitTest extends Thread {
@@ -55,6 +56,28 @@ public class UnitTest extends Thread {
this (null, ctx);
}
+ protected void _RS_ASSERT(String message, boolean b) {
+ if(b == false) {
+ result = -1;
+ Log.e(name, message + " FAILED");
+ }
+ }
+
+ protected void updateUI() {
+ if (mItem != null) {
+ mItem.result = result;
+ msgHandled = true;
+ try {
+ mRSTC.refreshTestResults();
+ }
+ catch (IllegalStateException e) {
+ /* Ignore the case where our message receiver has been
+ disconnected. This happens when we leave the application
+ before it finishes running all of the unit tests. */
+ }
+ }
+ }
+
protected RSMessageHandler mRsMessage = new RSMessageHandler() {
public void run() {
if (result == 0) {
@@ -71,18 +94,7 @@ public class UnitTest extends Thread {
}
}
- if (mItem != null) {
- mItem.result = result;
- msgHandled = true;
- try {
- mRSTC.refreshTestResults();
- }
- catch (IllegalStateException e) {
- /* Ignore the case where our message receiver has been
- disconnected. This happens when we leave the application
- before it finishes running all of the unit tests. */
- }
- }
+ updateUI();
}
};