Changed the black box tests to require an absolute number of images to decode success...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 18 Apr 2008 14:43:56 +0000 (14:43 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 18 Apr 2008 14:43:56 +0000 (14:43 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@367 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java
core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java
core/test/src/com/google/zxing/oned/Code128BlackBox1TestCase.java
core/test/src/com/google/zxing/oned/Code39BlackBox1TestCase.java
core/test/src/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java
core/test/src/com/google/zxing/oned/EAN13BlackBox1TestCase.java
core/test/src/com/google/zxing/oned/EAN8BlackBox1TestCase.java
core/test/src/com/google/zxing/oned/UPCABlackBox1TestCase.java
core/test/src/com/google/zxing/oned/UPCEBlackBox1TestCase.java
core/test/src/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java
core/test/src/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java

index 94ccc5e..f31ea46 100644 (file)
@@ -49,8 +49,7 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
   private static final FilenameFilter IMAGE_NAME_FILTER = new FilenameFilter() {
     public boolean accept(File dir, String name) {
       String lowerCase = name.toLowerCase();
-      return
-          lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg") ||
+      return lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg") ||
               lowerCase.endsWith(".gif") || lowerCase.endsWith(".png") ||
               lowerCase.endsWith(".url");
     }
@@ -58,16 +57,16 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
 
   private final File testBase;
   private final Reader barcodeReader;
-  private final double passPercent;
+  private final int mustPassCount;
   private final BarcodeFormat expectedFormat;
 
   protected AbstractBlackBoxTestCase(File testBase,
                                      Reader barcodeReader,
-                                     double passPercent,
+                                     int mustPassCount,
                                      BarcodeFormat expectedFormat) {
     this.testBase = testBase;
     this.barcodeReader = barcodeReader;
-    this.passPercent = passPercent;
+    this.mustPassCount = mustPassCount;
     this.expectedFormat = expectedFormat;
   }
 
@@ -99,8 +98,8 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
       assertEquals(expectedFormat, result.getBarcodeFormat());
 
       String testImageFileName = testImage.getName();
-      File expectedTextFile =
-          new File(testBase, testImageFileName.substring(0, testImageFileName.indexOf('.')) + ".txt");
+      File expectedTextFile = new File(testBase,
+          testImageFileName.substring(0, testImageFileName.indexOf('.')) + ".txt");
       String expectedText = readFileAsString(expectedTextFile);
       String resultText = result.getText();
 
@@ -116,16 +115,19 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
         result = barcodeReader.decode(source, TRY_HARDER_HINT);
       } catch (ReaderException re) {
         if (passed) {
-          fail("Normal mode succeed but \"try harder\" failed");
+          fail("Normal mode succeeded 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());
+      assertEquals("Normal mode succeeded but \"try harder\" failed", expectedFormat,
+          result.getBarcodeFormat());
+      assertEquals("Normal mode succeeded but \"try harder\" failed", expectedText,
+          result.getText());
     }
 
-    System.out.println(passedCount + " of " + imageFiles.length + " images passed");
-    assertTrue("Too many images failed", passedCount >= (int) (imageFiles.length * passPercent));
+    System.out.println(passedCount + " of " + imageFiles.length + " images passed (" +
+        mustPassCount + " required)");
+    assertTrue("Too many images failed", passedCount >= mustPassCount);
   }
 
   private static String readFileAsString(File file) throws IOException {
index 3820403..f3e690a 100644 (file)
@@ -29,7 +29,7 @@ public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase
 
   public DataMatrixBlackBox1TestCase() {
     // TODO use MultiFormatReader here once Data Matrix decoder is done
-    super(new File("test/data/blackbox/datamatrix-1"), new DataMatrixReader(), 1.0, BarcodeFormat.DATAMATRIX);
+    super(new File("test/data/blackbox/datamatrix-1"), new DataMatrixReader(), 7, BarcodeFormat.DATAMATRIX);
   }
 
 }
\ No newline at end of file
index 5922e73..c9fec32 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class Code128BlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public Code128BlackBox1TestCase() {
-    super(new File("test/data/blackbox/code128-1"), new MultiFormatReader(), 1.0, BarcodeFormat.CODE_128);
+    super(new File("test/data/blackbox/code128-1"), new MultiFormatReader(), 5, BarcodeFormat.CODE_128);
   }
 
 }
\ No newline at end of file
index 204c976..ee68b51 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class Code39BlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public Code39BlackBox1TestCase() {
-    super(new File("test/data/blackbox/code39-1"), new MultiFormatReader(), 1.0, BarcodeFormat.CODE_39);
+    super(new File("test/data/blackbox/code39-1"), new MultiFormatReader(), 4, BarcodeFormat.CODE_39);
   }
 
 }
\ No newline at end of file
index 55cbf59..270524e 100644 (file)
@@ -27,7 +27,7 @@ import java.io.File;
 public final class Code39ExtendedBlackBox2TestCase extends AbstractBlackBoxTestCase {
 
   public Code39ExtendedBlackBox2TestCase() {
-    super(new File("test/data/blackbox/code39-2"), new Code39Reader(false, true), 1.0, BarcodeFormat.CODE_39);
+    super(new File("test/data/blackbox/code39-2"), new Code39Reader(false, true), 2, BarcodeFormat.CODE_39);
   }
 
 }
\ No newline at end of file
index d98db59..29fb9c2 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class EAN13BlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public EAN13BlackBox1TestCase() {
-    super(new File("test/data/blackbox/ean13-1"), new MultiFormatReader(), 0.66, BarcodeFormat.EAN_13);
+    super(new File("test/data/blackbox/ean13-1"), new MultiFormatReader(), 25, BarcodeFormat.EAN_13);
   }
 
 }
\ No newline at end of file
index 009a547..2cd3a1c 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class EAN8BlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public EAN8BlackBox1TestCase() {
-    super(new File("test/data/blackbox/ean8-1"), new MultiFormatReader(), 1.0, BarcodeFormat.EAN_8);
+    super(new File("test/data/blackbox/ean8-1"), new MultiFormatReader(), 8, BarcodeFormat.EAN_8);
   }
 
 }
\ No newline at end of file
index 7d099d4..9f3f0c0 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class UPCABlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public UPCABlackBox1TestCase() {
-    super(new File("test/data/blackbox/upca-1"), new MultiFormatReader(), 0.5, BarcodeFormat.UPC_A);
+    super(new File("test/data/blackbox/upca-1"), new MultiFormatReader(), 14, BarcodeFormat.UPC_A);
   }
 
 }
\ No newline at end of file
index c4c93c8..56c487e 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class UPCEBlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public UPCEBlackBox1TestCase() {
-    super(new File("test/data/blackbox/upce-1"), new MultiFormatReader(), 1.0, BarcodeFormat.UPC_E);
+    super(new File("test/data/blackbox/upce-1"), new MultiFormatReader(), 3, BarcodeFormat.UPC_E);
   }
 
 }
\ No newline at end of file
index 801f626..a0cdba9 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class QRCodeBlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public QRCodeBlackBox1TestCase() {
-    super(new File("test/data/blackbox/qrcode-1"), new MultiFormatReader(), 0.5, BarcodeFormat.QR_CODE);
+    super(new File("test/data/blackbox/qrcode-1"), new MultiFormatReader(), 16, BarcodeFormat.QR_CODE);
   }
 
 }
\ No newline at end of file
index f1ecdd5..4c2f0dc 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase {
 
   public QRCodeBlackBox2TestCase() {
-    super(new File("test/data/blackbox/qrcode-2"), new MultiFormatReader(), 1.0, BarcodeFormat.QR_CODE);
+    super(new File("test/data/blackbox/qrcode-2"), new MultiFormatReader(), 10, BarcodeFormat.QR_CODE);
   }
 
 }
\ No newline at end of file