fix: guard STEP-113 empty annotation and expose PBF blockers
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
tei
2026-10-11 11:50:03 +09:00
parent e2d202b560
commit c48a72a9d4
14 changed files with 726 additions and 12 deletions

View File

@@ -4,8 +4,10 @@
#include <mln/test/map_adapter.hpp>
#include <mln/annotation/annotation.hpp>
#include <mln/annotation/annotation_manager.hpp>
#include <mln/style/style.hpp>
#include <mln/style/image.hpp>
#include <mln/style/layers/symbol_layer.hpp>
#include <mln/map/map_options.hpp>
#include <mln/util/io.hpp>
#include <mln/util/run_loop.hpp>
@@ -66,6 +68,53 @@ TEST(Annotations, SymbolAnnotation) {
// }
}
TEST(Annotations, Step116EmptyPointLayerRestoredBeforeRealAdd) {
AnnotationTest test;
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
test.frontend.render(test.map);
auto& style = test.map.getStyle();
ASSERT_NE(style.getSource(AnnotationManager::SourceID), nullptr);
ASSERT_TRUE(style.removeLayer(AnnotationManager::PointLayerID));
test.map.addAnnotationImage(namedMarker("default_marker"));
test.map.addAnnotation(SymbolAnnotation{Point<double>(0, 0), "default_marker"});
// Check before rendering: a polling/render callback is too late to repair
// the immutable UpdateParameters captured by Map::onUpdate.
ASSERT_NE(style.getLayer(AnnotationManager::PointLayerID), nullptr);
test.checkRendering("point_annotation");
}
TEST(Annotations, Step116NoOpUpdateRepairsPointLayerAndSchedulesRender) {
AnnotationTest test;
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotationImage(namedMarker("default_marker"));
const SymbolAnnotation annotation{Point<double>(0, 0), "default_marker"};
const auto id = test.map.addAnnotation(annotation);
test.checkRendering("point_annotation");
ASSERT_TRUE(test.map.getStyle().removeLayer(AnnotationManager::PointLayerID));
test.map.updateAnnotation(id, annotation);
ASSERT_NE(test.map.getStyle().getLayer(AnnotationManager::PointLayerID), nullptr);
test.checkRendering("point_annotation");
}
TEST(Annotations, Step116ReloadRestoresHelperWithoutReplacingExistingLayer) {
AnnotationTest test;
const auto json = util::read_file("test/fixtures/api/empty.json");
test.map.getStyle().loadJSON(json);
test.frontend.render(test.map);
auto& style = test.map.getStyle();
ASSERT_TRUE(style.removeLayer(AnnotationManager::PointLayerID));
auto supplied = std::make_unique<mln::style::SymbolLayer>(AnnotationManager::PointLayerID,
AnnotationManager::SourceID);
auto* identity = supplied.get();
style.addLayer(std::move(supplied));
test.map.addAnnotationImage(namedMarker("default_marker"));
test.map.addAnnotation(SymbolAnnotation{Point<double>(0, 0), "default_marker"});
EXPECT_EQ(style.getLayer(AnnotationManager::PointLayerID), identity);
style.loadJSON(json);
test.checkRendering("point_annotation");
EXPECT_NE(style.getLayer(AnnotationManager::PointLayerID), nullptr);
}
TEST(Annotations, SymbolAnnotationTileBoundary) {
// Almost exactly the same as SymbolAnnotation test above, but offset my
// fractions of a degree tests precision issue from