summaryrefslogtreecommitdiff
path: root/test/api/annotations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/api/annotations.cpp')
-rw-r--r--test/api/annotations.cpp62
1 files changed, 43 insertions, 19 deletions
diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp
index 552a386f96..e3f189c166 100644
--- a/test/api/annotations.cpp
+++ b/test/api/annotations.cpp
@@ -8,6 +8,7 @@
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
+#include <mbgl/util/color.hpp>
using namespace mbgl;
@@ -41,6 +42,10 @@ TEST(Annotations, SymbolAnnotation) {
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" });
test.checkRendering("point_annotation");
+
+ // FIXME: https://github.com/mapbox/mapbox-gl-native/issues/5419
+ //test.map.setZoom(test.map.getMaxZoom());
+ //test.checkRendering("point_annotation");
}
TEST(Annotations, LineAnnotation) {
@@ -48,12 +53,15 @@ TEST(Annotations, LineAnnotation) {
LineString<double> line = {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }};
LineAnnotation annotation { line };
- annotation.color = {{ 255, 0, 0, 1 }};
- annotation.width = 5;
+ annotation.color = { { 255, 0, 0, 1 } };
+ annotation.width = { 5 };
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotation(annotation);
test.checkRendering("line_annotation");
+
+ test.map.setZoom(test.map.getMaxZoom());
+ test.checkRendering("line_annotation_max_zoom");
}
TEST(Annotations, FillAnnotation) {
@@ -61,11 +69,29 @@ TEST(Annotations, FillAnnotation) {
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
FillAnnotation annotation { polygon };
- annotation.color = {{ 255, 0, 0, 1 }};
+ annotation.color = { { 255, 0, 0, 1 } };
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotation(annotation);
test.checkRendering("fill_annotation");
+
+ test.map.setZoom(test.map.getMaxZoom());
+ test.checkRendering("fill_annotation_max_zoom");
+}
+
+TEST(Annotations, OverlappingFillAnnotation) {
+ AnnotationTest test;
+
+ Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
+ FillAnnotation underlaidAnnotation { polygon };
+ underlaidAnnotation.color = { { 0, 255, 0, 1 } };
+ FillAnnotation overlaidAnnotation { polygon };
+ overlaidAnnotation.color = { { 255, 0, 0, 1 } };
+
+ test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ test.map.addAnnotation(underlaidAnnotation);
+ test.map.addAnnotation(overlaidAnnotation);
+ test.checkRendering("overlapping_fill_annotation");
}
TEST(Annotations, OverlappingFillAnnotation) {
@@ -114,29 +140,27 @@ TEST(Annotations, NonImmediateAdd) {
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
FillAnnotation annotation { polygon };
- annotation.color = {{ 255, 0, 0, 1 }};
+ annotation.color = { { 255, 0, 0, 1 } };
test.map.addAnnotation(annotation);
test.checkRendering("non_immediate_add");
}
-TEST(Annotations, UpdateIcon) {
+TEST(Annotations, UpdateSymbolAnnotationGeometry) {
AnnotationTest test;
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
- test.map.addAnnotationIcon("flipped_marker", namedMarker("default_marker.png"));
- test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "flipped_marker" });
+ test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
+ test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png"));
+ AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
test::render(test.map);
- test.map.removeAnnotationIcon("flipped_marker");
- test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png"));
- test.map.update(Update::Annotations);
-
- test.checkRendering("update_icon");
+ test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" });
+ test.checkRendering("update_point");
}
-TEST(Annotations, UpdatePoint) {
+TEST(Annotations, UpdateSymbolAnnotationIcon) {
AnnotationTest test;
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
@@ -146,8 +170,8 @@ TEST(Annotations, UpdatePoint) {
test::render(test.map);
- test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { -10, 0 }, "flipped_marker" });
- test.checkRendering("update_point");
+ test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { 0, 0 }, "flipped_marker" });
+ test.checkRendering("update_icon");
}
TEST(Annotations, RemovePoint) {
@@ -168,8 +192,8 @@ TEST(Annotations, RemoveShape) {
LineString<double> line = {{ { 0, 0 }, { 45, 45 } }};
LineAnnotation annotation { line };
- annotation.color = {{ 255, 0, 0, 1 }};
- annotation.width = 5;
+ annotation.color = { { 255, 0, 0, 1 } };
+ annotation.width = { 5 };
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
AnnotationID shape = test.map.addAnnotation(annotation);
@@ -210,7 +234,7 @@ TEST(Annotations, QueryRenderedFeatures) {
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
test::render(test.map);
-
+
auto features = test.map.queryRenderedFeatures(test.map.pixelForLatLng({ 0, 0 }));
- EXPECT_EQ(features.size(), 1);
+ EXPECT_EQ(features.size(), 1u);
}