summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
Diffstat (limited to 'test/api')
-rw-r--r--test/api/annotations.test.cpp7
-rw-r--r--test/api/api_misuse.test.cpp10
-rw-r--r--test/api/custom_geometry_source.test.cpp8
-rw-r--r--test/api/custom_layer.test.cpp8
-rw-r--r--test/api/query.test.cpp13
-rw-r--r--test/api/recycle_map.cpp10
6 files changed, 26 insertions, 30 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index aad85f8d57..2a9737e10b 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -1,11 +1,11 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_file_source.hpp>
+#include <mbgl/test/map_adapter.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
-#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -28,13 +28,12 @@ std::unique_ptr<style::Image> namedMarker(const std::string& name) {
class AnnotationTest {
public:
util::RunLoop loop;
- StubFileSource fileSource;
ThreadPool threadPool { 4 };
float pixelRatio { 1 };
HeadlessFrontend frontend { pixelRatio, threadPool };
- Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static)};
+ MapAdapter map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, std::make_shared<StubFileSource>(),
+ threadPool, MapOptions().withMapMode(MapMode::Static)};
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 2ccfb0a7ff..6fc04ab26f 100644
--- a/test/api/api_misuse.test.cpp
+++ b/test/api/api_misuse.test.cpp
@@ -1,12 +1,11 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_file_source.hpp>
#include <mbgl/test/fixture_log_observer.hpp>
+#include <mbgl/test/map_adapter.hpp>
-#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/renderer/backend_scope.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -22,14 +21,13 @@ TEST(API, RenderWithoutCallback) {
util::RunLoop loop;
- StubFileSource fileSource;
ThreadPool threadPool(4);
float pixelRatio { 1 };
HeadlessFrontend frontend { pixelRatio, threadPool };
- auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(),
- pixelRatio, fileSource, threadPool,
- MapOptions().withMapMode(MapMode::Static));
+ auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(), frontend.getSize(),
+ pixelRatio, std::make_shared<StubFileSource>(), threadPool,
+ MapOptions().withMapMode(MapMode::Static));
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 6959a36f15..58af09c1ac 100644
--- a/test/api/custom_geometry_source.test.cpp
+++ b/test/api/custom_geometry_source.test.cpp
@@ -3,8 +3,8 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/shared_thread_pool.hpp>
-#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/headless_frontend.hpp>
+#include <mbgl/storage/resource_options.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
@@ -20,12 +20,12 @@ using namespace mbgl::style;
TEST(CustomGeometrySource, Grid) {
util::RunLoop loop;
- DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets");
auto threadPool = sharedThreadPool();
float pixelRatio { 1 };
HeadlessFrontend frontend { pixelRatio, *threadPool };
- Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- *threadPool, MapOptions().withMapMode(MapMode::Static));
+ Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, *threadPool,
+ MapOptions().withMapMode(MapMode::Static),
+ ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
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 18c6dc1692..e16d2852ec 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -4,9 +4,9 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/default_thread_pool.hpp>
-#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/defines.hpp>
#include <mbgl/gl/headless_frontend.hpp>
+#include <mbgl/storage/resource_options.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
@@ -90,12 +90,12 @@ public:
TEST(CustomLayer, Basic) {
util::RunLoop loop;
- DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets");
ThreadPool threadPool(4);
float pixelRatio { 1 };
HeadlessFrontend frontend { pixelRatio, threadPool };
- Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static));
+ Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, threadPool,
+ MapOptions().withMapMode(MapMode::Static),
+ ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
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 5567eabc73..b4297bfe82 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -1,4 +1,5 @@
-#include <mbgl/map/map.hpp>
+#include <mbgl/test/map_adapter.hpp>
+
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/test/stub_file_source.hpp>
@@ -33,16 +34,16 @@ public:
}
util::RunLoop loop;
- StubFileSource fileSource;
+ std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
ThreadPool threadPool { 4 };
float pixelRatio { 1 };
HeadlessFrontend frontend { pixelRatio, threadPool };
- Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static)};
+ MapAdapter map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
+ threadPool, MapOptions().withMapMode(MapMode::Static)};
};
std::vector<Feature> getTopClusterFeature(QueryTest& test) {
- test.fileSource.sourceResponse = [&] (const Resource& resource) {
+ test.fileSource->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));
@@ -54,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(*test.fileSource);
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 db576b4cf6..7d14bd14de 100644
--- a/test/api/recycle_map.cpp
+++ b/test/api/recycle_map.cpp
@@ -1,11 +1,10 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_file_source.hpp>
+#include <mbgl/test/map_adapter.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/renderer/backend_scope.hpp>
-#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/image.hpp>
@@ -24,14 +23,13 @@ using namespace mbgl::style;
TEST(API, RecycleMapUpdateImages) {
util::RunLoop loop;
- StubFileSource fileSource;
ThreadPool threadPool(4);
float pixelRatio { 1 };
HeadlessFrontend frontend { pixelRatio, threadPool };
- auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(),
- pixelRatio, fileSource, threadPool,
- MapOptions().withMapMode(MapMode::Static));
+ auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(), frontend.getSize(),
+ pixelRatio, std::make_shared<StubFileSource>(), threadPool,
+ MapOptions().withMapMode(MapMode::Static));
EXPECT_TRUE(map);