diff options
author | Mike Morris <mikemorris@users.noreply.github.com> | 2016-10-12 17:28:22 -0400 |
---|---|---|
committer | Mike Morris <mikemorris@users.noreply.github.com> | 2016-10-20 14:37:36 -0400 |
commit | 817c26111a0d6650e7ebae73e46621626106d0a7 (patch) | |
tree | 60a5206f2f7658b06b214d9b7435a65a243d6e83 /test | |
parent | ab85fdb4524788ce7279e8ac362a0c1edbd5d5df (diff) | |
download | qtlocation-mapboxgl-817c26111a0d6650e7ebae73e46621626106d0a7.tar.gz |
[core] [node] pass thread pool impl to Map constructor
Updates mbgl::Map constructor usage everywhere
Adds NodeThreadPool implementation using AsyncQueue to call
Nan::AsyncQueueWorker from main thread
Diffstat (limited to 'test')
-rw-r--r-- | test/actor/actor.test.cpp | 2 | ||||
-rw-r--r-- | test/actor/actor_ref.test.cpp | 2 | ||||
-rw-r--r-- | test/api/annotations.test.cpp | 4 | ||||
-rw-r--r-- | test/api/api_misuse.test.cpp | 7 | ||||
-rw-r--r-- | test/api/custom_layer.test.cpp | 5 | ||||
-rw-r--r-- | test/api/query.test.cpp | 4 | ||||
-rw-r--r-- | test/api/render_missing.test.cpp | 7 | ||||
-rw-r--r-- | test/api/repeated_render.test.cpp | 8 | ||||
-rw-r--r-- | test/map/map.test.cpp | 36 | ||||
-rw-r--r-- | test/style/source.test.cpp | 2 | ||||
-rw-r--r-- | test/tile/raster_tile.test.cpp | 2 | ||||
-rw-r--r-- | test/tile/vector_tile.test.cpp | 2 | ||||
-rw-r--r-- | test/util/memory.test.cpp | 12 |
13 files changed, 57 insertions, 36 deletions
diff --git a/test/actor/actor.test.cpp b/test/actor/actor.test.cpp index 7bb76784d6..c24d0b6c25 100644 --- a/test/actor/actor.test.cpp +++ b/test/actor/actor.test.cpp @@ -1,5 +1,5 @@ #include <mbgl/actor/actor.hpp> -#include <mbgl/actor/thread_pool.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/test/util.hpp> diff --git a/test/actor/actor_ref.test.cpp b/test/actor/actor_ref.test.cpp index 655529035f..4be714278e 100644 --- a/test/actor/actor_ref.test.cpp +++ b/test/actor/actor_ref.test.cpp @@ -1,5 +1,5 @@ #include <mbgl/actor/actor.hpp> -#include <mbgl/actor/thread_pool.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/test/util.hpp> diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 6d6734a10f..c1716a5228 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -1,6 +1,7 @@ #include <mbgl/test/util.hpp> #include <mbgl/test/stub_file_source.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/annotation/annotation.hpp> #include <mbgl/sprite/sprite_image.hpp> #include <mbgl/map/map.hpp> @@ -25,7 +26,8 @@ public: std::shared_ptr<HeadlessDisplay> display { std::make_shared<HeadlessDisplay>() }; HeadlessView view { display, 1 }; StubFileSource fileSource; - Map map { view, fileSource, MapMode::Still }; + ThreadPool threadPool { 4 }; + Map map { view, fileSource, threadPool, MapMode::Still }; 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 e9fe307718..2016e278da 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -5,6 +5,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_display.hpp> #include <mbgl/storage/online_file_source.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/util/exception.hpp> #include <mbgl/util/run_loop.hpp> @@ -22,8 +23,9 @@ TEST(API, RenderWithoutCallback) { HeadlessView view(display, 1); view.resize(128, 512); StubFileSource fileSource; + ThreadPool threadPool(4); - std::unique_ptr<Map> map = std::make_unique<Map>(view, fileSource, MapMode::Still); + std::unique_ptr<Map> map = std::make_unique<Map>(view, fileSource, threadPool, MapMode::Still); map->renderStill(nullptr); // Force Map thread to join. @@ -46,8 +48,9 @@ TEST(API, RenderWithoutStyle) { HeadlessView view(display, 1); view.resize(128, 512); StubFileSource fileSource; + ThreadPool threadPool(4); - Map map(view, fileSource, MapMode::Still); + Map map(view, fileSource, threadPool, MapMode::Still); std::exception_ptr error; map.renderStill([&](std::exception_ptr error_, PremultipliedImage&&) { diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 2dded19256..1342dfa50c 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -4,6 +4,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_display.hpp> #include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/style/layers/custom_layer.hpp> #include <mbgl/style/layers/fill_layer.hpp> @@ -94,7 +95,9 @@ TEST(CustomLayer, Basic) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); #endif - Map map(view, fileSource, MapMode::Still); + ThreadPool threadPool(4); + + Map map(view, fileSource, threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); map.addLayer(std::make_unique<CustomLayer>( diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index 7da0f4311c..da38dd0cb2 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -1,6 +1,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_display.hpp> #include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/sprite/sprite_image.hpp> #include <mbgl/test/stub_file_source.hpp> #include <mbgl/test/util.hpp> @@ -28,7 +29,8 @@ public: std::shared_ptr<HeadlessDisplay> display { std::make_shared<HeadlessDisplay>() }; HeadlessView view { display, 1 }; StubFileSource fileSource; - Map map { view, fileSource, MapMode::Still }; + ThreadPool threadPool { 4 }; + Map map { view, fileSource, threadPool, MapMode::Still }; }; } // end namespace diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp index 024ebd3729..d57a5a98bd 100644 --- a/test/api/render_missing.test.cpp +++ b/test/api/render_missing.test.cpp @@ -2,8 +2,9 @@ #include <mbgl/test/fixture_log_observer.hpp> #include <mbgl/map/map.hpp> -#include <mbgl/platform/default/headless_view.hpp> #include <mbgl/platform/default/headless_display.hpp> +#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> @@ -33,9 +34,11 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); #endif + ThreadPool threadPool(4); + Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(view, fileSource, MapMode::Still); + Map map(view, fileSource, threadPool, MapMode::Still); std::string message; diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp index cf71cb8416..4229f9d7ad 100644 --- a/test/api/repeated_render.test.cpp +++ b/test/api/repeated_render.test.cpp @@ -2,8 +2,9 @@ #include <mbgl/test/fixture_log_observer.hpp> #include <mbgl/map/map.hpp> -#include <mbgl/platform/default/headless_view.hpp> #include <mbgl/platform/default/headless_display.hpp> +#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> @@ -20,6 +21,7 @@ TEST(API, RepeatedRender) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1, 256, 512); + #ifdef MBGL_ASSET_ZIP // Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/` DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip"); @@ -27,9 +29,11 @@ TEST(API, RepeatedRender) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); #endif + ThreadPool threadPool(4); + Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(view, fileSource, MapMode::Still); + Map map(view, fileSource, threadPool, MapMode::Still); { map.setStyleJSON(style); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 5b66d9b753..c03a038dc0 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -4,8 +4,9 @@ #include <mbgl/test/fixture_log_observer.hpp> #include <mbgl/map/map.hpp> -#include <mbgl/platform/default/headless_view.hpp> #include <mbgl/platform/default/headless_display.hpp> +#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/sprite/sprite_image.hpp> #include <mbgl/storage/network_status.hpp> #include <mbgl/storage/default_file_source.hpp> @@ -24,11 +25,12 @@ struct MapTest { std::shared_ptr<HeadlessDisplay> display { std::make_shared<mbgl::HeadlessDisplay>() }; HeadlessView view { display, 1 }; StubFileSource fileSource; + ThreadPool threadPool { 4 }; }; TEST(Map, LatLngBehavior) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); @@ -62,7 +64,7 @@ TEST(Map, Offline) { fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf")); NetworkStatus::Set(NetworkStatus::Status::Offline); - Map map(test.view, fileSource, MapMode::Still); + Map map(test.view, fileSource, test.threadPool, MapMode::Still); map.setStyleURL(prefix + "style.json"); test::checkImage("test/fixtures/map/offline", @@ -86,7 +88,7 @@ TEST(Map, SetStyleInvalidJSON) { }); { - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON("invalid"); } @@ -117,7 +119,7 @@ TEST(Map, SetStyleInvalidURL) { } }); - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://bar"); test.runLoop.run(); @@ -126,7 +128,7 @@ TEST(Map, SetStyleInvalidURL) { TEST(Map, DoubleStyleLoad) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(""); map.setStyleJSON(""); } @@ -137,7 +139,7 @@ TEST(Map, StyleFresh) { MapTest test; FakeFileSource fileSource; - Map map(test.view, fileSource, MapMode::Still); + Map map(test.view, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -157,7 +159,7 @@ TEST(Map, StyleExpired) { MapTest test; FakeFileSource fileSource; - Map map(test.view, fileSource, MapMode::Still); + Map map(test.view, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -184,7 +186,7 @@ TEST(Map, StyleExpiredWithAnnotations) { MapTest test; FakeFileSource fileSource; - Map map(test.view, fileSource, MapMode::Still); + Map map(test.view, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -208,7 +210,7 @@ TEST(Map, StyleEarlyMutation) { MapTest test; FakeFileSource fileSource; - Map map(test.view, fileSource, MapMode::Still); + Map map(test.view, fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://styles/test"); map.addLayer(std::make_unique<style::BackgroundLayer>("bg")); @@ -222,7 +224,7 @@ TEST(Map, StyleEarlyMutation) { TEST(Map, StyleLoadedSignal) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); // The map should emit a signal on style loaded bool emitted = false; @@ -243,7 +245,7 @@ TEST(Map, StyleLoadedSignal) { TEST(Map, AddLayer) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); auto layer = std::make_unique<BackgroundLayer>("background"); @@ -256,7 +258,7 @@ TEST(Map, AddLayer) { TEST(Map, RemoveLayer) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); auto layer = std::make_unique<BackgroundLayer>("background"); @@ -281,7 +283,7 @@ TEST(Map, DisabledSources) { return {}; }; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setZoom(1); // This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0. @@ -331,7 +333,7 @@ TEST(Map, DisabledSources) { TEST(Map, Classes) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); EXPECT_FALSE(map.getTransitionOptions().duration); @@ -365,7 +367,7 @@ TEST(Map, Classes) { TEST(Map, AddImage) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); auto decoded1 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto decoded2 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto image1 = std::make_unique<SpriteImage>(std::move(decoded1), 1.0); @@ -382,7 +384,7 @@ TEST(Map, AddImage) { TEST(Map, RemoveImage) { MapTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0); diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index 3270894a59..3aebe10769 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -11,7 +11,7 @@ #include <mbgl/util/string.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/tileset.hpp> -#include <mbgl/actor/thread_pool.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/platform/log.hpp> #include <mbgl/map/transform.hpp> diff --git a/test/tile/raster_tile.test.cpp b/test/tile/raster_tile.test.cpp index 4e9e907321..2a15fd1b99 100644 --- a/test/tile/raster_tile.test.cpp +++ b/test/tile/raster_tile.test.cpp @@ -3,7 +3,7 @@ #include <mbgl/tile/raster_tile.hpp> #include <mbgl/tile/tile_loader_impl.hpp> -#include <mbgl/actor/thread_pool.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/map/transform.hpp> #include <mbgl/style/style.hpp> diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index fa75e24480..c07db42c3c 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -3,7 +3,7 @@ #include <mbgl/tile/vector_tile.hpp> #include <mbgl/tile/tile_loader_impl.hpp> -#include <mbgl/actor/thread_pool.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/map/transform.hpp> #include <mbgl/style/style.hpp> diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp index d1b9f2412a..e2ace99c41 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -4,6 +4,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_display.hpp> #include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> @@ -58,6 +59,7 @@ public: std::shared_ptr<HeadlessDisplay> display { std::make_shared<mbgl::HeadlessDisplay>() }; HeadlessView view { display, 2 }; StubFileSource fileSource; + ThreadPool threadPool { 4 }; private: Response response(const std::string& path) { @@ -91,7 +93,7 @@ private: TEST(Memory, Vector) { MemoryTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setZoom(16); // more map features map.setStyleURL("mapbox://streets"); @@ -101,7 +103,7 @@ TEST(Memory, Vector) { TEST(Memory, Raster) { MemoryTest test; - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource, test.threadPool, MapMode::Still); map.setStyleURL("mapbox://satellite"); test::render(map); @@ -128,7 +130,7 @@ TEST(Memory, Footprint) { // Warm up buffers and cache. for (unsigned i = 0; i < 10; ++i) { - Map map(test.view, test.fileSource, MapMode::Still); + Map map(test.view, test.fileSource,test.threadPool, MapMode::Still); renderMap(&map, "mapbox://streets"); renderMap(&map, "mapbox://satellite"); }; @@ -142,7 +144,7 @@ TEST(Memory, Footprint) { long vectorInitialRSS = getRSS(); for (unsigned i = 0; i < runs; ++i) { - auto vector = std::make_unique<Map>(test.view, test.fileSource, MapMode::Still); + auto vector = std::make_unique<Map>(test.view, test.fileSource, test.threadPool, MapMode::Still); renderMap(vector.get(), "mapbox://streets"); maps.push_back(std::move(vector)); }; @@ -151,7 +153,7 @@ TEST(Memory, Footprint) { long rasterInitialRSS = getRSS(); for (unsigned i = 0; i < runs; ++i) { - auto raster = std::make_unique<Map>(test.view, test.fileSource, MapMode::Still); + auto raster = std::make_unique<Map>(test.view, test.fileSource, test.threadPool, MapMode::Still); renderMap(raster.get(), "mapbox://satellite"); maps.push_back(std::move(raster)); }; |