@@ -34,7 +34,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 0x16@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 0x16@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -44,7 +45,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 16x0@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 16x0@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -54,7 +56,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: -1x16@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: -1x16@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -64,7 +67,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 16x-1@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 16x-1@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -74,7 +78,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 1x1@0,0 in 200x299@0x sprite",
|
||||
"Can't create image with invalid metrics: 1x1@0,0 in 200x299@0x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -84,7 +89,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 1x1@0,0 in 200x299@-1x sprite",
|
||||
"Can't create image with invalid metrics: 1x1@0,0 in 200x299@-1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -94,7 +100,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 1x1@0,0 in 200x299@23x sprite",
|
||||
"Can't create image with invalid metrics: 1x1@0,0 in 200x299@23x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -104,7 +111,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 2048x16@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 2048x16@0,0 in "
|
||||
"200x299@1x sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -114,7 +122,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 16x1025@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 16x1025@0,0 in "
|
||||
"200x299@1x sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -124,7 +133,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 16x16@-1,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 16x16@-1,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -134,7 +144,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 16x16@0,-1 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 16x16@0,-1 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -146,7 +157,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 201x16@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 201x16@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -158,7 +170,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 16x300@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 16x300@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -168,7 +181,8 @@ TEST(Sprite, SpriteImageCreationInvalid) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metadata: stretchX is out of bounds or overlapping",
|
||||
"Can't create image with invalid metadata: stretchX is out of "
|
||||
"bounds or overlapping",
|
||||
}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
@@ -196,7 +210,8 @@ TEST(Sprite, SpriteImageCreation1x) {
|
||||
EXPECT_EQ(18u, sprite->getImage().size.width);
|
||||
EXPECT_EQ(18u, sprite->getImage().size.height);
|
||||
EXPECT_EQ(1, sprite->getPixelRatio());
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation1x-museum.png"),
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/"
|
||||
"result-spriteimagecreation1x-museum.png"),
|
||||
sprite->getImage());
|
||||
}
|
||||
}
|
||||
@@ -210,8 +225,7 @@ TEST(Sprite, SpriteImageCreation2x) {
|
||||
EXPECT_EQ(36u, sprite->getImage().size.width);
|
||||
EXPECT_EQ(36u, sprite->getImage().size.height);
|
||||
EXPECT_EQ(2, sprite->getPixelRatio());
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation2x.png"),
|
||||
sprite->getImage());
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation2x.png"), sprite->getImage());
|
||||
}
|
||||
|
||||
TEST(Sprite, SpriteImageCreation1_5x) {
|
||||
@@ -223,7 +237,8 @@ TEST(Sprite, SpriteImageCreation1_5x) {
|
||||
EXPECT_EQ(36u, sprite->getImage().size.width);
|
||||
EXPECT_EQ(36u, sprite->getImage().size.height);
|
||||
EXPECT_EQ(1.5, sprite->getPixelRatio());
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation1_5x-museum.png"),
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/"
|
||||
"result-spriteimagecreation1_5x-museum.png"),
|
||||
sprite->getImage());
|
||||
|
||||
// "hospital_icon":{"x":314,"y":518,"width":36,"height":36,"pixelRatio":2,"sdf":false}
|
||||
@@ -232,7 +247,8 @@ TEST(Sprite, SpriteImageCreation1_5x) {
|
||||
EXPECT_EQ(35u, sprite2->getImage().size.width);
|
||||
EXPECT_EQ(35u, sprite2->getImage().size.height);
|
||||
EXPECT_EQ(1.5, sprite2->getPixelRatio());
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/result-spriteimagecreation1_5x-hospital.png"),
|
||||
EXPECT_EQ(readImage("test/fixtures/annotations/"
|
||||
"result-spriteimagecreation1_5x-hospital.png"),
|
||||
sprite2->getImage());
|
||||
}
|
||||
|
||||
@@ -246,84 +262,84 @@ TEST(Sprite, SpriteParsing) {
|
||||
std::transform(
|
||||
images.begin(), images.end(), std::inserter(names, names.begin()), [](const auto& image) { return image->id; });
|
||||
|
||||
EXPECT_EQ(std::set<std::string>({ "airfield_icon",
|
||||
"airport_icon",
|
||||
"background",
|
||||
"cemetery_icon",
|
||||
"college_icon",
|
||||
"default_1",
|
||||
"default_2",
|
||||
"default_3",
|
||||
"default_4",
|
||||
"default_5",
|
||||
"default_6",
|
||||
"default_marker",
|
||||
"dlr",
|
||||
"dlr.london-overground.london-underground.national-rail",
|
||||
"dlr.london-underground",
|
||||
"dlr.london-underground.national-rail",
|
||||
"dlr.national-rail",
|
||||
"dot",
|
||||
"embassy_icon",
|
||||
"fire-station_icon",
|
||||
"generic-metro",
|
||||
"generic-rail",
|
||||
"generic_icon",
|
||||
"golf_icon",
|
||||
"government_icon",
|
||||
"grass_pattern",
|
||||
"harbor_icon",
|
||||
"hospital_icon",
|
||||
"hospital_striped",
|
||||
"interstate_1",
|
||||
"interstate_2",
|
||||
"interstate_3",
|
||||
"library_icon",
|
||||
"london-overground",
|
||||
"london-overground.london-underground",
|
||||
"london-overground.london-underground.national-rail",
|
||||
"london-overground.national-rail",
|
||||
"london-underground",
|
||||
"london-underground.national-rail",
|
||||
"marker_icon",
|
||||
"metro",
|
||||
"metro.rer",
|
||||
"monument_icon",
|
||||
"moscow-metro",
|
||||
"museum_icon",
|
||||
"national-rail",
|
||||
"oneway_motorway",
|
||||
"oneway_road",
|
||||
"park_icon",
|
||||
"police_icon",
|
||||
"post_icon",
|
||||
"prison_icon",
|
||||
"religious-christian_icon",
|
||||
"religious-jewish_icon",
|
||||
"religious-muslim_icon",
|
||||
"rer",
|
||||
"rer.transilien",
|
||||
"s-bahn",
|
||||
"s-bahn.u-bahn",
|
||||
"sand_noise",
|
||||
"school_icon",
|
||||
"school_striped",
|
||||
"secondary_marker",
|
||||
"u-bahn",
|
||||
"us_highway_1",
|
||||
"us_highway_2",
|
||||
"us_highway_3",
|
||||
"us_state_1",
|
||||
"us_state_2",
|
||||
"us_state_3",
|
||||
"washington-metro",
|
||||
"wiener-linien",
|
||||
"zoo_icon" }),
|
||||
EXPECT_EQ(std::set<std::string>({"airfield_icon",
|
||||
"airport_icon",
|
||||
"background",
|
||||
"cemetery_icon",
|
||||
"college_icon",
|
||||
"default_1",
|
||||
"default_2",
|
||||
"default_3",
|
||||
"default_4",
|
||||
"default_5",
|
||||
"default_6",
|
||||
"default_marker",
|
||||
"dlr",
|
||||
"dlr.london-overground.london-underground.national-rail",
|
||||
"dlr.london-underground",
|
||||
"dlr.london-underground.national-rail",
|
||||
"dlr.national-rail",
|
||||
"dot",
|
||||
"embassy_icon",
|
||||
"fire-station_icon",
|
||||
"generic-metro",
|
||||
"generic-rail",
|
||||
"generic_icon",
|
||||
"golf_icon",
|
||||
"government_icon",
|
||||
"grass_pattern",
|
||||
"harbor_icon",
|
||||
"hospital_icon",
|
||||
"hospital_striped",
|
||||
"interstate_1",
|
||||
"interstate_2",
|
||||
"interstate_3",
|
||||
"library_icon",
|
||||
"london-overground",
|
||||
"london-overground.london-underground",
|
||||
"london-overground.london-underground.national-rail",
|
||||
"london-overground.national-rail",
|
||||
"london-underground",
|
||||
"london-underground.national-rail",
|
||||
"marker_icon",
|
||||
"metro",
|
||||
"metro.rer",
|
||||
"monument_icon",
|
||||
"moscow-metro",
|
||||
"museum_icon",
|
||||
"national-rail",
|
||||
"oneway_motorway",
|
||||
"oneway_road",
|
||||
"park_icon",
|
||||
"police_icon",
|
||||
"post_icon",
|
||||
"prison_icon",
|
||||
"religious-christian_icon",
|
||||
"religious-jewish_icon",
|
||||
"religious-muslim_icon",
|
||||
"rer",
|
||||
"rer.transilien",
|
||||
"s-bahn",
|
||||
"s-bahn.u-bahn",
|
||||
"sand_noise",
|
||||
"school_icon",
|
||||
"school_striped",
|
||||
"secondary_marker",
|
||||
"u-bahn",
|
||||
"us_highway_1",
|
||||
"us_highway_2",
|
||||
"us_highway_3",
|
||||
"us_state_1",
|
||||
"us_state_2",
|
||||
"us_state_3",
|
||||
"washington-metro",
|
||||
"wiener-linien",
|
||||
"zoo_icon"}),
|
||||
names);
|
||||
|
||||
{
|
||||
auto& sprite =
|
||||
*std::find_if(images.begin(), images.end(), [](const auto& image) { return image->id == "generic-metro"; });
|
||||
auto& sprite = *std::find_if(
|
||||
images.begin(), images.end(), [](const auto& image) { return image->id == "generic-metro"; });
|
||||
EXPECT_EQ(18u, sprite->image.size.width);
|
||||
EXPECT_EQ(18u, sprite->image.size.height);
|
||||
EXPECT_EQ(1, sprite->pixelRatio);
|
||||
@@ -340,7 +356,8 @@ TEST(Sprite, SpriteParsingInvalidJSON) {
|
||||
FAIL() << "Expected exception";
|
||||
} catch (std::runtime_error& err) {
|
||||
EXPECT_STREQ(
|
||||
"Failed to parse JSON: Missing a closing quotation mark in string. at offset 14",
|
||||
"Failed to parse JSON: Missing a closing quotation mark in string. "
|
||||
"at offset 14",
|
||||
err.what());
|
||||
}
|
||||
}
|
||||
@@ -364,7 +381,8 @@ TEST(Sprite, SpriteParsingInvalidStretches) {
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': value of 'stretchX' must be an array"}));
|
||||
"Invalid sprite image 'interstate_1': value of 'stretchX' must be "
|
||||
"an array"}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
parseSprite(image_1x, R"JSON({
|
||||
@@ -377,12 +395,12 @@ TEST(Sprite, SpriteParsingInvalidStretches) {
|
||||
"stretchX": [[[]]]
|
||||
}
|
||||
})JSON");
|
||||
EXPECT_EQ(
|
||||
1u,
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': members of 'stretchX' must be an array of two numbers"}));
|
||||
EXPECT_EQ(1u,
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': members of 'stretchX' must "
|
||||
"be an array of two numbers"}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
parseSprite(image_1x, R"JSON({
|
||||
@@ -395,12 +413,12 @@ TEST(Sprite, SpriteParsingInvalidStretches) {
|
||||
"stretchX": [[4, false]]
|
||||
}
|
||||
})JSON");
|
||||
EXPECT_EQ(
|
||||
1u,
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': members of 'stretchX' must be an array of two numbers"}));
|
||||
EXPECT_EQ(1u,
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': members of 'stretchX' must "
|
||||
"be an array of two numbers"}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
}
|
||||
|
||||
@@ -423,7 +441,8 @@ TEST(Sprite, SpriteParsingInvalidContent) {
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': value of 'content' must be an array of four numbers"}));
|
||||
"Invalid sprite image 'interstate_1': value of 'content' must be "
|
||||
"an array of four numbers"}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
parseSprite(image_1x, R"JSON({
|
||||
@@ -440,7 +459,8 @@ TEST(Sprite, SpriteParsingInvalidContent) {
|
||||
log.count({EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'interstate_1': value of 'content' must be an array of four numbers"}));
|
||||
"Invalid sprite image 'interstate_1': value of 'content' must be "
|
||||
"an array of four numbers"}));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
}
|
||||
|
||||
@@ -482,7 +502,8 @@ TEST(Sprite, SpriteParsingEmptyImage) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 0x0@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 0x0@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -510,14 +531,16 @@ TEST(Sprite, SpriteParsingWidthTooBig) {
|
||||
EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'image': value of 'width' must be an integer between 0 and 65535",
|
||||
"Invalid sprite image 'image': value of 'width' must be an integer "
|
||||
"between 0 and 65535",
|
||||
}));
|
||||
EXPECT_EQ(1u,
|
||||
log.count({
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 0x32@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 0x32@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -535,14 +558,16 @@ TEST(Sprite, SpriteParsingNegativeWidth) {
|
||||
EventSeverity::Warning,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Invalid sprite image 'image': value of 'width' must be an integer between 0 and 65535",
|
||||
"Invalid sprite image 'image': value of 'width' must be an integer "
|
||||
"between 0 and 65535",
|
||||
}));
|
||||
EXPECT_EQ(1u,
|
||||
log.count({
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 0x32@0,0 in 200x299@1x sprite",
|
||||
"Can't create image with invalid metrics: 0x32@0,0 in 200x299@1x "
|
||||
"sprite",
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -560,6 +585,7 @@ TEST(Sprite, SpriteParsingNullRatio) {
|
||||
EventSeverity::Error,
|
||||
Event::Sprite,
|
||||
int64_t(-1),
|
||||
"Can't create image with invalid metrics: 32x32@0,0 in 200x299@0x sprite",
|
||||
"Can't create image with invalid metrics: 32x32@0,0 in 200x299@0x "
|
||||
"sprite",
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user