summaryrefslogtreecommitdiff
path: root/test/sprite
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-12 12:32:42 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-15 08:20:18 -0700
commit8fb1a81c46f4358d731712c16868aa1108d5d34c (patch)
treef56e8f16e0c0824b0d9aab045bd234bfd7fcde45 /test/sprite
parentb3ec985568176b077756b66754470988436d43c1 (diff)
downloadqtlocation-mapboxgl-8fb1a81c46f4358d731712c16868aa1108d5d34c.tar.gz
[core] Immutable<Impl> for Image
Diffstat (limited to 'test/sprite')
-rw-r--r--test/sprite/sprite_atlas.test.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp
index 0cbd211de8..70cdfd9fa6 100644
--- a/test/sprite/sprite_atlas.test.cpp
+++ b/test/sprite/sprite_atlas.test.cpp
@@ -5,6 +5,7 @@
#include <mbgl/sprite/sprite_atlas.hpp>
#include <mbgl/sprite/sprite_parser.hpp>
+#include <mbgl/style/image_impl.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -22,7 +23,7 @@ TEST(SpriteAtlas, Basic) {
auto images = parseSprite(util::read_file("test/fixtures/annotations/emerald.png"),
util::read_file("test/fixtures/annotations/emerald.json"));
for (auto& pair : images) {
- atlas.addImage(pair.first, std::move(pair.second));
+ atlas.addImage(pair.first, pair.second->impl);
}
EXPECT_EQ(1.0f, atlas.getPixelRatio());
@@ -79,7 +80,7 @@ TEST(SpriteAtlas, Size) {
auto images = parseSprite(util::read_file("test/fixtures/annotations/emerald.png"),
util::read_file("test/fixtures/annotations/emerald.json"));
for (auto& pair : images) {
- atlas.addImage(pair.first, std::move(pair.second));
+ atlas.addImage(pair.first, pair.second->impl);
}
EXPECT_DOUBLE_EQ(1.4f, atlas.getPixelRatio());
@@ -112,7 +113,7 @@ TEST(SpriteAtlas, Updates) {
EXPECT_EQ(32u, atlas.getSize().width);
EXPECT_EQ(32u, atlas.getSize().height);
- atlas.addImage("one", std::make_unique<style::Image>(PremultipliedImage({ 16, 12 }), 1));
+ atlas.addImage("one", makeMutable<style::Image::Impl>(PremultipliedImage({ 16, 12 }), 1));
auto one = *atlas.getIcon("one");
float imagePixelRatio = one.relativePixelRatio * atlas.getPixelRatio();
EXPECT_EQ(0, one.pos.x);
@@ -136,7 +137,7 @@ TEST(SpriteAtlas, Updates) {
for (size_t i = 0; i < image2.bytes(); i++) {
image2.data.get()[i] = 255;
}
- atlas.addImage("one", std::make_unique<style::Image>(std::move(image2), 1));
+ atlas.addImage("one", makeMutable<style::Image::Impl>(std::move(image2), 1));
test::checkImage("test/fixtures/sprite_atlas/updates_after", atlas.getAtlasImage());
}
@@ -145,9 +146,9 @@ TEST(SpriteAtlas, AddRemove) {
FixtureLog log;
SpriteAtlas atlas({ 32, 32 }, 1);
- atlas.addImage("one", std::make_unique<style::Image>(PremultipliedImage({ 16, 16 }), 2));
- atlas.addImage("two", std::make_unique<style::Image>(PremultipliedImage({ 16, 16 }), 2));
- atlas.addImage("three", std::make_unique<style::Image>(PremultipliedImage({ 16, 16 }), 2));
+ atlas.addImage("one", makeMutable<style::Image::Impl>(PremultipliedImage({ 16, 16 }), 2));
+ atlas.addImage("two", makeMutable<style::Image::Impl>(PremultipliedImage({ 16, 16 }), 2));
+ atlas.addImage("three", makeMutable<style::Image::Impl>(PremultipliedImage({ 16, 16 }), 2));
atlas.removeImage("one");
atlas.removeImage("two");
@@ -175,12 +176,12 @@ TEST(SpriteAtlas, RemoveReleasesBinPackRect) {
SpriteAtlas atlas({ 36, 36 }, 1);
- atlas.addImage("big", std::make_unique<style::Image>(PremultipliedImage({ 32, 32 }), 1));
+ atlas.addImage("big", makeMutable<style::Image::Impl>(PremultipliedImage({ 32, 32 }), 1));
EXPECT_TRUE(atlas.getIcon("big"));
atlas.removeImage("big");
- atlas.addImage("big", std::make_unique<style::Image>(PremultipliedImage({ 32, 32 }), 1));
+ atlas.addImage("big", makeMutable<style::Image::Impl>(PremultipliedImage({ 32, 32 }), 1));
EXPECT_TRUE(atlas.getIcon("big"));
EXPECT_TRUE(log.empty());
}