summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
Diffstat (limited to 'test/api')
-rw-r--r--test/api/annotations.cpp62
-rw-r--r--test/api/api_misuse.cpp2
-rw-r--r--test/api/custom_layer.cpp2
-rw-r--r--test/api/render_missing.cpp2
-rw-r--r--test/api/repeated_render.cpp8
-rw-r--r--test/api/set_style.cpp2
6 files changed, 51 insertions, 27 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);
}
diff --git a/test/api/api_misuse.cpp b/test/api/api_misuse.cpp
index 2400550a68..e9fe307718 100644
--- a/test/api/api_misuse.cpp
+++ b/test/api/api_misuse.cpp
@@ -13,7 +13,7 @@
using namespace mbgl;
TEST(API, RenderWithoutCallback) {
- FixtureLogObserver* log = new FixtureLogObserver();
+ auto log = new FixtureLogObserver();
Log::setObserver(std::unique_ptr<Log::Observer>(log));
util::RunLoop loop;
diff --git a/test/api/custom_layer.cpp b/test/api/custom_layer.cpp
index e0be341c4b..90c94aaea4 100644
--- a/test/api/custom_layer.cpp
+++ b/test/api/custom_layer.cpp
@@ -56,7 +56,7 @@ public:
MBGL_CHECK_ERROR(glUseProgram(program));
MBGL_CHECK_ERROR(glBindBuffer(GL_ARRAY_BUFFER, buffer));
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
- MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_FLOAT, GL_FALSE, 0, NULL));
+ MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_FLOAT, GL_FALSE, 0, nullptr));
MBGL_CHECK_ERROR(glDisable(GL_STENCIL_TEST));
MBGL_CHECK_ERROR(glDisable(GL_DEPTH_TEST));
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
diff --git a/test/api/render_missing.cpp b/test/api/render_missing.cpp
index e0fb8e4c55..135c1ecae5 100644
--- a/test/api/render_missing.cpp
+++ b/test/api/render_missing.cpp
@@ -56,7 +56,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
auto observer = Log::removeObserver();
auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
- EXPECT_EQ(1, flo->count(FixtureLog::Message(
+ EXPECT_EQ(1u, flo->count(FixtureLog::Message(
EventSeverity::Error, Event::Style, -1,
std::string("Failed to load tile 0/0/0=>0 for source mapbox: " + message))));
auto unchecked = flo->unchecked();
diff --git a/test/api/repeated_render.cpp b/test/api/repeated_render.cpp
index 3a71ddb08d..cf71cb8416 100644
--- a/test/api/repeated_render.cpp
+++ b/test/api/repeated_render.cpp
@@ -42,8 +42,8 @@ TEST(API, RepeatedRender) {
loop.runOnce();
}
- ASSERT_EQ(256, result.width);
- ASSERT_EQ(512, result.height);
+ ASSERT_EQ(256u, result.width);
+ ASSERT_EQ(512u, result.height);
#if !TEST_READ_ONLY
util::write_file("test/fixtures/api/1.png", encodePNG(result));
#endif
@@ -60,8 +60,8 @@ TEST(API, RepeatedRender) {
loop.runOnce();
}
- ASSERT_EQ(256, result.width);
- ASSERT_EQ(512, result.height);
+ ASSERT_EQ(256u, result.width);
+ ASSERT_EQ(512u, result.height);
#if !TEST_READ_ONLY
util::write_file("test/fixtures/api/2.png", encodePNG(result));
#endif
diff --git a/test/api/set_style.cpp b/test/api/set_style.cpp
index fb5027c076..2399e4ea50 100644
--- a/test/api/set_style.cpp
+++ b/test/api/set_style.cpp
@@ -26,7 +26,7 @@ TEST(API, SetStyle) {
auto observer = Log::removeObserver();
auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
- EXPECT_EQ(1ul, flo->count({ EventSeverity::Error, Event::ParseStyle, -1,
+ EXPECT_EQ(1u, flo->count({ EventSeverity::Error, Event::ParseStyle, -1,
"Error parsing style JSON at 0: Invalid value." }));
auto unchecked = flo->unchecked();
EXPECT_TRUE(unchecked.empty()) << unchecked;