diff options
Diffstat (limited to 'test/src/mbgl')
-rw-r--r-- | test/src/mbgl/test/conversion_stubs.hpp | 2 | ||||
-rw-r--r-- | test/src/mbgl/test/fixture_log_observer.hpp | 2 | ||||
-rw-r--r-- | test/src/mbgl/test/util.cpp | 23 | ||||
-rw-r--r-- | test/src/mbgl/test/util.hpp | 9 |
4 files changed, 24 insertions, 12 deletions
diff --git a/test/src/mbgl/test/conversion_stubs.hpp b/test/src/mbgl/test/conversion_stubs.hpp index b80a2c98bd..ddffb1e3b2 100644 --- a/test/src/mbgl/test/conversion_stubs.hpp +++ b/test/src/mbgl/test/conversion_stubs.hpp @@ -104,7 +104,7 @@ inline optional<mbgl::Value> toValue(const Value& value) { } else if (value.is<std::string>()) { return { value.get<std::string>() }; } else if (value.is<float>()) { - return { value.get<float>() }; + return { double(value.get<float>()) }; } else { return {}; } diff --git a/test/src/mbgl/test/fixture_log_observer.hpp b/test/src/mbgl/test/fixture_log_observer.hpp index 918bbee18c..96ddc2c54f 100644 --- a/test/src/mbgl/test/fixture_log_observer.hpp +++ b/test/src/mbgl/test/fixture_log_observer.hpp @@ -1,6 +1,6 @@ #pragma once -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> #include <vector> #include <cstdarg> diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp index 7f98c43dc9..7ca2d72504 100644 --- a/test/src/mbgl/test/util.cpp +++ b/test/src/mbgl/test/util.cpp @@ -1,8 +1,9 @@ #include <mbgl/test/util.hpp> #include <mbgl/map/map.hpp> -#include <mbgl/platform/default/offscreen_view.hpp> -#include <mbgl/platform/log.hpp> +#include <mbgl/gl/offscreen_view.hpp> +#include <mbgl/gl/headless_display.hpp> +#include <mbgl/util/logging.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/chrono.hpp> @@ -98,13 +99,18 @@ Server::~Server() { } } +std::shared_ptr<HeadlessDisplay> sharedDisplay() { + static auto display = std::make_shared<HeadlessDisplay>(); + return display; +} + PremultipliedImage render(Map& map, OffscreenView& view) { PremultipliedImage result; map.renderStill(view, [&](std::exception_ptr) { result = view.readStillImage(); }); - while (!result.size()) { + while (!result.valid()) { util::RunLoop::Get()->runOnce(); } @@ -132,24 +138,23 @@ void checkImage(const std::string& base, } PremultipliedImage expected = decodeImage(expected_image); - PremultipliedImage diff { expected.width, expected.height }; + PremultipliedImage diff { expected.size }; #if !TEST_READ_ONLY util::write_file(base + "/actual.png", encodePNG(actual)); #endif - ASSERT_EQ(expected.width, actual.width); - ASSERT_EQ(expected.height, actual.height); + ASSERT_EQ(expected.size, actual.size); double pixels = mapbox::pixelmatch(actual.data.get(), expected.data.get(), - expected.width, - expected.height, + expected.size.width, + expected.size.height, diff.data.get(), pixelThreshold); - EXPECT_LE(pixels / (expected.width * expected.height), imageThreshold); + EXPECT_LE(pixels / (expected.size.width * expected.size.height), imageThreshold); #if !TEST_READ_ONLY util::write_file(base + "/diff.png", encodePNG(diff)); diff --git a/test/src/mbgl/test/util.hpp b/test/src/mbgl/test/util.hpp index b8ecf175aa..34d8969d3c 100644 --- a/test/src/mbgl/test/util.hpp +++ b/test/src/mbgl/test/util.hpp @@ -4,7 +4,10 @@ #include <TargetConditionals.h> #endif -#if TARGET_OS_IOS +#if __ANDROID__ +#define TEST_READ_ONLY 0 +#define TEST_HAS_SERVER 0 +#elif TARGET_OS_IOS #define TEST_READ_ONLY 1 #define TEST_HAS_SERVER 0 #else @@ -46,6 +49,7 @@ #include <mbgl/util/chrono.hpp> #include <cstdint> +#include <memory> #include <gtest/gtest.h> @@ -53,6 +57,7 @@ namespace mbgl { class Map; class OffscreenView; +class HeadlessDisplay; namespace test { @@ -65,6 +70,8 @@ private: int fd = -1; }; +std::shared_ptr<HeadlessDisplay> sharedDisplay(); + PremultipliedImage render(Map&, OffscreenView&); void checkImage(const std::string& base, |