summaryrefslogtreecommitdiff
path: root/test/style/conversion/layer.test.cpp
blob: 33cd32999923f35c7efb6d61ea89552464755195 (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
#include <mbgl/test/util.hpp>

#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/layer.hpp>
#include <mbgl/style/layers/background_layer_impl.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) {
    Error error;
    return std::move(*convertJSON<std::unique_ptr<Layer>>(src, error));
}

TEST(StyleConversion, LayerTransition) {
    auto layer = parseLayer(R"JSON({
        "type": "background",
        "id": "background",
        "paint": {
            "background-color-transition": {
                "duration": 400,
                "delay": 500
            }
        }
    })JSON");

    ASSERT_EQ(400ms, *layer->as<BackgroundLayer>()->impl().paint
        .get<BackgroundColor>().options.duration);
    ASSERT_EQ(500ms, *layer->as<BackgroundLayer>()->impl().paint
        .get<BackgroundColor>().options.delay);
}