summaryrefslogtreecommitdiff
path: root/test/map/map.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/map/map.test.cpp')
-rw-r--r--test/map/map.test.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index a21f9c7e75..c57fe28ae5 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -18,6 +18,8 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/layers/background_layer.hpp>
+#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/util/color.hpp>
using namespace mbgl;
@@ -69,12 +71,48 @@ TEST(Map, RendererState) {
test.runLoop.runOnce();
test.frontend.render(test.map);
+ // RendererState::getCameraOptions
const CameraOptions& options = test.frontend.getCameraOptions();
EXPECT_NEAR(options.center->latitude(), coordinate.latitude(), 1e-7);
EXPECT_NEAR(options.center->longitude(), coordinate.longitude(), 1e-7);
ASSERT_DOUBLE_EQ(*options.zoom, zoom);
ASSERT_DOUBLE_EQ(*options.pitch, pitchInDegrees);
EXPECT_NEAR(*options.angle, bearingInDegrees, 1e-7);
+
+ // RendererState::hasImage
+ test.map.getStyle().addImage(std::make_unique<style::Image>("default_marker", decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0));
+
+ // The frontend has not yet been notified about the newly-added image.
+ EXPECT_FALSE(test.frontend.hasImage("default_marker"));
+
+ test.runLoop.runOnce();
+ test.frontend.render(test.map);
+
+ EXPECT_TRUE(test.frontend.hasImage("default_marker"));
+
+ // RendererState::hasSource
+ auto source = std::make_unique<GeoJSONSource>("GeoJSONSource");
+ source->setGeoJSON( Geometry<double>{ Point<double>{ 0, 0 } } );
+ test.map.getStyle().addSource(std::move(source));
+
+ // The frontend has not yet been notified about the newly-added source.
+ EXPECT_FALSE(test.frontend.hasSource("GeoJSONSource"));
+
+ test.runLoop.runOnce();
+ test.frontend.render(test.map);
+
+ EXPECT_TRUE(test.frontend.hasSource("GeoJSONSource"));
+
+ // RendererState::hasLayer
+ test.map.getStyle().addLayer(std::make_unique<SymbolLayer>("SymbolLayer", "GeoJSONSource"));
+
+ // The frontend has not yet been notified about the newly-added source.
+ EXPECT_FALSE(test.frontend.hasLayer("SymbolLayer"));
+
+ test.runLoop.runOnce();
+ test.frontend.render(test.map);
+
+ EXPECT_TRUE(test.frontend.hasLayer("SymbolLayer"));
}
TEST(Map, LatLngBehavior) {