Adding support for dynamically updated test status
Change-Id: If67de45f7fbf3ecaf4c6e85ed8dded0099e543fd
This commit is contained in:
@@ -51,8 +51,8 @@ public class RSTestCore {
|
||||
|
||||
unitTests = new ArrayList<UnitTest>();
|
||||
|
||||
unitTests.add(new UT_primitives(mRes));
|
||||
unitTests.add(new UT_fp_mad(mRes));
|
||||
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());
|
||||
@@ -62,23 +62,26 @@ public class RSTestCore {
|
||||
UnitTest [] uta = new UnitTest[unitTests.size()];
|
||||
uta = unitTests.toArray(uta);
|
||||
|
||||
/* 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 = new ScriptField_ListAllocs_s(mRS, uta.length);
|
||||
for (int i = 0; i < uta.length; i++) {
|
||||
ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
|
||||
listElem.text = Allocation.createFromString(mRS, uta[i].name);
|
||||
listElem.result = uta[i].result;
|
||||
mListAllocs.set(listElem, i, false);
|
||||
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();
|
||||
@@ -92,6 +95,15 @@ public class RSTestCore {
|
||||
mRS.finish();
|
||||
}
|
||||
|
||||
public void refreshTestResults() {
|
||||
if (mListAllocs != null && mScript != null && mRS != null) {
|
||||
mListAllocs.copyAll();
|
||||
|
||||
mScript.bind_gList(mListAllocs);
|
||||
mRS.contextBindRootScript(mScript);
|
||||
}
|
||||
}
|
||||
|
||||
public void newTouchPosition(float x, float y, float pressure, int id) {
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import android.renderscript.*;
|
||||
public class UT_fp_mad extends UnitTest {
|
||||
private Resources mRes;
|
||||
|
||||
protected UT_fp_mad(Resources res) {
|
||||
super("Fp_Mad");
|
||||
protected UT_fp_mad(RSTestCore rstc, Resources res) {
|
||||
super(rstc, "Fp_Mad");
|
||||
mRes = res;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import android.renderscript.*;
|
||||
public class UT_primitives extends UnitTest {
|
||||
private Resources mRes;
|
||||
|
||||
protected UT_primitives(Resources res) {
|
||||
super("Primitives");
|
||||
protected UT_primitives(RSTestCore rstc, Resources res) {
|
||||
super(rstc, "Primitives");
|
||||
mRes = res;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ public class UT_primitives extends UnitTest {
|
||||
pRS.mMessageCallback = mRsMessage;
|
||||
s.invoke_primitives_test(0, 0);
|
||||
pRS.finish();
|
||||
//android.util.Log.v("UT", "After pRS.finish");
|
||||
|
||||
pRS.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,23 +20,30 @@ import android.renderscript.RenderScript.RSMessage;
|
||||
public class UnitTest extends Thread {
|
||||
public String name;
|
||||
public int result;
|
||||
private ScriptField_ListAllocs_s.Item mItem;
|
||||
private RSTestCore mRSTC;
|
||||
|
||||
/* These constants must match those in shared.rsh */
|
||||
public static final int RS_MSG_TEST_PASSED = 100;
|
||||
public static final int RS_MSG_TEST_FAILED = 101;
|
||||
|
||||
protected UnitTest(String n, int initResult) {
|
||||
protected UnitTest(RSTestCore rstc, String n, int initResult) {
|
||||
super();
|
||||
mRSTC = rstc;
|
||||
name = n;
|
||||
result = initResult;
|
||||
}
|
||||
|
||||
protected UnitTest(String n) {
|
||||
this(n, 0);
|
||||
protected UnitTest(RSTestCore rstc, String n) {
|
||||
this(rstc, n, 0);
|
||||
}
|
||||
|
||||
protected UnitTest(RSTestCore rstc) {
|
||||
this (rstc, "<Unknown>");
|
||||
}
|
||||
|
||||
protected UnitTest() {
|
||||
this ("<Unknown>");
|
||||
this (null);
|
||||
}
|
||||
|
||||
protected RSMessage mRsMessage = new RSMessage() {
|
||||
@@ -51,9 +58,18 @@ public class UnitTest extends Thread {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mItem != null) {
|
||||
mItem.result = result;
|
||||
mRSTC.refreshTestResults();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void setItem(ScriptField_ListAllocs_s.Item item) {
|
||||
mItem = item;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
/* This method needs to be implemented for each subclass */
|
||||
}
|
||||
|
||||
@@ -71,8 +71,10 @@ int root(int launchID) {
|
||||
case -1: /* Failed */
|
||||
rsgFontColor(0.9f, 0.5f, 0.5f, 1.0f);
|
||||
break;
|
||||
case 0: /* Unknown */
|
||||
default:
|
||||
case 0: /* Still Testing */
|
||||
rsgFontColor(0.9f, 0.9f, 0.5f, 1.0f);
|
||||
break;
|
||||
default: /* Unknown */
|
||||
rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user