mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Tries TRY_HARDER too in tests now, to confirm it only improves accuracy, never hurts
git-svn-id: https://zxing.googlecode.com/svn/trunk@236 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
c4ee6727d6
commit
7c1d8184f3
|
@ -17,6 +17,7 @@
|
|||
package com.google.zxing.common;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.MonochromeBitmapSource;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
|
@ -32,12 +33,19 @@ import java.io.FilenameFilter;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* @author srowen@google.com (Sean Owen)
|
||||
*/
|
||||
public abstract class AbstractBlackBoxTestCase extends TestCase {
|
||||
|
||||
private static final Hashtable TRY_HARDER_HINT;
|
||||
static {
|
||||
TRY_HARDER_HINT = new Hashtable();
|
||||
TRY_HARDER_HINT.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
|
||||
}
|
||||
|
||||
private static final FilenameFilter IMAGE_NAME_FILTER = new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
String lowerCase = name.toLowerCase();
|
||||
|
@ -96,12 +104,24 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
|
|||
String expectedText = readFileAsString(expectedTextFile);
|
||||
String resultText = result.getText();
|
||||
|
||||
if (expectedText.equals(resultText)) {
|
||||
boolean passed = expectedText.equals(resultText);
|
||||
if (passed) {
|
||||
passedCount++;
|
||||
} else {
|
||||
System.out.println("Mismatch: expected '" + expectedText + "' but got '" + resultText + '\'');
|
||||
}
|
||||
|
||||
// Try "try harder" mode
|
||||
try {
|
||||
result = barcodeReader.decode(source, TRY_HARDER_HINT);
|
||||
} catch (ReaderException re) {
|
||||
if (passed) {
|
||||
fail("Normal mode succeed but \"try harder\" failed");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
assertEquals("Normal mode succeed but \"try harder\" failed", expectedFormat, result.getBarcodeFormat());
|
||||
assertEquals("Normal mode succeed but \"try harder\" failed", expectedText, result.getText());
|
||||
}
|
||||
|
||||
System.out.println(passedCount + " of " + imageFiles.length + " images passed");
|
||||
|
|
Loading…
Reference in a new issue