[tests] Add tests for Map::[add|remove]Image
This commit is contained in:
@@ -6,8 +6,10 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/platform/default/headless_view.hpp>
|
||||
#include <mbgl/platform/default/headless_display.hpp>
|
||||
#include <mbgl/sprite/sprite_image.hpp>
|
||||
#include <mbgl/storage/network_status.hpp>
|
||||
#include <mbgl/storage/default_file_source.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/style/layers/background_layer.hpp>
|
||||
@@ -343,3 +345,34 @@ TEST(Map, Classes) {
|
||||
EXPECT_TRUE(map.getClasses().empty());
|
||||
EXPECT_FALSE(map.getTransitionOptions().duration);
|
||||
}
|
||||
|
||||
TEST(Map, AddImage) {
|
||||
MapTest test;
|
||||
|
||||
Map map(test.view, test.fileSource, MapMode::Still);
|
||||
auto decoded1 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
|
||||
auto decoded2 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
|
||||
auto image1 = std::make_unique<SpriteImage>(std::move(decoded1), 1.0);
|
||||
auto image2 = std::make_unique<SpriteImage>(std::move(decoded2), 1.0);
|
||||
|
||||
// No-op.
|
||||
map.addImage("test-icon", std::move(image1));
|
||||
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json"));
|
||||
map.addImage("test-icon", std::move(image2));
|
||||
test::checkImage("test/fixtures/map/add_icon", test::render(map));
|
||||
}
|
||||
|
||||
TEST(Map, RemoveImage) {
|
||||
MapTest test;
|
||||
|
||||
Map map(test.view, test.fileSource, MapMode::Still);
|
||||
auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
|
||||
auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0);
|
||||
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json"));
|
||||
map.addImage("test-icon", std::move(image));
|
||||
map.removeImage("test-icon");
|
||||
test::checkImage("test/fixtures/map/remove_icon", test::render(map));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user