summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-04-21 13:35:34 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-22 08:04:39 -0700
commit1520a56813f82bbe875774fdc2b3df26392278d6 (patch)
treed8f6ccc10e118bd2be6a954951c037f9c2fc1384 /test
parentbe7e9bbb8d54c775127f53d793c117c4bf5e2764 (diff)
downloadqtlocation-mapboxgl-1520a56813f82bbe875774fdc2b3df26392278d6.tar.gz
[all] Promote Style to public API
Diffstat (limited to 'test')
-rw-r--r--test/api/custom_layer.test.cpp5
-rw-r--r--test/api/query.test.cpp3
-rw-r--r--test/map/map.test.cpp57
-rw-r--r--test/style/style.test.cpp8
-rw-r--r--test/style/style_layer.test.cpp4
5 files changed, 19 insertions, 58 deletions
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp
index 5a30220cd7..e11ed299a6 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -7,6 +7,7 @@
#include <mbgl/gl/offscreen_view.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/style/style.hpp>
#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/util/io.hpp>
@@ -95,7 +96,7 @@ TEST(CustomLayer, Basic) {
Map map(backend, view.getSize(), 1, 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>(
+ map.getStyle().addLayer(std::make_unique<CustomLayer>(
"custom",
[] (void* context) {
reinterpret_cast<TestLayer*>(context)->initialize();
@@ -110,7 +111,7 @@ TEST(CustomLayer, Basic) {
auto layer = std::make_unique<FillLayer>("landcover", "mapbox");
layer->setSourceLayer("landcover");
layer->setFillColor(Color{ 1.0, 1.0, 0.0, 1.0 });
- map.addLayer(std::move(layer));
+ map.getStyle().addLayer(std::move(layer));
test::checkImage("test/fixtures/custom_layer/basic", test::render(map, view), 0.0006, 0.1);
}
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index 5b7f7c00ff..ad4dc6f4de 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -8,6 +8,7 @@
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
+#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/source.hpp>
@@ -20,7 +21,7 @@ class QueryTest {
public:
QueryTest() {
map.setStyleJSON(util::read_file("test/fixtures/api/query_style.json"));
- map.addImage(std::make_unique<style::Image>("test-icon",
+ map.getStyle().addImage(std::make_unique<style::Image>("test-icon",
decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0));
test::render(map, view);
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index 0ff828ce40..9045f1c8c2 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -16,6 +16,7 @@
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/async_task.hpp>
+#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/util/color.hpp>
@@ -247,12 +248,12 @@ TEST(Map, StyleExpired) {
fileSource.respond(Resource::Style, response);
EXPECT_EQ(1u, fileSource.requests.size());
- map.addLayer(std::make_unique<style::BackgroundLayer>("bg"));
+ map.getStyle().addLayer(std::make_unique<style::BackgroundLayer>("bg"));
EXPECT_EQ(1u, fileSource.requests.size());
fileSource.respond(Resource::Style, response);
EXPECT_EQ(0u, fileSource.requests.size());
- EXPECT_NE(nullptr, map.getLayer("bg"));
+ EXPECT_NE(nullptr, map.getStyle().getLayer("bg"));
}
TEST(Map, StyleExpiredWithAnnotations) {
@@ -289,14 +290,14 @@ TEST(Map, StyleEarlyMutation) {
Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://styles/test");
- map.addLayer(std::make_unique<style::BackgroundLayer>("bg"));
+ map.getStyle().addLayer(std::make_unique<style::BackgroundLayer>("bg"));
Response response;
response.data = std::make_shared<std::string>(util::read_file("test/fixtures/api/water.json"));
fileSource.respond(Resource::Style, response);
EXPECT_EQ(0u, fileSource.requests.size());
- EXPECT_NE(nullptr, map.getLayer("water"));
+ EXPECT_NE(nullptr, map.getStyle().getLayer("water"));
}
TEST(Map, MapLoadingSignal) {
@@ -396,7 +397,7 @@ TEST(Map, AddLayer) {
auto layer = std::make_unique<BackgroundLayer>("background");
layer->setBackgroundColor({ { 1, 0, 0, 1 } });
- map.addLayer(std::move(layer));
+ map.getStyle().addLayer(std::move(layer));
test::checkImage("test/fixtures/map/add_layer", test::render(map, test.view));
}
@@ -422,8 +423,8 @@ TEST(Map, RemoveLayer) {
auto layer = std::make_unique<BackgroundLayer>("background");
layer->setBackgroundColor({{ 1, 0, 0, 1 }});
- map.addLayer(std::move(layer));
- map.removeLayer("background");
+ map.getStyle().addLayer(std::move(layer));
+ map.getStyle().removeLayer("background");
test::checkImage("test/fixtures/map/remove_layer", test::render(map, test.view));
}
@@ -489,48 +490,6 @@ TEST(Map, DisabledSources) {
test::checkImage("test/fixtures/map/disabled_layers/second", test::render(map, test.view));
}
-TEST(Map, AddImage) {
- MapTest test;
-
- Map map(test.backend, test.view.getSize(), 1, 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<style::Image>("test-icon", std::move(decoded1), 1.0);
- auto image2 = std::make_unique<style::Image>("test-icon", std::move(decoded2), 1.0);
-
- // No-op.
- map.addImage(std::move(image1));
-
- map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json"));
- map.addImage(std::move(image2));
- test::checkImage("test/fixtures/map/add_icon", test::render(map, test.view));
-}
-
-TEST(Map, RemoveImage) {
- MapTest test;
-
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
- auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
- auto image = std::make_unique<style::Image>("test-icon", std::move(decoded), 1.0);
-
- map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json"));
- map.addImage(std::move(image));
- map.removeImage("test-icon");
- test::checkImage("test/fixtures/map/remove_icon", test::render(map, test.view));
-}
-
-TEST(Map, GetImage) {
- MapTest test;
-
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
- auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
- auto image = std::make_unique<style::Image>("test-icon", std::move(decoded), 1.0);
-
- map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json"));
- map.addImage(std::move(image));
- test::checkImage("test/fixtures/map/get_icon", map.getImage("test-icon")->getImage());
-}
-
TEST(Map, DontLoadUnneededTiles) {
MapTest test;
diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp
index 841c7b291b..701e4a6434 100644
--- a/test/style/style.test.cpp
+++ b/test/style/style.test.cpp
@@ -2,7 +2,7 @@
#include <mbgl/test/stub_file_source.hpp>
#include <mbgl/test/fixture_log_observer.hpp>
-#include <mbgl/style/style.hpp>
+#include <mbgl/style/style_impl.hpp>
#include <mbgl/style/source_impl.hpp>
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/layer.hpp>
@@ -21,7 +21,7 @@ TEST(Style, Properties) {
ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style style { threadPool, fileSource, 1.0 };
+ Style::Impl style { threadPool, fileSource, 1.0 };
style.setJSON(R"STYLE({"name": "Test"})STYLE");
ASSERT_EQ("Test", style.getName());
@@ -56,7 +56,7 @@ TEST(Style, DuplicateSource) {
ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style style { threadPool, fileSource, 1.0 };
+ Style::Impl style { threadPool, fileSource, 1.0 };
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
@@ -78,7 +78,7 @@ TEST(Style, RemoveSourceInUse) {
ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style style { threadPool, fileSource, 1.0 };
+ Style::Impl style { threadPool, fileSource, 1.0 };
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index 7d0eb318c0..0e7957c490 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -1,7 +1,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_layer_observer.hpp>
#include <mbgl/test/stub_file_source.hpp>
-#include <mbgl/style/style.hpp>
+#include <mbgl/style/style_impl.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/background_layer_impl.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
@@ -275,7 +275,7 @@ TEST(Layer, DuplicateLayer) {
// Setup style
ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style style { threadPool, fileSource, 1.0 };
+ Style::Impl style { threadPool, fileSource, 1.0 };
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
// Add initial layer