Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -51,9 +51,11 @@ public:
MapAdapter map;
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
: fileSource(std::make_shared<FileSource>(ResourceOptions::Default(), ClientOptions()))
, frontend(pixelRatio)
, map(frontend, observer, fileSource,
: fileSource(std::make_shared<FileSource>(ResourceOptions::Default(), ClientOptions())),
frontend(pixelRatio),
map(frontend,
observer,
fileSource,
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
explicit MapTest(MapOptions options)
@@ -67,13 +69,14 @@ public:
float pixelRatio = 1,
MapMode mode = MapMode::Static,
typename std::enable_if_t<std::is_same_v<T, MainResourceLoader>>* = nullptr)
: fileSource(std::make_shared<T>(ResourceOptions().withCachePath(cachePath).withAssetPath(assetPath), ClientOptions())),
: fileSource(std::make_shared<T>(ResourceOptions().withCachePath(cachePath).withAssetPath(assetPath),
ClientOptions())),
frontend(pixelRatio),
map(frontend,
observer,
fileSource,
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
template <typename T = FileSource>
MapTest(const ResourceOptions& resourceOptions,
const ClientOptions& clientOptions = ClientOptions(),
@@ -94,13 +97,14 @@ TEST(Map, RendererState) {
CameraOptions nullOptions;
ASSERT_EQ(test.frontend.getCameraOptions(), nullOptions);
LatLng coordinate { 1, 1 };
LatLng coordinate{1, 1};
double zoom = 12.0;
double pitchInDegrees = 45.0;
double bearingInDegrees = 30.0;
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.jumpTo(CameraOptions().withCenter(coordinate).withZoom(zoom).withPitch(pitchInDegrees).withBearing(bearingInDegrees));
test.map.jumpTo(
CameraOptions().withCenter(coordinate).withZoom(zoom).withPitch(pitchInDegrees).withBearing(bearingInDegrees));
test.runLoop.runOnce();
test.frontend.render(test.map);
@@ -114,7 +118,7 @@ TEST(Map, RendererState) {
EXPECT_NEAR(*options.bearing, bearingInDegrees, 1e-7);
{
const LatLng& latLng = test.frontend.latLngForPixel(ScreenCoordinate { 0, 0 });
const LatLng& latLng = test.frontend.latLngForPixel(ScreenCoordinate{0, 0});
const ScreenCoordinate& point = test.frontend.pixelForLatLng(coordinate);
EXPECT_NEAR(coordinate.latitude(), latLng.latitude(), 1e-1);
EXPECT_NEAR(coordinate.longitude(), latLng.longitude(), 1e-1);
@@ -124,7 +128,8 @@ TEST(Map, RendererState) {
}
// RendererState::hasImage
test.map.getStyle().addImage(std::make_unique<style::Image>("default_marker", decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0f));
test.map.getStyle().addImage(std::make_unique<style::Image>(
"default_marker", decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0f));
// The frontend has not yet been notified about the newly-added image.
EXPECT_FALSE(test.frontend.hasImage("default_marker"));
@@ -136,7 +141,7 @@ TEST(Map, RendererState) {
// RendererState::hasSource
auto source = std::make_unique<GeoJSONSource>("GeoJSONSource");
source->setGeoJSON( Geometry<double>{ Point<double>{ 0, 0 } } );
source->setGeoJSON(Geometry<double>{Point<double>{0, 0}});
test.map.getStyle().addSource(std::move(source));
// The frontend has not yet been notified about the newly-added source.
@@ -162,10 +167,10 @@ TEST(Map, RendererState) {
TEST(Map, LatLngBehavior) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 1.0, 1.0 }).withZoom(0.0));
test.map.jumpTo(CameraOptions().withCenter(LatLng{1.0, 1.0}).withZoom(0.0));
auto latLng1 = *test.map.getCameraOptions().center;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 1.0, 1.0 }));
test.map.jumpTo(CameraOptions().withCenter(LatLng{1.0, 1.0}));
auto latLng2 = *test.map.getCameraOptions().center;
ASSERT_DOUBLE_EQ(latLng1.latitude(), latLng2.latitude());
@@ -175,9 +180,9 @@ TEST(Map, LatLngBehavior) {
TEST(Map, LatLngBoundsToCamera) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0));
test.map.jumpTo(CameraOptions().withCenter(LatLng{40.712730, -74.005953}).withZoom(16.0));
LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281});
LatLngBounds bounds = LatLngBounds::hull({15.68169, 73.499857}, {53.560711, 134.77281});
CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {});
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
@@ -187,9 +192,9 @@ TEST(Map, LatLngBoundsToCamera) {
TEST(Map, LatLngBoundsToCameraWithExcessivePadding) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0));
test.map.jumpTo(CameraOptions().withCenter(LatLng{40.712730, -74.005953}).withZoom(16.0));
LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281});
LatLngBounds bounds = LatLngBounds::hull({15.68169, 73.499857}, {53.560711, 134.77281});
CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {500, 0, 1200, 0});
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
@@ -199,9 +204,9 @@ TEST(Map, LatLngBoundsToCameraWithExcessivePadding) {
TEST(Map, LatLngBoundsToCameraWithBearing) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0));
test.map.jumpTo(CameraOptions().withCenter(LatLng{40.712730, -74.005953}).withZoom(16.0));
LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281});
LatLngBounds bounds = LatLngBounds::hull({15.68169, 73.499857}, {53.560711, 134.77281});
CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {}, 35.0);
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
@@ -211,11 +216,11 @@ TEST(Map, LatLngBoundsToCameraWithBearing) {
TEST(Map, LatLngBoundsToCameraWithBearingPitchAndPadding) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0));
LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281});
test.map.jumpTo(CameraOptions().withCenter(LatLng{40.712730, -74.005953}).withZoom(16.0));
LatLngBounds bounds = LatLngBounds::hull({15.68169, 73.499857}, {53.560711, 134.77281});
CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {}, 35, 20);
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
EXPECT_NEAR(*virtualCamera.zoom, 13.66272, 1e-5);
@@ -239,7 +244,7 @@ TEST(Map, LatLngBoundsToCameraWithBearingPitchAndPadding) {
TEST(Map, LatLngsToCamera) {
MapTest<> test;
std::vector<LatLng> latLngs{{ 40.712730, 74.005953 }, {15.68169,73.499857}, {30.82678, 83.4082}};
std::vector<LatLng> latLngs{{40.712730, 74.005953}, {15.68169, 73.499857}, {30.82678, 83.4082}};
CameraOptions virtualCamera = test.map.cameraForLatLngs(latLngs, {}, 23.0);
EXPECT_NEAR(virtualCamera.bearing.value_or(0), 23.0, 1e-5);
@@ -250,9 +255,9 @@ TEST(Map, LatLngsToCamera) {
TEST(Map, LatLngsToCameraWithBearingAndPitch) {
MapTest<> test;
std::vector<LatLng> latLngs{{ 40.712730, 74.005953 }, {15.68169,73.499857}, {30.82678, 83.4082}};
std::vector<LatLng> latLngs{{40.712730, 74.005953}, {15.68169, 73.499857}, {30.82678, 83.4082}};
CameraOptions virtualCamera = test.map.cameraForLatLngs(latLngs, {}, 23, 20);
EXPECT_NEAR(virtualCamera.bearing.value_or(0), 23.0, 1e-5);
EXPECT_NEAR(virtualCamera.zoom.value_or(0), 3.04378, 1e-5);
@@ -290,12 +295,11 @@ TEST(Map, LatLngsToCameraWithBearingAndPitchMinMax) {
TEST(Map, CameraToLatLngBounds) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 45, 90 }).withZoom(16.0));
test.map.jumpTo(CameraOptions().withCenter(LatLng{45, 90}).withZoom(16.0));
const Size size = test.map.getMapOptions().size();
LatLngBounds bounds = LatLngBounds::hull(
test.map.latLngForPixel({}),
test.map.latLngForPixel({ double(size.width), double(size.height) }));
LatLngBounds bounds = LatLngBounds::hull(test.map.latLngForPixel({}),
test.map.latLngForPixel({double(size.width), double(size.height)}));
CameraOptions camera = test.map.getCameraOptions();
@@ -353,17 +357,17 @@ TEST(Map, CameraToLatLngBoundsUnwrappedCrossDateLine) {
TEST(Map, Offline) {
MapTest<MainResourceLoader> test{":memory:", "."};
auto expiredItem = [] (const std::string& path) {
auto expiredItem = [](const std::string& path) {
Response response;
response.data = std::make_shared<std::string>(util::read_file("test/fixtures/map/offline/"s + path));
response.expires = Timestamp{ Seconds(0) };
response.expires = Timestamp{Seconds(0)};
return response;
};
NetworkStatus::Set(NetworkStatus::Status::Offline);
const std::string prefix = "http://127.0.0.1:3000/";
std::shared_ptr<FileSource> dbfs =
FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{});
std::shared_ptr<FileSource> dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database,
ResourceOptions{});
dbfs->forward(Resource::style(prefix + "style.json"), expiredItem("style.json"), [] {});
dbfs->forward(Resource::source(prefix + "streets.json"), expiredItem("streets.json"), [] {});
dbfs->forward(Resource::spriteJSON(prefix + "sprite", 1.0), expiredItem("sprite.json"), [] {});
@@ -390,7 +394,7 @@ TEST(Map, SetStyleDefaultCamera) {
EXPECT_DOUBLE_EQ(*camera.zoom, 0.0);
EXPECT_DOUBLE_EQ(*camera.pitch, 0.0);
EXPECT_DOUBLE_EQ(*camera.bearing, 0.0);
EXPECT_EQ(*camera.center, LatLng {});
EXPECT_EQ(*camera.center, LatLng{});
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty-zoomed.json"));
camera = test.map.getCameraOptions();
@@ -439,13 +443,13 @@ TEST(Map, DefaultBoundOptions) {
}
TEST(Map, MapOptions) {
float pixelRatio { 2 };
MapTest<> test { pixelRatio, MapMode::Continuous };
float pixelRatio{2};
MapTest<> test{pixelRatio, MapMode::Continuous};
test.map.setNorthOrientation(NorthOrientation::Rightwards);
test.map.setConstrainMode(ConstrainMode::None);
test.map.setViewportMode(ViewportMode::FlippedY);
Size size = { 512, 512 };
Size size = {512, 512};
test.map.setSize(size);
auto options = test.map.getMapOptions();
@@ -488,8 +492,9 @@ TEST(Map, SetStyleInvalidJSON) {
auto observer = Log::removeObserver();
auto flo = static_cast<FixtureLogObserver*>(observer.get());
EXPECT_EQ(1u, flo->count({ EventSeverity::Error, Event::ParseStyle, -1,
"Failed to parse style: Invalid value. at offset 0" }));
EXPECT_EQ(
1u,
flo->count({EventSeverity::Error, Event::ParseStyle, -1, "Failed to parse style: Invalid value. at offset 0"}));
auto unchecked = flo->unchecked();
EXPECT_TRUE(unchecked.empty()) << unchecked;
}
@@ -497,11 +502,9 @@ TEST(Map, SetStyleInvalidJSON) {
TEST(Map, SetStyleInvalidURL) {
MapTest<> test;
test.fileSource->styleResponse = [] (const Resource&) {
test.fileSource->styleResponse = [](const Resource&) {
Response response;
response.error = std::make_unique<Response::Error>(
Response::Error::Reason::Other,
"Failed by the test case");
response.error = std::make_unique<Response::Error>(Response::Error::Reason::Other, "Failed by the test case");
return response;
};
@@ -554,19 +557,20 @@ TEST(Map, StyleExpired) {
test.fileSource->respond(Resource::Style, response);
EXPECT_EQ(1u, test.fileSource->requests.size());
// Mutate layer. From now on, sending a response to the style won't overwrite it anymore, but
// we should continue to wait for a fresh response.
// Mutate layer. From now on, sending a response to the style won't
// overwrite it anymore, but we should continue to wait for a fresh
// response.
test.map.getStyle().addLayer(std::make_unique<style::BackgroundLayer>("bg"));
EXPECT_EQ(1u, test.fileSource->requests.size());
// Send another expired response, and confirm that we didn't overwrite the style, but continue
// to wait for a fresh response.
// Send another expired response, and confirm that we didn't overwrite the
// style, but continue to wait for a fresh response.
test.fileSource->respond(Resource::Style, response);
EXPECT_EQ(1u, test.fileSource->requests.size());
EXPECT_NE(nullptr, test.map.getStyle().getLayer("bg"));
// Send a fresh response, and confirm that we didn't overwrite the style, but continue to wait
// for a fresh response.
// Send a fresh response, and confirm that we didn't overwrite the style,
// but continue to wait for a fresh response.
response.expires = util::now() + 1h;
test.fileSource->respond(Resource::Style, response);
EXPECT_EQ(1u, test.fileSource->requests.size());
@@ -590,7 +594,7 @@ TEST(Map, StyleExpiredWithAnnotations) {
test.fileSource->respond(Resource::Style, response);
EXPECT_EQ(1u, test.fileSource->requests.size());
test.map.addAnnotation(LineAnnotation { LineString<double> {{ { 0, 0 }, { 10, 10 } }} });
test.map.addAnnotation(LineAnnotation{LineString<double>{{{0, 0}, {10, 10}}}});
EXPECT_EQ(1u, test.fileSource->requests.size());
test.fileSource->respond(Resource::Style, response);
@@ -649,7 +653,7 @@ TEST(Map, MapLoadingSignal) {
}
TEST(Map, MapLoadedSignal) {
MapTest<> test { 1, MapMode::Continuous };
MapTest<> test{1, MapMode::Continuous};
test.observer.didFinishLoadingMapCallback = [&]() {
test.runLoop.stop();
@@ -703,9 +707,7 @@ TEST(Map, TEST_REQUIRES_SERVER(StyleNotFound)) {
};
test.observer.didFailLoadingMapCallback = [&]() {
timer.start(Milliseconds(1100), 0s, [&] {
test.runLoop.stop();
});
timer.start(Milliseconds(1100), 0s, [&] { test.runLoop.stop(); });
};
test.runLoop.run();
@@ -721,7 +723,7 @@ TEST(Map, AddLayer) {
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
auto layer = std::make_unique<BackgroundLayer>("background");
layer->setBackgroundColor({ { 1, 0, 0, 1 } });
layer->setBackgroundColor({{1, 0, 0, 1}});
test.map.getStyle().addLayer(std::move(layer));
test::checkImage("test/fixtures/map/add_layer", test.frontend.render(test.map).image);
@@ -733,7 +735,7 @@ TEST(Map, RemoveLayer) {
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
auto layer = std::make_unique<BackgroundLayer>("background");
layer->setBackgroundColor({{ 1, 0, 0, 1 }});
layer->setBackgroundColor({{1, 0, 0, 1}});
test.map.getStyle().addLayer(std::move(layer));
test.map.getStyle().removeLayer("background");
@@ -744,7 +746,7 @@ TEST(Map, DisabledSources) {
MapTest<> test;
// Always load the same image tile for raster layers.
test.fileSource->response = [] (const Resource& res) -> std::optional<Response> {
test.fileSource->response = [](const Resource& res) -> std::optional<Response> {
if (res.url == "asset://tile.png") {
Response response;
response.data = std::make_shared<std::string>(
@@ -756,11 +758,13 @@ TEST(Map, DisabledSources) {
test.map.jumpTo(CameraOptions().withZoom(1.0));
// This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0.
// We first render a map at zoom level 1, which should show both layers (both are "visible" due
// to an opacity of 0.5). Then, we are zooming back out to a zoom level of 0.5 and rerender.
// The "raster1" layer should not be visible anymore since it has minzoom 1, while "raster2"
// should still be there. Both layers have a distinct color through "raster-hue-rotate".
// This stylesheet has two raster layers, one that starts at zoom 1, the
// other at zoom 0. We first render a map at zoom level 1, which should show
// both layers (both are "visible" due to an opacity of 0.5). Then, we are
// zooming back out to a zoom level of 0.5 and rerender. The "raster1" layer
// should not be visible anymore since it has minzoom 1, while "raster2"
// should still be there. Both layers have a distinct color through
// "raster-hue-rotate".
test.map.getStyle().loadJSON(R"STYLE(
{
"version": 8,
@@ -829,14 +833,15 @@ TEST(Map, DontLoadUnneededTiles) {
std::unordered_map<double, Tiles> referenceTiles = {
// Since the layer's minzoom is 0.3, we shouldn't load tiles before z0.3
{ 0.3, { "a/0/0/0" } },
{ 1.0, { "a/1/1/0", "a/1/0/1", "a/1/0/0", "a/1/1/1" } },
{0.3, {"a/0/0/0"}},
{1.0, {"a/1/1/0", "a/1/0/1", "a/1/0/0", "a/1/1/1"}},
// Since the layer's maxzoom is 1.6, we should never load z2 or z3 tiles.
};
// Loop through zoom levels from 0 to 3 and check that the correct tiles are loaded at every
// step. The source is marked with maxzoom 1.0, which means that it won't be visible anymore
// after z1.0, so we should under no circumstances attempt to load z2 tiles.
// Loop through zoom levels from 0 to 3 and check that the correct tiles are
// loaded at every step. The source is marked with maxzoom 1.0, which means
// that it won't be visible anymore after z1.0, so we should under no
// circumstances attempt to load z2 tiles.
for (unsigned zoom = 0; zoom <= 30; zoom++) { // times 10
// Note: using z += 0.1 in the loop doesn't produce accurate floating point numbers.
const double z = double(zoom) / 10;
@@ -863,16 +868,16 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
HeadlessFrontend frontend(1);
StubMapObserver observer;
observer.didFinishRenderingFrameCallback = [&] (MapObserver::RenderFrameStatus) {
// Start a timer that ends the test one second from now. If we are continuing to render
// indefinitely, the timer will be constantly restarted and never trigger. Instead, the
// emergency shutoff above will trigger, failing the test.
timer.start(1s, 0s, [&] {
runLoop.stop();
});
observer.didFinishRenderingFrameCallback = [&](MapObserver::RenderFrameStatus) {
// Start a timer that ends the test one second from now. If we are
// continuing to render indefinitely, the timer will be constantly
// restarted and never trigger. Instead, the emergency shutoff above
// will trigger, failing the test.
timer.start(1s, 0s, [&] { runLoop.stop(); });
};
Map map(frontend, observer,
Map map(frontend,
observer,
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
@@ -889,8 +894,8 @@ TEST(Map, NoContentTiles) {
Response response;
response.noContent = true;
response.expires = util::now() + 1h;
std::shared_ptr<FileSource> dbfs =
FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{});
std::shared_ptr<FileSource> dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database,
ResourceOptions{});
dbfs->forward(
Resource::tile("http://example.com/{z}-{x}-{y}.vector.pbf", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response, [&] {
test.map.getStyle().loadJSON(R"STYLE({
@@ -921,7 +926,7 @@ TEST(Map, NoContentTiles) {
// https://github.com/mapbox/mapbox-gl-native/issues/12432
TEST(Map, Issue12432) {
MapTest<> test { 1, MapMode::Continuous };
MapTest<> test{1, MapMode::Continuous};
test.fileSource->tileResponse = [&](const Resource&) {
Response result;
@@ -970,7 +975,7 @@ TEST(Map, Issue12432) {
// https://github.com/mapbox/mapbox-gl-native/issues/15216
TEST(Map, Issue15216) {
MapTest<> test { 1.0f, MapMode::Continuous };
MapTest<> test{1.0f, MapMode::Continuous};
test.map.getStyle().addSource(std::make_unique<ImageSource>("ImageSource", std::array<LatLng, 4>()));
test.map.getStyle().addLayer(std::make_unique<RasterLayer>("RasterLayer", "ImageSource"));
// Passes, if there is no assertion hit.
@@ -978,9 +983,10 @@ TEST(Map, Issue15216) {
}
// https://github.com/mapbox/mapbox-gl-native/issues/15342
// Tests the fix for constant repaint caused by `RenderSource::hasFadingTiles()` returning `true` all the time.
// Tests the fix for constant repaint caused by `RenderSource::hasFadingTiles()`
// returning `true` all the time.
TEST(Map, Issue15342) {
MapTest<> test { 1, MapMode::Continuous };
MapTest<> test{1, MapMode::Continuous};
test.fileSource->tileResponse = [&](const Resource&) {
Response result;
@@ -1016,7 +1022,7 @@ TEST(Map, Issue15342) {
"layers": []
})STYLE");
test.map.jumpTo(CameraOptions().withZoom(20.0));
test.observer.didFinishRenderingFrameCallback = [&] (MapObserver::RenderFrameStatus status) {
test.observer.didFinishRenderingFrameCallback = [&](MapObserver::RenderFrameStatus status) {
if (!status.needsRepaint) {
test.runLoop.stop();
}
@@ -1204,7 +1210,8 @@ TEST(Map, PrefetchDeltaOverride) {
// Custom source
CustomGeometrySource::Options options;
options.cancelTileFunction = [](const CanonicalTileID&) {};
options.cancelTileFunction = [](const CanonicalTileID&) {
};
options.fetchTileFunction = [&requestedTiles, &test](const CanonicalTileID& tileID) {
++requestedTiles;
auto* customSrc = static_cast<CustomGeometrySource*>(test.map.getStyle().getSource("custom"));
@@ -1217,7 +1224,9 @@ TEST(Map, PrefetchDeltaOverride) {
test.map.getStyle().addSource(std::move(customSource));
test.map.jumpTo(CameraOptions().withZoom(double(16)));
test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
test.observer.didFinishLoadingMapCallback = [&] {
test.runLoop.stop();
};
test.runLoop.run();
// 2 sources x 4 tiles
EXPECT_EQ(8, requestedTiles);
@@ -1260,7 +1269,8 @@ TEST(Map, PrefetchDeltaOverrideCustomSource) {
auto makeCustomSource = [&requestedTiles, &test] {
CustomGeometrySource::Options options;
options.cancelTileFunction = [](const CanonicalTileID&) {};
options.cancelTileFunction = [](const CanonicalTileID&) {
};
options.fetchTileFunction = [&requestedTiles, &test](const CanonicalTileID& tileID) {
++requestedTiles;
auto* source = static_cast<CustomGeometrySource*>(test.map.getStyle().getSource("custom"));
@@ -1276,7 +1286,9 @@ TEST(Map, PrefetchDeltaOverrideCustomSource) {
test.map.getStyle().addSource(std::move(customSource));
test.map.jumpTo(CameraOptions().withZoom(double(16)));
test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
test.observer.didFinishLoadingMapCallback = [&] {
test.runLoop.stop();
};
test.runLoop.run();
EXPECT_EQ(4, requestedTiles);
requestedTiles = 0;
@@ -1293,8 +1305,8 @@ TEST(Map, PrefetchDeltaOverrideCustomSource) {
test.map.getStyle().addSource(makeCustomSource());
test.runLoop.run();
// Source was significantly mutated, therefore, tile pyramid would be cleared
// and current zoom level + parent tiles would be re-requested.
// Source was significantly mutated, therefore, tile pyramid would be
// cleared and current zoom level + parent tiles would be re-requested.
EXPECT_EQ(8, requestedTiles);
}
@@ -1330,13 +1342,15 @@ TEST(Map, TEST_REQUIRES_SERVER(ExpiredSpriteSheet)) {
NetworkStatus::Set(NetworkStatus::Status::Online);
test.observer.didBecomeIdleCallback = [&test] { test.runLoop.stop(); };
test.observer.didBecomeIdleCallback = [&test] {
test.runLoop.stop();
};
};
NetworkStatus::Set(NetworkStatus::Status::Offline);
const std::string prefix = "http://127.0.0.1:3000/online/";
std::shared_ptr<FileSource> dbfs =
FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{});
std::shared_ptr<FileSource> dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database,
ResourceOptions{});
dbfs->forward(Resource::style(prefix + "style.json"), makeResponse("style.json"), [] {});
dbfs->forward(Resource::source(prefix + "streets.json"), makeResponse("streets.json"), [] {});
dbfs->forward(Resource::spriteJSON(prefix + "sprite", 1.0), makeResponse("sprite.json", true), [] {});
@@ -1398,7 +1412,9 @@ TEST(Map, SourceMinimumUpdateIntervalOverride) {
};
test.map.jumpTo(CameraOptions().withZoom(double(16)));
test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
test.observer.didFinishLoadingMapCallback = [&] {
test.runLoop.stop();
};
test.runLoop.run();
EXPECT_EQ(8, requestedTilesA);
@@ -1473,7 +1489,7 @@ TEST(Map, DISABLED_PlacedSymbolData) {
// Camera options will give exactly one tile (12/1171/1566)
test.map.jumpTo(CameraOptions().withZoom(16).withCenter(LatLng{50.072317, 14.444827}));
test.map.getStyle().loadURL("maptiler://maps/streets");
Size viewportSize = test.frontend.getSize();
test.frontend.getRenderer()->collectPlacedSymbolData(true);
@@ -1558,7 +1574,9 @@ TEST(Map, VolatileSource) {
test.map.getStyle().addSource(std::move(source));
test.map.jumpTo(CameraOptions().withZoom(16.0));
test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
test.observer.didFinishLoadingMapCallback = [&] {
test.runLoop.stop();
};
test.runLoop.run();
EXPECT_EQ(8, requestedTiles);
}
@@ -1573,10 +1591,10 @@ TEST(Map, ObserveShaderRegistration) {
test.map.jumpTo(CameraOptions().withZoom(10));
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
test.frontend.render(test.map);
EXPECT_EQ(observedRegistry, true);
// Should not see it again
observedRegistry = false;
test.frontend.render(test.map);