summaryrefslogtreecommitdiff
path: root/core/src/test/java/com
diff options
context:
space:
mode:
authorSean Owen <srowen@gmail.com>2019-12-12 00:29:40 +0300
committerSean Owen <srowen@gmail.com>2019-12-12 00:29:49 +0300
commit459c0197a7ce16ba9d2ce8d7acac2169a87fe066 (patch)
tree0e4133125463c08e88e4f8472733b153b2d13379 /core/src/test/java/com
parentcfe86846696ad13fa12fc6d426a86a8e63b1647a (diff)
downloadzxing-459c0197a7ce16ba9d2ce8d7acac2169a87fe066.tar.xz
Plugin updates; misc code simplifications and optimizations
Diffstat (limited to 'core/src/test/java/com')
-rw-r--r--core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java21
-rw-r--r--core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java32
-rw-r--r--core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java18
3 files changed, 29 insertions, 42 deletions
diff --git a/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java b/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java
index cdf3af682..a777be5c8 100644
--- a/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java
+++ b/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java
@@ -65,17 +65,18 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
// black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a
// barcode image. Force any such pixel to be white:
if ((pixel & 0xFF000000) == 0) {
- pixel = 0xFFFFFFFF; // = white
- }
-
- // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
- // (306*R) >> 10 is approximately equal to R*0.299, and so on.
- // 0x200 >> 10 is 0.5, it implements rounding.
- buffer[x] =
+ // white, so we know its luminance is 255
+ buffer[x] = 0xFF;
+ } else {
+ // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
+ // (306*R) >> 10 is approximately equal to R*0.299, and so on.
+ // 0x200 >> 10 is 0.5, it implements rounding.
+ buffer[x] =
(306 * ((pixel >> 16) & 0xFF) +
- 601 * ((pixel >> 8) & 0xFF) +
- 117 * (pixel & 0xFF) +
- 0x200) >> 10;
+ 601 * ((pixel >> 8) & 0xFF) +
+ 117 * (pixel & 0xFF) +
+ 0x200) >> 10;
+ }
}
raster.setPixels(left, y, width, 1, buffer);
}
diff --git a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java
index 413d21497..cc2374371 100644
--- a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java
+++ b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java
@@ -125,14 +125,8 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
return barcodeReader;
}
- // This workaround is used because AbstractNegativeBlackBoxTestCase overrides this method but does
- // not return SummaryResults.
@Test
public void testBlackBox() throws IOException {
- testBlackBoxCountingResults(true);
- }
-
- private void testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
assertFalse(testResults.isEmpty());
List<Path> imageFiles = getImageFiles();
@@ -235,20 +229,18 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
}
// Then run through again and assert if any failed
- if (assertOnFailure) {
- 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());
- label = "Rotation " + testResult.getRotation() + " degrees: Too many images misread";
- assertTrue(label,
- misreadCounts[x] <= testResult.getMaxMisreads());
- assertTrue("Try harder, " + label,
- tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads());
- }
+ 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());
+ label = "Rotation " + testResult.getRotation() + " degrees: Too many images misread";
+ assertTrue(label,
+ misreadCounts[x] <= testResult.getMaxMisreads());
+ assertTrue("Try harder, " + label,
+ tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads());
}
}
diff --git a/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java b/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
index f61b643be..de4952a26 100644
--- a/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
+++ b/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
@@ -51,7 +51,7 @@ import java.util.logging.Logger;
/**
* This class tests Macro PDF417 barcode specific functionality. It ensures that information, which is split into
* several barcodes can be properly combined again to yield the original data content.
- *
+ *
* @author Guenther Grau
*/
public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
@@ -69,10 +69,6 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
@Test
@Override
public void testBlackBox() throws IOException {
- testPDF417BlackBoxCountingResults(true);
- }
-
- private void testPDF417BlackBoxCountingResults(boolean assertOnFailure) throws IOException {
assertFalse(testResults.isEmpty());
Map<String,List<Path>> imageFiles = getImageFileLists();
@@ -157,13 +153,11 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
}
// Then run through again and assert if any failed
- if (assertOnFailure) {
- 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());
- }
+ 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());
}
}