summaryrefslogtreecommitdiff
path: root/test/sprite
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-18 16:31:16 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-26 11:21:56 -0700
commitd766af44c80ca41adbd988eeb681f90fb52ec817 (patch)
treede0adcd07c2c4b6057256009bd70458fa21cb0d9 /test/sprite
parente4e08aca7910d1a8d75791db61de39fa03673fde (diff)
downloadqtlocation-mapboxgl-d766af44c80ca41adbd988eeb681f90fb52ec817.tar.gz
[core] Auto-growable SpriteAtlas using shelf-pack
Diffstat (limited to 'test/sprite')
-rw-r--r--test/sprite/sprite_atlas.test.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp
index c673c5ca0e..7a638a9ec5 100644
--- a/test/sprite/sprite_atlas.test.cpp
+++ b/test/sprite/sprite_atlas.test.cpp
@@ -18,7 +18,7 @@ using namespace mbgl;
TEST(SpriteAtlas, Basic) {
FixtureLog log;
- SpriteAtlas atlas({ 63, 112 }, 1);
+ SpriteAtlas atlas;
auto images = parseSprite(util::read_file("test/fixtures/annotations/emerald.png"),
util::read_file("test/fixtures/annotations/emerald.json"));
@@ -26,9 +26,6 @@ TEST(SpriteAtlas, Basic) {
atlas.addImage(image->impl);
}
- EXPECT_EQ(63u, atlas.getPixelSize().width);
- EXPECT_EQ(112u, atlas.getPixelSize().height);
-
auto metro = *atlas.getIcon("metro");
EXPECT_EQ(1, metro.tl()[0]);
EXPECT_EQ(1, metro.tl()[1]);
@@ -38,8 +35,7 @@ TEST(SpriteAtlas, Basic) {
EXPECT_EQ(18, metro.displaySize()[1]);
EXPECT_EQ(1.0f, metro.pixelRatio);
- EXPECT_EQ(63u, atlas.getAtlasImage().size.width);
- EXPECT_EQ(112u, atlas.getAtlasImage().size.height);
+ EXPECT_EQ(atlas.getPixelSize(), atlas.getAtlasImage().size);
auto missing = atlas.getIcon("doesnotexist");
EXPECT_FALSE(missing);
@@ -62,7 +58,7 @@ TEST(SpriteAtlas, Basic) {
}
TEST(SpriteAtlas, Size) {
- SpriteAtlas atlas({ 63, 112 }, 1.4);
+ SpriteAtlas atlas;
auto images = parseSprite(util::read_file("test/fixtures/annotations/emerald.png"),
util::read_file("test/fixtures/annotations/emerald.json"));
@@ -70,9 +66,6 @@ TEST(SpriteAtlas, Size) {
atlas.addImage(image->impl);
}
- EXPECT_EQ(89u, atlas.getPixelSize().width);
- EXPECT_EQ(157u, atlas.getPixelSize().height);
-
auto metro = *atlas.getIcon("metro");
EXPECT_EQ(1, metro.tl()[0]);
EXPECT_EQ(1, metro.tl()[1]);
@@ -86,10 +79,7 @@ TEST(SpriteAtlas, Size) {
}
TEST(SpriteAtlas, Updates) {
- SpriteAtlas atlas({ 32, 32 }, 1);
-
- EXPECT_EQ(32u, atlas.getPixelSize().width);
- EXPECT_EQ(32u, atlas.getPixelSize().height);
+ SpriteAtlas atlas;
atlas.addImage(makeMutable<style::Image::Impl>("one", PremultipliedImage({ 16, 12 }), 1));
auto one = *atlas.getIcon("one");
@@ -101,10 +91,6 @@ TEST(SpriteAtlas, Updates) {
EXPECT_EQ(12, one.displaySize()[1]);
EXPECT_EQ(1.0f, one.pixelRatio);
- // Now the image was created lazily.
- EXPECT_EQ(32u, atlas.getAtlasImage().size.width);
- EXPECT_EQ(32u, atlas.getAtlasImage().size.height);
-
test::checkImage("test/fixtures/sprite_atlas/updates_before", atlas.getAtlasImage());
// Update image
@@ -119,7 +105,7 @@ TEST(SpriteAtlas, Updates) {
TEST(SpriteAtlas, AddRemove) {
FixtureLog log;
- SpriteAtlas atlas({ 32, 32 }, 1);
+ SpriteAtlas atlas;
atlas.addImage(makeMutable<style::Image::Impl>("one", PremultipliedImage({ 16, 16 }), 2));
atlas.addImage(makeMutable<style::Image::Impl>("two", PremultipliedImage({ 16, 16 }), 2));
@@ -148,8 +134,7 @@ TEST(SpriteAtlas, AddRemove) {
TEST(SpriteAtlas, RemoveReleasesBinPackRect) {
FixtureLog log;
-
- SpriteAtlas atlas({ 36, 36 }, 1);
+ SpriteAtlas atlas;
atlas.addImage(makeMutable<style::Image::Impl>("big", PremultipliedImage({ 32, 32 }), 1));
EXPECT_TRUE(atlas.getIcon("big"));