summaryrefslogtreecommitdiff
path: root/test/sprite
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2016-01-14 17:11:25 -0800
committerAnsis Brammanis <brammanis@gmail.com>2016-01-19 18:20:54 -0800
commit26faa6a5ade54c0a423aab84106876dc59be868f (patch)
tree16c476ea5bc3d2084cd07e7051eb5d55d10d5be2 /test/sprite
parent9b62661b07e86fc1d64e308fde3e15527c1cd8c8 (diff)
downloadqtlocation-mapboxgl-26faa6a5ade54c0a423aab84106876dc59be868f.tar.gz
[core][ios][osx][android] fix icons with non-integer width/height
ref #3031 ref #2198 For example, an icon that has: - a pixel width of 10 - a pixel ratio of 3 - a scaled with of 3.333 is now supported.
Diffstat (limited to 'test/sprite')
-rw-r--r--test/sprite/sprite_image.cpp8
-rw-r--r--test/sprite/sprite_parser.cpp6
-rw-r--r--test/sprite/sprite_store.cpp18
3 files changed, 16 insertions, 16 deletions
diff --git a/test/sprite/sprite_image.cpp b/test/sprite/sprite_image.cpp
index 8bc88fcc84..1ed4e56ff6 100644
--- a/test/sprite/sprite_image.cpp
+++ b/test/sprite/sprite_image.cpp
@@ -28,7 +28,7 @@ TEST(Sprite, SpriteImageZeroRatio) {
SpriteImage(16, 16, 0, "");
FAIL() << "Expected exception";
} catch (util::SpriteImageException& ex) {
- EXPECT_STREQ("Sprite image dimensions may not be zero", ex.what());
+ EXPECT_STREQ("Sprite image pixel count mismatch", ex.what());
}
}
@@ -43,7 +43,7 @@ TEST(Sprite, SpriteImageMismatchedData) {
TEST(Sprite, SpriteImage) {
std::string pixels(32 * 24 * 4, '\0');
- SpriteImage sprite(16, 12, 2, std::move(pixels));
+ SpriteImage sprite(32, 24, 2, std::move(pixels));
EXPECT_EQ(16, sprite.width);
EXPECT_EQ(32, sprite.pixelWidth);
EXPECT_EQ(12, sprite.height);
@@ -54,8 +54,8 @@ TEST(Sprite, SpriteImage) {
TEST(Sprite, SpriteImageFractionalRatio) {
std::string pixels(20 * 12 * 4, '\0');
- SpriteImage sprite(13, 8, 1.5, std::move(pixels));
- EXPECT_EQ(13, sprite.width);
+ SpriteImage sprite(20, 12, 1.5, std::move(pixels));
+ EXPECT_EQ(14, sprite.width);
EXPECT_EQ(20, sprite.pixelWidth);
EXPECT_EQ(8, sprite.height);
EXPECT_EQ(12, sprite.pixelHeight);
diff --git a/test/sprite/sprite_parser.cpp b/test/sprite/sprite_parser.cpp
index 0eb298b23e..9eb19a8095 100644
--- a/test/sprite/sprite_parser.cpp
+++ b/test/sprite/sprite_parser.cpp
@@ -106,10 +106,10 @@ TEST(Sprite, SpriteImageCreation1_5x) {
ASSERT_TRUE(sprite2.get());
EXPECT_EQ(24, sprite2->width);
EXPECT_EQ(24, sprite2->height);
- EXPECT_EQ(36, sprite2->pixelWidth);
- EXPECT_EQ(36, sprite2->pixelHeight);
+ EXPECT_EQ(35, sprite2->pixelWidth);
+ EXPECT_EQ(35, sprite2->pixelHeight);
EXPECT_EQ(1.5, sprite2->pixelRatio);
- EXPECT_EQ(0x134A530C742DD141u, test::crc64(sprite2->data));
+ EXPECT_EQ(14312995667113444493u, test::crc64(sprite2->data));
}
TEST(Sprite, SpriteParsing) {
diff --git a/test/sprite/sprite_store.cpp b/test/sprite/sprite_store.cpp
index 8f9aebbe67..5056b89cb7 100644
--- a/test/sprite/sprite_store.cpp
+++ b/test/sprite/sprite_store.cpp
@@ -13,9 +13,9 @@ using namespace mbgl;
TEST(SpriteStore, SpriteStore) {
FixtureLog log;
- const auto sprite1 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
- const auto sprite2 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
- const auto sprite3 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite1 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite2 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite3 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
using Sprites = std::map<std::string, std::shared_ptr<const SpriteImage>>;
SpriteStore store(1);
@@ -90,8 +90,8 @@ TEST(SpriteStore, OtherPixelRatio) {
}
TEST(SpriteStore, Multiple) {
- const auto sprite1 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
- const auto sprite2 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite1 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite2 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
using Sprites = std::map<std::string, std::shared_ptr<const SpriteImage>>;
SpriteStore store(1);
@@ -109,8 +109,8 @@ TEST(SpriteStore, Multiple) {
TEST(SpriteStore, Replace) {
FixtureLog log;
- const auto sprite1 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
- const auto sprite2 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite1 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite2 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
using Sprites = std::map<std::string, std::shared_ptr<const SpriteImage>>;
SpriteStore store(1);
@@ -126,8 +126,8 @@ TEST(SpriteStore, Replace) {
TEST(SpriteStore, ReplaceWithDifferentDimensions) {
FixtureLog log;
- const auto sprite1 = std::make_shared<SpriteImage>(8, 8, 2, std::string(16 * 16 * 4, '\0'));
- const auto sprite2 = std::make_shared<SpriteImage>(9, 9, 2, std::string(18 * 18 * 4, '\0'));
+ const auto sprite1 = std::make_shared<SpriteImage>(16, 16, 2, std::string(16 * 16 * 4, '\0'));
+ const auto sprite2 = std::make_shared<SpriteImage>(18, 18, 2, std::string(18 * 18 * 4, '\0'));
using Sprites = std::map<std::string, std::shared_ptr<const SpriteImage>>;
SpriteStore store(1);