diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-02-27 19:01:29 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-04 14:45:32 +0200 |
commit | f5f10ec11989ccb403c2cd4261db74c44b263558 (patch) | |
tree | 8c88ee24819281609206e36c719eef617acb52b6 /test | |
parent | 491fce68790e05cd0a876815751dc5cb72a2761e (diff) | |
download | qtlocation-mapboxgl-f5f10ec11989ccb403c2cd4261db74c44b263558.tar.gz |
[core] Remove map zoom setters/getters
Diffstat (limited to 'test')
-rw-r--r-- | test/api/annotations.test.cpp | 27 | ||||
-rw-r--r-- | test/api/custom_geometry_source.test.cpp | 2 | ||||
-rw-r--r-- | test/api/custom_layer.test.cpp | 2 | ||||
-rw-r--r-- | test/api/query.test.cpp | 2 | ||||
-rw-r--r-- | test/gl/context.test.cpp | 2 | ||||
-rw-r--r-- | test/map/map.test.cpp | 37 | ||||
-rw-r--r-- | test/map/prefetch.test.cpp | 2 | ||||
-rw-r--r-- | test/util/memory.test.cpp | 4 |
8 files changed, 39 insertions, 39 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index d13bc15ea7..c0c4f38cf9 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -53,7 +53,7 @@ TEST(Annotations, SymbolAnnotation) { // auto size = test.frontend.getSize(); // auto screenBox = ScreenBox { {}, { double(size.width), double(size.height) } }; // for (uint8_t zoom = test.map.getMinZoom(); zoom <= test.map.getMaxZoom(); ++zoom) { -// test.map.setZoom(zoom); +// test.map.jumpTo(CameraOptions().withZoom(zoom)); // test.checkRendering("point_annotation"); // EXPECT_EQ(test.map.queryPointAnnotations(screenBox).size(), 1u); // } @@ -67,7 +67,7 @@ TEST(Annotations, SymbolAnnotationTileBoundary) { 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.000000000000001, 0.00000000000001), "default_marker" }); - test.map.setZoom(10); + test.map.jumpTo(CameraOptions().withZoom(10)); test.checkRendering("point_annotation"); } @@ -83,7 +83,7 @@ TEST(Annotations, LineAnnotation) { test.map.addAnnotation(annotation); test.checkRendering("line_annotation"); - test.map.setZoom(test.map.getMaxZoom()); + test.map.jumpTo(CameraOptions().withZoom(test.map.getMaxZoom())); test.checkRendering("line_annotation_max_zoom"); } @@ -98,7 +98,7 @@ TEST(Annotations, FillAnnotation) { test.map.addAnnotation(annotation); test.checkRendering("fill_annotation"); - test.map.setZoom(test.map.getMaxZoom()); + test.map.jumpTo(CameraOptions().withZoom(test.map.getMaxZoom())); test.checkRendering("fill_annotation_max_zoom"); } @@ -106,7 +106,7 @@ TEST(Annotations, AntimeridianAnnotationSmall) { AnnotationTest test; double antimeridian = 180; - test.map.setLatLngZoom(mbgl::LatLng(0, antimeridian), 0); + test.map.jumpTo(CameraOptions().withCenter(LatLng { 0, antimeridian }).withZoom(0.0)); test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); LineString<double> line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; @@ -127,7 +127,7 @@ TEST(Annotations, AntimeridianAnnotationLarge) { AnnotationTest test; double antimeridian = 180; - test.map.setLatLngZoom(mbgl::LatLng(0, antimeridian), 0); + test.map.jumpTo(CameraOptions().withCenter(mbgl::LatLng(0.0, antimeridian)).withZoom(0.0)); test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); LineString<double> line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; @@ -384,9 +384,9 @@ TEST(Annotations, QueryFractionalZoomLevels) { } } - test.map.setLatLngZoom({ 5, 5 }, 0); + test.map.jumpTo(CameraOptions().withCenter(mbgl::LatLng(5.0, 5.0)).withZoom(0.0)); for (uint16_t zoomSteps = 10; zoomSteps <= 20; ++zoomSteps) { - test.map.setZoom(zoomSteps / 10.0); + test.map.jumpTo(CameraOptions().withZoom(zoomSteps / 10.0)); test.frontend.render(test.map); auto features = test.frontend.getRenderer()->queryRenderedFeatures(box); @@ -408,7 +408,7 @@ TEST(Annotations, VisibleFeatures) { test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); - test.map.setLatLngZoom({ 5, 5 }, 3); + test.map.jumpTo(CameraOptions().withCenter(mbgl::LatLng(5.0, 5.0)).withZoom(3.0)); std::vector<mbgl::AnnotationID> ids; for (int longitude = 0; longitude < 10; longitude += 2) { @@ -428,8 +428,7 @@ TEST(Annotations, VisibleFeatures) { features.erase(std::unique(features.begin(), features.end(), sameID), features.end()); EXPECT_EQ(features.size(), ids.size()); - test.map.setBearing(0); - test.map.setZoom(4); + test.map.jumpTo(CameraOptions().withZoom(4.0).withAngle(0.0)); test.frontend.render(test.map); features = test.frontend.getRenderer()->queryRenderedFeatures(box); std::sort(features.begin(), features.end(), sortID); @@ -452,7 +451,7 @@ TEST(Annotations, DebugEmpty) { test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); - test.map.setZoom(1); + test.map.jumpTo(CameraOptions().withZoom(1.0)); test.checkRendering("debug_empty"); } @@ -465,7 +464,7 @@ TEST(Annotations, DebugSparse) { test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); - test.map.setZoom(1); + test.map.jumpTo(CameraOptions().withZoom(1.0)); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double>(10, 10), "default_marker" }); @@ -484,7 +483,7 @@ TEST(Annotations, ChangeMaxZoom) { test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); test.map.setMaxZoom(14); - test.map.setZoom(test.map.getMaxZoom()); + test.map.jumpTo(CameraOptions().withZoom(test.map.getMaxZoom())); test.checkRendering("line_annotation_max_zoom"); } diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp index 51d026e30d..3e18cca01a 100644 --- a/test/api/custom_geometry_source.test.cpp +++ b/test/api/custom_geometry_source.test.cpp @@ -26,7 +26,7 @@ TEST(CustomGeometrySource, Grid) { Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, *threadPool, MapMode::Static); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); - map.setLatLngZoom({ 37.8, -122.5 }, 10); + map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); CustomGeometrySource::Options options; options.fetchTileFunction = [&map](const mbgl::CanonicalTileID& tileID) { diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index c2a0797483..114b88398a 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -96,7 +96,7 @@ TEST(CustomLayer, Basic) { Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, threadPool, MapMode::Static); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); - map.setLatLngZoom({ 37.8, -122.5 }, 10); + map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); map.getStyle().addLayer(std::make_unique<CustomLayer>( "custom", std::make_unique<TestLayer>())); diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index f5eb32788d..efda84baa9 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -59,7 +59,7 @@ std::vector<Feature> getTopClusterFeature(QueryTest& test) { clusterLayer->setIconImage("test-icon"s); clusterLayer->setIconSize(12.0f); - test.map.setLatLngZoom(coordinate, 0); + test.map.jumpTo(CameraOptions().withCenter(coordinate).withZoom(0.0)); test.map.getStyle().addSource(std::move(source)); test.map.getStyle().addLayer(std::move(clusterLayer)); test.loop.runOnce(); diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp index 176257916f..a5f9807a8e 100644 --- a/test/gl/context.test.cpp +++ b/test/gl/context.test.cpp @@ -93,7 +93,7 @@ TEST(GLContextMode, Shared) { Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, threadPool, MapMode::Static); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); - map.setLatLngZoom({ 37.8, -122.5 }, 10); + map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); // Set transparent background layer. auto layer = map.getStyle().getLayer("background"); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 690df6b3e9..da3abfcb24 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -64,9 +64,7 @@ TEST(Map, RendererState) { double bearingInDegrees = 30.0; test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.setLatLngZoom(coordinate, zoom); - test.map.setPitch(pitchInDegrees); - test.map.setBearing(bearingInDegrees); + test.map.jumpTo(CameraOptions().withCenter(coordinate).withZoom(zoom).withPitch(pitchInDegrees).withAngle(bearingInDegrees)); test.runLoop.runOnce(); test.frontend.render(test.map); @@ -128,7 +126,7 @@ TEST(Map, RendererState) { TEST(Map, LatLngBehavior) { MapTest<> test; - test.map.setLatLngZoom({ 1, 1 }, 0); + test.map.jumpTo(CameraOptions().withCenter(LatLng { 1.0, 1.0 }).withZoom(0.0)); auto latLng1 = test.map.getLatLng(); test.map.setLatLng({ 1, 1 }); @@ -141,7 +139,7 @@ TEST(Map, LatLngBehavior) { TEST(Map, LatLngBoundsToCamera) { MapTest<> test; - test.map.setLatLngZoom({ 40.712730, -74.005953 }, 16.0); + test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0)); LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281}); @@ -153,7 +151,7 @@ TEST(Map, LatLngBoundsToCamera) { TEST(Map, LatLngBoundsToCameraWithAngle) { MapTest<> test; - test.map.setLatLngZoom({ 40.712730, -74.005953 }, 16.0); + test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0)); LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281}); @@ -166,7 +164,7 @@ TEST(Map, LatLngBoundsToCameraWithAngle) { TEST(Map, LatLngBoundsToCameraWithAngleAndPitch) { MapTest<> test; - test.map.setLatLngZoom({ 40.712730, -74.005953 }, 16.0); + test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0)); LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281}); @@ -206,13 +204,13 @@ TEST(Map, LatLngsToCameraWithAngleAndPitch) { TEST(Map, CameraToLatLngBounds) { MapTest<> test; - test.map.setLatLngZoom({ 45, 90 }, 16); + test.map.jumpTo(CameraOptions().withCenter(LatLng { 45, 90 }).withZoom(16.0)); LatLngBounds bounds = LatLngBounds::hull( test.map.latLngForPixel({}), test.map.latLngForPixel({ double(test.map.getSize().width), double(test.map.getSize().height) })); - CameraOptions camera = test.map.getCameraOptions({}); + CameraOptions camera = test.map.getCameraOptions(); ASSERT_EQ(bounds, test.map.latLngBoundsForCamera(camera)); @@ -255,16 +253,19 @@ TEST(Map, Offline) { TEST(Map, SetStyleDefaultCamera) { MapTest<> test; test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); - EXPECT_DOUBLE_EQ(test.map.getZoom(), 0.0); - EXPECT_DOUBLE_EQ(test.map.getPitch(), 0.0); - EXPECT_DOUBLE_EQ(test.map.getBearing(), 0.0); - EXPECT_EQ(test.map.getLatLng(), LatLng {}); + CameraOptions camera = test.map.getCameraOptions(); + EXPECT_DOUBLE_EQ(*camera.zoom, 0.0); + EXPECT_DOUBLE_EQ(*camera.pitch, 0.0); + EXPECT_DOUBLE_EQ(*camera.angle, 0.0); + EXPECT_EQ(*camera.center, LatLng {}); test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty-zoomed.json")); - EXPECT_DOUBLE_EQ(test.map.getZoom(), 0.0); + camera = test.map.getCameraOptions(); + EXPECT_DOUBLE_EQ(*camera.zoom, 0.0); test.map.jumpTo(test.map.getStyle().getDefaultCamera()); - EXPECT_DOUBLE_EQ(test.map.getZoom(), 0.5); + camera = test.map.getCameraOptions(); + EXPECT_DOUBLE_EQ(*camera.zoom, 0.5); } TEST(Map, SetStyleInvalidJSON) { @@ -561,7 +562,7 @@ TEST(Map, DisabledSources) { return {}; }; - test.map.setZoom(1); + test.map.jumpTo(CameraOptions().withZoom(1.0)); // This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0. // We first render a map at zoom level 1, which should show both layers (both are "visible" due @@ -603,7 +604,7 @@ TEST(Map, DisabledSources) { )STYLE"); test::checkImage("test/fixtures/map/disabled_layers/first", test.frontend.render(test.map)); - test.map.setZoom(0.5); + test.map.jumpTo(CameraOptions().withZoom(0.5)); test::checkImage("test/fixtures/map/disabled_layers/second", test.frontend.render(test.map)); } @@ -648,7 +649,7 @@ TEST(Map, DontLoadUnneededTiles) { // Note: using z += 0.1 in the loop doesn't produce accurate floating point numbers. const double z = double(zoom) / 10; tiles.clear(); - test.map.setZoom(z); + test.map.jumpTo(CameraOptions().withZoom(z)); test.frontend.render(test.map); EXPECT_EQ(referenceTiles[z], tiles) << "zoom level " << z; } diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp index 9b61224027..9e513d61cd 100644 --- a/test/map/prefetch.test.cpp +++ b/test/map/prefetch.test.cpp @@ -58,7 +58,7 @@ TEST(Map, PrefetchTiles) { // Force tile reloading. map.getStyle().loadJSON(util::read_file("test/fixtures/map/prefetch/empty.json")); map.getStyle().loadJSON(util::read_file("test/fixtures/map/prefetch/style.json")); - map.setLatLngZoom({ 40.726989, -73.992857 }, zoom); // Manhattan + map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(zoom)); // Manhattan runLoop.run(); ASSERT_EQ(tiles.size(), expected.size()); diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp index 6befb521f0..e92311226b 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -73,7 +73,7 @@ TEST(Memory, Vector) { HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource, test.threadPool }; Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), ratio, test.fileSource, test.threadPool, MapMode::Static); - map.setZoom(16); // more map features + map.jumpTo(CameraOptions().withZoom(16)); map.getStyle().loadURL("mapbox://streets"); frontend.render(map); @@ -123,7 +123,7 @@ TEST(Memory, Footprint) { FrontendAndMap(MemoryTest& test_, const char* style) : frontend(Size{ 256, 256 }, 2, test_.fileSource, test_.threadPool) , map(frontend, MapObserver::nullObserver(), frontend.getSize(), 2, test_.fileSource, test_.threadPool, MapMode::Static) { - map.setZoom(16); + map.jumpTo(CameraOptions().withZoom(16)); map.getStyle().loadURL(style); frontend.render(map); } |