From 1045934d5e62eaf85bc280ce2d75e7558f5a5104 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Tue, 6 Dec 2016 02:16:13 +0100 Subject: [core, ios, macos] Add image accessor to MGLStyle (#7096) * [core] Add interface to get image from sprite atlas * [tests] Add tests for Map::getImage * [ios, macos] WIP: get MGLImage for name from style * [ios, macos] Fixed -imageForName: Convert from sprite images to platform images using the existing encodePNG() function, which is also used for printing. Allow -imageForName: to return nil without an assertion failure. Added a basic test. --- test/map/map.test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/map/map.test.cpp') diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 97a09e94a0..ac82bbacae 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -394,3 +394,15 @@ TEST(Map, RemoveImage) { map.removeImage("test-icon"); test::checkImage("test/fixtures/map/remove_icon", test::render(map, test.view)); } + +TEST(Map, GetImage) { + MapTest test; + + Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still); + auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); + auto image = std::make_unique(std::move(decoded), 1.0); + + map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); + map.addImage("test-icon", std::move(image)); + test::checkImage("test/fixtures/map/get_icon", map.getImage("test-icon")->image); +} -- cgit v1.2.1 From 9456bec1721f5cd69e7813c68b829db4c7ff9660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Mon, 5 Dec 2016 18:48:00 -0800 Subject: [test] Fixed Map-GetImage Followup to #7096. --- test/map/map.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/map/map.test.cpp') diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index ac82bbacae..5311aeb17f 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -398,7 +398,7 @@ TEST(Map, RemoveImage) { TEST(Map, GetImage) { MapTest test; - Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto image = std::make_unique(std::move(decoded), 1.0); -- cgit v1.2.1