diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-11-26 22:34:00 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-12-01 11:49:02 +0200 |
commit | 7caaebb16236ae014f534b490b05f5b5d6a90213 (patch) | |
tree | 5464b2d6895f8f17ded5889fab14b5308c63042d /test/api | |
parent | ab6477d9065f76c1b560ce2ad4a3da6214e041f6 (diff) | |
download | qtlocation-mapboxgl-7caaebb16236ae014f534b490b05f5b5d6a90213.tar.gz |
[tests] Fix/improve Asset utests
ASSET=zip make test-* was broken and now works.
Also added a test stressing concurrent file access.
Diffstat (limited to 'test/api')
-rw-r--r-- | test/api/annotations.cpp | 32 | ||||
-rw-r--r-- | test/api/repeated_render.cpp | 4 |
2 files changed, 26 insertions, 10 deletions
diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp index 4c06b39e43..7514fc2dcc 100644 --- a/test/api/annotations.cpp +++ b/test/api/annotations.cpp @@ -14,6 +14,18 @@ using namespace mbgl; +namespace { + +std::string getFileSourceRoot() { +#ifdef MBGL_ASSET_ZIP + return "test/fixtures/annotations/assets.zip"; +#else + return ""; +#endif +} + +} + 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())); @@ -36,7 +48,7 @@ void checkRendering(Map& map, const char * name) { TEST(Annotations, PointAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -49,7 +61,7 @@ TEST(Annotations, PointAnnotation) { TEST(Annotations, LineAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -68,7 +80,7 @@ TEST(Annotations, LineAnnotation) { TEST(Annotations, FillAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -86,7 +98,7 @@ TEST(Annotations, FillAnnotation) { TEST(Annotations, StyleSourcedShapeAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/annotation.json"), ""); @@ -101,7 +113,7 @@ TEST(Annotations, StyleSourcedShapeAnnotation) { TEST(Annotations, AddMultiple) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -118,7 +130,7 @@ TEST(Annotations, AddMultiple) { TEST(Annotations, NonImmediateAdd) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -138,7 +150,7 @@ TEST(Annotations, NonImmediateAdd) { TEST(Annotations, RemovePoint) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -155,7 +167,7 @@ TEST(Annotations, RemovePoint) { TEST(Annotations, RemoveShape) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); AnnotationSegments segments = {{ {{ { 0, 0 }, { 45, 45 } }} }}; @@ -177,7 +189,7 @@ TEST(Annotations, RemoveShape) { TEST(Annotations, ImmediateRemoveShape) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.removeAnnotation(map.addShapeAnnotation(ShapeAnnotation({}, {}))); @@ -189,7 +201,7 @@ TEST(Annotations, ImmediateRemoveShape) { TEST(Annotations, SwitchStyle) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - DefaultFileSource fileSource(nullptr); + DefaultFileSource fileSource(nullptr, getFileSourceRoot()); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); diff --git a/test/api/repeated_render.cpp b/test/api/repeated_render.cpp index 77e4569dbf..d92dcf2909 100644 --- a/test/api/repeated_render.cpp +++ b/test/api/repeated_render.cpp @@ -17,7 +17,11 @@ TEST(API, RepeatedRender) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1, 256, 512); +#ifdef MBGL_ASSET_ZIP + DefaultFileSource fileSource(nullptr, "test/fixtures/api/assets.zip"); +#else DefaultFileSource fileSource(nullptr); +#endif Log::setObserver(std::make_unique<FixtureLogObserver>()); |