blob: 22be61e809c0d1f7baea18a9753649e0e73a546d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#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;
std::unique_ptr<Layer> parseLayer(const std::string& src) {
JSDocument doc;
doc.Parse<0>(src);
Error error;
return std::move(*convert<std::unique_ptr<Layer>, JSValue>(doc, error));
}
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
.get<BackgroundColor>().getTransition({}).duration);
ASSERT_EQ(500ms, *layer->as<BackgroundLayer>()->impl().paint
.get<BackgroundColor>().getTransition({}).delay);
ASSERT_EQ(100ms, *layer->as<BackgroundLayer>()->impl().paint
.get<BackgroundColor>().getTransition({"class"}).duration);
ASSERT_FALSE(bool(layer->as<BackgroundLayer>()->impl().paint
.get<BackgroundColor>().getTransition({"class"}).delay));
}
|