summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-10 16:09:02 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-05 19:38:08 -0700
commit1cf46d93b944095726396acf84649519e2fd96ad (patch)
tree40d9e15b9862e1c234dff14151a51c3573f85e80 /test
parent591af0021bfb8b9fdfd803b55fb6c18a24c46943 (diff)
downloadqtlocation-mapboxgl-1cf46d93b944095726396acf84649519e2fd96ad.tar.gz
[core] Simplify LayerObserver API
Diffstat (limited to 'test')
-rw-r--r--test/src/mbgl/test/stub_layer_observer.hpp26
-rw-r--r--test/style/style_layer.test.cpp20
2 files changed, 19 insertions, 27 deletions
diff --git a/test/src/mbgl/test/stub_layer_observer.hpp b/test/src/mbgl/test/stub_layer_observer.hpp
index 9acd4b077a..0fa413aefe 100644
--- a/test/src/mbgl/test/stub_layer_observer.hpp
+++ b/test/src/mbgl/test/stub_layer_observer.hpp
@@ -10,29 +10,9 @@ using namespace mbgl::style;
*/
class StubLayerObserver : public style::LayerObserver {
public:
- void onLayerFilterChanged(Layer& layer) override {
- if (layerFilterChanged) layerFilterChanged(layer);
+ void onLayerChanged(Layer& layer) override {
+ if (layerChanged) layerChanged(layer);
}
- void onLayerVisibilityChanged(Layer& layer) override {
- if (layerVisibilityChanged) layerVisibilityChanged(layer);
- }
-
- void onLayerPaintPropertyChanged(Layer& layer) override {
- if (layerPaintPropertyChanged) layerPaintPropertyChanged(layer);
- }
-
- void onLayerDataDrivenPaintPropertyChanged(Layer& layer) override {
- if (layerDataDrivenPaintPropertyChanged) layerDataDrivenPaintPropertyChanged(layer);
- }
-
- void onLayerLayoutPropertyChanged(Layer& layer, const char * property) override {
- if (layerLayoutPropertyChanged) layerLayoutPropertyChanged(layer, property);
- }
-
- std::function<void (Layer&)> layerFilterChanged;
- std::function<void (Layer&)> layerVisibilityChanged;
- std::function<void (Layer&)> layerPaintPropertyChanged;
- std::function<void (Layer&)> layerDataDrivenPaintPropertyChanged;
- std::function<void (Layer&, const char *)> layerLayoutPropertyChanged;
+ std::function<void (Layer&)> layerChanged;
};
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index 2a8379bf20..7d0eb318c0 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -207,7 +207,7 @@ TEST(Layer, Observer) {
// Notifies observer on filter change.
bool filterChanged = false;
- observer.layerFilterChanged = [&] (Layer& layer_) {
+ observer.layerChanged = [&] (Layer& layer_) {
EXPECT_EQ(layer.get(), &layer_);
filterChanged = true;
};
@@ -216,7 +216,7 @@ TEST(Layer, Observer) {
// Notifies observer on visibility change.
bool visibilityChanged = false;
- observer.layerVisibilityChanged = [&] (Layer& layer_) {
+ observer.layerChanged = [&] (Layer& layer_) {
EXPECT_EQ(layer.get(), &layer_);
visibilityChanged = true;
};
@@ -225,7 +225,7 @@ TEST(Layer, Observer) {
// Notifies observer on paint property change.
bool paintPropertyChanged = false;
- observer.layerPaintPropertyChanged = [&] (Layer& layer_) {
+ observer.layerChanged = [&] (Layer& layer_) {
EXPECT_EQ(layer.get(), &layer_);
paintPropertyChanged = true;
};
@@ -234,7 +234,7 @@ TEST(Layer, Observer) {
// Notifies observer on layout property change.
bool layoutPropertyChanged = false;
- observer.layerLayoutPropertyChanged = [&] (Layer& layer_, const char *) {
+ observer.layerChanged = [&] (Layer& layer_) {
EXPECT_EQ(layer.get(), &layer_);
layoutPropertyChanged = true;
};
@@ -243,16 +243,28 @@ TEST(Layer, Observer) {
// Does not notify observer on no-op visibility change.
visibilityChanged = false;
+ observer.layerChanged = [&] (Layer& layer_) {
+ EXPECT_EQ(layer.get(), &layer_);
+ visibilityChanged = true;
+ };
layer->setVisibility(VisibilityType::None);
EXPECT_FALSE(visibilityChanged);
// Does not notify observer on no-op paint property change.
paintPropertyChanged = false;
+ observer.layerChanged = [&] (Layer& layer_) {
+ EXPECT_EQ(layer.get(), &layer_);
+ paintPropertyChanged = true;
+ };
layer->setLineColor(color);
EXPECT_FALSE(paintPropertyChanged);
// Does not notify observer on no-op layout property change.
layoutPropertyChanged = false;
+ observer.layerChanged = [&] (Layer& layer_) {
+ EXPECT_EQ(layer.get(), &layer_);
+ layoutPropertyChanged = true;
+ };
layer->setLineCap(lineCap);
EXPECT_FALSE(layoutPropertyChanged);
}