diff options
author | Stephen Hines <srhines@google.com> | 2010-09-24 14:38:30 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2010-09-28 10:28:12 -0700 |
commit | ab98bb6e8b95bef7415c1ad239be71f93322fbad (patch) | |
tree | 88bddc3d4e5b7df752a26a14f18d2b8ef808a303 /libs | |
parent | b0725a4aebbb74a633ce9ec795d291c1e619f963 (diff) | |
download | frameworks_base-ab98bb6e8b95bef7415c1ad239be71f93322fbad.zip frameworks_base-ab98bb6e8b95bef7415c1ad239be71f93322fbad.tar.gz frameworks_base-ab98bb6e8b95bef7415c1ad239be71f93322fbad.tar.bz2 |
Fix RS bug with message ID 0.
Clamp RSTest list to nice viewable range.
Change-Id: I0909511e16984ec78150cda17c22e22af1fa0cdb
Diffstat (limited to 'libs')
5 files changed, 83 insertions, 21 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 cd8f814..dbc9133 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 @@ -40,6 +40,8 @@ public class RSTestCore { private ScriptC_rslist mScript; private ArrayList<UnitTest> unitTests; + private ListIterator<UnitTest> test_iter; + private UnitTest activeTest; public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; @@ -54,9 +56,13 @@ public class RSTestCore { unitTests.add(new UT_primitives(this, mRes)); unitTests.add(new UT_fp_mad(this, mRes)); /* - unitTests.add(new UnitTest("<Pass>", 1)); + unitTests.add(new UnitTest(null, "<Pass>", 1)); unitTests.add(new UnitTest()); - unitTests.add(new UnitTest("<Fail>", -1)); + unitTests.add(new UnitTest(null, "<Fail>", -1)); + + for (int i = 0; i < 20; i++) { + unitTests.add(new UnitTest(null, "<Pass>", 1)); + } */ UnitTest [] uta = new UnitTest[unitTests.size()]; @@ -71,19 +77,6 @@ public class RSTestCore { uta[i].setItem(listElem); } - /* Run the actual unit tests */ - ListIterator<UnitTest> test_iter = unitTests.listIterator(); - while (test_iter.hasNext()) { - UnitTest t = test_iter.next(); - t.start(); - /* - try { - t.join(); - } catch (InterruptedException e) { - } - */ - } - mListAllocs.copyAll(); mScript.bind_gList(mListAllocs); @@ -92,10 +85,40 @@ public class RSTestCore { mScript.set_gFont(mFont); mRS.contextBindRootScript(mScript); - mRS.finish(); + + test_iter = unitTests.listIterator(); + refreshTestResults(); /* Kick off the first test */ + } + + static int count = 0; + public void checkAndRunNextTest() { + if (activeTest != null) { + if (!activeTest.isAlive()) { + /* Properly clean up on our last test */ + try { + activeTest.join(); + } + catch (InterruptedException e) { + } + activeTest = null; + } + } + + if (activeTest == null) { + if (test_iter.hasNext()) { + activeTest = test_iter.next(); + activeTest.start(); + /* This routine will only get called once when a new test + * should start running. The message handler in UnitTest.java + * ensures this. */ + } + } + count++; } public void refreshTestResults() { + checkAndRunNextTest(); + if (mListAllocs != null && mScript != null && mRS != null) { mListAllocs.copyAll(); @@ -111,6 +134,7 @@ public class RSTestCore { mScript.set_gDY(0.0f); mLastX = x; mLastY = y; + refreshTestResults(); } public void onActionMove(int x, int y) { @@ -125,5 +149,6 @@ public class RSTestCore { mLastX = x; mLastY = y; + refreshTestResults(); } } diff --git a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java index d98b763..5eb0d67 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java +++ b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java @@ -16,6 +16,7 @@ package com.android.rs.test; import android.renderscript.RenderScript.RSMessage; +import android.util.Log; public class UnitTest extends Thread { public String name; @@ -27,11 +28,15 @@ public class UnitTest extends Thread { public static final int RS_MSG_TEST_PASSED = 100; public static final int RS_MSG_TEST_FAILED = 101; + private static int numTests = 0; + public int testID; + protected UnitTest(RSTestCore rstc, String n, int initResult) { super(); mRSTC = rstc; name = n; result = initResult; + testID = numTests++; } protected UnitTest(RSTestCore rstc, String n) { @@ -56,12 +61,20 @@ public class UnitTest extends Thread { result = -1; break; default: - break; + android.util.Log.v("RenderScript", "Unit test got unexpected message"); + return; } if (mItem != null) { mItem.result = result; - mRSTC.refreshTestResults(); + 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. */ + } } } }; @@ -72,6 +85,9 @@ public class UnitTest extends Thread { public void run() { /* This method needs to be implemented for each subclass */ + if (mRSTC != null) { + mRSTC.refreshTestResults(); + } } } diff --git a/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs b/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs index eb82e56..dfd77e6 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs @@ -170,7 +170,7 @@ void fp_mad_test(uint32_t index, int test_num) { // TODO Actually verify test result accuracy rsDebug("fp_mad_test PASSED", 0); - rsSendToClient(RS_MSG_TEST_PASSED); + rsSendToClientBlocking(RS_MSG_TEST_PASSED); } 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 index 2ba5d52..5312bcc 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs @@ -42,10 +42,10 @@ void primitives_test(uint32_t index, int test_num) { failed |= test_primitive_types(index); if (failed) { - rsSendToClient(RS_MSG_TEST_FAILED); + rsSendToClientBlocking(RS_MSG_TEST_FAILED); } else { - rsSendToClient(RS_MSG_TEST_PASSED); + rsSendToClientBlocking(RS_MSG_TEST_PASSED); } } diff --git a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs index 72d1850..a5f0f6b 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs @@ -56,6 +56,27 @@ int root(int launchID) { int height = rsgGetHeight(); int itemHeight = 80; + int totalItemHeight = itemHeight * allocSize; + + /* Prevent scrolling above the top of the list */ + int firstItem = height - totalItemHeight; + if (firstItem < 0) { + firstItem = 0; + } + + /* Prevent scrolling past the last line of the list */ + int lastItem = -1 * (totalItemHeight - height); + if (lastItem > 0) { + lastItem = 0; + } + + if (textPos > firstItem) { + textPos = firstItem; + } + else if (textPos < lastItem) { + textPos = lastItem; + } + int currentYPos = itemHeight + textPos; for(int i = 0; i < allocSize; i ++) { |