diff options
Diffstat (limited to 'test/api')
-rw-r--r-- | test/api/annotations.test.cpp | 12 | ||||
-rw-r--r-- | test/api/api_misuse.test.cpp | 11 | ||||
-rw-r--r-- | test/api/custom_geometry_source.test.cpp | 11 | ||||
-rw-r--r-- | test/api/custom_layer.test.cpp | 10 | ||||
-rw-r--r-- | test/api/query.test.cpp | 17 | ||||
-rw-r--r-- | test/api/recycle_map.cpp | 11 |
6 files changed, 44 insertions, 28 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index a67e691f69..a4ba981a13 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -6,6 +6,7 @@ #include <mbgl/style/image.hpp> #include <mbgl/map/map.hpp> #include <mbgl/map/map_options.hpp> +#include <mbgl/platform/factory.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/util/color.hpp> @@ -27,12 +28,15 @@ std::unique_ptr<style::Image> namedMarker(const std::string& name) { class AnnotationTest { public: util::RunLoop loop; - StubFileSource fileSource; + FileSourceOptions stubFileSourceOptions; + std::shared_ptr<FileSource> fileSource = platform::Factory::sharedFileSource( + stubFileSourceOptions, std::make_shared<StubFileSource>()); float pixelRatio { 1 }; - HeadlessFrontend frontend { pixelRatio, fileSource }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - MapOptions().withMapMode(MapMode::Static)}; + HeadlessFrontend frontend { pixelRatio, stubFileSourceOptions }; + + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + MapOptions().withMapMode(MapMode::Static), stubFileSourceOptions }; void checkRendering(const char * name) { test::checkImage(std::string("test/fixtures/annotations/") + name, diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp index 9490c14e1f..ab98aa0e81 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -4,6 +4,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/map/map_options.hpp> +#include <mbgl/platform/factory.hpp> #include <mbgl/renderer/backend_scope.hpp> #include <mbgl/gl/headless_frontend.hpp> #include <mbgl/storage/online_file_source.hpp> @@ -21,13 +22,15 @@ TEST(API, RenderWithoutCallback) { util::RunLoop loop; - StubFileSource fileSource; + FileSourceOptions stubFileSourceOptions; + auto fileSource = platform::Factory::sharedFileSource(stubFileSourceOptions, std::make_shared<StubFileSource>()); + float pixelRatio { 1 }; - HeadlessFrontend frontend { pixelRatio, fileSource }; + + HeadlessFrontend frontend { pixelRatio, stubFileSourceOptions }; auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(), - pixelRatio, fileSource, - MapOptions().withMapMode(MapMode::Static)); + pixelRatio, MapOptions().withMapMode(MapMode::Static), stubFileSourceOptions); map->renderStill(nullptr); // Force Map thread to join. diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp index 54df2e5cfb..549036e3b0 100644 --- a/test/api/custom_geometry_source.test.cpp +++ b/test/api/custom_geometry_source.test.cpp @@ -2,6 +2,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/map/map_options.hpp> +#include <mbgl/platform/factory.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/gl/headless_frontend.hpp> #include <mbgl/style/style.hpp> @@ -15,15 +16,17 @@ using namespace mbgl; using namespace mbgl::style; +using namespace mbgl::platform; TEST(CustomGeometrySource, Grid) { util::RunLoop loop; - DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); + auto fileSourceOptions = FileSourceOptions().withCachePath(":memory:").withAssetRoot("test/fixtures/api/assets"); + float pixelRatio { 1 }; - HeadlessFrontend frontend { pixelRatio, fileSource }; - Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - MapOptions().withMapMode(MapMode::Static)); + HeadlessFrontend frontend { pixelRatio, fileSourceOptions }; + Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + MapOptions().withMapMode(MapMode::Static), fileSourceOptions); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 7ea5f57cd8..e55398f0d9 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -1,6 +1,7 @@ #include <mbgl/test/util.hpp> #include <mbgl/platform/gl_functions.hpp> +#include <mbgl/platform/factory.hpp> #include <mbgl/map/map.hpp> #include <mbgl/map/map_options.hpp> #include <mbgl/storage/default_file_source.hpp> @@ -89,11 +90,12 @@ public: TEST(CustomLayer, Basic) { util::RunLoop loop; - DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); + auto fileSourceOptions = FileSourceOptions().withCachePath(":memory:").withAssetRoot("test/fixtures/api/assets"); + float pixelRatio { 1 }; - HeadlessFrontend frontend { pixelRatio, fileSource }; - Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - MapOptions().withMapMode(MapMode::Static)); + HeadlessFrontend frontend { pixelRatio, fileSourceOptions }; + Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + MapOptions().withMapMode(MapMode::Static), fileSourceOptions); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); map.getStyle().addLayer(std::make_unique<CustomLayer>( diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index b7359e4e60..99b74ab393 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -1,6 +1,7 @@ #include <mbgl/map/map.hpp> -#include <mbgl/map/map_options.hpp> #include <mbgl/test/stub_file_source.hpp> +#include <mbgl/map/map_options.hpp> +#include <mbgl/platform/factory.hpp> #include <mbgl/test/util.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> @@ -32,15 +33,17 @@ public: } util::RunLoop loop; - StubFileSource fileSource; + FileSourceOptions stubFileSourceOptions; + std::shared_ptr<FileSource> fileSource = platform::Factory::sharedFileSource(stubFileSourceOptions, std::make_shared<StubFileSource>()); float pixelRatio { 1 }; - HeadlessFrontend frontend { pixelRatio, fileSource }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - MapOptions().withMapMode(MapMode::Static)}; + HeadlessFrontend frontend { pixelRatio, stubFileSourceOptions }; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + MapOptions().withMapMode(MapMode::Static), stubFileSourceOptions }; }; std::vector<Feature> getTopClusterFeature(QueryTest& test) { - test.fileSource.sourceResponse = [&] (const Resource& resource) { + auto stubFileSource = std::static_pointer_cast<StubFileSource>(test.fileSource); + stubFileSource->sourceResponse = [&] (const Resource& resource) { EXPECT_EQ("http://url"s, resource.url); Response response; response.data = std::make_unique<std::string>(util::read_file("test/fixtures/supercluster/places.json"s)); @@ -52,7 +55,7 @@ std::vector<Feature> getTopClusterFeature(QueryTest& test) { options.cluster = true; auto source = std::make_unique<GeoJSONSource>("cluster_source"s, options); source->setURL("http://url"s); - source->loadDescription(test.fileSource); + source->loadDescription(stubFileSource); auto clusterLayer = std::make_unique<SymbolLayer>("cluster_layer"s, "cluster_source"s); clusterLayer->setIconImage("test-icon"s); diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp index 5598dfbd85..fe6161d6fa 100644 --- a/test/api/recycle_map.cpp +++ b/test/api/recycle_map.cpp @@ -4,6 +4,7 @@ #include <mbgl/gl/headless_frontend.hpp> #include <mbgl/map/map.hpp> #include <mbgl/map/map_options.hpp> +#include <mbgl/platform/factory.hpp> #include <mbgl/renderer/backend_scope.hpp> #include <mbgl/storage/online_file_source.hpp> #include <mbgl/style/layers/symbol_layer.hpp> @@ -23,13 +24,13 @@ using namespace mbgl::style; TEST(API, RecycleMapUpdateImages) { util::RunLoop loop; - StubFileSource fileSource; + auto fileSource = platform::Factory::sharedFileSource({}, std::make_shared<StubFileSource>()); float pixelRatio { 1 }; - HeadlessFrontend frontend { pixelRatio, fileSource }; - auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(), - pixelRatio, fileSource, - MapOptions().withMapMode(MapMode::Static)); + FileSourceOptions stubFileSourceOptions; + HeadlessFrontend frontend { pixelRatio, stubFileSourceOptions }; + auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + MapOptions().withMapMode(MapMode::Static), stubFileSourceOptions ); EXPECT_TRUE(map); |