Loading libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +48 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.renderscript.*; import android.util.Log; import java.util.ArrayList; import java.util.ListIterator; import java.util.Timer; import java.util.TimerTask; public class RSTestCore { Loading @@ -42,12 +44,18 @@ public class RSTestCore { private ArrayList<UnitTest> unitTests; private ListIterator<UnitTest> test_iter; private UnitTest activeTest; private boolean stopTesting; /* Periodic timer for ensuring future tests get scheduled */ private Timer mTimer; public static final int RS_TIMER_PERIOD = 100; public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; mRes = res; mWidth = width; mHeight = height; stopTesting = false; mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist, true); Loading Loading @@ -88,9 +96,17 @@ public class RSTestCore { test_iter = unitTests.listIterator(); refreshTestResults(); /* Kick off the first test */ TimerTask pTask = new TimerTask() { public void run() { refreshTestResults(); } }; mTimer = new Timer(); mTimer.schedule(pTask, RS_TIMER_PERIOD, RS_TIMER_PERIOD); } static int count = 0; public void checkAndRunNextTest() { if (activeTest != null) { if (!activeTest.isAlive()) { Loading @@ -104,7 +120,7 @@ public class RSTestCore { } } if (activeTest == null) { if (!stopTesting && activeTest == null) { if (test_iter.hasNext()) { activeTest = test_iter.next(); activeTest.start(); Loading @@ -112,8 +128,14 @@ public class RSTestCore { * should start running. The message handler in UnitTest.java * ensures this. */ } else { if (mTimer != null) { mTimer.cancel(); mTimer.purge(); mTimer = null; } } } count++; } public void refreshTestResults() { Loading @@ -127,6 +149,29 @@ public class RSTestCore { } } public void cleanup() { stopTesting = true; UnitTest t = activeTest; /* Stop periodic refresh of testing */ if (mTimer != null) { mTimer.cancel(); mTimer.purge(); mTimer = null; } /* Wait to exit until we finish the current test */ if (t != null) { try { t.join(); } catch (InterruptedException e) { } t = null; } } public void newTouchPosition(float x, float y, float pressure, int id) { } Loading libs/rs/java/tests/src/com/android/rs/test/RSTestView.java +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class RSTestView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { if(mRS != null) { mRender.cleanup(); mRS = null; destroyRenderScript(); } Loading libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public class UT_fp_mad extends UnitTest { pRS.mMessageCallback = mRsMessage; s.invoke_fp_mad_test(0, 0); pRS.finish(); waitForMessage(); pRS.destroy(); } } Loading libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public class UT_primitives extends UnitTest { pRS.mMessageCallback = mRsMessage; s.invoke_primitives_test(0, 0); pRS.finish(); waitForMessage(); pRS.destroy(); } } Loading libs/rs/java/tests/src/com/android/rs/test/UnitTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ public class UnitTest extends Thread { public int result; private ScriptField_ListAllocs_s.Item mItem; private RSTestCore mRSTC; private boolean msgHandled; /* These constants must match those in shared.rsh */ public static final int RS_MSG_TEST_PASSED = 100; Loading @@ -35,6 +36,7 @@ public class UnitTest extends Thread { super(); mRSTC = rstc; name = n; msgHandled = false; result = initResult; testID = numTests++; } Loading Loading @@ -67,6 +69,7 @@ public class UnitTest extends Thread { if (mItem != null) { mItem.result = result; msgHandled = true; try { mRSTC.refreshTestResults(); } Loading @@ -79,6 +82,12 @@ public class UnitTest extends Thread { } }; public void waitForMessage() { while (!msgHandled) { yield(); } } public void setItem(ScriptField_ListAllocs_s.Item item) { mItem = item; } Loading Loading
libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +48 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.renderscript.*; import android.util.Log; import java.util.ArrayList; import java.util.ListIterator; import java.util.Timer; import java.util.TimerTask; public class RSTestCore { Loading @@ -42,12 +44,18 @@ public class RSTestCore { private ArrayList<UnitTest> unitTests; private ListIterator<UnitTest> test_iter; private UnitTest activeTest; private boolean stopTesting; /* Periodic timer for ensuring future tests get scheduled */ private Timer mTimer; public static final int RS_TIMER_PERIOD = 100; public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; mRes = res; mWidth = width; mHeight = height; stopTesting = false; mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist, true); Loading Loading @@ -88,9 +96,17 @@ public class RSTestCore { test_iter = unitTests.listIterator(); refreshTestResults(); /* Kick off the first test */ TimerTask pTask = new TimerTask() { public void run() { refreshTestResults(); } }; mTimer = new Timer(); mTimer.schedule(pTask, RS_TIMER_PERIOD, RS_TIMER_PERIOD); } static int count = 0; public void checkAndRunNextTest() { if (activeTest != null) { if (!activeTest.isAlive()) { Loading @@ -104,7 +120,7 @@ public class RSTestCore { } } if (activeTest == null) { if (!stopTesting && activeTest == null) { if (test_iter.hasNext()) { activeTest = test_iter.next(); activeTest.start(); Loading @@ -112,8 +128,14 @@ public class RSTestCore { * should start running. The message handler in UnitTest.java * ensures this. */ } else { if (mTimer != null) { mTimer.cancel(); mTimer.purge(); mTimer = null; } } } count++; } public void refreshTestResults() { Loading @@ -127,6 +149,29 @@ public class RSTestCore { } } public void cleanup() { stopTesting = true; UnitTest t = activeTest; /* Stop periodic refresh of testing */ if (mTimer != null) { mTimer.cancel(); mTimer.purge(); mTimer = null; } /* Wait to exit until we finish the current test */ if (t != null) { try { t.join(); } catch (InterruptedException e) { } t = null; } } public void newTouchPosition(float x, float y, float pressure, int id) { } Loading
libs/rs/java/tests/src/com/android/rs/test/RSTestView.java +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class RSTestView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { if(mRS != null) { mRender.cleanup(); mRS = null; destroyRenderScript(); } Loading
libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public class UT_fp_mad extends UnitTest { pRS.mMessageCallback = mRsMessage; s.invoke_fp_mad_test(0, 0); pRS.finish(); waitForMessage(); pRS.destroy(); } } Loading
libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public class UT_primitives extends UnitTest { pRS.mMessageCallback = mRsMessage; s.invoke_primitives_test(0, 0); pRS.finish(); waitForMessage(); pRS.destroy(); } } Loading
libs/rs/java/tests/src/com/android/rs/test/UnitTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ public class UnitTest extends Thread { public int result; private ScriptField_ListAllocs_s.Item mItem; private RSTestCore mRSTC; private boolean msgHandled; /* These constants must match those in shared.rsh */ public static final int RS_MSG_TEST_PASSED = 100; Loading @@ -35,6 +36,7 @@ public class UnitTest extends Thread { super(); mRSTC = rstc; name = n; msgHandled = false; result = initResult; testID = numTests++; } Loading Loading @@ -67,6 +69,7 @@ public class UnitTest extends Thread { if (mItem != null) { mItem.result = result; msgHandled = true; try { mRSTC.refreshTestResults(); } Loading @@ -79,6 +82,12 @@ public class UnitTest extends Thread { } }; public void waitForMessage() { while (!msgHandled) { yield(); } } public void setItem(ScriptField_ListAllocs_s.Item item) { mItem = item; } Loading