summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-11-28 18:12:13 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-11-28 19:18:17 +0200
commit8c9b038af3723252014362557bba9e9c43780ff3 (patch)
treeb768eb51c949dd09823c21ca81de4b4e1fc113cd
parentb5794730b5cfba58be0aa63070718cde662bb538 (diff)
downloadqtlocation-mapboxgl-8c9b038af3723252014362557bba9e9c43780ff3.tar.gz
[render-test] Add support for measuring compressed file size
Useful because for platform such as Android, we want to measure the size of the library inside the APK, which is usually compressed.
-rw-r--r--render-test/runner.cpp16
-rw-r--r--render-test/tests/file-size/pass-size-is-same/metrics.json14
-rw-r--r--render-test/tests/file-size/pass-size-is-same/style.json4
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