Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add unit tests for addPointAnnotations()
Browse files Browse the repository at this point in the history
This test would have caught #1874
  • Loading branch information
tmpsantos committed Jul 10, 2015
1 parent 0d44402 commit 30416c5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/api/annotations.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "../fixtures/fixture_log_observer.hpp"
#include "../fixtures/mock_file_source.hpp"
#include "../fixtures/util.hpp"

#include <mbgl/annotation/point_annotation.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/still_image.hpp>
#include <mbgl/platform/default/headless_display.hpp>
#include <mbgl/platform/default/headless_view.hpp>

#include <future>
#include <vector>

TEST(API, PointAnnotation) {
using namespace mbgl;

auto display = std::make_shared<mbgl::HeadlessDisplay>();
HeadlessView view(display, 1);

MockFileSource fileSource(MockFileSource::Success, "");

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);

std::promise<bool> promise;
map.renderStill([&promise](std::exception_ptr, std::unique_ptr<const StillImage>) {
promise.set_value(true);
});

promise.get_future().get();
}
1 change: 1 addition & 0 deletions test/test.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'annotations/sprite_store.cpp',
'annotations/sprite_parser.cpp',

'api/annotations.cpp',
'api/api_misuse.cpp',
'api/repeated_render.cpp',
'api/set_style.cpp',
Expand Down

0 comments on commit 30416c5

Please sign in to comment.