|
|
|
@ -29,6 +29,11 @@ import static junit.framework.Assert.assertFalse; |
|
|
|
|
import static junit.framework.Assert.assertTrue; |
|
|
|
|
|
|
|
|
|
public class OpenCVTestCase extends TestCase { |
|
|
|
|
|
|
|
|
|
public static class TestSkipException extends RuntimeException { |
|
|
|
|
public TestSkipException() {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//change to 'true' to unblock fail on fail("Not yet implemented")
|
|
|
|
|
public static final boolean passNYI = true; |
|
|
|
|
|
|
|
|
@ -188,12 +193,40 @@ public class OpenCVTestCase extends TestCase { |
|
|
|
|
protected void runTest() throws Throwable { |
|
|
|
|
// Do nothing if the precondition does not hold.
|
|
|
|
|
if (isTestCaseEnabled) { |
|
|
|
|
super.runTest(); |
|
|
|
|
try { |
|
|
|
|
super.runTest(); |
|
|
|
|
} catch (TestSkipException ex) { |
|
|
|
|
Log.w(TAG, "Test case \"" + this.getClass().getName() + "\" skipped!"); |
|
|
|
|
assertTrue(true); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Log.e(TAG, "Test case \"" + this.getClass().getName() + "\" disabled!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void runBare() throws Throwable { |
|
|
|
|
Throwable exception = null; |
|
|
|
|
try { |
|
|
|
|
setUp(); |
|
|
|
|
} catch (TestSkipException ex) { |
|
|
|
|
Log.w(TAG, "Test case \"" + this.getClass().getName() + "\" skipped!"); |
|
|
|
|
assertTrue(true); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
runTest(); |
|
|
|
|
} catch (Throwable running) { |
|
|
|
|
exception = running; |
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
tearDown(); |
|
|
|
|
} catch (Throwable tearingDown) { |
|
|
|
|
if (exception == null) exception = tearingDown; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (exception != null) throw exception; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected Mat getMat(int type, double... vals) |
|
|
|
|
{ |
|
|
|
|
return new Mat(matSize, matSize, type, new Scalar(vals)); |
|
|
|
@ -211,6 +244,10 @@ public class OpenCVTestCase extends TestCase { |
|
|
|
|
TestCase.fail(msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void assertGE(double v1, double v2) { |
|
|
|
|
assertTrue("Failed: " + v1 + " >= " + v2, v1 >= v2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static <E extends Number> void assertListEquals(List<E> list1, List<E> list2) { |
|
|
|
|
if (list1.size() != list2.size()) { |
|
|
|
|
throw new UnsupportedOperationException(); |
|
|
|
@ -425,10 +462,10 @@ public class OpenCVTestCase extends TestCase { |
|
|
|
|
|
|
|
|
|
if (isEqualityMeasured) |
|
|
|
|
assertTrue("Max difference between expected and actiual Mats is "+ maxDiff + ", that bigger than " + eps, |
|
|
|
|
Core.checkRange(diff, true, 0.0, eps)); |
|
|
|
|
maxDiff <= eps); |
|
|
|
|
else |
|
|
|
|
assertFalse("Max difference between expected and actiual Mats is "+ maxDiff + ", that less than " + eps, |
|
|
|
|
Core.checkRange(diff, true, 0.0, eps)); |
|
|
|
|
maxDiff <= eps); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static String readFile(String path) { |
|
|
|
@ -497,6 +534,10 @@ public class OpenCVTestCase extends TestCase { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch(Exception ex) { |
|
|
|
|
if (cname.startsWith(XFEATURES2D)) |
|
|
|
|
{ |
|
|
|
|
throw new TestSkipException(); |
|
|
|
|
} |
|
|
|
|
message = TAG + " :: " + "could not instantiate " + cname + "! Exception: " + ex.getMessage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|