summaryrefslogtreecommitdiff
path: root/test/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-02-09 12:36:40 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-09 15:08:51 -0600
commitb6e5edc26844df6a5f1f6e34881826828d36ce6a (patch)
tree214b77ec99c2302acedb8ee4beb9699e3e2d9d17 /test/style
parent925d394ab52f3d859c4111d53242b403d4e2e300 (diff)
downloadqtlocation-mapboxgl-b6e5edc26844df6a5f1f6e34881826828d36ce6a.tar.gz
[core] Restore support for *-transition properties
Diffstat (limited to 'test/style')
-rw-r--r--test/style/conversion/layer.test.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/style/conversion/layer.test.cpp b/test/style/conversion/layer.test.cpp
new file mode 100644
index 0000000000..b27c1841ee
--- /dev/null
+++ b/test/style/conversion/layer.test.cpp
@@ -0,0 +1,46 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/rapidjson_conversion.hpp>
+#include <mbgl/style/conversion/layer.hpp>
+#include <mbgl/style/layers/background_layer_impl.hpp>
+#include <mbgl/util/rapidjson.hpp>
+
+using namespace mbgl;
+using namespace mbgl::style;
+using namespace mbgl::style::conversion;
+using namespace std::literals::chrono_literals;
+
+auto parseLayer(const std::string& src) {
+ JSDocument doc;
+ doc.Parse<0>(src);
+ return convert<std::unique_ptr<Layer>, JSValue>(doc);
+}
+
+TEST(StyleConversion, LayerTransition) {
+ auto layer = parseLayer(R"JSON({
+ "type": "background",
+ "id": "background",
+ "paint": {
+ "background-color-transition": {
+ "duration": 400,
+ "delay": 500
+ }
+ },
+ "paint.class": {
+ "background-color-transition": {
+ "duration": 100
+ }
+ }
+ })JSON");
+
+ ASSERT_EQ(400ms, *(*layer)->as<BackgroundLayer>()->impl->paint.cascading
+ .get<BackgroundColor>().getTransition({}).duration);
+ ASSERT_EQ(500ms, *(*layer)->as<BackgroundLayer>()->impl->paint.cascading
+ .get<BackgroundColor>().getTransition({}).delay);
+
+ ASSERT_EQ(100ms, *(*layer)->as<BackgroundLayer>()->impl->paint.cascading
+ .get<BackgroundColor>().getTransition({"class"}).duration);
+ ASSERT_FALSE(bool((*layer)->as<BackgroundLayer>()->impl->paint.cascading
+ .get<BackgroundColor>().getTransition({"class"}).delay));
+}