diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-10-10 17:16:37 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-10-25 13:52:36 -0700 |
commit | a4d259c33f9bb890bba97fd89552720e3e0ec09b (patch) | |
tree | 342ecc27a6993c48f3a2e1d739fce890350bc44d /test/map | |
parent | 5cc390d694fc7510d445310d8eb9e32429a5e67b (diff) | |
download | qtlocation-mapboxgl-a4d259c33f9bb890bba97fd89552720e3e0ec09b.tar.gz |
[core] move gl::Context to Backend and refactor View
Diffstat (limited to 'test/map')
-rw-r--r-- | test/map/map.test.cpp | 70 |
1 files changed, 27 insertions, 43 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index a5d634e77a..97a09e94a0 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -5,7 +5,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/sprite/sprite_image.hpp> #include <mbgl/storage/network_status.hpp> @@ -23,15 +23,14 @@ using namespace std::literals::string_literals; struct MapTest { util::RunLoop runLoop; HeadlessBackend backend; - HeadlessView view; + OffscreenView view { backend.getContext() }; StubFileSource fileSource; ThreadPool threadPool { 4 }; }; TEST(Map, LatLngBehavior) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); @@ -65,12 +64,11 @@ TEST(Map, Offline) { fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf")); NetworkStatus::Set(NetworkStatus::Status::Offline); - Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.setStyleURL(prefix + "style.json"); test::checkImage("test/fixtures/map/offline", - test::render(map), + test::render(map, test.view), 0.0015, 0.1); @@ -90,8 +88,8 @@ TEST(Map, SetStyleInvalidJSON) { }); { - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, - test.threadPool, MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, + MapMode::Still); map.setStyleJSON("invalid"); } @@ -122,8 +120,7 @@ TEST(Map, SetStyleInvalidURL) { } }); - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://bar"); test.runLoop.run(); @@ -132,8 +129,7 @@ TEST(Map, SetStyleInvalidURL) { TEST(Map, DoubleStyleLoad) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(""); map.setStyleJSON(""); } @@ -144,8 +140,7 @@ TEST(Map, StyleFresh) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -165,8 +160,7 @@ TEST(Map, StyleExpired) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -193,8 +187,7 @@ TEST(Map, StyleExpiredWithAnnotations) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -218,8 +211,7 @@ TEST(Map, StyleEarlyMutation) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); map.addLayer(std::make_unique<style::BackgroundLayer>("bg")); @@ -233,8 +225,7 @@ TEST(Map, StyleEarlyMutation) { TEST(Map, StyleLoadedSignal) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); // The map should emit a signal on style loaded bool emitted = false; @@ -255,22 +246,20 @@ TEST(Map, StyleLoadedSignal) { TEST(Map, AddLayer) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); auto layer = std::make_unique<BackgroundLayer>("background"); - layer->setBackgroundColor({{ 1, 0, 0, 1 }}); + layer->setBackgroundColor({ { 1, 0, 0, 1 } }); map.addLayer(std::move(layer)); - test::checkImage("test/fixtures/map/add_layer", test::render(map)); + test::checkImage("test/fixtures/map/add_layer", test::render(map, test.view)); } TEST(Map, RemoveLayer) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); auto layer = std::make_unique<BackgroundLayer>("background"); @@ -278,7 +267,7 @@ TEST(Map, RemoveLayer) { map.addLayer(std::move(layer)); map.removeLayer("background"); - test::checkImage("test/fixtures/map/remove_layer", test::render(map)); + test::checkImage("test/fixtures/map/remove_layer", test::render(map, test.view)); } TEST(Map, DisabledSources) { @@ -295,8 +284,7 @@ TEST(Map, DisabledSources) { return {}; }; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setZoom(1); // This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0. @@ -338,16 +326,15 @@ TEST(Map, DisabledSources) { } )STYLE"); - test::checkImage("test/fixtures/map/disabled_layers/first", test::render(map)); + test::checkImage("test/fixtures/map/disabled_layers/first", test::render(map, test.view)); map.setZoom(0.5); - test::checkImage("test/fixtures/map/disabled_layers/second", test::render(map)); + test::checkImage("test/fixtures/map/disabled_layers/second", test::render(map, test.view)); } TEST(Map, Classes) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); EXPECT_FALSE(map.getTransitionOptions().duration); @@ -381,8 +368,7 @@ TEST(Map, Classes) { TEST(Map, AddImage) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); auto decoded1 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto decoded2 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto image1 = std::make_unique<SpriteImage>(std::move(decoded1), 1.0); @@ -393,20 +379,18 @@ TEST(Map, AddImage) { map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); map.addImage("test-icon", std::move(image2)); - test::checkImage("test/fixtures/map/add_icon", test::render(map)); + test::checkImage("test/fixtures/map/add_icon", test::render(map, test.view)); } TEST(Map, RemoveImage) { MapTest test; - Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool, - MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0); map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); map.addImage("test-icon", std::move(image)); map.removeImage("test-icon"); - test::checkImage("test/fixtures/map/remove_icon", test::render(map)); + test::checkImage("test/fixtures/map/remove_icon", test::render(map, test.view)); } - |