Files
MapLibreParticleLab/test/style/conversion/layer.test.cpp
Mikhail Pozdnyakov 361982fef8 [core][Android][Darwin] LayerManager creates RenderLayer instances
`LayerManager` is now responsible for `RenderLayer` instances creation,
so that there is a single entry point for creating of objects, which
correspond to a certain layer type.

The `LayerType type` field is dropped from `Layer::Impl`.
2018-11-27 18:10:21 +02:00

34 lines
1.1 KiB
C++

#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_STREQ("background", layer->getTypeInfo()->type);
ASSERT_EQ(400ms, *static_cast<BackgroundLayer*>(layer.get())->impl().paint
.get<BackgroundColor>().options.duration);
ASSERT_EQ(500ms, *static_cast<BackgroundLayer*>(layer.get())->impl().paint
.get<BackgroundColor>().options.delay);
}