summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-09-22 16:58:38 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-09-28 14:10:00 -0700
commit028abaab00f2ff3a19c67366c3a9f8c803e27423 (patch)
treeedd263033a8b24326ab8e284377e319aa174bf8a /test/api
parentaec145ded3b9c0b4f928fb7cb1d92faac4e0e89a (diff)
downloadqtlocation-mapboxgl-028abaab00f2ff3a19c67366c3a9f8c803e27423.tar.gz
Ensure that LiveTileData can be reparsed
Annotation tiles may become partially parsed just like regular tiles, for example if a point annotation is added to the map before the style's sprite has been loaded. In such cases, they need to be reparsed or the annotation will not be rendered. Previously, the code path for reparsing would be short-circuited by a dynamic_cast<VectorTileData*> followed by a null check. This commit removes that case and adds (back) a virtual reparse method to the TileData interface.
Diffstat (limited to 'test/api')
-rw-r--r--test/api/annotations.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp
index 33374d4386..39862b1069 100644
--- a/test/api/annotations.cpp
+++ b/test/api/annotations.cpp
@@ -1,5 +1,3 @@
-#include "../fixtures/fixture_log_observer.hpp"
-#include "../fixtures/mock_file_source.hpp"
#include "../fixtures/util.hpp"
#include <mbgl/annotation/point_annotation.hpp>
@@ -7,30 +5,30 @@
#include <mbgl/map/still_image.hpp>
#include <mbgl/platform/default/headless_display.hpp>
#include <mbgl/platform/default/headless_view.hpp>
+#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/util/image.hpp>
+#include <mbgl/util/io.hpp>
#include <future>
#include <vector>
-TEST(API, PointAnnotation) {
+TEST(Annotations, PointAnnotation) {
using namespace mbgl;
auto display = std::make_shared<mbgl::HeadlessDisplay>();
HeadlessView view(display, 1);
-
- MockFileSource fileSource(MockFileSource::Success, "");
+ DefaultFileSource fileSource(nullptr);
Map map(view, fileSource, MapMode::Still);
- map.setStyleURL("test/fixtures/resources/style.json");
-
- std::vector<PointAnnotation> points;
- points.emplace_back(PointAnnotation({ 50.0, 50.0 }, "default_marker"));
-
- map.addPointAnnotations(points);
+ map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
+ map.addPointAnnotation(PointAnnotation({ 0, 0 }, "default_marker"));
- std::promise<bool> promise;
- map.renderStill([&promise](std::exception_ptr, std::unique_ptr<const StillImage>) {
- promise.set_value(true);
+ std::promise<std::unique_ptr<const StillImage>> promise;
+ map.renderStill([&promise](std::exception_ptr, std::unique_ptr<const StillImage> image) {
+ promise.set_value(std::move(image));
});
- promise.get_future().get();
+ auto result = promise.get_future().get();
+ const std::string png = util::compress_png(result->width, result->height, result->pixels.get());
+ util::write_file("test/output/point_annotation.png", png);
}