|
6 | 6 | #include <mbgl/map/map.hpp>
|
7 | 7 | #include <mbgl/platform/default/headless_view.hpp>
|
8 | 8 | #include <mbgl/platform/default/headless_display.hpp>
|
| 9 | +#include <mbgl/sprite/sprite_image.hpp> |
9 | 10 | #include <mbgl/storage/network_status.hpp>
|
10 | 11 | #include <mbgl/storage/default_file_source.hpp>
|
| 12 | +#include <mbgl/util/image.hpp> |
11 | 13 | #include <mbgl/util/io.hpp>
|
12 | 14 | #include <mbgl/util/run_loop.hpp>
|
13 | 15 | #include <mbgl/style/layers/background_layer.hpp>
|
@@ -262,3 +264,35 @@ TEST(Map, Classes) {
|
262 | 264 | EXPECT_TRUE(map.getClasses().empty());
|
263 | 265 | EXPECT_FALSE(map.getTransitionOptions().duration);
|
264 | 266 | }
|
| 267 | + |
| 268 | +TEST(Map, AddIcon) { |
| 269 | + MapTest test; |
| 270 | + |
| 271 | + Map map(test.view, test.fileSource, MapMode::Still); |
| 272 | + auto image = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); |
| 273 | + auto icon = std::make_shared<SpriteImage>(std::move(image), 1.0); |
| 274 | + |
| 275 | + // No-op. |
| 276 | + map.addIcon("test-icon", icon); |
| 277 | + |
| 278 | + map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); |
| 279 | + map.addIcon("test-icon", icon); |
| 280 | + test::checkImage("test/fixtures/map/add_icon", test::render(map)); |
| 281 | +} |
| 282 | + |
| 283 | +TEST(Map, RemoveIcon) { |
| 284 | + MapTest test; |
| 285 | + |
| 286 | + Map map(test.view, test.fileSource, MapMode::Still); |
| 287 | + auto image = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); |
| 288 | + auto icon = std::make_shared<SpriteImage>(std::move(image), 1.0); |
| 289 | + |
| 290 | + // No-op. |
| 291 | + map.addIcon("test-icon", icon); |
| 292 | + |
| 293 | + map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); |
| 294 | + map.addIcon("test-icon", icon); |
| 295 | + map.removeIcon("test-icon"); |
| 296 | + test::checkImage("test/fixtures/map/remove_icon", test::render(map)); |
| 297 | +} |
| 298 | + |
0 commit comments