X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=core%2Ftest%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fcommon%2FAbstractBlackBoxTestCase.java;h=2ef12b43dda2e70a5b990fc345b97a2920d57f37;hb=608fe313d82bb79f0f5a96856697bdfb4a6305d3;hp=e24f5fbaa688137d32afc6ad979ed7577935ab84;hpb=afc10a58143505842f5a3433ba5675d45346f0be;p=zxing.git diff --git a/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java b/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java index e24f5fba..2ef12b43 100644 --- a/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java +++ b/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java @@ -160,10 +160,10 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { // This workaround is used because AbstractNegativeBlackBoxTestCase overrides this method but does // not return SummaryResults. public void testBlackBox() throws IOException { - testBlackBoxCountingResults(); + testBlackBoxCountingResults(true); } - public SummaryResults testBlackBoxCountingResults() throws IOException { + public SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException { assertFalse(testResults.isEmpty()); File[] imageFiles = getImageFiles(); @@ -184,7 +184,7 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { float rotation = testResults.get(x).getRotation(); BufferedImage rotatedImage = rotateImage(image, rotation); LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); - BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source)); + BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); if (decode(bitmap, rotation, expectedText, false)) { passedCounts[x]++; } @@ -212,19 +212,23 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { int totalTests = imageFiles.length * testCount * 2; System.out.println("TOTALS:\n Decoded " + totalFound + " images out of " + totalTests + - " (" + (totalFound * 100 / totalTests) + "%)"); + " (" + (totalFound * 100 / totalTests) + "%, " + totalMustPass + " required)"); if (totalFound > totalMustPass) { System.out.println(" *** Test too lax by " + (totalFound - totalMustPass) + " images"); + } else if (totalFound < totalMustPass) { + System.out.println(" *** Test failed by " + (totalMustPass - totalFound) + " images"); } // Then run through again and assert if any failed - for (int x = 0; x < testCount; x++) { - assertTrue("Rotation " + testResults.get(x).getRotation() + - " degrees: Too many images failed", - passedCounts[x] >= testResults.get(x).getMustPassCount()); - assertTrue("Try harder, Rotation " + testResults.get(x).getRotation() + - " degrees: Too many images failed", - tryHarderCounts[x] >= testResults.get(x).getTryHarderCount()); + if (assertOnFailure) { + for (int x = 0; x < testCount; x++) { + assertTrue("Rotation " + testResults.get(x).getRotation() + + " degrees: Too many images failed", + passedCounts[x] >= testResults.get(x).getMustPassCount()); + assertTrue("Try harder, Rotation " + testResults.get(x).getRotation() + + " degrees: Too many images failed", + tryHarderCounts[x] >= testResults.get(x).getTryHarderCount()); + } } return new SummaryResults(totalFound, totalMustPass, totalTests); } @@ -290,4 +294,4 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { } } -} \ No newline at end of file +}