[tests] Don't use icons from the style for annotations
@@ -20,6 +20,7 @@ public:
|
||||
std::array<uint16_t, 2> getFramebufferSize() const override;
|
||||
|
||||
void initialize(mbgl::Map *map) override;
|
||||
void notifyMapChange(mbgl::MapChange) override;
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
void notify() override;
|
||||
@@ -61,6 +62,7 @@ private:
|
||||
std::vector<std::string> spriteIDs;
|
||||
|
||||
private:
|
||||
bool initializedDefaultMarker = false;
|
||||
bool fullscreen = false;
|
||||
const bool benchmark = false;
|
||||
bool tracking = false;
|
||||
|
||||
@@ -117,6 +117,13 @@ void GLFWView::initialize(mbgl::Map *map_) {
|
||||
View::initialize(map_);
|
||||
}
|
||||
|
||||
void GLFWView::notifyMapChange(mbgl::MapChange change) {
|
||||
if (change == mbgl::MapChange::MapChangeDidFinishLoadingMap && !initializedDefaultMarker) {
|
||||
initializedDefaultMarker = true;
|
||||
map->setSprite("default_marker", makeSpriteImage(22, 22, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
|
||||
@@ -234,7 +241,7 @@ void GLFWView::addRandomPointAnnotations(int count) {
|
||||
std::vector<mbgl::PointAnnotation> points;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
points.emplace_back(makeRandomPoint(), "marker-15");
|
||||
points.emplace_back(makeRandomPoint(), "default_marker");
|
||||
}
|
||||
|
||||
auto newIDs = map->addPointAnnotations(points);
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
std::shared_ptr<SpriteImage> defaultMarker() {
|
||||
PremultipliedImage image = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
|
||||
return std::make_shared<SpriteImage>(image.width, image.height, 1.0, std::string(reinterpret_cast<char*>(image.data.get()), image.size()));
|
||||
}
|
||||
|
||||
PremultipliedImage render(Map& map) {
|
||||
std::promise<PremultipliedImage> promise;
|
||||
map.renderStill([&](std::exception_ptr, PremultipliedImage&& image) {
|
||||
@@ -35,7 +40,8 @@ TEST(Annotations, PointAnnotation) {
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.addPointAnnotation(PointAnnotation({ 0, -20 }, "default_marker"));
|
||||
map.setSprite("default_marker", defaultMarker());
|
||||
map.addPointAnnotation(PointAnnotation({ 0, 0 }, "default_marker"));
|
||||
|
||||
checkRendering(map, "point_annotation");
|
||||
}
|
||||
@@ -99,11 +105,12 @@ TEST(Annotations, AddMultiple) {
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.addPointAnnotation(PointAnnotation({ 0, -20 }, "default_marker"));
|
||||
map.setSprite("default_marker", defaultMarker());
|
||||
map.addPointAnnotation(PointAnnotation({ 0, -10 }, "default_marker"));
|
||||
|
||||
render(map);
|
||||
|
||||
map.addPointAnnotation(PointAnnotation({ 0, 20 }, "default_marker"));
|
||||
map.addPointAnnotation(PointAnnotation({ 0, 10 }, "default_marker"));
|
||||
|
||||
checkRendering(map, "add_multiple");
|
||||
}
|
||||
@@ -135,6 +142,7 @@ TEST(Annotations, RemovePoint) {
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.setSprite("default_marker", defaultMarker());
|
||||
uint32_t point = map.addPointAnnotation(PointAnnotation({ 0, 0 }, "default_marker"));
|
||||
|
||||
render(map);
|
||||
@@ -185,7 +193,8 @@ TEST(Annotations, SwitchStyle) {
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.addPointAnnotation(PointAnnotation({ 0, -20 }, "default_marker"));
|
||||
map.setSprite("default_marker", defaultMarker());
|
||||
map.addPointAnnotation(PointAnnotation({ 0, 0 }, "default_marker"));
|
||||
|
||||
render(map);
|
||||
|
||||
@@ -193,16 +202,3 @@ TEST(Annotations, SwitchStyle) {
|
||||
|
||||
checkRendering(map, "switch_style");
|
||||
}
|
||||
|
||||
TEST(Annotations, CustomIcon) {
|
||||
auto display = std::make_shared<mbgl::HeadlessDisplay>();
|
||||
HeadlessView view(display, 1);
|
||||
DefaultFileSource fileSource(nullptr);
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.setSprite("cafe", std::make_shared<SpriteImage>(12, 12, 1, std::string(12 * 12 * 4, '\xFF')));
|
||||
map.addPointAnnotation(PointAnnotation({ 0, 0 }, "cafe"));
|
||||
|
||||
checkRendering(map, "custom_icon");
|
||||
}
|
||||
|
||||
BIN
test/fixtures/annotations/add_multiple/expected.png
vendored
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
test/fixtures/annotations/switch_style/expected.png
vendored
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 2.5 KiB |
3
test/fixtures/api/empty.json
vendored
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {},
|
||||
"layers": [],
|
||||
"sprite": "asset://TEST_DATA/fixtures/resources/sprite"
|
||||
"layers": []
|
||||
}
|
||||
|
||||
BIN
test/fixtures/sprites/default_marker.png
vendored
Normal file
|
After Width: | Height: | Size: 1010 B |