summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-26 10:23:12 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-26 11:21:56 -0700
commite4e08aca7910d1a8d75791db61de39fa03673fde (patch)
tree1127c627ca0556e650ed3b48764f2f55a15e4d85 /test
parent2c8343aa8233333dae0caf91f25bf1fe4689c88e (diff)
downloadqtlocation-mapboxgl-e4e08aca7910d1a8d75791db61de39fa03673fde.tar.gz
[tests] Add test for calling addAnnotationImage with an existing ID
Diffstat (limited to 'test')
-rw-r--r--test/api/annotations.test.cpp20
-rw-r--r--test/fixtures/annotations/readd_image/expected.pngbin0 -> 1031 bytes
2 files changed, 18 insertions, 2 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index 9e85a74c5b..4c27c871ae 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -16,9 +16,12 @@ using namespace mbgl;
namespace {
+PremultipliedImage namedImage(const std::string& name) {
+ return decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png"));
+}
+
std::unique_ptr<style::Image> namedMarker(const std::string& name) {
- PremultipliedImage image = decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png"));
- return std::make_unique<style::Image>(name, std::move(image), 1.0);
+ return std::make_unique<style::Image>(name, namedImage(name), 1.0);
}
class AnnotationTest {
@@ -319,6 +322,19 @@ TEST(Annotations, SwitchStyle) {
test.checkRendering("switch_style");
}
+TEST(Annotations, ReaddImage) {
+ AnnotationTest test;
+
+ test.map.setStyleJSON(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.addAnnotationImage(std::make_unique<style::Image>("default_marker", namedImage("flipped_marker"), 1.0));
+ test.checkRendering("readd_image");
+}
+
TEST(Annotations, QueryRenderedFeatures) {
AnnotationTest test;
diff --git a/test/fixtures/annotations/readd_image/expected.png b/test/fixtures/annotations/readd_image/expected.png
new file mode 100644
index 0000000000..3c4847f3a7
--- /dev/null
+++ b/test/fixtures/annotations/readd_image/expected.png
Binary files differ