diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-06-08 14:02:43 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-06-11 13:41:43 +0200 |
commit | 5c01142b902aa35a54fff72bc1ca9c708df16794 (patch) | |
tree | b12841db4fc15e6149a74ad311757aa8d9e54759 | |
parent | 871903bf62acb86820cafa66839c6cb83f9dc5d4 (diff) | |
download | qtlocation-mapboxgl-5c01142b902aa35a54fff72bc1ca9c708df16794.tar.gz |
[android] - show amount failed tests and executed tests, integrate pixelratio in tests
3 files changed, 43 insertions, 7 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestDefinition.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestDefinition.java index fa8c816203..3cff4cad54 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestDefinition.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestDefinition.java @@ -49,6 +49,17 @@ public class RenderTestDefinition { return DEFAULT_HEIGHT; } + public float getPixelRatio() { + RenderTestStyleDefinition.Test test = getTest(); + if (test != null) { + Float pixelRatio = test.getPixelRatio(); + if (pixelRatio != null && pixelRatio > 0) { + return pixelRatio; + } + } + return 1; + } + public String getStyleJson() { return styleJson; } @@ -65,6 +76,7 @@ public class RenderTestDefinition { return new MapSnapshotter .Options(getWidth(), getHeight()) .withStyleJson(styleJson) + .withPixelRatio(getPixelRatio()) .withLogo(false); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestStyleDefinition.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestStyleDefinition.java index c9d2224da4..6f4aa0b6f0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestStyleDefinition.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestStyleDefinition.java @@ -60,6 +60,7 @@ public class RenderTestStyleDefinition { private Integer width; private Integer height; + private Float pixelRatio; private List<Integer> center = null; private Integer zoom; private Double diff; @@ -82,6 +83,10 @@ public class RenderTestStyleDefinition { this.height = height; } + public Float getPixelRatio() { + return pixelRatio; + } + public List<Integer> getCenter() { return center; } diff --git a/platform/android/scripts/run-render-test.py b/platform/android/scripts/run-render-test.py index 83376256a4..1a7289a116 100644 --- a/platform/android/scripts/run-render-test.py +++ b/platform/android/scripts/run-render-test.py @@ -1,9 +1,11 @@ #!/usr/bin/python import os -from shutil import copyfile +import shutil catPath = os.getcwd() + "/platform/android/build/render-test/render/" +failCounter = 0 +testCounter = 0 for cat in os.listdir(catPath): testPath = catPath + cat + "/" for test in os.listdir(testPath): @@ -14,11 +16,28 @@ for cat in os.listdir(catPath): actual = outputPath + "/actual.png" output = outputPath + "/output.png" - copyfile(inputPath + "/expected.png", expected) - copyfile(inputPath + "/style.json", outputPath + "/style.json") - pixelmatch = "node_modules/pixelmatch/bin/pixelmatch " + actual + " " + expected + " " + output + " 0.1" + shutil.copyfile(inputPath + "/expected.png", expected) + shutil.copyfile(inputPath + "/style.json", outputPath + "/style.json") + pixelmatchCommand = "node_modules/pixelmatch/bin/pixelmatch " + actual + " " + expected + " " + output + " 0.1" - print - print "Pixel match "+ cat + " " + test - os.system(pixelmatch) + print "Pixel match " + cat + " " + test + + with os.popen(pixelmatchCommand) as f: + for line_terminated in f: + line = line_terminated.rstrip('\n') + pair = line.split(": ") + if pair[0] == "error": + testCounter += 1 + currentError = pair[1] + if currentError != "0%": + failCounter += 1 + # below deletes successful results + # print cat + " " + test + " " + currentError + # else: + # try: + # if os.path.isdir(outputPath): + # shutil.rmtree(outputPath) + # except OSError, e: + # print ("Error: %s - %s." % (e.filename, e.strerror)) print +print str(failCounter) + "/" + str(testCounter) |