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;
|
package com.google.zxing.common;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.DecodeHintType;
|
||||||
import com.google.zxing.MonochromeBitmapSource;
|
import com.google.zxing.MonochromeBitmapSource;
|
||||||
import com.google.zxing.Reader;
|
import com.google.zxing.Reader;
|
||||||
import com.google.zxing.ReaderException;
|
import com.google.zxing.ReaderException;
|
||||||
|
@ -32,12 +33,19 @@ import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author srowen@google.com (Sean Owen)
|
* @author srowen@google.com (Sean Owen)
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBlackBoxTestCase extends TestCase {
|
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() {
|
private static final FilenameFilter IMAGE_NAME_FILTER = new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
String lowerCase = name.toLowerCase();
|
String lowerCase = name.toLowerCase();
|
||||||
|
@ -96,12 +104,24 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
|
||||||
String expectedText = readFileAsString(expectedTextFile);
|
String expectedText = readFileAsString(expectedTextFile);
|
||||||
String resultText = result.getText();
|
String resultText = result.getText();
|
||||||
|
|
||||||
if (expectedText.equals(resultText)) {
|
boolean passed = expectedText.equals(resultText);
|
||||||
|
if (passed) {
|
||||||
passedCount++;
|
passedCount++;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Mismatch: expected '" + expectedText + "' but got '" + resultText + '\'');
|
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");
|
System.out.println(passedCount + " of " + imageFiles.length + " images passed");
|
||||||
|
|
Loading…
Reference in a new issue