diff options
-rw-r--r-- | render-test/runner.cpp | 16 | ||||
-rw-r--r-- | render-test/tests/file-size/pass-size-is-same/metrics.json | 14 | ||||
-rw-r--r-- | render-test/tests/file-size/pass-size-is-same/style.json | 4 |
3 files changed, 30 insertions, 4 deletions
diff --git a/render-test/runner.cpp b/render-test/runner.cpp index 05ba089d81..24bc6668d7 100644 --- a/render-test/runner.cpp +++ b/render-test/runner.cpp @@ -12,6 +12,7 @@ #include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/style/style.hpp> #include <mbgl/util/chrono.hpp> +#include <mbgl/util/compression.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> @@ -837,12 +838,25 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata, R float tolerance = operationArray[3].GetDouble(); mbgl::filesystem::path filePath(path); + bool compressed = false; + if (operationArray.Size() == 5) { + assert(operationArray[4].IsString()); + assert(std::string(operationArray[4].GetString(), operationArray[4].GetStringLength()) == "compressed"); + compressed = true; + } + if (!filePath.is_absolute()) { filePath = metadata.paths.defaultExpectations() / filePath; } if (mbgl::filesystem::exists(filePath)) { - auto size = mbgl::filesystem::file_size(filePath); + size_t size = 0; + if (compressed) { + size = mbgl::util::compress(*mbgl::util::readFile(filePath)).size(); + } else { + size = mbgl::filesystem::file_size(filePath); + } + metadata.metrics.fileSize.emplace(std::piecewise_construct, std::forward_as_tuple(std::move(mark)), std::forward_as_tuple(std::move(path), size, tolerance)); diff --git a/render-test/tests/file-size/pass-size-is-same/metrics.json b/render-test/tests/file-size/pass-size-is-same/metrics.json index 3d560bd610..15f8c35617 100644 --- a/render-test/tests/file-size/pass-size-is-same/metrics.json +++ b/render-test/tests/file-size/pass-size-is-same/metrics.json @@ -6,9 +6,19 @@ 169 ], [ + "image-compressed", + "expected.png", + 167 + ], + [ "style", "style.json", - 516 + 674 + ], + [ + "style-compressed", + "style.json", + 256 ] ] -}
\ No newline at end of file +} diff --git a/render-test/tests/file-size/pass-size-is-same/style.json b/render-test/tests/file-size/pass-size-is-same/style.json index 839a8d4a12..b13f37500a 100644 --- a/render-test/tests/file-size/pass-size-is-same/style.json +++ b/render-test/tests/file-size/pass-size-is-same/style.json @@ -3,8 +3,10 @@ "metadata": { "test": { "operations": [ + ["probeFileSize", "image", "expected.png", 0], + ["probeFileSize", "image-compressed", "expected.png", 0, "compressed"], ["probeFileSize", "style", "style.json", 0], - ["probeFileSize", "image", "expected.png", 0] + ["probeFileSize", "style-compressed", "style.json", 0, "compressed"] ], "width": 64, "height": 64 |