Fix a nagging inconvenience from my IDE in running tests, due to working directory issues

git-svn-id: https://zxing.googlecode.com/svn/trunk@832 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-01-28 19:03:25 +00:00
parent bb373c5929
commit 4d225d48e1
29 changed files with 38 additions and 85 deletions

View file

@ -86,9 +86,15 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
private final BarcodeFormat expectedFormat;
private final List<TestResult> testResults;
protected AbstractBlackBoxTestCase(File testBase,
protected AbstractBlackBoxTestCase(String testBasePathSuffix,
Reader barcodeReader,
BarcodeFormat expectedFormat) {
// A little workaround to prevent aggravation in my IDE
File testBase = new File(testBasePathSuffix);
if (!testBase.exists()) {
// try starting with 'core' since the test base is often given as the project root
testBase = new File("core/" + testBasePathSuffix);
}
this.testBase = testBase;
this.barcodeReader = barcodeReader;
this.expectedFormat = expectedFormat;
@ -184,7 +190,7 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
}
}
result = getReader().decode(source, hints);
result = barcodeReader.decode(source, hints);
} catch (ReaderException re) {
System.out.println(re + suffix);
return false;
@ -225,7 +231,7 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
return original;
} else {
AffineTransform at = new AffineTransform();
at.rotate(Math.toRadians(degrees), original.getWidth() / 2.0f, original.getHeight() / 2.0f);
at.rotate(Math.toRadians(degrees), original.getWidth() / 2.0, original.getHeight() / 2.0);
BufferedImageOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
return op.filter(original, null);
}

View file

@ -58,8 +58,8 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
private final List<TestResult> testResults;
// Use the multiformat reader to evaluate all decoders in the system.
protected AbstractNegativeBlackBoxTestCase(File testBase) {
super(testBase, new MultiFormatReader(), null);
protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
super(testBasePathSuffix, new MultiFormatReader(), null);
testResults = new ArrayList<TestResult>();
}

View file

@ -16,12 +16,9 @@
package com.google.zxing.datamatrix;
//import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author bbrown@google.com (Brian Brown)
*/
@ -29,7 +26,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(), BarcodeFormat.DATAMATRIX);
super("test/data/blackbox/datamatrix-1", new DataMatrixReader(), BarcodeFormat.DATAMATRIX);
addTest(7, 7, 0.0f);
addTest(7, 7, 90.0f);
addTest(6, 6, 180.0f);

View file

@ -16,12 +16,9 @@
package com.google.zxing.datamatrix;
//import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
@ -29,7 +26,7 @@ public final class DataMatrixBlackBox2TestCase extends AbstractBlackBoxTestCase
public DataMatrixBlackBox2TestCase() {
// TODO use MultiFormatReader here once Data Matrix decoder is done
super(new File("test/data/blackbox/datamatrix-2"), new DataMatrixReader(), BarcodeFormat.DATAMATRIX);
super("test/data/blackbox/datamatrix-2", new DataMatrixReader(), BarcodeFormat.DATAMATRIX);
addTest(3, 3, 0.0f);
addTest(1, 1, 90.0f);
addTest(3, 3, 180.0f);

View file

@ -18,8 +18,6 @@ package com.google.zxing.negative;
import com.google.zxing.common.AbstractNegativeBlackBoxTestCase;
import java.io.File;
/**
* This test ensures that random images with high contrast patterns do not decode as barcodes.
*
@ -28,7 +26,7 @@ import java.io.File;
public final class FalsePositivesBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase {
public FalsePositivesBlackBoxTestCase() {
super(new File("test/data/blackbox/falsepositives"));
super("test/data/blackbox/falsepositives");
addTest(2, 0.0f);
addTest(0, 90.0f);
addTest(0, 180.0f);

View file

@ -18,8 +18,6 @@ package com.google.zxing.negative;
import com.google.zxing.common.AbstractNegativeBlackBoxTestCase;
import java.io.File;
/**
* This test ensures that partial barcodes do not decode.
*
@ -28,7 +26,7 @@ import java.io.File;
public final class PartialBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase {
public PartialBlackBoxTestCase() {
super(new File("test/data/blackbox/partial"));
super("test/data/blackbox/partial");
addTest(0, 0.0f);
addTest(1, 90.0f);
addTest(1, 180.0f);

View file

@ -18,8 +18,6 @@ package com.google.zxing.negative;
import com.google.zxing.common.AbstractNegativeBlackBoxTestCase;
import java.io.File;
/**
* This test ensures that unsupported barcodes do not decode.
*
@ -28,7 +26,7 @@ import java.io.File;
public final class UnsupportedBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase {
public UnsupportedBlackBoxTestCase() {
super(new File("test/data/blackbox/unsupported"));
super("test/data/blackbox/unsupported");
addTest(0, 0.0f);
addTest(0, 90.0f);
addTest(1, 180.0f);

View file

@ -20,15 +20,13 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class Code128BlackBox1TestCase extends AbstractBlackBoxTestCase {
public Code128BlackBox1TestCase() {
super(new File("test/data/blackbox/code128-1"), new MultiFormatReader(), BarcodeFormat.CODE_128);
super("test/data/blackbox/code128-1", new MultiFormatReader(), BarcodeFormat.CODE_128);
addTest(5, 5, 0.0f);
addTest(5, 5, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class Code128BlackBox2TestCase extends AbstractBlackBoxTestCase {
public Code128BlackBox2TestCase() {
super(new File("test/data/blackbox/code128-2"), new MultiFormatReader(), BarcodeFormat.CODE_128);
super("test/data/blackbox/code128-2", new MultiFormatReader(), BarcodeFormat.CODE_128);
addTest(33, 39, 0.0f);
addTest(34, 37, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class Code128BlackBox3TestCase extends AbstractBlackBoxTestCase {
public Code128BlackBox3TestCase() {
super(new File("test/data/blackbox/code128-3"), new MultiFormatReader(), BarcodeFormat.CODE_128);
super("test/data/blackbox/code128-3", new MultiFormatReader(), BarcodeFormat.CODE_128);
addTest(2, 2, 0.0f);
addTest(2, 2, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class Code39BlackBox1TestCase extends AbstractBlackBoxTestCase {
public Code39BlackBox1TestCase() {
super(new File("test/data/blackbox/code39-1"), new MultiFormatReader(), BarcodeFormat.CODE_39);
super("test/data/blackbox/code39-1", new MultiFormatReader(), BarcodeFormat.CODE_39);
addTest(4, 4, 0.0f);
addTest(4, 4, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class Code39BlackBox3TestCase extends AbstractBlackBoxTestCase {
public Code39BlackBox3TestCase() {
super(new File("test/data/blackbox/code39-3"), new MultiFormatReader(), BarcodeFormat.CODE_39);
super("test/data/blackbox/code39-3", new MultiFormatReader(), BarcodeFormat.CODE_39);
addTest(17, 17, 0.0f);
addTest(17, 17, 180.0f);
}

View file

@ -19,15 +19,13 @@ package com.google.zxing.oned;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.BarcodeFormat;
import java.io.File;
/**
* @author Sean Owen
*/
public final class Code39ExtendedBlackBox2TestCase extends AbstractBlackBoxTestCase {
public Code39ExtendedBlackBox2TestCase() {
super(new File("test/data/blackbox/code39-2"), new Code39Reader(false, true), BarcodeFormat.CODE_39);
super("test/data/blackbox/code39-2", new Code39Reader(false, true), BarcodeFormat.CODE_39);
addTest(2, 2, 0.0f);
addTest(2, 2, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class EAN13BlackBox1TestCase extends AbstractBlackBoxTestCase {
public EAN13BlackBox1TestCase() {
super(new File("test/data/blackbox/ean13-1"), new MultiFormatReader(), BarcodeFormat.EAN_13);
super("test/data/blackbox/ean13-1", new MultiFormatReader(), BarcodeFormat.EAN_13);
addTest(28, 31, 0.0f);
addTest(27, 31, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class EAN13BlackBox2TestCase extends AbstractBlackBoxTestCase {
public EAN13BlackBox2TestCase() {
super(new File("test/data/blackbox/ean13-2"), new MultiFormatReader(), BarcodeFormat.EAN_13);
super("test/data/blackbox/ean13-2", new MultiFormatReader(), BarcodeFormat.EAN_13);
addTest(1, 1, 0.0f);
addTest(1, 1, 180.0f);
}

View file

@ -28,7 +28,7 @@ import java.io.File;
public final class EAN13BlackBox3TestCase extends AbstractBlackBoxTestCase {
public EAN13BlackBox3TestCase() {
super(new File("test/data/blackbox/ean13-3"), new MultiFormatReader(), BarcodeFormat.EAN_13);
super("test/data/blackbox/ean13-3", new MultiFormatReader(), BarcodeFormat.EAN_13);
addTest(49, 55, 0.0f);
addTest(52, 55, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class EAN8BlackBox1TestCase extends AbstractBlackBoxTestCase {
public EAN8BlackBox1TestCase() {
super(new File("test/data/blackbox/ean8-1"), new MultiFormatReader(), BarcodeFormat.EAN_8);
super("test/data/blackbox/ean8-1", new MultiFormatReader(), BarcodeFormat.EAN_8);
addTest(8, 8, 0.0f);
addTest(8, 8, 180.0f);
}

View file

@ -21,7 +21,6 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
import java.util.Hashtable;
import java.util.Vector;
@ -31,7 +30,7 @@ import java.util.Vector;
public final class ITFBlackBox1TestCase extends AbstractBlackBoxTestCase {
public ITFBlackBox1TestCase() {
super(new File("test/data/blackbox/itf-1"), new MultiFormatReader(), BarcodeFormat.ITF);
super("test/data/blackbox/itf-1", new MultiFormatReader(), BarcodeFormat.ITF);
addTest(9, 12, 0.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class UPCABlackBox1TestCase extends AbstractBlackBoxTestCase {
public UPCABlackBox1TestCase() {
super(new File("test/data/blackbox/upca-1"), new MultiFormatReader(), BarcodeFormat.UPC_A);
super("test/data/blackbox/upca-1", new MultiFormatReader(), BarcodeFormat.UPC_A);
addTest(15, 16, 0.0f);
addTest(15, 19, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class UPCABlackBox2TestCase extends AbstractBlackBoxTestCase {
public UPCABlackBox2TestCase() {
super(new File("test/data/blackbox/upca-2"), new MultiFormatReader(), BarcodeFormat.UPC_A);
super("test/data/blackbox/upca-2", new MultiFormatReader(), BarcodeFormat.UPC_A);
addTest(25, 35, 0.0f);
addTest(25, 35, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class UPCABlackBox3ReflectiveTestCase extends AbstractBlackBoxTestCase {
public UPCABlackBox3ReflectiveTestCase() {
super(new File("test/data/blackbox/upca-3"), new MultiFormatReader(), BarcodeFormat.UPC_A);
super("test/data/blackbox/upca-3", new MultiFormatReader(), BarcodeFormat.UPC_A);
addTest(8, 8, 0.0f);
addTest(6, 9, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class UPCABlackBox4TestCase extends AbstractBlackBoxTestCase {
public UPCABlackBox4TestCase() {
super(new File("test/data/blackbox/upca-4"), new MultiFormatReader(), BarcodeFormat.UPC_A);
super("test/data/blackbox/upca-4", new MultiFormatReader(), BarcodeFormat.UPC_A);
addTest(8, 13, 0.0f);
addTest(8, 12, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class UPCEBlackBox1TestCase extends AbstractBlackBoxTestCase {
public UPCEBlackBox1TestCase() {
super(new File("test/data/blackbox/upce-1"), new MultiFormatReader(), BarcodeFormat.UPC_E);
super("test/data/blackbox/upce-1", new MultiFormatReader(), BarcodeFormat.UPC_E);
addTest(3, 3, 0.0f);
addTest(3, 3, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class UPCEBlackBox2TestCase extends AbstractBlackBoxTestCase {
public UPCEBlackBox2TestCase() {
super(new File("test/data/blackbox/upce-2"), new MultiFormatReader(), BarcodeFormat.UPC_E);
super("test/data/blackbox/upce-2", new MultiFormatReader(), BarcodeFormat.UPC_E);
addTest(30, 35, 0.0f);
addTest(29, 35, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class UPCEBlackBox3ReflectiveTestCase extends AbstractBlackBoxTestCase {
public UPCEBlackBox3ReflectiveTestCase() {
super(new File("test/data/blackbox/upce-3"), new MultiFormatReader(), BarcodeFormat.UPC_E);
super("test/data/blackbox/upce-3", new MultiFormatReader(), BarcodeFormat.UPC_E);
addTest(4, 8, 0.0f);
addTest(4, 8, 180.0f);
}

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class QRCodeBlackBox1TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox1TestCase() {
super(new File("test/data/blackbox/qrcode-1"), new MultiFormatReader(), BarcodeFormat.QR_CODE);
super("test/data/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(18, 18, 0.0f);
addTest(14, 14, 90.0f);
addTest(18, 18, 180.0f);

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author Sean Owen
*/
public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox2TestCase() {
super(new File("test/data/blackbox/qrcode-2"), new MultiFormatReader(), BarcodeFormat.QR_CODE);
super("test/data/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(22, 22, 0.0f);
addTest(18, 18, 90.0f);
addTest(22, 22, 180.0f);

View file

@ -20,15 +20,13 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox3TestCase() {
super(new File("test/data/blackbox/qrcode-3"), new MultiFormatReader(), BarcodeFormat.QR_CODE);
super("test/data/blackbox/qrcode-3", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(29, 29, 0.0f);
addTest(26, 26, 90.0f);
addTest(30, 30, 180.0f);

View file

@ -20,8 +20,6 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* Tests of various QR Codes from t-shirts, which are notoriously not flat.
*
@ -30,7 +28,7 @@ import java.io.File;
public final class QRCodeBlackBox4TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox4TestCase() {
super(new File("test/data/blackbox/qrcode-4"), new MultiFormatReader(), BarcodeFormat.QR_CODE);
super("test/data/blackbox/qrcode-4", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(32, 32, 0.0f);
addTest(33, 33, 90.0f);
addTest(32, 32, 180.0f);