|
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>
|
@@ -343,3 +345,34 @@ TEST(Map, Classes) {
|
343 | 345 | EXPECT_TRUE(map.getClasses().empty());
|
344 | 346 | EXPECT_FALSE(map.getTransitionOptions().duration);
|
345 | 347 | }
|
| 348 | + |
| 349 | +TEST(Map, AddImage) { |
| 350 | + MapTest test; |
| 351 | + |
| 352 | + Map map(test.view, test.fileSource, MapMode::Still); |
| 353 | + auto decoded1 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); |
| 354 | + auto decoded2 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); |
| 355 | + auto image1 = std::make_unique<SpriteImage>(std::move(decoded1), 1.0); |
| 356 | + auto image2 = std::make_unique<SpriteImage>(std::move(decoded2), 1.0); |
| 357 | + |
| 358 | + // No-op. |
| 359 | + map.addImage("test-icon", std::move(image1)); |
| 360 | + |
| 361 | + map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); |
| 362 | + map.addImage("test-icon", std::move(image2)); |
| 363 | + test::checkImage("test/fixtures/map/add_icon", test::render(map)); |
| 364 | +} |
| 365 | + |
| 366 | +TEST(Map, RemoveImage) { |
| 367 | + MapTest test; |
| 368 | + |
| 369 | + Map map(test.view, test.fileSource, MapMode::Still); |
| 370 | + auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); |
| 371 | + auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0); |
| 372 | + |
| 373 | + map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); |
| 374 | + map.addImage("test-icon", std::move(image)); |
| 375 | + map.removeImage("test-icon"); |
| 376 | + test::checkImage("test/fixtures/map/remove_icon", test::render(map)); |
| 377 | +} |
| 378 | + |
0 commit comments