From 817c26111a0d6650e7ebae73e46621626106d0a7 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 12 Oct 2016 17:28:22 -0400 Subject: [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 --- test/map/map.test.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'test/map/map.test.cpp') 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 #include -#include #include +#include +#include #include #include #include @@ -24,11 +25,12 @@ struct MapTest { std::shared_ptr display { std::make_shared() }; 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("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("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("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(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(std::move(decoded), 1.0); -- cgit v1.2.1