summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKRenderTest/scripts/pixelmatch.js
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKRenderTest/scripts/pixelmatch.js')
-rw-r--r--platform/android/MapboxGLAndroidSDKRenderTest/scripts/pixelmatch.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKRenderTest/scripts/pixelmatch.js b/platform/android/MapboxGLAndroidSDKRenderTest/scripts/pixelmatch.js
new file mode 100644
index 0000000000..21758b99b2
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKRenderTest/scripts/pixelmatch.js
@@ -0,0 +1,18 @@
+// TODO: support multiple test cases
+var testCase = 'background-color/function'
+
+var fs = require('fs'),
+ PNG = require('pngjs').PNG,
+ pixelmatch = require('pixelmatch');
+
+var img1 = fs.createReadStream('build/outputs/' + testCase + '/expected.png').pipe(new PNG()).on('parsed', doneReading),
+ img2 = fs.createReadStream('build/outputs/' + testCase + '/actual.png').pipe(new PNG()).on('parsed', doneReading),
+ filesRead = 0;
+
+function doneReading() {
+ if (++filesRead < 2) return;
+ var diff = new PNG({width: img1.width, height: img1.height});
+ var numberMismatchPixels = pixelmatch(img1.data, img2.data, diff.data, img1.width, img1.height, {threshold: 0.1});
+ console.log("PixelMatching: " + testCase + ": " + numberMismatchPixels + " mismatched pixels.");
+ diff.pack().pipe(fs.createWriteStream('build/outputs/' + testCase + '/diff.png'));
+} \ No newline at end of file