diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-20 17:12:58 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-22 08:04:39 -0700 |
commit | 40e47556214e999c952c1e88e026d673cdd96c72 (patch) | |
tree | e8d15795cbecc07c94908a8ebed31b73def64614 /test/api | |
parent | 1520a56813f82bbe875774fdc2b3df26392278d6 (diff) | |
download | qtlocation-mapboxgl-40e47556214e999c952c1e88e026d673cdd96c72.tar.gz |
[core] Move setStyleJSON/URL to Style; add Map::setStyle
Diffstat (limited to 'test/api')
-rw-r--r-- | test/api/annotations.test.cpp | 51 | ||||
-rw-r--r-- | test/api/custom_layer.test.cpp | 2 | ||||
-rw-r--r-- | test/api/query.test.cpp | 2 | ||||
-rw-r--r-- | test/api/render_missing.test.cpp | 3 | ||||
-rw-r--r-- | test/api/repeated_render.test.cpp | 5 |
5 files changed, 33 insertions, 30 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 12acdbca2f..7594d5ed73 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -3,6 +3,7 @@ #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/annotation/annotation.hpp> +#include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/map/map.hpp> #include <mbgl/map/backend_scope.hpp> @@ -45,7 +46,7 @@ public: TEST(Annotations, SymbolAnnotation) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" }); test.checkRendering("point_annotation"); @@ -67,7 +68,7 @@ TEST(Annotations, LineAnnotation) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); test.checkRendering("line_annotation"); @@ -82,7 +83,7 @@ TEST(Annotations, FillAnnotation) { FillAnnotation annotation { polygon }; annotation.color = Color::red(); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); test.checkRendering("fill_annotation"); @@ -95,7 +96,7 @@ TEST(Annotations, AntimeridianAnnotationSmall) { double antimeridian = 180; test.map.setLatLngZoom(mbgl::LatLng(0, antimeridian), 0); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); LineString<double> line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; LineAnnotation lineAnnotation { line }; @@ -116,7 +117,7 @@ TEST(Annotations, AntimeridianAnnotationLarge) { double antimeridian = 180; test.map.setLatLngZoom(mbgl::LatLng(0, antimeridian), 0); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); LineString<double> line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; LineAnnotation lineAnnotation { line }; @@ -141,7 +142,7 @@ TEST(Annotations, OverlappingFillAnnotation) { FillAnnotation overlaidAnnotation { polygon }; overlaidAnnotation.color = Color::red(); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(underlaidAnnotation); test.map.addAnnotation(overlaidAnnotation); test.checkRendering("overlapping_fill_annotation"); @@ -150,7 +151,7 @@ TEST(Annotations, OverlappingFillAnnotation) { TEST(Annotations, AddMultiple) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" }); @@ -163,7 +164,7 @@ TEST(Annotations, AddMultiple) { TEST(Annotations, NonImmediateAdd) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test::render(test.map, test.view); Polygon<double> polygon = { {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }; @@ -177,7 +178,7 @@ TEST(Annotations, NonImmediateAdd) { TEST(Annotations, UpdateSymbolAnnotationGeometry) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotationImage(namedMarker("flipped_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); @@ -191,7 +192,7 @@ TEST(Annotations, UpdateSymbolAnnotationGeometry) { TEST(Annotations, UpdateSymbolAnnotationIcon) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotationImage(namedMarker("flipped_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); @@ -209,7 +210,7 @@ TEST(Annotations, UpdateLineAnnotationGeometry) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); test::render(test.map, test.view); @@ -226,7 +227,7 @@ TEST(Annotations, UpdateLineAnnotationStyle) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); test::render(test.map, test.view); @@ -243,7 +244,7 @@ TEST(Annotations, UpdateFillAnnotationGeometry) { FillAnnotation annotation { Polygon<double> { {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} } }; annotation.color = Color::red(); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); test::render(test.map, test.view); @@ -260,7 +261,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) { FillAnnotation annotation { polygon }; annotation.color = Color::red(); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); test::render(test.map, test.view); @@ -273,7 +274,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) { TEST(Annotations, RemovePoint) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); @@ -291,7 +292,7 @@ TEST(Annotations, RemoveShape) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID shape = test.map.addAnnotation(annotation); test::render(test.map, test.view); @@ -304,7 +305,7 @@ TEST(Annotations, ImmediateRemoveShape) { AnnotationTest test; test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation { LineString<double>() })); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test::render(test.map, test.view); } @@ -312,20 +313,20 @@ TEST(Annotations, ImmediateRemoveShape) { TEST(Annotations, SwitchStyle) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test::render(test.map, test.view); - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.checkRendering("switch_style"); } TEST(Annotations, ReaddImage) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); @@ -338,7 +339,7 @@ TEST(Annotations, ReaddImage) { TEST(Annotations, QueryRenderedFeatures) { AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 50 }, "default_marker" }); @@ -362,7 +363,7 @@ TEST(Annotations, QueryFractionalZoomLevels) { auto viewSize = test.view.getSize(); auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); std::vector<mbgl::AnnotationID> ids; @@ -394,7 +395,7 @@ TEST(Annotations, VisibleFeatures) { auto viewSize = test.view.getSize(); auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.setLatLngZoom({ 5, 5 }, 3); @@ -438,7 +439,7 @@ TEST(Annotations, DebugEmpty) { // should not render them. AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); test.map.setZoom(1); @@ -451,7 +452,7 @@ TEST(Annotations, DebugSparse) { // tiles because they're all empty. AnnotationTest test; - test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); test.map.setZoom(1); test.map.addAnnotationImage(namedMarker("default_marker")); diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index e11ed299a6..2b1138a1d3 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -94,7 +94,7 @@ TEST(CustomLayer, Basic) { ThreadPool threadPool(4); Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); - map.setStyleJSON(util::read_file("test/fixtures/api/water.json")); + map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); map.getStyle().addLayer(std::make_unique<CustomLayer>( "custom", diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index ad4dc6f4de..0b6d75ec4f 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -20,7 +20,7 @@ namespace { class QueryTest { public: QueryTest() { - map.setStyleJSON(util::read_file("test/fixtures/api/query_style.json")); + map.getStyle().loadJSON(util::read_file("test/fixtures/api/query_style.json")); map.getStyle().addImage(std::make_unique<style::Image>("test-icon", decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0)); diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp index 6e99501708..2e0c4401f4 100644 --- a/test/api/render_missing.test.cpp +++ b/test/api/render_missing.test.cpp @@ -10,6 +10,7 @@ #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> +#include <mbgl/style/style.hpp> #include <future> @@ -40,7 +41,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { // This host does not respond (== connection error). // Are you seeing this test fail? Make sure you don't have a server running on port 3001! - map.setStyleJSON(style); + map.getStyle().loadJSON(style); map.renderStill(view, [&](std::exception_ptr err) { ASSERT_TRUE(err.operator bool()); try { diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp index 0b9726d3fa..b6565dbf23 100644 --- a/test/api/repeated_render.test.cpp +++ b/test/api/repeated_render.test.cpp @@ -10,6 +10,7 @@ #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> +#include <mbgl/style/style.hpp> #include <future> @@ -33,7 +34,7 @@ TEST(API, RepeatedRender) { Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); { - map.setStyleJSON(style); + map.getStyle().loadJSON(style); PremultipliedImage result; map.renderStill(view, [&](std::exception_ptr) { result = view.readStillImage(); @@ -51,7 +52,7 @@ TEST(API, RepeatedRender) { } { - map.setStyleJSON(style); + map.getStyle().loadJSON(style); PremultipliedImage result; map.renderStill(view, [&](std::exception_ptr) { result = view.readStillImage(); |