Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
BIN
test/fixtures/map/style_update_zoom_dependency/after_update_green/expected.png
vendored
Normal file
BIN
test/fixtures/map/style_update_zoom_dependency/after_update_green/expected.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 913 B |
BIN
test/fixtures/map/style_update_zoom_dependency/initial_red/expected.png
vendored
Normal file
BIN
test/fixtures/map/style_update_zoom_dependency/initial_red/expected.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 853 B |
13
test/fixtures/map/style_update_zoom_dependency/style.json
vendored
Normal file
13
test/fixtures/map/style_update_zoom_dependency/style.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {},
|
||||
"layers": [
|
||||
{
|
||||
"id": "background",
|
||||
"type": "background",
|
||||
"paint": {
|
||||
"background-color": "#ff0000"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -19,8 +19,10 @@
|
||||
#include <mbgl/storage/network_status.hpp>
|
||||
#include <mbgl/storage/online_file_source.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/style/image.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
#include <mbgl/style/image_impl.hpp>
|
||||
#include <mbgl/style/image.hpp>
|
||||
#include <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/style/layers/fill_layer.hpp>
|
||||
#include <mbgl/style/layers/raster_layer.hpp>
|
||||
@@ -29,8 +31,8 @@
|
||||
#include <mbgl/style/sources/geojson_source.hpp>
|
||||
#include <mbgl/style/sources/image_source.hpp>
|
||||
#include <mbgl/style/sources/vector_source.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/style/style_impl.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/util/async_task.hpp>
|
||||
#include <mbgl/util/client_options.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
@@ -1866,3 +1868,31 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
EXPECT_FALSE(parsing);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BackgroundLayer, StyleUpdateZoomDependency) {
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
|
||||
MapTest<> test;
|
||||
test.map.getStyle().loadJSON(util::read_file("test/fixtures/map/style_update_zoom_dependency/style.json"));
|
||||
test.map.jumpTo(CameraOptions().withZoom(0.0));
|
||||
|
||||
// Initial render: background should be red at zoom 0
|
||||
test::checkImage("test/fixtures/map/style_update_zoom_dependency/initial_red",
|
||||
test.frontend.render(test.map).image,
|
||||
0.0006,
|
||||
0.1);
|
||||
|
||||
// Update background layer to use zoom-dependent color
|
||||
auto layer = static_cast<style::BackgroundLayer*>(test.map.getStyle().getLayer("background"));
|
||||
layer->setBackgroundColor(PropertyExpression<Color>(
|
||||
interpolate(linear(), zoom(), 0.0, literal(Color::red()), 14.0, literal(Color::green()))));
|
||||
|
||||
test.frontend.render(test.map);
|
||||
|
||||
// Change zoom to 14 and re-render
|
||||
test.map.jumpTo(CameraOptions().withZoom(14.0));
|
||||
test::checkImage("test/fixtures/map/style_update_zoom_dependency/after_update_green",
|
||||
test.frontend.render(test.map).image,
|
||||
0.0006,
|
||||
0.1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user