move all Result to RXingResult

This commit is contained in:
Henry Schimke
2022-08-20 12:12:30 -05:00
parent 9f72478dc8
commit 90ace738b7
149 changed files with 1658 additions and 1658 deletions

View File

@@ -18,11 +18,11 @@ package com.google.zxing.aztec.decoder;
import com.google.zxing.aztec.encoder.EncoderTest;
import com.google.zxing.FormatException;
import com.google.zxing.ResultPoint;
import com.google.zxing.aztec.AztecDetectorResult;
import com.google.zxing.RXingResultPoint;
import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult;
import com.google.zxing.common.DecoderRXingResult;
import org.junit.Test;
import org.junit.Assert;
@@ -31,7 +31,7 @@ import org.junit.Assert;
*/
public final class DecoderTest extends Assert {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
@Test
public void testHighLevelDecode() throws FormatException {
@@ -64,7 +64,7 @@ public final class DecoderTest extends Assert {
}
@Test
public void testAztecResult() throws FormatException {
public void testAztecRXingResult() throws FormatException {
BitMatrix matrix = BitMatrix.parse(
"X X X X X X X X X X X X X X \n" +
"X X X X X X X X X X X X X X X \n" +
@@ -90,8 +90,8 @@ public final class DecoderTest extends Assert {
"X X X X X X X X X X X X X X \n" +
" X X X X X X X X X X X X X \n",
"X ", " ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 30, 2);
DecoderResult result = new Decoder().decode(r);
AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, false, 30, 2);
DecoderRXingResult result = new Decoder().decode(r);
assertEquals("88888TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", result.getText());
assertArrayEquals(
new byte[] {-11, 85, 85, 117, 107, 90, -42, -75, -83, 107,
@@ -102,7 +102,7 @@ public final class DecoderTest extends Assert {
}
@Test
public void testAztecResultECI() throws FormatException {
public void testAztecRXingResultECI() throws FormatException {
BitMatrix matrix = BitMatrix.parse(
" X X X X X X \n" +
" X X X X X X X X X X X X \n" +
@@ -124,8 +124,8 @@ public final class DecoderTest extends Assert {
" X X X X X X X X X X X \n" +
"X X X X X X X X \n",
"X ", " ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 15, 1);
DecoderResult result = new Decoder().decode(r);
AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, false, 15, 1);
DecoderRXingResult result = new Decoder().decode(r);
assertEquals("Français", result.getText());
}
@@ -160,7 +160,7 @@ public final class DecoderTest extends Assert {
+ "X X X X . . . X . . X X X . X X . . X . . . . X X X . \n"
+ "X X . X . X . . . X . X . . . . X X . X . . X X . . . \n",
"X ", ". ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4);
AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, true, 16, 4);
new Decoder().decode(r);
}
@@ -195,7 +195,7 @@ public final class DecoderTest extends Assert {
+ ". X X X X . . X . . X X X . X X . . X . . . . X X X . \n"
+ "X X . . . X X . . X . X . . . . X X . X . . X . X . X \n",
"X ", ". ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4);
AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, true, 16, 4);
new Decoder().decode(r);
}

View File

@@ -17,13 +17,13 @@
package com.google.zxing.aztec.detector;
import com.google.zxing.NotFoundException;
import com.google.zxing.aztec.AztecDetectorResult;
import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.aztec.decoder.Decoder;
import com.google.zxing.aztec.detector.Detector.Point;
import com.google.zxing.aztec.encoder.AztecCode;
import com.google.zxing.aztec.encoder.Encoder;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult;
import com.google.zxing.common.DecoderRXingResult;
import org.junit.Assert;
import org.junit.Test;
@@ -78,11 +78,11 @@ public final class DetectorTest extends Assert {
copy.flip(orientationPoints.get(error2).getX(), orientationPoints.get(error2).getY());
}
// The detector doesn't seem to work when matrix bits are only 1x1. So magnify.
AztecDetectorResult r = new Detector(makeLarger(copy, 3)).detect(isMirror);
AztecDetectorRXingResult r = new Detector(makeLarger(copy, 3)).detect(isMirror);
assertNotNull(r);
assertEquals(r.getNbLayers(), layers);
assertEquals(r.isCompact(), compact);
DecoderResult res = new Decoder().decode(r);
DecoderRXingResult res = new Decoder().decode(r);
assertEquals(data, res.getText());
}
}

View File

@@ -19,13 +19,13 @@ package com.google.zxing.aztec.encoder;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.FormatException;
import com.google.zxing.ResultPoint;
import com.google.zxing.aztec.AztecDetectorResult;
import com.google.zxing.RXingResultPoint;
import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.aztec.AztecWriter;
import com.google.zxing.aztec.decoder.Decoder;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult;
import com.google.zxing.common.DecoderRXingResult;
import org.junit.Assert;
import org.junit.Test;
@@ -52,7 +52,7 @@ public final class EncoderTest extends Assert {
private static final Pattern DOTX = Pattern.compile("[^.X]");
private static final Pattern SPACES = Pattern.compile("\\s+");
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
// real life tests
@@ -492,9 +492,9 @@ public final class EncoderTest extends Assert {
assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact());
assertEquals("Unexpected nr. of layers", layers, aztec.getLayers());
BitMatrix matrix = aztec.getMatrix();
AztecDetectorResult r =
new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
DecoderResult res = new Decoder().decode(r);
AztecDetectorRXingResult r =
new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
DecoderRXingResult res = new Decoder().decode(r);
assertEquals(data, res.getText());
// Check error correction by introducing a few minor errors
Random random = getPseudoRandom();
@@ -502,7 +502,7 @@ public final class EncoderTest extends Assert {
matrix.flip(random.nextInt(matrix.getWidth()), matrix.getHeight() - 2 + random.nextInt(2));
matrix.flip(random.nextInt(2), random.nextInt(matrix.getHeight()));
matrix.flip(matrix.getWidth() - 2 + random.nextInt(2), random.nextInt(matrix.getHeight()));
r = new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
r = new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
res = new Decoder().decode(r);
assertEquals(data, res.getText());
}
@@ -526,9 +526,9 @@ public final class EncoderTest extends Assert {
assertEquals("Unexpected nr. of layers", layers, aztec.getLayers());
BitMatrix matrix2 = aztec.getMatrix();
assertEquals(matrix, matrix2);
AztecDetectorResult r =
new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
DecoderResult res = new Decoder().decode(r);
AztecDetectorRXingResult r =
new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
DecoderRXingResult res = new Decoder().decode(r);
assertEquals(data, res.getText());
// Check error correction by introducing up to eccPercent/2 errors
int ecWords = aztec.getCodeWords() * eccPercent / 100 / 2;
@@ -543,7 +543,7 @@ public final class EncoderTest extends Assert {
: matrix.getHeight() - 1 - random.nextInt(aztec.getLayers() * 2);
matrix.flip(x, y);
}
r = new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
r = new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
res = new Decoder().decode(r);
assertEquals(data, res.getText());
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link AddressBookParsedResult}.
* Tests {@link AddressBookParsedRXingResult}.
*
* @author Sean Owen
*/
public final class AddressBookParsedResultTestCase extends Assert {
public final class AddressBookParsedRXingResultTestCase extends Assert {
@Test
public void testAddressBookDocomo() {
@@ -149,21 +149,21 @@ public final class AddressBookParsedResultTestCase extends Assert {
String[] urls,
String birthday,
String note) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.ADDRESSBOOK, result.getType());
AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
assertEquals(title, addressResult.getTitle());
assertArrayEquals(names, addressResult.getNames());
assertEquals(pronunciation, addressResult.getPronunciation());
assertArrayEquals(addresses, addressResult.getAddresses());
assertArrayEquals(emails, addressResult.getEmails());
assertArrayEquals(phoneNumbers, addressResult.getPhoneNumbers());
assertArrayEquals(phoneTypes, addressResult.getPhoneTypes());
assertEquals(org, addressResult.getOrg());
assertArrayEquals(urls, addressResult.getURLs());
assertEquals(birthday, addressResult.getBirthday());
assertEquals(note, addressResult.getNote());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.ADDRESSBOOK, result.getType());
AddressBookParsedRXingResult addressRXingResult = (AddressBookParsedRXingResult) result;
assertEquals(title, addressRXingResult.getTitle());
assertArrayEquals(names, addressRXingResult.getNames());
assertEquals(pronunciation, addressRXingResult.getPronunciation());
assertArrayEquals(addresses, addressRXingResult.getAddresses());
assertArrayEquals(emails, addressRXingResult.getEmails());
assertArrayEquals(phoneNumbers, addressRXingResult.getPhoneNumbers());
assertArrayEquals(phoneTypes, addressRXingResult.getPhoneTypes());
assertEquals(org, addressRXingResult.getOrg());
assertArrayEquals(urls, addressRXingResult.getURLs());
assertEquals(birthday, addressRXingResult.getBirthday());
assertEquals(note, addressRXingResult.getNote());
}
}

View File

@@ -17,7 +17,7 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -28,11 +28,11 @@ import java.util.Locale;
import java.util.TimeZone;
/**
* Tests {@link CalendarParsedResult}.
* Tests {@link CalendarParsedRXingResult}.
*
* @author Sean Owen
*/
public final class CalendarParsedResultTestCase extends Assert {
public final class CalendarParsedRXingResultTestCase extends Assert {
private static final double EPSILON = 1.0E-10;
@@ -142,11 +142,11 @@ public final class CalendarParsedResultTestCase extends Assert {
@Test
public void testBadGeo() {
// Not parsed as VEVENT
Result fakeResult = new Result("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
RXingResult fakeRXingResult = new RXingResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
"GEO:-12.345\r\n" +
"END:VEVENT\r\nEND:VCALENDAR", null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.TEXT, result.getType());
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.TEXT, result.getType());
}
@Test
@@ -223,20 +223,20 @@ public final class CalendarParsedResultTestCase extends Assert {
String[] attendees,
double latitude,
double longitude) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.CALENDAR, result.getType());
CalendarParsedResult calResult = (CalendarParsedResult) result;
assertEquals(description, calResult.getDescription());
assertEquals(summary, calResult.getSummary());
assertEquals(location, calResult.getLocation());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.CALENDAR, result.getType());
CalendarParsedRXingResult calRXingResult = (CalendarParsedRXingResult) result;
assertEquals(description, calRXingResult.getDescription());
assertEquals(summary, calRXingResult.getSummary());
assertEquals(location, calRXingResult.getLocation());
DateFormat dateFormat = makeGMTFormat();
assertEquals(startString, dateFormat.format(calResult.getStartTimestamp()));
assertEquals(endString, calResult.getEndTimestamp() < 0L ? null : dateFormat.format(calResult.getEndTimestamp()));
assertEquals(organizer, calResult.getOrganizer());
assertArrayEquals(attendees, calResult.getAttendees());
assertEqualOrNaN(latitude, calResult.getLatitude());
assertEqualOrNaN(longitude, calResult.getLongitude());
assertEquals(startString, dateFormat.format(calRXingResult.getStartTimestamp()));
assertEquals(endString, calRXingResult.getEndTimestamp() < 0L ? null : dateFormat.format(calRXingResult.getEndTimestamp()));
assertEquals(organizer, calRXingResult.getOrganizer());
assertArrayEquals(attendees, calRXingResult.getAttendees());
assertEqualOrNaN(latitude, calRXingResult.getLatitude());
assertEqualOrNaN(longitude, calRXingResult.getLongitude());
}
private static void assertEqualOrNaN(double expected, double actual) {

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link EmailAddressParsedResult}.
* Tests {@link EmailAddressParsedRXingResult}.
*
* @author Sean Owen
*/
public final class EmailAddressParsedResultTestCase extends Assert {
public final class EmailAddressParsedRXingResultTestCase extends Assert {
@Test
public void testEmailAddress() {
@@ -107,15 +107,15 @@ public final class EmailAddressParsedResultTestCase extends Assert {
String[] bccs,
String subject,
String body) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.EMAIL_ADDRESS, result.getType());
EmailAddressParsedResult emailResult = (EmailAddressParsedResult) result;
assertArrayEquals(tos, emailResult.getTos());
assertArrayEquals(ccs, emailResult.getCCs());
assertArrayEquals(bccs, emailResult.getBCCs());
assertEquals(subject, emailResult.getSubject());
assertEquals(body, emailResult.getBody());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.EMAIL_ADDRESS, result.getType());
EmailAddressParsedRXingResult emailRXingResult = (EmailAddressParsedRXingResult) result;
assertArrayEquals(tos, emailRXingResult.getTos());
assertArrayEquals(ccs, emailRXingResult.getCCs());
assertArrayEquals(bccs, emailRXingResult.getBCCs());
assertEquals(subject, emailRXingResult.getSubject());
assertEquals(body, emailRXingResult.getBody());
}
}

View File

@@ -27,7 +27,7 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
@@ -38,15 +38,15 @@ import java.util.Map;
* @author Antonio Manuel Benjumea Conde, Servinform, S.A.
* @author Agustín Delgado, Servinform, S.A.
*/
public final class ExpandedProductParsedResultTestCase extends Assert {
public final class ExpandedProductParsedRXingResultTestCase extends Assert {
@Test
public void testRSSExpanded() {
Map<String,String> uncommonAIs = new HashMap<>();
uncommonAIs.put("123", "544654");
Result result =
new Result("(01)66546(13)001205(3932)4455(3102)6544(123)544654", null, null, BarcodeFormat.RSS_EXPANDED);
ExpandedProductParsedResult o = new ExpandedProductResultParser().parse(result);
RXingResult result =
new RXingResult("(01)66546(13)001205(3932)4455(3102)6544(123)544654", null, null, BarcodeFormat.RSS_EXPANDED);
ExpandedProductParsedRXingResult o = new ExpandedProductRXingResultParser().parse(result);
assertNotNull(o);
assertEquals("66546", o.getProductID());
assertNull(o.getSscc());

View File

@@ -19,16 +19,16 @@ package com.google.zxing.client.result;
import java.util.Locale;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link GeoParsedResult}.
* Tests {@link GeoParsedRXingResult}.
*
* @author Sean Owen
*/
public final class GeoParsedResultTestCase extends Assert {
public final class GeoParsedRXingResultTestCase extends Assert {
private static final double EPSILON = 1.0E-10;
@@ -47,15 +47,15 @@ public final class GeoParsedResultTestCase extends Assert {
double altitude,
String query,
String uri) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.GEO, result.getType());
GeoParsedResult geoResult = (GeoParsedResult) result;
assertEquals(latitude, geoResult.getLatitude(), EPSILON);
assertEquals(longitude, geoResult.getLongitude(), EPSILON);
assertEquals(altitude, geoResult.getAltitude(), EPSILON);
assertEquals(query, geoResult.getQuery());
assertEquals(uri == null ? contents.toLowerCase(Locale.ENGLISH) : uri, geoResult.getGeoURI());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.GEO, result.getType());
GeoParsedRXingResult geoRXingResult = (GeoParsedRXingResult) result;
assertEquals(latitude, geoRXingResult.getLatitude(), EPSILON);
assertEquals(longitude, geoRXingResult.getLongitude(), EPSILON);
assertEquals(altitude, geoRXingResult.getAltitude(), EPSILON);
assertEquals(query, geoRXingResult.getQuery());
assertEquals(uri == null ? contents.toLowerCase(Locale.ENGLISH) : uri, geoRXingResult.getGeoURI());
}
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link ISBNParsedResult}.
* Tests {@link ISBNParsedRXingResult}.
*
* @author Sean Owen
*/
public final class ISBNParsedResultTestCase extends Assert {
public final class ISBNParsedRXingResultTestCase extends Assert {
@Test
public void testISBN() {
@@ -34,11 +34,11 @@ public final class ISBNParsedResultTestCase extends Assert {
}
private static void doTest(String contents) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.EAN_13);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.ISBN, result.getType());
ISBNParsedResult isbnResult = (ISBNParsedResult) result;
assertEquals(contents, isbnResult.getISBN());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.EAN_13);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.ISBN, result.getType());
ISBNParsedRXingResult isbnRXingResult = (ISBNParsedRXingResult) result;
assertEquals(contents, isbnRXingResult.getISBN());
}
}

View File

@@ -17,7 +17,7 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -28,12 +28,12 @@ import java.util.Locale;
import java.util.TimeZone;
/**
* Tests {@link ParsedResult}.
* Tests {@link ParsedRXingResult}.
*
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class ParsedReaderResultTestCase extends Assert {
public final class ParsedReaderRXingResultTestCase extends Assert {
@Before
public void setUp() {
@@ -43,208 +43,208 @@ public final class ParsedReaderResultTestCase extends Assert {
@Test
public void testTextType() {
doTestResult("", "", ParsedResultType.TEXT);
doTestResult("foo", "foo", ParsedResultType.TEXT);
doTestResult("Hi.", "Hi.", ParsedResultType.TEXT);
doTestResult("This is a test", "This is a test", ParsedResultType.TEXT);
doTestResult("This is a test\nwith newlines", "This is a test\nwith newlines",
ParsedResultType.TEXT);
doTestResult("This: a test with lots of @ nearly-random punctuation! No? OK then.",
doTestRXingResult("", "", ParsedRXingResultType.TEXT);
doTestRXingResult("foo", "foo", ParsedRXingResultType.TEXT);
doTestRXingResult("Hi.", "Hi.", ParsedRXingResultType.TEXT);
doTestRXingResult("This is a test", "This is a test", ParsedRXingResultType.TEXT);
doTestRXingResult("This is a test\nwith newlines", "This is a test\nwith newlines",
ParsedRXingResultType.TEXT);
doTestRXingResult("This: a test with lots of @ nearly-random punctuation! No? OK then.",
"This: a test with lots of @ nearly-random punctuation! No? OK then.",
ParsedResultType.TEXT);
ParsedRXingResultType.TEXT);
}
@Test
public void testBookmarkType() {
doTestResult("MEBKM:URL:google.com;;", "http://google.com", ParsedResultType.URI);
doTestResult("MEBKM:URL:google.com;TITLE:Google;;", "Google\nhttp://google.com",
ParsedResultType.URI);
doTestResult("MEBKM:TITLE:Google;URL:google.com;;", "Google\nhttp://google.com",
ParsedResultType.URI);
doTestResult("MEBKM:URL:http://google.com;;", "http://google.com", ParsedResultType.URI);
doTestResult("MEBKM:URL:HTTPS://google.com;;", "HTTPS://google.com", ParsedResultType.URI);
doTestRXingResult("MEBKM:URL:google.com;;", "http://google.com", ParsedRXingResultType.URI);
doTestRXingResult("MEBKM:URL:google.com;TITLE:Google;;", "Google\nhttp://google.com",
ParsedRXingResultType.URI);
doTestRXingResult("MEBKM:TITLE:Google;URL:google.com;;", "Google\nhttp://google.com",
ParsedRXingResultType.URI);
doTestRXingResult("MEBKM:URL:http://google.com;;", "http://google.com", ParsedRXingResultType.URI);
doTestRXingResult("MEBKM:URL:HTTPS://google.com;;", "HTTPS://google.com", ParsedRXingResultType.URI);
}
@Test
public void testURLTOType() {
doTestResult("urlto:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI);
doTestResult("URLTO:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI);
doTestResult("URLTO::bar.com", "http://bar.com", ParsedResultType.URI);
doTestResult("URLTO::http://bar.com", "http://bar.com", ParsedResultType.URI);
doTestRXingResult("urlto:foo:bar.com", "foo\nhttp://bar.com", ParsedRXingResultType.URI);
doTestRXingResult("URLTO:foo:bar.com", "foo\nhttp://bar.com", ParsedRXingResultType.URI);
doTestRXingResult("URLTO::bar.com", "http://bar.com", ParsedRXingResultType.URI);
doTestRXingResult("URLTO::http://bar.com", "http://bar.com", ParsedRXingResultType.URI);
}
@Test
public void testEmailType() {
doTestResult("MATMSG:TO:srowen@example.org;;",
"srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
doTestResult("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org\nStuff",
ParsedResultType.EMAIL_ADDRESS);
doTestResult("MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;",
"srowen@example.org\nStuff\nThis is some text", ParsedResultType.EMAIL_ADDRESS);
doTestResult("MATMSG:SUB:Stuff;BODY:This is some text;TO:srowen@example.org;;",
"srowen@example.org\nStuff\nThis is some text", ParsedResultType.EMAIL_ADDRESS);
doTestResult("TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;",
"TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", ParsedResultType.TEXT);
doTestRXingResult("MATMSG:TO:srowen@example.org;;",
"srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org\nStuff",
ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;",
"srowen@example.org\nStuff\nThis is some text", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("MATMSG:SUB:Stuff;BODY:This is some text;TO:srowen@example.org;;",
"srowen@example.org\nStuff\nThis is some text", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;",
"TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", ParsedRXingResultType.TEXT);
}
@Test
public void testEmailAddressType() {
doTestResult("srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
doTestResult("mailto:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
doTestResult("MAILTO:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
doTestResult("srowen@example", "srowen@example", ParsedResultType.EMAIL_ADDRESS);
doTestResult("srowen", "srowen", ParsedResultType.TEXT);
doTestResult("Let's meet @ 2", "Let's meet @ 2", ParsedResultType.TEXT);
doTestRXingResult("srowen@example.org", "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("mailto:srowen@example.org", "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("MAILTO:srowen@example.org", "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("srowen@example", "srowen@example", ParsedRXingResultType.EMAIL_ADDRESS);
doTestRXingResult("srowen", "srowen", ParsedRXingResultType.TEXT);
doTestRXingResult("Let's meet @ 2", "Let's meet @ 2", ParsedRXingResultType.TEXT);
}
@Test
public void testAddressBookType() {
doTestResult("MECARD:N:Sean Owen;;", "Sean Owen", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;;", "Sean Owen\n+12125551212",
ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;;",
"Sean Owen\n+12125551212\ngoogle.com", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\n+12125551212\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:ADR:76 9th Ave;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\n76 9th Ave\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:BDAY:19760520;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nsrowen@example.org\ngoogle.com\n19760520", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:ORG:Google;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nGoogle\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nsrowen@example.org\ngoogle.com\nZXing Team", ParsedResultType.ADDRESSBOOK);
doTestResult("N:Sean Owen;TEL:+12125551212;;", "N:Sean Owen;TEL:+12125551212;;",
ParsedResultType.TEXT);
doTestRXingResult("MECARD:N:Sean Owen;;", "Sean Owen", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:TEL:+12125551212;N:Sean Owen;;", "Sean Owen\n+12125551212",
ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;;",
"Sean Owen\n+12125551212\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\n+12125551212\nsrowen@example.org\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:ADR:76 9th Ave;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\n76 9th Ave\nsrowen@example.org\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:BDAY:19760520;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nsrowen@example.org\ngoogle.com\n19760520", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:ORG:Google;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nGoogle\nsrowen@example.org\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nsrowen@example.org\ngoogle.com\nZXing Team", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("N:Sean Owen;TEL:+12125551212;;", "N:Sean Owen;TEL:+12125551212;;",
ParsedRXingResultType.TEXT);
}
@Test
public void testAddressBookAUType() {
doTestResult("MEMORY:\r\n", "", ParsedResultType.ADDRESSBOOK);
doTestResult("MEMORY:foo\r\nNAME1:Sean\r\n", "Sean\nfoo", ParsedResultType.ADDRESSBOOK);
doTestResult("TEL1:+12125551212\r\nMEMORY:\r\n", "+12125551212", ParsedResultType.ADDRESSBOOK);
doTestRXingResult("MEMORY:\r\n", "", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("MEMORY:foo\r\nNAME1:Sean\r\n", "Sean\nfoo", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("TEL1:+12125551212\r\nMEMORY:\r\n", "+12125551212", ParsedRXingResultType.ADDRESSBOOK);
}
@Test
public void testBizcard() {
doTestResult("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12225551212;E:srowen@example.org;",
"Sean Owen\nGoogle\n123 Main St\n+12225551212\nsrowen@example.org", ParsedResultType.ADDRESSBOOK);
doTestRXingResult("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12225551212;E:srowen@example.org;",
"Sean Owen\nGoogle\n123 Main St\n+12225551212\nsrowen@example.org", ParsedRXingResultType.ADDRESSBOOK);
}
@Test
public void testUPCA() {
doTestResult("123456789012", "123456789012", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestResult("1234567890123", "1234567890123", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestResult("12345678901", "12345678901", ParsedResultType.TEXT);
doTestRXingResult("123456789012", "123456789012", ParsedRXingResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestRXingResult("1234567890123", "1234567890123", ParsedRXingResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestRXingResult("12345678901", "12345678901", ParsedRXingResultType.TEXT);
}
@Test
public void testUPCE() {
doTestResult("01234565", "01234565", ParsedResultType.PRODUCT, BarcodeFormat.UPC_E);
doTestRXingResult("01234565", "01234565", ParsedRXingResultType.PRODUCT, BarcodeFormat.UPC_E);
}
@Test
public void testEAN() {
doTestResult("00393157", "00393157", ParsedResultType.PRODUCT, BarcodeFormat.EAN_8);
doTestResult("00393158", "00393158", ParsedResultType.TEXT);
doTestResult("5051140178499", "5051140178499", ParsedResultType.PRODUCT, BarcodeFormat.EAN_13);
doTestResult("5051140178490", "5051140178490", ParsedResultType.TEXT);
doTestRXingResult("00393157", "00393157", ParsedRXingResultType.PRODUCT, BarcodeFormat.EAN_8);
doTestRXingResult("00393158", "00393158", ParsedRXingResultType.TEXT);
doTestRXingResult("5051140178499", "5051140178499", ParsedRXingResultType.PRODUCT, BarcodeFormat.EAN_13);
doTestRXingResult("5051140178490", "5051140178490", ParsedRXingResultType.TEXT);
}
@Test
public void testISBN() {
doTestResult("9784567890123", "9784567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13);
doTestResult("9794567890123", "9794567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13);
doTestResult("97845678901", "97845678901", ParsedResultType.TEXT);
doTestResult("97945678901", "97945678901", ParsedResultType.TEXT);
doTestRXingResult("9784567890123", "9784567890123", ParsedRXingResultType.ISBN, BarcodeFormat.EAN_13);
doTestRXingResult("9794567890123", "9794567890123", ParsedRXingResultType.ISBN, BarcodeFormat.EAN_13);
doTestRXingResult("97845678901", "97845678901", ParsedRXingResultType.TEXT);
doTestRXingResult("97945678901", "97945678901", ParsedRXingResultType.TEXT);
}
@Test
public void testURI() {
doTestResult("http://google.com", "http://google.com", ParsedResultType.URI);
doTestResult("google.com", "http://google.com", ParsedResultType.URI);
doTestResult("https://google.com", "https://google.com", ParsedResultType.URI);
doTestResult("HTTP://google.com", "HTTP://google.com", ParsedResultType.URI);
doTestResult("http://google.com/foobar", "http://google.com/foobar", ParsedResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI);
doTestResult("google.com:443", "http://google.com:443", ParsedResultType.URI);
doTestResult("google.com:443/", "http://google.com:443/", ParsedResultType.URI);
doTestResult("google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI);
doTestResult("http://google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI);
doTestResult("ftp://google.com/fake", "ftp://google.com/fake", ParsedResultType.URI);
doTestResult("gopher://google.com/obsolete", "gopher://google.com/obsolete", ParsedResultType.URI);
doTestRXingResult("http://google.com", "http://google.com", ParsedRXingResultType.URI);
doTestRXingResult("google.com", "http://google.com", ParsedRXingResultType.URI);
doTestRXingResult("https://google.com", "https://google.com", ParsedRXingResultType.URI);
doTestRXingResult("HTTP://google.com", "HTTP://google.com", ParsedRXingResultType.URI);
doTestRXingResult("http://google.com/foobar", "http://google.com/foobar", ParsedRXingResultType.URI);
doTestRXingResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedRXingResultType.URI);
doTestRXingResult("google.com:443", "http://google.com:443", ParsedRXingResultType.URI);
doTestRXingResult("google.com:443/", "http://google.com:443/", ParsedRXingResultType.URI);
doTestRXingResult("google.com:443/foobar", "http://google.com:443/foobar", ParsedRXingResultType.URI);
doTestRXingResult("http://google.com:443/foobar", "http://google.com:443/foobar", ParsedRXingResultType.URI);
doTestRXingResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedRXingResultType.URI);
doTestRXingResult("ftp://google.com/fake", "ftp://google.com/fake", ParsedRXingResultType.URI);
doTestRXingResult("gopher://google.com/obsolete", "gopher://google.com/obsolete", ParsedRXingResultType.URI);
}
@Test
public void testGeo() {
doTestResult("geo:1,2", "1.0, 2.0", ParsedResultType.GEO);
doTestResult("GEO:1,2", "1.0, 2.0", ParsedResultType.GEO);
doTestResult("geo:1,2,3", "1.0, 2.0, 3.0m", ParsedResultType.GEO);
doTestResult("geo:80.33,-32.3344,3.35", "80.33, -32.3344, 3.35m", ParsedResultType.GEO);
doTestResult("geo", "geo", ParsedResultType.TEXT);
doTestResult("geography", "geography", ParsedResultType.TEXT);
doTestRXingResult("geo:1,2", "1.0, 2.0", ParsedRXingResultType.GEO);
doTestRXingResult("GEO:1,2", "1.0, 2.0", ParsedRXingResultType.GEO);
doTestRXingResult("geo:1,2,3", "1.0, 2.0, 3.0m", ParsedRXingResultType.GEO);
doTestRXingResult("geo:80.33,-32.3344,3.35", "80.33, -32.3344, 3.35m", ParsedRXingResultType.GEO);
doTestRXingResult("geo", "geo", ParsedRXingResultType.TEXT);
doTestRXingResult("geography", "geography", ParsedRXingResultType.TEXT);
}
@Test
public void testTel() {
doTestResult("tel:+15551212", "+15551212", ParsedResultType.TEL);
doTestResult("TEL:+15551212", "+15551212", ParsedResultType.TEL);
doTestResult("tel:212 555 1212", "212 555 1212", ParsedResultType.TEL);
doTestResult("tel:2125551212", "2125551212", ParsedResultType.TEL);
doTestResult("tel:212-555-1212", "212-555-1212", ParsedResultType.TEL);
doTestResult("tel", "tel", ParsedResultType.TEXT);
doTestResult("telephone", "telephone", ParsedResultType.TEXT);
doTestRXingResult("tel:+15551212", "+15551212", ParsedRXingResultType.TEL);
doTestRXingResult("TEL:+15551212", "+15551212", ParsedRXingResultType.TEL);
doTestRXingResult("tel:212 555 1212", "212 555 1212", ParsedRXingResultType.TEL);
doTestRXingResult("tel:2125551212", "2125551212", ParsedRXingResultType.TEL);
doTestRXingResult("tel:212-555-1212", "212-555-1212", ParsedRXingResultType.TEL);
doTestRXingResult("tel", "tel", ParsedRXingResultType.TEXT);
doTestRXingResult("telephone", "telephone", ParsedRXingResultType.TEXT);
}
@Test
public void testVCard() {
doTestResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
ParsedResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
ParsedResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
"Sean Owen\n123 Main St", ParsedResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD", "", ParsedResultType.ADDRESSBOOK);
doTestRXingResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
"Sean Owen\n123 Main St", ParsedRXingResultType.ADDRESSBOOK);
doTestRXingResult("BEGIN:VCARD", "", ParsedRXingResultType.ADDRESSBOOK);
}
@Test
public void testVEvent() {
// UTC times
doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
doTestRXingResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
"DTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + formatTime(2008, 5, 5, 23, 45, 55),
ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
ParsedRXingResultType.CALENDAR);
doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
"DTEND:20080505T234555Z\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" +
formatTime(2008, 5, 5, 23, 45, 55),
ParsedResultType.CALENDAR);
ParsedRXingResultType.CALENDAR);
// Local times
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\n" +
doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\n" +
"DTEND:20080505T234555\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" +
formatTime(2008, 5, 5, 23, 45, 55),
ParsedResultType.CALENDAR);
ParsedRXingResultType.CALENDAR);
// Date only (all day event)
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\n" +
doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\n" +
"DTEND:20080505\r\nEND:VEVENT", "foo\n" + formatDate(2008, 5, 4) + "\n" +
formatDate(2008, 5, 5),
ParsedResultType.CALENDAR);
ParsedRXingResultType.CALENDAR);
// Start time only
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
"foo\n" + formatDate(2008, 5, 4), ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT",
"BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT);
doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedRXingResultType.CALENDAR);
doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedRXingResultType.CALENDAR);
doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
"foo\n" + formatDate(2008, 5, 4), ParsedRXingResultType.CALENDAR);
doTestRXingResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT",
"BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedRXingResultType.TEXT);
// Yeah, it's OK that this is thought of as maybe a URI as long as it's not CALENDAR
// Make sure illegal entries without newlines don't crash
doTestResult(
doTestRXingResult(
"BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
"BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
ParsedResultType.URI);
ParsedRXingResultType.URI);
}
private static String formatDate(int year, int month, int day) {
@@ -263,68 +263,68 @@ public final class ParsedReaderResultTestCase extends Assert {
@Test
public void testSMS() {
doTestResult("sms:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("SMS:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("sms:+15551212;via=999333", "+15551212", ParsedResultType.SMS);
doTestResult("sms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS);
doTestResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS);
doTestRXingResult("sms:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("SMS:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("sms:+15551212;via=999333", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("sms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedRXingResultType.SMS);
doTestRXingResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedRXingResultType.SMS);
}
@Test
public void testSMSTO() {
doTestResult("SMSTO:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("smsto:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("smsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS);
doTestResult("smsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS);
doTestRXingResult("SMSTO:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("smsto:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("smsto:+15551212:subject", "+15551212\nsubject", ParsedRXingResultType.SMS);
doTestRXingResult("smsto:+15551212:My message", "+15551212\nMy message", ParsedRXingResultType.SMS);
// Need to handle question mark in the subject
doTestResult("smsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS);
doTestRXingResult("smsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedRXingResultType.SMS);
// Need to handle colon in the subject
doTestResult("smsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
ParsedResultType.SMS);
doTestResult("smsto:212-555-1212:Here's a longer message. Should be fine.",
doTestRXingResult("smsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
ParsedRXingResultType.SMS);
doTestRXingResult("smsto:212-555-1212:Here's a longer message. Should be fine.",
"212-555-1212\nHere's a longer message. Should be fine.",
ParsedResultType.SMS);
ParsedRXingResultType.SMS);
}
@Test
public void testMMS() {
doTestResult("mms:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("MMS:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("mms:+15551212;via=999333", "+15551212", ParsedResultType.SMS);
doTestResult("mms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS);
doTestResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS);
doTestRXingResult("mms:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("MMS:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("mms:+15551212;via=999333", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("mms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedRXingResultType.SMS);
doTestRXingResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedRXingResultType.SMS);
}
@Test
public void testMMSTO() {
doTestResult("MMSTO:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("mmsto:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("mmsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS);
doTestResult("mmsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS);
doTestResult("mmsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS);
doTestResult("mmsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
ParsedResultType.SMS);
doTestResult("mmsto:212-555-1212:Here's a longer message. Should be fine.",
"212-555-1212\nHere's a longer message. Should be fine.", ParsedResultType.SMS);
doTestRXingResult("MMSTO:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("mmsto:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestRXingResult("mmsto:+15551212:subject", "+15551212\nsubject", ParsedRXingResultType.SMS);
doTestRXingResult("mmsto:+15551212:My message", "+15551212\nMy message", ParsedRXingResultType.SMS);
doTestRXingResult("mmsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedRXingResultType.SMS);
doTestRXingResult("mmsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
ParsedRXingResultType.SMS);
doTestRXingResult("mmsto:212-555-1212:Here's a longer message. Should be fine.",
"212-555-1212\nHere's a longer message. Should be fine.", ParsedRXingResultType.SMS);
}
private static void doTestResult(String contents,
String goldenResult,
ParsedResultType type) {
doTestResult(contents, goldenResult, type, BarcodeFormat.QR_CODE); // QR code is arbitrary
private static void doTestRXingResult(String contents,
String goldenRXingResult,
ParsedRXingResultType type) {
doTestRXingResult(contents, goldenRXingResult, type, BarcodeFormat.QR_CODE); // QR code is arbitrary
}
private static void doTestResult(String contents,
String goldenResult,
ParsedResultType type,
private static void doTestRXingResult(String contents,
String goldenRXingResult,
ParsedRXingResultType type,
BarcodeFormat format) {
Result fakeResult = new Result(contents, null, null, format);
ParsedResult result = ResultParser.parseResult(fakeResult);
RXingResult fakeRXingResult = new RXingResult(contents, null, null, format);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertNotNull(result);
assertSame(type, result.getType());
String displayResult = result.getDisplayResult();
assertEquals(goldenResult, displayResult);
String displayRXingResult = result.getDisplayRXingResult();
assertEquals(goldenRXingResult, displayRXingResult);
}
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link ProductParsedResult}.
* Tests {@link ProductParsedRXingResult}.
*
* @author Sean Owen
*/
public final class ProductParsedResultTestCase extends Assert {
public final class ProductParsedRXingResultTestCase extends Assert {
@Test
public void testProduct() {
@@ -37,12 +37,12 @@ public final class ProductParsedResultTestCase extends Assert {
}
private static void doTest(String contents, String normalized, BarcodeFormat format) {
Result fakeResult = new Result(contents, null, null, format);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.PRODUCT, result.getType());
ProductParsedResult productResult = (ProductParsedResult) result;
assertEquals(contents, productResult.getProductID());
assertEquals(normalized, productResult.getNormalizedProductID());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, format);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.PRODUCT, result.getType());
ProductParsedRXingResult productRXingResult = (ProductParsedRXingResult) result;
assertEquals(contents, productRXingResult.getProductID());
assertEquals(normalized, productRXingResult.getNormalizedProductID());
}
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link SMSParsedResult}.
* Tests {@link SMSParsedRXingResult}.
*
* @author Sean Owen
*/
public final class SMSMMSParsedResultTestCase extends Assert {
public final class SMSMMSParsedRXingResultTestCase extends Assert {
@Test
public void testSMS() {
@@ -52,15 +52,15 @@ public final class SMSMMSParsedResultTestCase extends Assert {
String body,
String via,
String parsedURI) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.SMS, result.getType());
SMSParsedResult smsResult = (SMSParsedResult) result;
assertArrayEquals(new String[] { number }, smsResult.getNumbers());
assertEquals(subject, smsResult.getSubject());
assertEquals(body, smsResult.getBody());
assertArrayEquals(new String[] { via }, smsResult.getVias());
assertEquals(parsedURI, smsResult.getSMSURI());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.SMS, result.getType());
SMSParsedRXingResult smsRXingResult = (SMSParsedRXingResult) result;
assertArrayEquals(new String[] { number }, smsRXingResult.getNumbers());
assertEquals(subject, smsRXingResult.getSubject());
assertEquals(body, smsRXingResult.getBody());
assertArrayEquals(new String[] { via }, smsRXingResult.getVias());
assertEquals(parsedURI, smsRXingResult.getSMSURI());
}
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link TelParsedResult}.
* Tests {@link TelParsedRXingResult}.
*
* @author Sean Owen
*/
public final class TelParsedResultTestCase extends Assert {
public final class TelParsedRXingResultTestCase extends Assert {
@Test
public void testTel() {
@@ -35,13 +35,13 @@ public final class TelParsedResultTestCase extends Assert {
}
private static void doTest(String contents, String number, String title) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.TEL, result.getType());
TelParsedResult telResult = (TelParsedResult) result;
assertEquals(number, telResult.getNumber());
assertEquals(title, telResult.getTitle());
assertEquals("tel:" + number, telResult.getTelURI());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.TEL, result.getType());
TelParsedRXingResult telRXingResult = (TelParsedRXingResult) result;
assertEquals(number, telRXingResult.getNumber());
assertEquals(title, telRXingResult.getTitle());
assertEquals("tel:" + number, telRXingResult.getTelURI());
}
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link URIParsedResult}.
* Tests {@link URIParsedRXingResult}.
*
* @author Sean Owen
*/
public final class URIParsedResultTestCase extends Assert {
public final class URIParsedRXingResultTestCase extends Assert {
@Test
public void testBookmarkDocomo() {
@@ -116,25 +116,25 @@ public final class URIParsedResultTestCase extends Assert {
}
private static void doTest(String contents, String uri, String title) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.URI, result.getType());
URIParsedResult uriResult = (URIParsedResult) result;
assertEquals(uri, uriResult.getURI());
assertEquals(title, uriResult.getTitle());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.URI, result.getType());
URIParsedRXingResult uriRXingResult = (URIParsedRXingResult) result;
assertEquals(uri, uriRXingResult.getURI());
assertEquals(title, uriRXingResult.getTitle());
}
private static void doTestNotUri(String text) {
Result fakeResult = new Result(text, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.TEXT, result.getType());
assertEquals(text, result.getDisplayResult());
RXingResult fakeRXingResult = new RXingResult(text, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.TEXT, result.getType());
assertEquals(text, result.getDisplayRXingResult());
}
private static void doTestIsPossiblyMalicious(String uri, boolean malicious) {
Result fakeResult = new Result(uri, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(malicious ? ParsedResultType.TEXT : ParsedResultType.URI, result.getType());
RXingResult fakeRXingResult = new RXingResult(uri, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(malicious ? ParsedRXingResultType.TEXT : ParsedRXingResultType.URI, result.getType());
}
}

View File

@@ -18,23 +18,23 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link VINParsedResult}.
* Tests {@link VINParsedRXingResult}.
*/
public final class VINParsedResultTestCase extends Assert {
public final class VINParsedRXingResultTestCase extends Assert {
@Test
public void testNotVIN() {
Result fakeResult = new Result("1M8GDM9A1KP042788", null, null, BarcodeFormat.CODE_39);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertEquals(ParsedResultType.TEXT, result.getType());
fakeResult = new Result("1M8GDM9AXKP042788", null, null, BarcodeFormat.CODE_128);
result = ResultParser.parseResult(fakeResult);
assertEquals(ParsedResultType.TEXT, result.getType());
RXingResult fakeRXingResult = new RXingResult("1M8GDM9A1KP042788", null, null, BarcodeFormat.CODE_39);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertEquals(ParsedRXingResultType.TEXT, result.getType());
fakeRXingResult = new RXingResult("1M8GDM9AXKP042788", null, null, BarcodeFormat.CODE_128);
result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertEquals(ParsedRXingResultType.TEXT, result.getType());
}
@Test
@@ -53,18 +53,18 @@ public final class VINParsedResultTestCase extends Assert {
int year,
char plant,
String sequential) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.CODE_39);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.VIN, result.getType());
VINParsedResult vinResult = (VINParsedResult) result;
assertEquals(wmi, vinResult.getWorldManufacturerID());
assertEquals(vds, vinResult.getVehicleDescriptorSection());
assertEquals(vis, vinResult.getVehicleIdentifierSection());
assertEquals(country, vinResult.getCountryCode());
assertEquals(attributes, vinResult.getVehicleAttributes());
assertEquals(year, vinResult.getModelYear());
assertEquals(plant, vinResult.getPlantCode());
assertEquals(sequential, vinResult.getSequentialNumber());
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.CODE_39);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedRXingResultType.VIN, result.getType());
VINParsedRXingResult vinRXingResult = (VINParsedRXingResult) result;
assertEquals(wmi, vinRXingResult.getWorldManufacturerID());
assertEquals(vds, vinRXingResult.getVehicleDescriptorSection());
assertEquals(vis, vinRXingResult.getVehicleIdentifierSection());
assertEquals(country, vinRXingResult.getCountryCode());
assertEquals(attributes, vinRXingResult.getVehicleAttributes());
assertEquals(year, vinRXingResult.getModelYear());
assertEquals(plant, vinRXingResult.getPlantCode());
assertEquals(sequential, vinRXingResult.getSequentialNumber());
}
}

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link WifiParsedResult}.
* Tests {@link WifiParsedRXingResult}.
*
* @author Vikram Aggarwal
*/
public final class WifiParsedResultTestCase extends Assert {
public final class WifiParsedRXingResultTestCase extends Assert {
@Test
public void testNoPassword() {
@@ -79,15 +79,15 @@ public final class WifiParsedResultTestCase extends Assert {
String ssid,
String password,
String type) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
// Ensure it is a wifi code
assertSame(ParsedResultType.WIFI, result.getType());
WifiParsedResult wifiResult = (WifiParsedResult) result;
assertSame(ParsedRXingResultType.WIFI, result.getType());
WifiParsedRXingResult wifiRXingResult = (WifiParsedRXingResult) result;
assertEquals(ssid, wifiResult.getSsid());
assertEquals(password, wifiResult.getPassword());
assertEquals(type, wifiResult.getNetworkEncryption());
assertEquals(ssid, wifiRXingResult.getSsid());
assertEquals(password, wifiRXingResult.getPassword());
assertEquals(type, wifiRXingResult.getNetworkEncryption());
}
}

View File

@@ -23,8 +23,8 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.Reader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.ResultMetadataType;
import com.google.zxing.RXingResult;
import com.google.zxing.RXingResultMetadataType;
import org.junit.Assert;
import org.junit.Test;
@@ -61,7 +61,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
private final Path testBase;
private final Reader barcodeReader;
private final BarcodeFormat expectedFormat;
private final List<TestResult> testResults;
private final List<TestRXingResult> testRXingResults;
private final EnumMap<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
public static Path buildTestBase(String testBasePathSuffix) {
@@ -80,7 +80,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
this.testBase = buildTestBase(testBasePathSuffix);
this.barcodeReader = barcodeReader;
this.expectedFormat = expectedFormat;
testResults = new ArrayList<>();
testRXingResults = new ArrayList<>();
System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n");
}
@@ -112,7 +112,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
int maxMisreads,
int maxTryHarderMisreads,
float rotation) {
testResults.add(new TestResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, rotation));
testRXingResults.add(new TestRXingResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, rotation));
}
protected final List<Path> getImageFiles() throws IOException {
@@ -132,10 +132,10 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
@Test
public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty());
assertFalse(testRXingResults.isEmpty());
List<Path> imageFiles = getImageFiles();
int testCount = testResults.size();
int testCount = testRXingResults.size();
int[] passedCounts = new int[testCount];
int[] misreadCounts = new int[testCount];
@@ -168,7 +168,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
}
for (int x = 0; x < testCount; x++) {
float rotation = testResults.get(x).getRotation();
float rotation = testRXingResults.get(x).getRotation();
BufferedImage rotatedImage = rotateImage(image, rotation);
LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
@@ -199,23 +199,23 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
int totalMisread = 0;
int totalMaxMisread = 0;
for (int x = 0; x < testResults.size(); x++) {
TestResult testResult = testResults.get(x);
log.info(String.format("Rotation %d degrees:", (int) testResult.getRotation()));
for (int x = 0; x < testRXingResults.size(); x++) {
TestRXingResult testRXingResult = testRXingResults.get(x);
log.info(String.format("Rotation %d degrees:", (int) testRXingResult.getRotation()));
log.info(String.format(" %d of %d images passed (%d required)",
passedCounts[x], imageFiles.size(), testResult.getMustPassCount()));
passedCounts[x], imageFiles.size(), testRXingResult.getMustPassCount()));
int failed = imageFiles.size() - passedCounts[x];
log.info(String.format(" %d failed due to misreads, %d not detected",
misreadCounts[x], failed - misreadCounts[x]));
log.info(String.format(" %d of %d images passed with try harder (%d required)",
tryHarderCounts[x], imageFiles.size(), testResult.getTryHarderCount()));
tryHarderCounts[x], imageFiles.size(), testRXingResult.getTryHarderCount()));
failed = imageFiles.size() - tryHarderCounts[x];
log.info(String.format(" %d failed due to misreads, %d not detected",
tryHarderMisreadCounts[x], failed - tryHarderMisreadCounts[x]));
totalFound += passedCounts[x] + tryHarderCounts[x];
totalMustPass += testResult.getMustPassCount() + testResult.getTryHarderCount();
totalMustPass += testRXingResult.getMustPassCount() + testRXingResult.getTryHarderCount();
totalMisread += misreadCounts[x] + tryHarderMisreadCounts[x];
totalMaxMisread += testResult.getMaxMisreads() + testResult.getMaxTryHarderMisreads();
totalMaxMisread += testRXingResult.getMaxMisreads() + testRXingResult.getMaxTryHarderMisreads();
}
int totalTests = imageFiles.size() * testCount * 2;
@@ -235,17 +235,17 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
// Then run through again and assert if any failed
for (int x = 0; x < testCount; x++) {
TestResult testResult = testResults.get(x);
String label = "Rotation " + testResult.getRotation() + " degrees: Too many images failed";
TestRXingResult testRXingResult = testRXingResults.get(x);
String label = "Rotation " + testRXingResult.getRotation() + " degrees: Too many images failed";
assertTrue(label,
passedCounts[x] >= testResult.getMustPassCount());
passedCounts[x] >= testRXingResult.getMustPassCount());
assertTrue("Try harder, " + label,
tryHarderCounts[x] >= testResult.getTryHarderCount());
label = "Rotation " + testResult.getRotation() + " degrees: Too many images misread";
tryHarderCounts[x] >= testRXingResult.getTryHarderCount());
label = "Rotation " + testRXingResult.getRotation() + " degrees: Too many images misread";
assertTrue(label,
misreadCounts[x] <= testResult.getMaxMisreads());
misreadCounts[x] <= testRXingResult.getMaxMisreads());
assertTrue("Try harder, " + label,
tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads());
tryHarderMisreadCounts[x] <= testRXingResult.getMaxTryHarderMisreads());
}
}
@@ -264,7 +264,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
// Try in 'pure' mode mostly to exercise PURE_BARCODE code paths for exceptions;
// not expected to pass, generally
Result result = null;
RXingResult result = null;
try {
Map<DecodeHintType,Object> pureHints = new EnumMap<>(hints);
pureHints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
@@ -290,9 +290,9 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
return false;
}
Map<ResultMetadataType,?> resultMetadata = result.getResultMetadata();
Map<RXingResultMetadataType,?> resultMetadata = result.getRXingResultMetadata();
for (Map.Entry<?,?> metadatum : expectedMetadata.entrySet()) {
ResultMetadataType key = ResultMetadataType.valueOf(metadatum.getKey().toString());
RXingResultMetadataType key = RXingResultMetadataType.valueOf(metadatum.getKey().toString());
Object expectedValue = metadatum.getValue();
Object actualValue = resultMetadata == null ? null : resultMetadata.get(key);
if (!expectedValue.equals(actualValue)) {

View File

@@ -22,7 +22,7 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import org.junit.Test;
import javax.imageio.ImageIO;
@@ -45,13 +45,13 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
private static final Logger log = Logger.getLogger(AbstractNegativeBlackBoxTestCase.class.getSimpleName());
private final List<TestResult> testResults;
private final List<TestRXingResult> testRXingResults;
private static final class TestResult {
private static final class TestRXingResult {
private final int falsePositivesAllowed;
private final float rotation;
TestResult(int falsePositivesAllowed, float rotation) {
TestRXingResult(int falsePositivesAllowed, float rotation) {
this.falsePositivesAllowed = falsePositivesAllowed;
this.rotation = rotation;
}
@@ -68,29 +68,29 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
// Use the multiformat reader to evaluate all decoders in the system.
protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
super(testBasePathSuffix, new MultiFormatReader(), null);
testResults = new ArrayList<>();
testRXingResults = new ArrayList<>();
}
protected final void addTest(int falsePositivesAllowed, float rotation) {
testResults.add(new TestResult(falsePositivesAllowed, rotation));
testRXingResults.add(new TestRXingResult(falsePositivesAllowed, rotation));
}
@Override
@Test
public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty());
assertFalse(testRXingResults.isEmpty());
List<Path> imageFiles = getImageFiles();
int[] falsePositives = new int[testResults.size()];
int[] falsePositives = new int[testRXingResults.size()];
for (Path testImage : imageFiles) {
log.info(String.format("Starting %s", testImage));
BufferedImage image = ImageIO.read(testImage.toFile());
if (image == null) {
throw new IOException("Could not read image: " + testImage);
}
for (int x = 0; x < testResults.size(); x++) {
TestResult testResult = testResults.get(x);
if (!checkForFalsePositives(image, testResult.getRotation())) {
for (int x = 0; x < testRXingResults.size(); x++) {
TestRXingResult testRXingResult = testRXingResults.get(x);
if (!checkForFalsePositives(image, testRXingResult.getRotation())) {
falsePositives[x]++;
}
}
@@ -99,10 +99,10 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
int totalFalsePositives = 0;
int totalAllowed = 0;
for (int x = 0; x < testResults.size(); x++) {
TestResult testResult = testResults.get(x);
for (int x = 0; x < testRXingResults.size(); x++) {
TestRXingResult testRXingResult = testRXingResults.get(x);
totalFalsePositives += falsePositives[x];
totalAllowed += testResult.getFalsePositivesAllowed();
totalAllowed += testRXingResult.getFalsePositivesAllowed();
}
if (totalFalsePositives < totalAllowed) {
@@ -111,13 +111,13 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
log.warning(String.format("--- Test failed by %d images", totalFalsePositives - totalAllowed));
}
for (int x = 0; x < testResults.size(); x++) {
TestResult testResult = testResults.get(x);
for (int x = 0; x < testRXingResults.size(); x++) {
TestRXingResult testRXingResult = testRXingResults.get(x);
log.info(String.format("Rotation %d degrees: %d of %d images were false positives (%d allowed)",
(int) testResult.getRotation(), falsePositives[x], imageFiles.size(),
testResult.getFalsePositivesAllowed()));
assertTrue("Rotation " + testResult.getRotation() + " degrees: Too many false positives found",
falsePositives[x] <= testResult.getFalsePositivesAllowed());
(int) testRXingResult.getRotation(), falsePositives[x], imageFiles.size(),
testRXingResult.getFalsePositivesAllowed()));
assertTrue("Rotation " + testRXingResult.getRotation() + " degrees: Too many false positives found",
falsePositives[x] <= testRXingResult.getFalsePositivesAllowed());
}
}
@@ -132,7 +132,7 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
BufferedImage rotatedImage = rotateImage(image, rotationInDegrees);
LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result;
RXingResult result;
try {
result = getReader().decode(bitmap);
log.info(String.format("Found false positive: '%s' with format '%s' (rotation: %d)",

View File

@@ -19,7 +19,7 @@ package com.google.zxing.common;
/**
* Encapsulates the result of one test over a batch of black-box images.
*/
public final class TestResult {
public final class TestRXingResult {
private final int mustPassCount;
private final int tryHarderCount;
@@ -27,7 +27,7 @@ public final class TestResult {
private final int maxTryHarderMisreads;
private final float rotation;
public TestResult(int mustPassCount, int tryHarderCount, int maxMisreads, int maxTryHarderMisreads, float rotation) {
public TestRXingResult(int mustPassCount, int tryHarderCount, int maxMisreads, int maxTryHarderMisreads, float rotation) {
this.mustPassCount = mustPassCount;
this.tryHarderCount = tryHarderCount;
this.maxMisreads = maxMisreads;

View File

@@ -25,7 +25,7 @@ import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer;
import org.junit.Assert;
@@ -47,7 +47,7 @@ public final class MultiTestCase extends Assert {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
MultipleBarcodeReader reader = new GenericMultipleBarcodeReader(new MultiFormatReader());
Result[] results = reader.decodeMultiple(bitmap);
RXingResult[] results = reader.decodeMultiple(bitmap);
assertNotNull(results);
assertEquals(2, results.length);

View File

@@ -28,9 +28,9 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.LuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.ResultMetadataType;
import com.google.zxing.ResultPoint;
import com.google.zxing.RXingResult;
import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.multi.MultipleBarcodeReader;
@@ -53,15 +53,15 @@ public final class MultiQRCodeTestCase extends Assert {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
MultipleBarcodeReader reader = new QRCodeMultiReader();
Result[] results = reader.decodeMultiple(bitmap);
RXingResult[] results = reader.decodeMultiple(bitmap);
assertNotNull(results);
assertEquals(4, results.length);
Collection<String> barcodeContents = new HashSet<>();
for (Result result : results) {
for (RXingResult result : results) {
barcodeContents.add(result.getText());
assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat());
assertNotNull(result.getResultMetadata());
assertNotNull(result.getRXingResultMetadata());
}
Collection<String> expectedContents = new HashSet<>();
expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!");
@@ -74,27 +74,27 @@ public final class MultiQRCodeTestCase extends Assert {
@Test
public void testProcessStructuredAppend() {
Result sa1 = new Result("SA1", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
Result sa2 = new Result("SA2", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
Result sa3 = new Result("SA3", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
sa1.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, 2);
sa1.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa2.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (1 << 4) + 2);
sa2.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa3.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (2 << 4) + 2);
sa3.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
RXingResult sa1 = new RXingResult("SA1", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
RXingResult sa2 = new RXingResult("SA2", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
RXingResult sa3 = new RXingResult("SA3", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
sa1.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE, 2);
sa1.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa2.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (1 << 4) + 2);
sa2.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa3.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (2 << 4) + 2);
sa3.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
Result nsa = new Result("NotSA", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
nsa.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
RXingResult nsa = new RXingResult("NotSA", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
nsa.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
List<Result> inputs = Arrays.asList(sa3, sa1, nsa, sa2);
List<RXingResult> inputs = Arrays.asList(sa3, sa1, nsa, sa2);
List<Result> results = QRCodeMultiReader.processStructuredAppend(inputs);
List<RXingResult> results = QRCodeMultiReader.processStructuredAppend(inputs);
assertNotNull(results);
assertEquals(2, results.size());
Collection<String> barcodeContents = new HashSet<>();
for (Result result : results) {
for (RXingResult result : results) {
barcodeContents.add(result.getText());
}
Collection<String> expectedContents = new HashSet<>();

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import com.google.zxing.Writer;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix;
@@ -118,12 +118,12 @@ public class Code128WriterTestCase extends Assert {
String toEncode = "\u00f1" + "10958" + "\u00f1" + "17160526";
String expected = "1095817160526";
BitMatrix encResult = encode(toEncode, false, expected);
BitMatrix encRXingResult = encode(toEncode, false, expected);
int width = encResult.getWidth();
encResult = encode(toEncode, true, expected);
int width = encRXingResult.getWidth();
encRXingResult = encode(toEncode, true, expected);
//Compact encoding has one latch less and encodes as STARTA,FNC1,1,CODEC,09,58,FNC1,17,16,05,26
assertEquals(width, encResult.getWidth() + 11);
assertEquals(width, encRXingResult.getWidth() + 11);
}
@Test
@@ -337,23 +337,23 @@ public class Code128WriterTestCase extends Assert {
if (compact) {
hints.put(EncodeHintType.CODE128_COMPACT, Boolean.TRUE);
}
BitMatrix encResult = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints);
BitMatrix encRXingResult = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints);
if (expectedLoopback != null) {
BitArray row = encResult.getRow(0, null);
Result rtResult = reader.decodeRow(0, row, null);
String actual = rtResult.getText();
BitArray row = encRXingResult.getRow(0, null);
RXingResult rtRXingResult = reader.decodeRow(0, row, null);
String actual = rtRXingResult.getText();
assertEquals(expectedLoopback, actual);
}
if (compact) {
//check that what is encoded compactly yields the same on loopback as what was encoded fast.
BitArray row = encResult.getRow(0, null);
Result rtResult = reader.decodeRow(0, row, null);
String actual = rtResult.getText();
BitMatrix encResultFast = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
row = encResultFast.getRow(0, null);
rtResult = reader.decodeRow(0, row, null);
assertEquals(rtResult.getText(), actual);
BitArray row = encRXingResult.getRow(0, null);
RXingResult rtRXingResult = reader.decodeRow(0, row, null);
String actual = rtRXingResult.getText();
BitMatrix encRXingResultFast = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
row = encRXingResultFast.getRow(0, null);
rtRXingResult = reader.decodeRow(0, row, null);
assertEquals(rtRXingResult.getText(), actual);
}
return encResult;
return encRXingResult;
}
}

View File

@@ -24,7 +24,7 @@ import com.google.zxing.common.BitArray;
import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
/**
* @author Michael Jahn
@@ -44,14 +44,14 @@ public final class Code39ExtendedModeTestCase extends Assert {
"000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000");
}
private static void doTest(String expectedResult, String encodedResult)
private static void doTest(String expectedRXingResult, String encodedRXingResult)
throws FormatException, ChecksumException, NotFoundException {
Code39Reader sut = new Code39Reader(false, true);
BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0");
BitMatrix matrix = BitMatrix.parse(encodedRXingResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth());
matrix.getRow(0, row);
Result result = sut.decodeRow(0, row, null);
assertEquals(expectedResult, result.getText());
RXingResult result = sut.decodeRow(0, row, null);
assertEquals(expectedRXingResult, result.getText());
}
}

View File

@@ -24,7 +24,7 @@ import com.google.zxing.common.BitArray;
import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
/**
* @author Daisuke Makiuchi
@@ -38,14 +38,14 @@ public final class Code93ReaderTestCase extends Assert {
"0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111");
}
private static void doTest(String expectedResult, String encodedResult)
private static void doTest(String expectedRXingResult, String encodedRXingResult)
throws FormatException, ChecksumException, NotFoundException {
Code93Reader sut = new Code93Reader();
BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0");
BitMatrix matrix = BitMatrix.parse(encodedRXingResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth());
matrix.getRow(0, row);
Result result = sut.decodeRow(0, row, null);
assertEquals(expectedResult, result.getText());
RXingResult result = sut.decodeRow(0, row, null);
assertEquals(expectedRXingResult, result.getText());
}
}

View File

@@ -43,10 +43,10 @@ import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.NotFoundException;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.client.result.ExpandedProductParsedResult;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ResultParser;
import com.google.zxing.RXingResult;
import com.google.zxing.client.result.ExpandedProductParsedRXingResult;
import com.google.zxing.client.result.ParsedRXingResult;
import com.google.zxing.client.result.RXingResultParser;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer;
@@ -63,18 +63,18 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
@Test
public void testDecodeRow2result2() throws Exception {
// (01)90012345678908(3103)001750
ExpandedProductParsedResult expected =
new ExpandedProductParsedResult("(01)90012345678908(3103)001750",
ExpandedProductParsedRXingResult expected =
new ExpandedProductParsedRXingResult("(01)90012345678908(3103)001750",
"90012345678908",
null, null, null, null, null, null,
"001750",
ExpandedProductParsedResult.KILOGRAM,
ExpandedProductParsedRXingResult.KILOGRAM,
"3", null, null, null, new HashMap<>());
assertCorrectImage2result("2.png", expected);
}
private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected)
private static void assertCorrectImage2result(String fileName, ExpandedProductParsedRXingResult expected)
throws IOException, NotFoundException {
Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);
@@ -83,18 +83,18 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null);
Result theResult;
RXingResult theRXingResult;
try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
theResult = rssExpandedReader.decodeRow(rowNumber, row, null);
theRXingResult = rssExpandedReader.decodeRow(rowNumber, row, null);
} catch (ReaderException re) {
fail(re.toString());
return;
}
assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());
assertSame(BarcodeFormat.RSS_EXPANDED, theRXingResult.getBarcodeFormat());
ParsedResult result = ResultParser.parseResult(theResult);
ParsedRXingResult result = RXingResultParser.parseRXingResult(theRXingResult);
assertEquals(expected, result);
}

View File

@@ -37,7 +37,7 @@ import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.NotFoundException;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer;
@@ -196,7 +196,7 @@ public final class RSSExpandedImage2stringTestCase extends Assert {
int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null);
Result result;
RXingResult result;
try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
result = rssExpandedReader.decodeRow(rowNumber, row, null);

View File

@@ -34,7 +34,7 @@ import org.junit.Test;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.RXingResult;
import com.google.zxing.common.BitArray;
/**
@@ -71,7 +71,7 @@ public final class RSSExpandedStackedInternalTestCase extends Assert {
List<ExpandedPair> totalPairs = rssExpandedReader.decodeRow2pairs(secondRowNumber, secondRow);
Result result = RSSExpandedReader.constructResult(totalPairs);
RXingResult result = RSSExpandedReader.constructRXingResult(totalPairs);
assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText());
}
@@ -81,7 +81,7 @@ public final class RSSExpandedStackedInternalTestCase extends Assert {
BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png");
Result result = rssExpandedReader.decode(binaryMap);
RXingResult result = rssExpandedReader.decode(binaryMap);
assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText());
}

View File

@@ -22,11 +22,11 @@ import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.ResultMetadataType;
import com.google.zxing.RXingResult;
import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.common.TestResult;
import com.google.zxing.common.TestRXingResult;
import com.google.zxing.multi.MultipleBarcodeReader;
import org.junit.Test;
@@ -59,20 +59,20 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
private final MultipleBarcodeReader barcodeReader = new PDF417Reader();
private final List<TestResult> testResults = new ArrayList<>();
private final List<TestRXingResult> testRXingResults = new ArrayList<>();
public PDF417BlackBox4TestCase() {
super("src/test/resources/blackbox/pdf417-4", null, BarcodeFormat.PDF_417);
testResults.add(new TestResult(3, 3, 0, 0, 0.0f));
testRXingResults.add(new TestRXingResult(3, 3, 0, 0, 0.0f));
}
@Test
@Override
public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty());
assertFalse(testRXingResults.isEmpty());
Map<String,List<Path>> imageFiles = getImageFileLists();
int testCount = testResults.size();
int testCount = testRXingResults.size();
int[] passedCounts = new int[testCount];
int[] tryHarderCounts = new int[testCount];
@@ -94,10 +94,10 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
}
for (int x = 0; x < testCount; x++) {
List<Result> results = new ArrayList<>();
List<RXingResult> results = new ArrayList<>();
for (Path imageFile : testImageGroup.getValue()) {
BufferedImage image = ImageIO.read(imageFile.toFile());
float rotation = testResults.get(x).getRotation();
float rotation = testRXingResults.get(x).getRotation();
BufferedImage rotatedImage = rotateImage(image, rotation);
LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
@@ -108,11 +108,11 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
// ignore
}
}
results.sort(Comparator.comparingInt((Result r) -> getMeta(r).getSegmentIndex()));
results.sort(Comparator.comparingInt((RXingResult r) -> getMeta(r).getSegmentIndex()));
StringBuilder resultText = new StringBuilder();
String fileId = null;
for (Result result : results) {
PDF417ResultMetadata resultMetadata = getMeta(result);
for (RXingResult result : results) {
PDF417RXingResultMetadata resultMetadata = getMeta(result);
assertNotNull("resultMetadata", resultMetadata);
if (fileId == null) {
fileId = resultMetadata.getFileId();
@@ -131,15 +131,15 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
int totalMustPass = 0;
int numberOfTests = imageFiles.keySet().size();
for (int x = 0; x < testResults.size(); x++) {
TestResult testResult = testResults.get(x);
log.info(String.format("Rotation %d degrees:", (int) testResult.getRotation()));
for (int x = 0; x < testRXingResults.size(); x++) {
TestRXingResult testRXingResult = testRXingResults.get(x);
log.info(String.format("Rotation %d degrees:", (int) testRXingResult.getRotation()));
log.info(String.format(" %d of %d images passed (%d required)", passedCounts[x], numberOfTests,
testResult.getMustPassCount()));
testRXingResult.getMustPassCount()));
log.info(String.format(" %d of %d images passed with try harder (%d required)", tryHarderCounts[x],
numberOfTests, testResult.getTryHarderCount()));
numberOfTests, testRXingResult.getTryHarderCount()));
totalFound += passedCounts[x] + tryHarderCounts[x];
totalMustPass += testResult.getMustPassCount() + testResult.getTryHarderCount();
totalMustPass += testRXingResult.getMustPassCount() + testRXingResult.getTryHarderCount();
}
int totalTests = numberOfTests * testCount * 2;
@@ -154,19 +154,19 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
// Then run through again and assert if any failed
for (int x = 0; x < testCount; x++) {
TestResult testResult = testResults.get(x);
String label = "Rotation " + testResult.getRotation() + " degrees: Too many images failed";
assertTrue(label, passedCounts[x] >= testResult.getMustPassCount());
assertTrue("Try harder, " + label, tryHarderCounts[x] >= testResult.getTryHarderCount());
TestRXingResult testRXingResult = testRXingResults.get(x);
String label = "Rotation " + testRXingResult.getRotation() + " degrees: Too many images failed";
assertTrue(label, passedCounts[x] >= testRXingResult.getMustPassCount());
assertTrue("Try harder, " + label, tryHarderCounts[x] >= testRXingResult.getTryHarderCount());
}
}
private static PDF417ResultMetadata getMeta(Result result) {
return result.getResultMetadata() == null ? null : (PDF417ResultMetadata) result.getResultMetadata().get(
ResultMetadataType.PDF417_EXTRA_METADATA);
private static PDF417RXingResultMetadata getMeta(RXingResult result) {
return result.getRXingResultMetadata() == null ? null : (PDF417RXingResultMetadata) result.getRXingResultMetadata().get(
RXingResultMetadataType.PDF417_EXTRA_METADATA);
}
private Result[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderException {
private RXingResult[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderException {
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
if (tryHarder) {
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

View File

@@ -18,8 +18,8 @@ package com.google.zxing.pdf417.decoder;
import com.google.zxing.FormatException;
import com.google.zxing.WriterException;
import com.google.zxing.pdf417.PDF417ResultMetadata;
import com.google.zxing.common.DecoderResult;
import com.google.zxing.pdf417.PDF417RXingResultMetadata;
import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.pdf417.encoder.Compaction;
import com.google.zxing.pdf417.encoder.PDF417HighLevelEncoderTestAdapter;
@@ -39,7 +39,7 @@ public class PDF417DecoderTestCase extends Assert {
*/
@Test
public void testStandardSample1() throws FormatException {
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
int[] sampleCodes = {20, 928, 111, 100, 17, 53, 923, 1, 111, 104, 923, 3, 64, 416, 34, 923, 4, 258, 446, 67,
// we should never reach these
1000, 1000, 1000};
@@ -66,7 +66,7 @@ public class PDF417DecoderTestCase extends Assert {
*/
@Test
public void testStandardSample2() throws FormatException {
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
int[] sampleCodes = {11, 928, 111, 103, 17, 53, 923, 1, 111, 104, 922,
// we should never reach these
1000, 1000, 1000};
@@ -93,7 +93,7 @@ public class PDF417DecoderTestCase extends Assert {
*/
@Test
public void testStandardSample3() throws FormatException {
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
int[] sampleCodes = {7, 928, 111, 100, 100, 200, 300,
0}; // Final dummy ECC codeword required to avoid ArrayIndexOutOfBounds
@@ -108,9 +108,9 @@ public class PDF417DecoderTestCase extends Assert {
assertNull(resultMetadata.getOptionalData());
// Check that symbol containing no data except Macro is accepted (see note in Annex H.2)
DecoderResult decoderResult = DecodedBitStreamParser.decode(sampleCodes, "0");
assertEquals("", decoderResult.getText());
assertNotNull(decoderResult.getOther());
DecoderRXingResult decoderRXingResult = DecodedBitStreamParser.decode(sampleCodes, "0");
assertEquals("", decoderRXingResult.getText());
assertNotNull(decoderRXingResult.getOther());
}
@Test
@@ -118,7 +118,7 @@ public class PDF417DecoderTestCase extends Assert {
int[] sampleCodes = {23, 477, 928, 111, 100, 0, 252, 21, 86, 923, 0, 815, 251, 133, 12, 148, 537, 593,
599, 923, 1, 111, 102, 98, 311, 355, 522, 920, 779, 40, 628, 33, 749, 267, 506, 213, 928, 465, 248,
493, 72, 780, 699, 780, 493, 755, 84, 198, 628, 368, 156, 198, 809, 19, 113};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata);
@@ -135,7 +135,7 @@ public class PDF417DecoderTestCase extends Assert {
public void testSampleWithNumericValues() throws FormatException {
int[] sampleCodes = {25, 477, 928, 111, 100, 0, 252, 21, 86, 923, 2, 2, 0, 1, 0, 0, 0, 923, 5, 130, 923,
6, 1, 500, 13, 0};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata);
@@ -151,7 +151,7 @@ public class PDF417DecoderTestCase extends Assert {
@Test
public void testSampleWithMacroTerminatorOnly() throws FormatException {
int[] sampleCodes = {7, 477, 928, 222, 198, 0, 922};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata);
@@ -165,14 +165,14 @@ public class PDF417DecoderTestCase extends Assert {
@Test(expected = FormatException.class)
public void testSampleWithBadSequenceIndexMacro() throws FormatException {
int[] sampleCodes = {3, 928, 222, 0};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata);
}
@Test(expected = FormatException.class)
public void testSampleWithNoFileIdMacro() throws FormatException {
int[] sampleCodes = {4, 928, 222, 198, 0};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata);
}
@@ -405,9 +405,9 @@ public class PDF417DecoderTestCase extends Assert {
}
}
private static void performDecodeTest(int[] codewords, String expectedResult) throws FormatException {
DecoderResult result = DecodedBitStreamParser.decode(codewords, "0");
assertEquals(expectedResult, result.getText());
private static void performDecodeTest(int[] codewords, String expectedRXingResult) throws FormatException {
DecoderRXingResult result = DecodedBitStreamParser.decode(codewords, "0");
assertEquals(expectedRXingResult, result.getText());
}
private static void performECITest(char[] chars,

View File

@@ -110,18 +110,18 @@ public final class QRCodeWriterTestCase extends Assert {
BufferedImage image = loadImage(fileName);
assertNotNull(image);
BitMatrix goldenResult = createMatrixFromImage(image);
assertNotNull(goldenResult);
BitMatrix goldenRXingResult = createMatrixFromImage(image);
assertNotNull(goldenRXingResult);
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.ERROR_CORRECTION, ecLevel);
Writer writer = new QRCodeWriter();
BitMatrix generatedResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution,
BitMatrix generatedRXingResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution,
resolution, hints);
assertEquals(resolution, generatedResult.getWidth());
assertEquals(resolution, generatedResult.getHeight());
assertEquals(goldenResult, generatedResult);
assertEquals(resolution, generatedRXingResult.getWidth());
assertEquals(resolution, generatedRXingResult.getHeight());
assertEquals(goldenRXingResult, generatedRXingResult);
}
// Golden images are generated with "qrcode_sample.cc". The images are checked with both eye balls

View File

@@ -905,11 +905,11 @@ public final class EncoderTestCase extends Assert {
".a.a.)", null, false);
}
static void verifyMinimalEncoding(String input, String expectedResult, Charset priorityCharset, boolean isGS1)
static void verifyMinimalEncoding(String input, String expectedRXingResult, Charset priorityCharset, boolean isGS1)
throws Exception {
MinimalEncoder.ResultList result = MinimalEncoder.encode(input, null, priorityCharset, isGS1,
MinimalEncoder.RXingResultList result = MinimalEncoder.encode(input, null, priorityCharset, isGS1,
ErrorCorrectionLevel.L);
assertEquals(result.toString(), expectedResult);
assertEquals(result.toString(), expectedRXingResult);
}
private static void verifyGS1EncodedData(QRCode qrCode) {

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java