summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-09-01 08:34:13 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-06 14:29:22 -0700
commitd6f667a5e762ce1faec80bee774b805fe7ef5e11 (patch)
tree527ae75a142d089203d971d1f909d311f3e51d7b /test
parent6d770cb40f1231e202b603fcc63d3b00efc3f551 (diff)
downloadqtlocation-mapboxgl-d6f667a5e762ce1faec80bee774b805fe7ef5e11.tar.gz
[core] Observe visibility changes
Diffstat (limited to 'test')
-rw-r--r--test/src/mbgl/test/stub_layer_observer.hpp5
-rw-r--r--test/style/style_layer.cpp14
2 files changed, 19 insertions, 0 deletions
diff --git a/test/src/mbgl/test/stub_layer_observer.hpp b/test/src/mbgl/test/stub_layer_observer.hpp
index 500103055d..f346080b10 100644
--- a/test/src/mbgl/test/stub_layer_observer.hpp
+++ b/test/src/mbgl/test/stub_layer_observer.hpp
@@ -14,6 +14,10 @@ public:
if (layerFilterChanged) layerFilterChanged(layer);
}
+ void onLayerVisibilityChanged(Layer& layer) override {
+ if (layerVisibilityChanged) layerVisibilityChanged(layer);
+ }
+
void onLayerPaintPropertyChanged(Layer& layer) override {
if (layerPaintPropertyChanged) layerPaintPropertyChanged(layer);
}
@@ -23,6 +27,7 @@ public:
}
std::function<void (Layer&)> layerFilterChanged;
+ std::function<void (Layer&)> layerVisibilityChanged;
std::function<void (Layer&)> layerPaintPropertyChanged;
std::function<void (Layer&)> layerLayoutPropertyChanged;
};
diff --git a/test/style/style_layer.cpp b/test/style/style_layer.cpp
index 0d2ed88edd..08952e3799 100644
--- a/test/style/style_layer.cpp
+++ b/test/style/style_layer.cpp
@@ -226,6 +226,15 @@ TEST(Layer, Observer) {
layer->setFilter(NullFilter());
EXPECT_TRUE(filterChanged);
+ // Notifies observer on visibility change.
+ bool visibilityChanged = false;
+ observer.layerVisibilityChanged = [&] (Layer& layer_) {
+ EXPECT_EQ(layer.get(), &layer_);
+ visibilityChanged = true;
+ };
+ layer->setVisibility(VisibilityType::None);
+ EXPECT_TRUE(visibilityChanged);
+
// Notifies observer on paint property change.
bool paintPropertyChanged = false;
observer.layerPaintPropertyChanged = [&] (Layer& layer_) {
@@ -244,6 +253,11 @@ TEST(Layer, Observer) {
layer->setLineCap(lineCap);
EXPECT_TRUE(layoutPropertyChanged);
+ // Does not notify observer on no-op visibility change.
+ visibilityChanged = false;
+ layer->setVisibility(VisibilityType::None);
+ EXPECT_FALSE(visibilityChanged);
+
// Does not notify observer on no-op paint property change.
paintPropertyChanged = false;
layer->setLineColor(color);