AbstractBlackBoxTestCase.java (zxing-zxing-3.4.0) | : | AbstractBlackBoxTestCase.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 128 | skipping to change at line 128 | |||
paths.add(path); | paths.add(path); | |||
} | } | |||
} | } | |||
return paths; | return paths; | |||
} | } | |||
final Reader getReader() { | final Reader getReader() { | |||
return barcodeReader; | return barcodeReader; | |||
} | } | |||
// This workaround is used because AbstractNegativeBlackBoxTestCase overrides | ||||
this method but does | ||||
// not return SummaryResults. | ||||
@Test | @Test | |||
public void testBlackBox() throws IOException { | public void testBlackBox() throws IOException { | |||
testBlackBoxCountingResults(true); | ||||
} | ||||
private void testBlackBoxCountingResults(boolean assertOnFailure) throws IOExc | ||||
eption { | ||||
assertFalse(testResults.isEmpty()); | assertFalse(testResults.isEmpty()); | |||
List<Path> imageFiles = getImageFiles(); | List<Path> imageFiles = getImageFiles(); | |||
int testCount = testResults.size(); | int testCount = testResults.size(); | |||
int[] passedCounts = new int[testCount]; | int[] passedCounts = new int[testCount]; | |||
int[] misreadCounts = new int[testCount]; | int[] misreadCounts = new int[testCount]; | |||
int[] tryHarderCounts = new int[testCount]; | int[] tryHarderCounts = new int[testCount]; | |||
int[] tryHarderMisreadCounts = new int[testCount]; | int[] tryHarderMisreadCounts = new int[testCount]; | |||
skipping to change at line 238 | skipping to change at line 232 | |||
log.warning(String.format("--- Test failed by %d images", totalMustPass - totalFound)); | log.warning(String.format("--- Test failed by %d images", totalMustPass - totalFound)); | |||
} | } | |||
if (totalMisread < totalMaxMisread) { | if (totalMisread < totalMaxMisread) { | |||
log.warning(String.format("+++ Test expects too many misreads by %d images ", totalMaxMisread - totalMisread)); | log.warning(String.format("+++ Test expects too many misreads by %d images ", totalMaxMisread - totalMisread)); | |||
} else if (totalMisread > totalMaxMisread) { | } else if (totalMisread > totalMaxMisread) { | |||
log.warning(String.format("--- Test had too many misreads by %d images", t otalMisread - totalMaxMisread)); | log.warning(String.format("--- Test had too many misreads by %d images", t otalMisread - totalMaxMisread)); | |||
} | } | |||
// Then run through again and assert if any failed | // Then run through again and assert if any failed | |||
if (assertOnFailure) { | for (int x = 0; x < testCount; x++) { | |||
for (int x = 0; x < testCount; x++) { | TestResult testResult = testResults.get(x); | |||
TestResult testResult = testResults.get(x); | String label = "Rotation " + testResult.getRotation() + " degrees: Too man | |||
String label = "Rotation " + testResult.getRotation() + " degrees: Too m | y images failed"; | |||
any images failed"; | assertTrue(label, | |||
assertTrue(label, | passedCounts[x] >= testResult.getMustPassCount()); | |||
passedCounts[x] >= testResult.getMustPassCount()); | assertTrue("Try harder, " + label, | |||
assertTrue("Try harder, " + label, | tryHarderCounts[x] >= testResult.getTryHarderCount()); | |||
tryHarderCounts[x] >= testResult.getTryHarderCount()); | label = "Rotation " + testResult.getRotation() + " degrees: Too many image | |||
label = "Rotation " + testResult.getRotation() + " degrees: Too many ima | s misread"; | |||
ges misread"; | assertTrue(label, | |||
assertTrue(label, | misreadCounts[x] <= testResult.getMaxMisreads()); | |||
misreadCounts[x] <= testResult.getMaxMisreads()); | assertTrue("Try harder, " + label, | |||
assertTrue("Try harder, " + label, | tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads | |||
tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisrea | ()); | |||
ds()); | ||||
} | ||||
} | } | |||
} | } | |||
private boolean decode(BinaryBitmap source, | private boolean decode(BinaryBitmap source, | |||
float rotation, | float rotation, | |||
String expectedText, | String expectedText, | |||
Map<?,?> expectedMetadata, | Map<?,?> expectedMetadata, | |||
boolean tryHarder) throws ReaderException { | boolean tryHarder) throws ReaderException { | |||
String suffix = String.format(" (%srotation: %d)", tryHarder ? "try harder, " : "", (int) rotation); | String suffix = String.format(" (%srotation: %d)", tryHarder ? "try harder, " : "", (int) rotation); | |||
End of changes. 3 change blocks. | ||||
25 lines changed or deleted | 15 lines changed or added |