summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/api/annotations.test.cpp14
-rw-r--r--test/api/api_misuse.test.cpp8
-rw-r--r--test/api/custom_layer.test.cpp2
-rw-r--r--test/api/query.test.cpp2
-rw-r--r--test/api/render_missing.test.cpp4
-rw-r--r--test/api/repeated_render.test.cpp16
-rw-r--r--test/map/map.test.cpp34
-rw-r--r--test/map/transform.test.cpp36
-rw-r--r--test/sprite/sprite_atlas.test.cpp44
-rw-r--r--test/sprite/sprite_image.test.cpp18
-rw-r--r--test/sprite/sprite_parser.test.cpp32
-rw-r--r--test/src/mbgl/test/util.cpp13
-rw-r--r--test/style/source.test.cpp2
-rw-r--r--test/tile/tile_coordinate.test.cpp3
-rw-r--r--test/util/image.test.cpp18
-rw-r--r--test/util/memory.test.cpp16
-rw-r--r--test/util/offscreen_texture.test.cpp6
-rw-r--r--test/util/tile_cover.test.cpp2
18 files changed, 134 insertions, 136 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index 2c875796bd..06a0a61b0a 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -27,7 +27,7 @@ public:
OffscreenView view{ backend.getContext() };
StubFileSource fileSource;
ThreadPool threadPool { 4 };
- Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still };
+ Map map { backend, view.size, 1, fileSource, threadPool, MapMode::Still };
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/annotations/") + name,
@@ -45,8 +45,8 @@ TEST(Annotations, SymbolAnnotation) {
test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" });
test.checkRendering("point_annotation");
- auto size = test.view.getSize();
- auto screenBox = ScreenBox { {}, { double(size[0]), double(size[1]) } };
+ auto size = test.view.size;
+ auto screenBox = ScreenBox { {}, { double(size.width), double(size.height) } };
auto features = test.map.queryPointAnnotations(screenBox);
EXPECT_EQ(features.size(), 1u);
@@ -354,8 +354,8 @@ TEST(Annotations, QueryRenderedFeatures) {
TEST(Annotations, QueryFractionalZoomLevels) {
AnnotationTest test;
- auto viewSize = test.view.getSize();
- auto box = ScreenBox { {}, { double(viewSize[0]), double(viewSize[1]) } };
+ auto viewSize = test.view.size;
+ auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } };
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
@@ -386,8 +386,8 @@ TEST(Annotations, QueryFractionalZoomLevels) {
TEST(Annotations, VisibleFeatures) {
AnnotationTest test;
- auto viewSize = test.view.getSize();
- auto box = ScreenBox { {}, { double(viewSize[0]), double(viewSize[1]) } };
+ auto viewSize = test.view.size;
+ auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } };
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp
index eb271b0258..50a8f38c33 100644
--- a/test/api/api_misuse.test.cpp
+++ b/test/api/api_misuse.test.cpp
@@ -21,12 +21,12 @@ TEST(API, RenderWithoutCallback) {
util::RunLoop loop;
HeadlessBackend backend;
- OffscreenView view(backend.getContext(), {{ 128, 512 }});
+ OffscreenView view(backend.getContext(), { 128, 512 });
StubFileSource fileSource;
ThreadPool threadPool(4);
std::unique_ptr<Map> map =
- std::make_unique<Map>(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still);
+ std::make_unique<Map>(backend, view.size, 1, fileSource, threadPool, MapMode::Still);
map->renderStill(view, nullptr);
// Force Map thread to join.
@@ -46,11 +46,11 @@ TEST(API, RenderWithoutStyle) {
util::RunLoop loop;
HeadlessBackend backend;
- OffscreenView view(backend.getContext(), {{ 128, 512 }});
+ OffscreenView view(backend.getContext(), { 128, 512 });
StubFileSource fileSource;
ThreadPool threadPool(4);
- Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view.size, 1, fileSource, threadPool, MapMode::Still);
std::exception_ptr error;
map.renderStill(view, [&](std::exception_ptr error_) {
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp
index 70de102b80..9d4ba04cee 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -97,7 +97,7 @@ TEST(CustomLayer, Basic) {
ThreadPool threadPool(4);
- Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view.size, 1, fileSource, threadPool, MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/water.json"));
map.setLatLngZoom({ 37.8, -122.5 }, 10);
map.addLayer(std::make_unique<CustomLayer>(
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index 8e59c19afc..d3c233ad34 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -30,7 +30,7 @@ public:
OffscreenView view { backend.getContext() };
StubFileSource fileSource;
ThreadPool threadPool { 4 };
- Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still };
+ Map map { backend, view.size, 1, fileSource, threadPool, MapMode::Still };
};
} // end namespace
diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp
index 366d71e67d..b24d59ab21 100644
--- a/test/api/render_missing.test.cpp
+++ b/test/api/render_missing.test.cpp
@@ -26,7 +26,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
const auto style = util::read_file("test/fixtures/api/water_missing_tiles.json");
HeadlessBackend backend;
- OffscreenView view(backend.getContext(), {{ 256, 512 }});
+ OffscreenView view(backend.getContext(), { 256, 512 });
#ifdef MBGL_ASSET_ZIP
// Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/`
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip");
@@ -38,7 +38,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
Log::setObserver(std::make_unique<FixtureLogObserver>());
- Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view.size, 1, fileSource, threadPool, MapMode::Still);
std::string message;
diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp
index 715b49b289..1bea05b1fb 100644
--- a/test/api/repeated_render.test.cpp
+++ b/test/api/repeated_render.test.cpp
@@ -20,7 +20,7 @@ TEST(API, RepeatedRender) {
const auto style = util::read_file("test/fixtures/api/water.json");
HeadlessBackend backend;
- OffscreenView view(backend.getContext(), {{ 256, 512 }});
+ OffscreenView view(backend.getContext(), { 256, 512 });
#ifdef MBGL_ASSET_ZIP
// Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/`
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip");
@@ -32,7 +32,7 @@ TEST(API, RepeatedRender) {
Log::setObserver(std::make_unique<FixtureLogObserver>());
- Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view.size, 1, fileSource, threadPool, MapMode::Still);
{
map.setStyleJSON(style);
@@ -41,12 +41,12 @@ TEST(API, RepeatedRender) {
result = view.readStillImage();
});
- while (!result.size()) {
+ while (!result.valid()) {
loop.runOnce();
}
- ASSERT_EQ(256u, result.width);
- ASSERT_EQ(512u, result.height);
+ ASSERT_EQ(256u, result.size.width);
+ ASSERT_EQ(512u, result.size.height);
#if !TEST_READ_ONLY
util::write_file("test/fixtures/api/1.png", encodePNG(result));
#endif
@@ -59,12 +59,12 @@ TEST(API, RepeatedRender) {
result = view.readStillImage();
});
- while (!result.size()) {
+ while (!result.valid()) {
loop.runOnce();
}
- ASSERT_EQ(256u, result.width);
- ASSERT_EQ(512u, result.height);
+ ASSERT_EQ(256u, result.size.width);
+ ASSERT_EQ(512u, result.size.height);
#if !TEST_READ_ONLY
util::write_file("test/fixtures/api/2.png", encodePNG(result));
#endif
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index f6b37d6bc2..a62bd10b57 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -30,7 +30,7 @@ struct MapTest {
TEST(Map, LatLngBehavior) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
@@ -64,7 +64,7 @@ TEST(Map, Offline) {
fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf"));
NetworkStatus::Set(NetworkStatus::Status::Offline);
- Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
map.setStyleURL(prefix + "style.json");
test::checkImage("test/fixtures/map/offline",
@@ -88,7 +88,7 @@ TEST(Map, SetStyleInvalidJSON) {
});
{
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool,
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool,
MapMode::Still);
map.setStyleJSON("invalid");
}
@@ -120,7 +120,7 @@ TEST(Map, SetStyleInvalidURL) {
}
});
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://bar");
test.runLoop.run();
@@ -129,7 +129,7 @@ TEST(Map, SetStyleInvalidURL) {
TEST(Map, DoubleStyleLoad) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleJSON("");
map.setStyleJSON("");
}
@@ -140,7 +140,7 @@ TEST(Map, StyleFresh) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://styles/test");
EXPECT_EQ(1u, fileSource.requests.size());
@@ -160,7 +160,7 @@ TEST(Map, StyleExpired) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://styles/test");
EXPECT_EQ(1u, fileSource.requests.size());
@@ -187,7 +187,7 @@ TEST(Map, StyleExpiredWithAnnotations) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://styles/test");
EXPECT_EQ(1u, fileSource.requests.size());
@@ -211,7 +211,7 @@ TEST(Map, StyleEarlyMutation) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://styles/test");
map.addLayer(std::make_unique<style::BackgroundLayer>("bg"));
@@ -225,7 +225,7 @@ TEST(Map, StyleEarlyMutation) {
TEST(Map, StyleLoadedSignal) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
// The map should emit a signal on style loaded
bool emitted = false;
@@ -246,7 +246,7 @@ TEST(Map, StyleLoadedSignal) {
TEST(Map, AddLayer) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
auto layer = std::make_unique<BackgroundLayer>("background");
@@ -259,7 +259,7 @@ TEST(Map, AddLayer) {
TEST(Map, RemoveLayer) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
auto layer = std::make_unique<BackgroundLayer>("background");
@@ -284,7 +284,7 @@ TEST(Map, DisabledSources) {
return {};
};
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setZoom(1);
// This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0.
@@ -334,7 +334,7 @@ TEST(Map, DisabledSources) {
TEST(Map, Classes) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
EXPECT_FALSE(map.getTransitionOptions().duration);
@@ -368,7 +368,7 @@ TEST(Map, Classes) {
TEST(Map, AddImage) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
auto decoded1 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
auto decoded2 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
auto image1 = std::make_unique<SpriteImage>(std::move(decoded1), 1.0);
@@ -385,7 +385,7 @@ TEST(Map, AddImage) {
TEST(Map, RemoveImage) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0);
@@ -398,7 +398,7 @@ TEST(Map, RemoveImage) {
TEST(Map, DontLoadUnneededTiles) {
MapTest test;
- Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleJSON(R"STYLE({
"sources": {
"a": { "type": "vector", "tiles": [ "a/{z}/{x}/{y}" ] }
diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp
index afb655abca..5c720d3f78 100644
--- a/test/map/transform.test.cpp
+++ b/test/map/transform.test.cpp
@@ -107,7 +107,7 @@ TEST(Transform, PerspectiveProjection) {
LatLng loc;
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
transform.setScale(2 << 9);
transform.setPitch(0.9);
transform.setLatLng(LatLng(38, -77));
@@ -137,7 +137,7 @@ TEST(Transform, PerspectiveProjection) {
TEST(Transform, UnwrappedLatLng) {
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
transform.setScale(2 << 9);
transform.setPitch(0.9);
transform.setLatLng(LatLng(38, -77));
@@ -169,7 +169,7 @@ TEST(Transform, ConstrainHeightOnly) {
LatLng loc;
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
transform.setScale(std::pow(2, util::MAX_ZOOM));
transform.setLatLng(LatLngBounds::world().southwest());
@@ -187,7 +187,7 @@ TEST(Transform, ConstrainWidthAndHeight) {
LatLng loc;
Transform transform(nullptr, ConstrainMode::WidthAndHeight);
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
transform.setScale(std::pow(2, util::MAX_ZOOM));
transform.setLatLng(LatLngBounds::world().southwest());
@@ -203,7 +203,7 @@ TEST(Transform, ConstrainWidthAndHeight) {
TEST(Transform, Anchor) {
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
const LatLng latLng { 10, -100 };
transform.setLatLngZoom(latLng, 10);
@@ -303,7 +303,7 @@ TEST(Transform, Anchor) {
TEST(Transform, Padding) {
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
ASSERT_DOUBLE_EQ(0, transform.getLatLng().latitude);
ASSERT_DOUBLE_EQ(0, transform.getLatLng().longitude);
@@ -340,7 +340,7 @@ TEST(Transform, Padding) {
TEST(Transform, MoveBy) {
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
transform.setLatLngZoom({ 0, 0 }, 10);
LatLng trueCenter = transform.getLatLng();
@@ -367,7 +367,7 @@ TEST(Transform, MoveBy) {
TEST(Transform, Antimeridian) {
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
transform.setLatLngZoom({ 0, 0 }, 1);
const LatLng coordinateSanFrancisco { 37.7833, -122.4167 };
@@ -410,7 +410,7 @@ TEST(Transform, Antimeridian) {
TEST(Transform, Camera) {
Transform transform;
- transform.resize({{ 1000, 1000 }});
+ transform.resize({ 1000, 1000 });
const LatLng latLng1 { 45, 135 };
CameraOptions cameraOptions1;
@@ -481,8 +481,8 @@ TEST(Transform, DefaultTransform) {
LatLng nullIsland, latLng = {};
ScreenCoordinate center, point = {};
- const uint16_t min = std::numeric_limits<uint16_t>::min();
- const uint16_t max = std::numeric_limits<uint16_t>::max();
+ const uint32_t min = 0;
+ const uint32_t max = 65535;
auto testConversions = [&](const LatLng& coord, const ScreenCoordinate& screenCoord) {
latLng = state.screenCoordinateToLatLng(center);
@@ -496,21 +496,21 @@ TEST(Transform, DefaultTransform) {
testConversions(nullIsland, center);
// Cannot assign the current size.
- ASSERT_FALSE(transform.resize({{}}));
+ ASSERT_FALSE(transform.resize({}));
- ASSERT_TRUE(transform.resize({{ min, max }}));
+ ASSERT_TRUE(transform.resize({ min, max }));
testConversions(nullIsland, center);
- ASSERT_TRUE(transform.resize({{ max, min }}));
+ ASSERT_TRUE(transform.resize({ max, min }));
testConversions(nullIsland, center);
- ASSERT_TRUE(transform.resize({{ min, min }}));
+ ASSERT_TRUE(transform.resize({ min, min }));
testConversions(nullIsland, center);
center = { max / 2., max / 2. };
- // -1 evaluates to UINT_MAX.
- ASSERT_TRUE(transform.resize({{ static_cast<uint16_t>(-1), static_cast<uint16_t>(-1) }}));
- ASSERT_FALSE(transform.resize({{ max, max }}));
+ // Double resize
+ ASSERT_TRUE(transform.resize({ max, max }));
+ ASSERT_FALSE(transform.resize({ max, max }));
testConversions(nullIsland, center);
}
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp
index f84e17cbcf..231e2b1246 100644
--- a/test/sprite/sprite_atlas.test.cpp
+++ b/test/sprite/sprite_atlas.test.cpp
@@ -26,7 +26,7 @@ auto imageFromAtlas(const SpriteAtlas& atlas) {
auto data = std::make_unique<uint8_t[]>(bytes);
const auto src = reinterpret_cast<const uint8_t*>(atlas.getData());
std::copy(src, src + bytes, data.get());
- return PremultipliedImage{ atlas.getTextureWidth(), atlas.getTextureHeight(), std::move(data) };
+ return PremultipliedImage{ { atlas.getTextureWidth(), atlas.getTextureHeight() }, std::move(data) };
}
} // namespace
@@ -56,8 +56,8 @@ TEST(SpriteAtlas, Basic) {
EXPECT_EQ(20, metro.pos.h);
EXPECT_EQ(18, metro.spriteImage->getWidth());
EXPECT_EQ(18, metro.spriteImage->getHeight());
- EXPECT_EQ(18u, metro.spriteImage->image.width);
- EXPECT_EQ(18u, metro.spriteImage->image.height);
+ EXPECT_EQ(18u, metro.spriteImage->image.size.width);
+ EXPECT_EQ(18u, metro.spriteImage->image.size.height);
EXPECT_EQ(1.0f, metro.spriteImage->pixelRatio);
EXPECT_TRUE(atlas.getData());
@@ -110,8 +110,8 @@ TEST(SpriteAtlas, Size) {
EXPECT_EQ(16, metro.pos.h);
EXPECT_EQ(18, metro.spriteImage->getWidth());
EXPECT_EQ(18, metro.spriteImage->getHeight());
- EXPECT_EQ(18u, metro.spriteImage->image.width);
- EXPECT_EQ(18u, metro.spriteImage->image.height);
+ EXPECT_EQ(18u, metro.spriteImage->image.size.width);
+ EXPECT_EQ(18u, metro.spriteImage->image.size.height);
EXPECT_EQ(1.0f, metro.spriteImage->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteatlassize.png"),
@@ -127,7 +127,7 @@ TEST(SpriteAtlas, Updates) {
EXPECT_EQ(32, atlas.getTextureWidth());
EXPECT_EQ(32, atlas.getTextureHeight());
- atlas.setSprite("one", std::make_shared<SpriteImage>(PremultipliedImage(16, 12), 1));
+ atlas.setSprite("one", std::make_shared<SpriteImage>(PremultipliedImage({ 16, 12 }), 1));
auto one = *atlas.getImage("one", SpritePatternMode::Single);
EXPECT_EQ(0, one.pos.x);
EXPECT_EQ(0, one.pos.y);
@@ -135,16 +135,16 @@ TEST(SpriteAtlas, Updates) {
EXPECT_EQ(16, one.pos.h);
EXPECT_EQ(16, one.spriteImage->getWidth());
EXPECT_EQ(12, one.spriteImage->getHeight());
- EXPECT_EQ(16u, one.spriteImage->image.width);
- EXPECT_EQ(12u, one.spriteImage->image.height);
+ EXPECT_EQ(16u, one.spriteImage->image.size.width);
+ EXPECT_EQ(12u, one.spriteImage->image.size.height);
EXPECT_EQ(1.0f, one.spriteImage->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteatlas-empty.png"),
imageFromAtlas(atlas));
// Update sprite
- PremultipliedImage image2(16, 12);
- for (size_t i = 0; i < image2.size(); i++) {
+ PremultipliedImage image2({ 16, 12 });
+ for (size_t i = 0; i < image2.bytes(); i++) {
image2.data.get()[i] = 255;
}
auto newSprite = std::make_shared<SpriteImage>(std::move(image2), 1);
@@ -165,9 +165,9 @@ TEST(SpriteAtlas, Updates) {
TEST(SpriteAtlas, AddRemove) {
FixtureLog log;
- const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
- const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
- const auto sprite3 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
+ const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
+ const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
+ const auto sprite3 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
SpriteAtlas atlas(32, 32, 1);
@@ -210,7 +210,7 @@ TEST(SpriteAtlas, AddRemove) {
TEST(SpriteAtlas, OtherPixelRatio) {
FixtureLog log;
- const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage(8, 8), 1);
+ const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage({ 8, 8 }), 1);
SpriteAtlas atlas(32, 32, 1);
@@ -219,8 +219,8 @@ TEST(SpriteAtlas, OtherPixelRatio) {
}
TEST(SpriteAtlas, Multiple) {
- const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
- const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
+ const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
+ const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
SpriteAtlas atlas(32, 32, 1);
@@ -232,8 +232,8 @@ TEST(SpriteAtlas, Multiple) {
TEST(SpriteAtlas, Replace) {
FixtureLog log;
- const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
- const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
+ const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
+ const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
SpriteAtlas atlas(32, 32, 1);
@@ -246,10 +246,10 @@ TEST(SpriteAtlas, Replace) {
TEST(SpriteAtlas, ReplaceWithDifferentDimensions) {
FixtureLog log;
- PremultipliedImage image(16, 16);
- PremultipliedImage image2(18, 18);
- const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage(16, 16), 2);
- const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage(18, 18), 2);
+ PremultipliedImage image({ 16, 16 });
+ PremultipliedImage image2({ 18, 18 });
+ const auto sprite1 = std::make_shared<SpriteImage>(PremultipliedImage({ 16, 16 }), 2);
+ const auto sprite2 = std::make_shared<SpriteImage>(PremultipliedImage({ 18, 18 }), 2);
SpriteAtlas atlas(32, 32, 1);
diff --git a/test/sprite/sprite_image.test.cpp b/test/sprite/sprite_image.test.cpp
index f8982826a3..97a37513ac 100644
--- a/test/sprite/sprite_image.test.cpp
+++ b/test/sprite/sprite_image.test.cpp
@@ -7,7 +7,7 @@
using namespace mbgl;
TEST(Sprite, SpriteImageZeroWidth) {
- PremultipliedImage image(0, 16);
+ PremultipliedImage image({ 0, 16 });
try {
SpriteImage(std::move(image), 2.0);
FAIL() << "Expected exception";
@@ -17,7 +17,7 @@ TEST(Sprite, SpriteImageZeroWidth) {
}
TEST(Sprite, SpriteImageZeroHeight) {
- PremultipliedImage image(16, 0);
+ PremultipliedImage image({ 16, 0 });
try {
SpriteImage(std::move(image), 2.0);
FAIL() << "Expected exception";
@@ -27,7 +27,7 @@ TEST(Sprite, SpriteImageZeroHeight) {
}
TEST(Sprite, SpriteImageZeroRatio) {
- PremultipliedImage image(16, 16);
+ PremultipliedImage image({ 16, 16 });
try {
SpriteImage(std::move(image), 0.0);
FAIL() << "Expected exception";
@@ -37,21 +37,21 @@ TEST(Sprite, SpriteImageZeroRatio) {
}
TEST(Sprite, SpriteImage) {
- PremultipliedImage image(32, 24);
+ PremultipliedImage image({ 32, 24 });
SpriteImage sprite(std::move(image), 2.0);
EXPECT_EQ(16, sprite.getWidth());
- EXPECT_EQ(32u, sprite.image.width);
+ EXPECT_EQ(32u, sprite.image.size.width);
EXPECT_EQ(12, sprite.getHeight());
- EXPECT_EQ(24u, sprite.image.height);
+ EXPECT_EQ(24u, sprite.image.size.height);
EXPECT_EQ(2, sprite.pixelRatio);
}
TEST(Sprite, SpriteImageFractionalRatio) {
- PremultipliedImage image(20, 12);
+ PremultipliedImage image({ 20, 12 });
SpriteImage sprite(std::move(image), 1.5);
EXPECT_EQ(float(20.0 / 1.5), sprite.getWidth());
- EXPECT_EQ(20u, sprite.image.width);
+ EXPECT_EQ(20u, sprite.image.size.width);
EXPECT_EQ(float(12.0 / 1.5), sprite.getHeight());
- EXPECT_EQ(12u, sprite.image.height);
+ EXPECT_EQ(12u, sprite.image.size.height);
EXPECT_EQ(1.5, sprite.pixelRatio);
}
diff --git a/test/sprite/sprite_parser.test.cpp b/test/sprite/sprite_parser.test.cpp
index 8d32d081bf..7bedf7bc28 100644
--- a/test/sprite/sprite_parser.test.cpp
+++ b/test/sprite/sprite_parser.test.cpp
@@ -24,8 +24,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
const PremultipliedImage image_1x = decodeImage(util::read_file("test/fixtures/annotations/emerald.png"));
- ASSERT_EQ(200u, image_1x.width);
- ASSERT_EQ(299u, image_1x.height);
+ ASSERT_EQ(200u, image_1x.size.width);
+ ASSERT_EQ(299u, image_1x.size.height);
ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, 0, 16, 1, false)); // width == 0
ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, 16, 0, 1, false)); // height == 0
@@ -38,8 +38,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, 16, 1025, 1, false)); // too tall
ASSERT_EQ(nullptr, createSpriteImage(image_1x, -1, 0, 16, 16, 1, false)); // srcX < 0
ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, -1, 16, 16, 1, false)); // srcY < 0
- ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, image_1x.width + 1, 16, 1, false)); // right edge out of bounds
- ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, 16, image_1x.height + 1, 1, false)); // bottom edge out of bounds
+ ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, image_1x.size.width + 1, 16, 1, false)); // right edge out of bounds
+ ASSERT_EQ(nullptr, createSpriteImage(image_1x, 0, 0, 16, image_1x.size.height + 1, 1, false)); // bottom edge out of bounds
EXPECT_EQ(13u, log.count({
EventSeverity::Error,
@@ -52,16 +52,16 @@ TEST(Sprite, SpriteImageCreationInvalid) {
TEST(Sprite, SpriteImageCreation1x) {
const PremultipliedImage image_1x = decodeImage(util::read_file("test/fixtures/annotations/emerald.png"));
- ASSERT_EQ(200u, image_1x.width);
- ASSERT_EQ(299u, image_1x.height);
+ ASSERT_EQ(200u, image_1x.size.width);
+ ASSERT_EQ(299u, image_1x.size.height);
{ // "museum_icon":{"x":177,"y":187,"width":18,"height":18,"pixelRatio":1,"sdf":false}
const auto sprite = createSpriteImage(image_1x, 177, 187, 18, 18, 1, false);
ASSERT_TRUE(sprite.get());
EXPECT_EQ(18, sprite->getWidth());
EXPECT_EQ(18, sprite->getHeight());
- EXPECT_EQ(18u, sprite->image.width);
- EXPECT_EQ(18u, sprite->image.height);
+ EXPECT_EQ(18u, sprite->image.size.width);
+ EXPECT_EQ(18u, sprite->image.size.height);
EXPECT_EQ(1, sprite->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation1x-museum.png"),
sprite->image);
@@ -76,8 +76,8 @@ TEST(Sprite, SpriteImageCreation2x) {
ASSERT_TRUE(sprite.get());
EXPECT_EQ(18, sprite->getWidth());
EXPECT_EQ(18, sprite->getHeight());
- EXPECT_EQ(36u, sprite->image.width);
- EXPECT_EQ(36u, sprite->image.height);
+ EXPECT_EQ(36u, sprite->image.size.width);
+ EXPECT_EQ(36u, sprite->image.size.height);
EXPECT_EQ(2, sprite->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation2x.png"),
sprite->image);
@@ -91,8 +91,8 @@ TEST(Sprite, SpriteImageCreation1_5x) {
ASSERT_TRUE(sprite.get());
EXPECT_EQ(24, sprite->getWidth());
EXPECT_EQ(24, sprite->getHeight());
- EXPECT_EQ(36u, sprite->image.width);
- EXPECT_EQ(36u, sprite->image.height);
+ EXPECT_EQ(36u, sprite->image.size.width);
+ EXPECT_EQ(36u, sprite->image.size.height);
EXPECT_EQ(1.5, sprite->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation1_5x-museum.png"),
sprite->image);
@@ -102,8 +102,8 @@ TEST(Sprite, SpriteImageCreation1_5x) {
ASSERT_TRUE(sprite2.get());
EXPECT_EQ(float(35 / 1.5), sprite2->getWidth());
EXPECT_EQ(float(35 / 1.5), sprite2->getHeight());
- EXPECT_EQ(35u, sprite2->image.width);
- EXPECT_EQ(35u, sprite2->image.height);
+ EXPECT_EQ(35u, sprite2->image.size.width);
+ EXPECT_EQ(35u, sprite2->image.size.height);
EXPECT_EQ(1.5, sprite2->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation1_5x-hospital.png"),
sprite2->image);
@@ -198,8 +198,8 @@ TEST(Sprite, SpriteParsing) {
auto sprite = images.find("generic-metro")->second;
EXPECT_EQ(18, sprite->getWidth());
EXPECT_EQ(18, sprite->getHeight());
- EXPECT_EQ(18u, sprite->image.width);
- EXPECT_EQ(18u, sprite->image.height);
+ EXPECT_EQ(18u, sprite->image.size.width);
+ EXPECT_EQ(18u, sprite->image.size.height);
EXPECT_EQ(1, sprite->pixelRatio);
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteparsing.png"), sprite->image);
}
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index 7f98c43dc9..2a82e0059f 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -104,7 +104,7 @@ PremultipliedImage render(Map& map, OffscreenView& view) {
result = view.readStillImage();
});
- while (!result.size()) {
+ while (!result.valid()) {
util::RunLoop::Get()->runOnce();
}
@@ -132,24 +132,23 @@ void checkImage(const std::string& base,
}
PremultipliedImage expected = decodeImage(expected_image);
- PremultipliedImage diff { expected.width, expected.height };
+ PremultipliedImage diff { expected.size };
#if !TEST_READ_ONLY
util::write_file(base + "/actual.png", encodePNG(actual));
#endif
- ASSERT_EQ(expected.width, actual.width);
- ASSERT_EQ(expected.height, actual.height);
+ ASSERT_EQ(expected.size, actual.size);
double pixels = mapbox::pixelmatch(actual.data.get(),
expected.data.get(),
- expected.width,
- expected.height,
+ expected.size.width,
+ expected.size.height,
diff.data.get(),
pixelThreshold);
- EXPECT_LE(pixels / (expected.width * expected.height), imageThreshold);
+ EXPECT_LE(pixels / (expected.size.width * expected.size.height), imageThreshold);
#if !TEST_READ_ONLY
util::write_file(base + "/diff.png", encodePNG(diff));
diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp
index 73908a144b..8d650ed17b 100644
--- a/test/style/source.test.cpp
+++ b/test/style/source.test.cpp
@@ -50,7 +50,7 @@ public:
// Squelch logging.
Log::setObserver(std::make_unique<Log::NullObserver>());
- transform.resize({{ 512, 512 }});
+ transform.resize({ 512, 512 });
transform.setLatLngZoom({0, 0}, 0);
transformState = transform.getState();
diff --git a/test/tile/tile_coordinate.test.cpp b/test/tile/tile_coordinate.test.cpp
index 740a03894d..4d58bf8c51 100644
--- a/test/tile/tile_coordinate.test.cpp
+++ b/test/tile/tile_coordinate.test.cpp
@@ -26,8 +26,7 @@ TEST(TileCoordinate, FromLatLng) {
Transform transform(onMapChange);
const double max = util::tileSize;
- const std::array<uint16_t, 2> size { { uint16_t(max), uint16_t(max) } };
- transform.resize(size);
+ transform.resize({ static_cast<uint32_t>(max), static_cast<uint32_t>(max) });
// Center, top-left, bottom-left, bottom-right, top-right edges.
std::vector<std::pair<LatLng, ScreenCoordinate>> edges {
diff --git a/test/util/image.test.cpp b/test/util/image.test.cpp
index b2814e66da..b15ddc1b3f 100644
--- a/test/util/image.test.cpp
+++ b/test/util/image.test.cpp
@@ -7,7 +7,7 @@
using namespace mbgl;
TEST(Image, PNGRoundTrip) {
- PremultipliedImage rgba { 1, 1 };
+ PremultipliedImage rgba({ 1, 1 });
rgba.data[0] = 128;
rgba.data[1] = 0;
rgba.data[2] = 0;
@@ -21,7 +21,7 @@ TEST(Image, PNGRoundTrip) {
}
TEST(Image, PNGRoundTripAlpha) {
- PremultipliedImage rgba { 1, 1 };
+ PremultipliedImage rgba({ 1, 1 });
rgba.data[0] = 128;
rgba.data[1] = 0;
rgba.data[2] = 0;
@@ -68,26 +68,26 @@ TEST(Image, PNGReadProfileAlpha) {
TEST(Image, PNGTile) {
PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/tile.png"));
- EXPECT_EQ(256u, image.width);
- EXPECT_EQ(256u, image.height);
+ EXPECT_EQ(256u, image.size.width);
+ EXPECT_EQ(256u, image.size.height);
}
TEST(Image, JPEGTile) {
PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/tile.jpeg"));
- EXPECT_EQ(256u, image.width);
- EXPECT_EQ(256u, image.height);
+ EXPECT_EQ(256u, image.size.width);
+ EXPECT_EQ(256u, image.size.height);
}
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
TEST(Image, WebPTile) {
PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/tile.webp"));
- EXPECT_EQ(256u, image.width);
- EXPECT_EQ(256u, image.height);
+ EXPECT_EQ(256u, image.size.width);
+ EXPECT_EQ(256u, image.size.height);
}
#endif // !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
TEST(Image, Premultiply) {
- UnassociatedImage rgba { 1, 1 };
+ UnassociatedImage rgba({ 1, 1 });
rgba.data[0] = 255;
rgba.data[1] = 254;
rgba.data[2] = 253;
diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp
index a1e47d6c2b..07927b43eb 100644
--- a/test/util/memory.test.cpp
+++ b/test/util/memory.test.cpp
@@ -57,7 +57,7 @@ public:
util::RunLoop runLoop;
HeadlessBackend backend;
- OffscreenView view{ backend.getContext(), {{ 512, 512 }} };
+ OffscreenView view{ backend.getContext(), { 512, 512 } };
StubFileSource fileSource;
ThreadPool threadPool { 4 };
@@ -93,7 +93,7 @@ private:
TEST(Memory, Vector) {
MemoryTest test;
- Map map(test.backend, { { 256, 256 } }, 2, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still);
map.setZoom(16); // more map features
map.setStyleURL("mapbox://streets");
@@ -103,7 +103,7 @@ TEST(Memory, Vector) {
TEST(Memory, Raster) {
MemoryTest test;
- Map map(test.backend, { { 256, 256 } }, 2, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still);
map.setStyleURL("mapbox://satellite");
test::render(map, test.view);
@@ -129,7 +129,7 @@ TEST(Memory, Footprint) {
// Warm up buffers and cache.
for (unsigned i = 0; i < 10; ++i) {
- Map map(test.backend, {{ 256, 256 }}, 2, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still);
renderMap(map, "mapbox://streets");
renderMap(map, "mapbox://satellite");
};
@@ -143,8 +143,8 @@ TEST(Memory, Footprint) {
long vectorInitialRSS = getRSS();
for (unsigned i = 0; i < runs; ++i) {
- auto vector = std::make_unique<Map>(test.backend, std::array<uint16_t, 2>{ { 256, 256 } },
- 2, test.fileSource, test.threadPool, MapMode::Still);
+ auto vector = std::make_unique<Map>(test.backend, Size{ 256, 256 }, 2, test.fileSource,
+ test.threadPool, MapMode::Still);
renderMap(*vector, "mapbox://streets");
maps.push_back(std::move(vector));
};
@@ -153,8 +153,8 @@ TEST(Memory, Footprint) {
long rasterInitialRSS = getRSS();
for (unsigned i = 0; i < runs; ++i) {
- auto raster = std::make_unique<Map>(test.backend, std::array<uint16_t, 2>{ { 256, 256 } },
- 2, test.fileSource, test.threadPool, MapMode::Still);
+ auto raster = std::make_unique<Map>(test.backend, Size{ 256, 256 }, 2, test.fileSource,
+ test.threadPool, MapMode::Still);
renderMap(*raster, "mapbox://satellite");
maps.push_back(std::move(raster));
};
diff --git a/test/util/offscreen_texture.test.cpp b/test/util/offscreen_texture.test.cpp
index bd4eab69a8..a1e444ed65 100644
--- a/test/util/offscreen_texture.test.cpp
+++ b/test/util/offscreen_texture.test.cpp
@@ -11,7 +11,7 @@ using namespace mbgl;
TEST(OffscreenTexture, EmptyRed) {
HeadlessBackend backend;
- OffscreenView view(backend.getContext(), {{ 512, 256 }});
+ OffscreenView view(backend.getContext(), { 512, 256 });
view.bind();
MBGL_CHECK_ERROR(glClearColor(1.0f, 0.0f, 0.0f, 1.0f));
@@ -106,7 +106,7 @@ void main() {
// Make sure the texture gets destructed before we call context.reset();
{
- OffscreenView view(context, {{ 512, 256 }});
+ OffscreenView view(context, { 512, 256 });
// First, draw red to the bound FBO.
context.clearColor = { 1, 0, 0, 1 };
@@ -115,7 +115,7 @@ void main() {
// Then, create a texture, bind it, and render yellow to that texture. This should not
// affect the originally bound FBO.
- OffscreenTexture texture(context, {{ 128, 128 }});
+ OffscreenTexture texture(context, { 128, 128 });
texture.bind();
context.clearColor = { 0, 0, 0, 0 };
diff --git a/test/util/tile_cover.test.cpp b/test/util/tile_cover.test.cpp
index cc183509d9..47440ff0b5 100644
--- a/test/util/tile_cover.test.cpp
+++ b/test/util/tile_cover.test.cpp
@@ -29,7 +29,7 @@ TEST(TileCover, WorldZ0) {
TEST(TileCover, Pitch) {
Transform transform;
- transform.resize({ { 512, 512 } });
+ transform.resize({ 512, 512 });
transform.setZoom(2);
transform.setPitch(40.0 * M_PI / 180.0);