summaryrefslogtreecommitdiff
path: root/test/renderer
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-04-21 09:19:47 -0700
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-04-25 17:23:54 -0700
commit3c175adf30546fe58713b8fed29ac35a85e150be (patch)
tree5666e9bcf311ed1b86a13444e50dc7a030c10da9 /test/renderer
parentea8ec38df156c6683c886253dbb1f6bc828686ff (diff)
downloadqtlocation-mapboxgl-3c175adf30546fe58713b8fed29ac35a85e150be.tar.gz
[core] split off render layers
Diffstat (limited to 'test/renderer')
-rw-r--r--test/renderer/group_by_layout.test.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/renderer/group_by_layout.test.cpp b/test/renderer/group_by_layout.test.cpp
new file mode 100644
index 0000000000..9c8e09e222
--- /dev/null
+++ b/test/renderer/group_by_layout.test.cpp
@@ -0,0 +1,54 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/renderer/group_by_layout.hpp>
+#include <mbgl/renderer/render_layer.hpp>
+#include <mbgl/style/layers/background_layer.hpp>
+#include <mbgl/style/layers/circle_layer.hpp>
+#include <mbgl/style/layers/line_layer.hpp>
+
+using namespace mbgl;
+using namespace mbgl::style;
+
+static std::vector<std::unique_ptr<RenderLayer>> toRenderLayers(const std::vector<std::unique_ptr<Layer>>& layers) {
+ std::vector<std::unique_ptr<RenderLayer>> result;
+ result.reserve(layers.size());
+ for (auto& layer : layers) {
+ result.push_back(layer->baseImpl->createRenderLayer());
+ }
+ return result;
+}
+
+TEST(GroupByLayout, Related) {
+ std::vector<std::unique_ptr<Layer>> layers;
+ layers.push_back(std::make_unique<LineLayer>("a", "source"));
+ layers.push_back(std::make_unique<LineLayer>("b", "source"));
+ auto result = groupByLayout(toRenderLayers(layers));
+ ASSERT_EQ(1u, result.size());
+ ASSERT_EQ(2u, result[0].size());
+}
+
+TEST(GroupByLayout, UnrelatedType) {
+ std::vector<std::unique_ptr<Layer>> layers;
+ layers.push_back(std::make_unique<BackgroundLayer>("background"));
+ layers.push_back(std::make_unique<CircleLayer>("circle", "source"));
+ auto result = groupByLayout(toRenderLayers(layers));
+ ASSERT_EQ(2u, result.size());
+}
+
+TEST(GroupByLayout, UnrelatedFilter) {
+ std::vector<std::unique_ptr<Layer>> layers;
+ layers.push_back(std::make_unique<LineLayer>("a", "source"));
+ layers.push_back(std::make_unique<LineLayer>("b", "source"));
+ layers[0]->as<LineLayer>()->setFilter(EqualsFilter());
+ auto result = groupByLayout(toRenderLayers(layers));
+ ASSERT_EQ(2u, result.size());
+}
+
+TEST(GroupByLayout, UnrelatedLayout) {
+ std::vector<std::unique_ptr<Layer>> layers;
+ layers.push_back(std::make_unique<LineLayer>("a", "source"));
+ layers.push_back(std::make_unique<LineLayer>("b", "source"));
+ layers[0]->as<LineLayer>()->setLineCap(LineCapType::Square);
+ auto result = groupByLayout(toRenderLayers(layers));
+ ASSERT_EQ(2u, result.size());
+}