diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-15 14:09:06 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-16 12:26:35 -0700 |
commit | cc1ea759a681cadcfd06fd7bdda79ca6deb38c62 (patch) | |
tree | 97ece422b0516b11979c84b8136f95aeabb1aa91 /test | |
parent | c0f6e5ccefc67dbdaa6ab7c7ea75a2a2d0c3f2ae (diff) | |
download | qtlocation-mapboxgl-cc1ea759a681cadcfd06fd7bdda79ca6deb38c62.tar.gz |
[core, node, darwin, android, qt] Make image ID part of Image
More like Source and Layer.
Diffstat (limited to 'test')
-rw-r--r-- | test/api/annotations.test.cpp | 28 | ||||
-rw-r--r-- | test/api/query.test.cpp | 2 | ||||
-rw-r--r-- | test/map/map.test.cpp | 16 | ||||
-rw-r--r-- | test/sprite/sprite_atlas.test.cpp | 22 | ||||
-rw-r--r-- | test/sprite/sprite_image_collection.test.cpp | 10 | ||||
-rw-r--r-- | test/sprite/sprite_loader.test.cpp | 10 | ||||
-rw-r--r-- | test/sprite/sprite_parser.test.cpp | 38 | ||||
-rw-r--r-- | test/style/style_image.test.cpp | 10 | ||||
-rw-r--r-- | test/text/quads.test.cpp | 4 |
9 files changed, 70 insertions, 70 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 100187c587..9e85a74c5b 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -17,8 +17,8 @@ using namespace mbgl; namespace { std::unique_ptr<style::Image> namedMarker(const std::string& name) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/sprites/" + name)); - return std::make_unique<style::Image>(std::move(image), 1.0); + PremultipliedImage image = decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png")); + return std::make_unique<style::Image>(name, std::move(image), 1.0); } class AnnotationTest { @@ -43,7 +43,7 @@ TEST(Annotations, SymbolAnnotation) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" }); test.checkRendering("point_annotation"); @@ -148,7 +148,7 @@ TEST(Annotations, AddMultiple) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" }); test::render(test.map, test.view); @@ -175,8 +175,8 @@ TEST(Annotations, UpdateSymbolAnnotationGeometry) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); - test.map.addAnnotationImage("flipped_marker", namedMarker("flipped_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); + test.map.addAnnotationImage(namedMarker("flipped_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test::render(test.map, test.view); @@ -189,8 +189,8 @@ TEST(Annotations, UpdateSymbolAnnotationIcon) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); - test.map.addAnnotationImage("flipped_marker", namedMarker("flipped_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); + test.map.addAnnotationImage(namedMarker("flipped_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test::render(test.map, test.view); @@ -271,7 +271,7 @@ TEST(Annotations, RemovePoint) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test::render(test.map, test.view); @@ -310,7 +310,7 @@ TEST(Annotations, SwitchStyle) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test::render(test.map, test.view); @@ -323,7 +323,7 @@ TEST(Annotations, QueryRenderedFeatures) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 50 }, "default_marker" }); @@ -347,7 +347,7 @@ TEST(Annotations, QueryFractionalZoomLevels) { auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); std::vector<mbgl::AnnotationID> ids; for (int longitude = 0; longitude < 10; ++longitude) { @@ -379,7 +379,7 @@ TEST(Annotations, VisibleFeatures) { auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); test.map.setLatLngZoom({ 5, 5 }, 3); std::vector<mbgl::AnnotationID> ids; @@ -432,7 +432,7 @@ TEST(Annotations, DebugSparse) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); test.map.setZoom(1); - test.map.addAnnotationImage("default_marker", namedMarker("default_marker.png")); + test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point<double>(10, 10), "default_marker" }); test.checkRendering("debug_sparse"); diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index c509753d2d..5b7f7c00ff 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -20,7 +20,7 @@ class QueryTest { public: QueryTest() { map.setStyleJSON(util::read_file("test/fixtures/api/query_style.json")); - map.addImage("test-icon", std::make_unique<style::Image>( + map.addImage(std::make_unique<style::Image>("test-icon", decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0)); test::render(map, view); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 2b7c3c2e3d..be78c8714b 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -445,14 +445,14 @@ TEST(Map, AddImage) { Map map(test.backend, test.view.getSize(), 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<style::Image>(std::move(decoded1), 1.0); - auto image2 = std::make_unique<style::Image>(std::move(decoded2), 1.0); + auto image1 = std::make_unique<style::Image>("test-icon", std::move(decoded1), 1.0); + auto image2 = std::make_unique<style::Image>("test-icon", std::move(decoded2), 1.0); // No-op. - map.addImage("test-icon", std::move(image1)); + map.addImage(std::move(image1)); map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); - map.addImage("test-icon", std::move(image2)); + map.addImage(std::move(image2)); test::checkImage("test/fixtures/map/add_icon", test::render(map, test.view)); } @@ -461,10 +461,10 @@ TEST(Map, RemoveImage) { Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); - auto image = std::make_unique<style::Image>(std::move(decoded), 1.0); + auto image = std::make_unique<style::Image>("test-icon", std::move(decoded), 1.0); map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); - map.addImage("test-icon", std::move(image)); + map.addImage(std::move(image)); map.removeImage("test-icon"); test::checkImage("test/fixtures/map/remove_icon", test::render(map, test.view)); } @@ -474,10 +474,10 @@ TEST(Map, GetImage) { Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")); - auto image = std::make_unique<style::Image>(std::move(decoded), 1.0); + auto image = std::make_unique<style::Image>("test-icon", std::move(decoded), 1.0); map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json")); - map.addImage("test-icon", std::move(image)); + map.addImage(std::move(image)); test::checkImage("test/fixtures/map/get_icon", map.getImage("test-icon")->getImage()); } diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp index 70cdfd9fa6..37a50ddddb 100644 --- a/test/sprite/sprite_atlas.test.cpp +++ b/test/sprite/sprite_atlas.test.cpp @@ -22,8 +22,8 @@ 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, pair.second->impl); + for (auto& image : images) { + atlas.addImage(image->impl); } EXPECT_EQ(1.0f, atlas.getPixelRatio()); @@ -79,8 +79,8 @@ 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, pair.second->impl); + for (auto& image : images) { + atlas.addImage(image->impl); } EXPECT_DOUBLE_EQ(1.4f, atlas.getPixelRatio()); @@ -113,7 +113,7 @@ TEST(SpriteAtlas, Updates) { EXPECT_EQ(32u, atlas.getSize().width); EXPECT_EQ(32u, atlas.getSize().height); - atlas.addImage("one", makeMutable<style::Image::Impl>(PremultipliedImage({ 16, 12 }), 1)); + atlas.addImage(makeMutable<style::Image::Impl>("one", PremultipliedImage({ 16, 12 }), 1)); auto one = *atlas.getIcon("one"); float imagePixelRatio = one.relativePixelRatio * atlas.getPixelRatio(); EXPECT_EQ(0, one.pos.x); @@ -137,7 +137,7 @@ TEST(SpriteAtlas, Updates) { for (size_t i = 0; i < image2.bytes(); i++) { image2.data.get()[i] = 255; } - atlas.addImage("one", makeMutable<style::Image::Impl>(std::move(image2), 1)); + atlas.addImage(makeMutable<style::Image::Impl>("one", std::move(image2), 1)); test::checkImage("test/fixtures/sprite_atlas/updates_after", atlas.getAtlasImage()); } @@ -146,9 +146,9 @@ TEST(SpriteAtlas, AddRemove) { FixtureLog log; SpriteAtlas atlas({ 32, 32 }, 1); - 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.addImage(makeMutable<style::Image::Impl>("one", PremultipliedImage({ 16, 16 }), 2)); + atlas.addImage(makeMutable<style::Image::Impl>("two", PremultipliedImage({ 16, 16 }), 2)); + atlas.addImage(makeMutable<style::Image::Impl>("three", PremultipliedImage({ 16, 16 }), 2)); atlas.removeImage("one"); atlas.removeImage("two"); @@ -176,12 +176,12 @@ TEST(SpriteAtlas, RemoveReleasesBinPackRect) { SpriteAtlas atlas({ 36, 36 }, 1); - atlas.addImage("big", makeMutable<style::Image::Impl>(PremultipliedImage({ 32, 32 }), 1)); + atlas.addImage(makeMutable<style::Image::Impl>("big", PremultipliedImage({ 32, 32 }), 1)); EXPECT_TRUE(atlas.getIcon("big")); atlas.removeImage("big"); - atlas.addImage("big", makeMutable<style::Image::Impl>(PremultipliedImage({ 32, 32 }), 1)); + atlas.addImage(makeMutable<style::Image::Impl>("big", PremultipliedImage({ 32, 32 }), 1)); EXPECT_TRUE(atlas.getIcon("big")); EXPECT_TRUE(log.empty()); } diff --git a/test/sprite/sprite_image_collection.test.cpp b/test/sprite/sprite_image_collection.test.cpp index 51ea20fdf3..788d7a59d5 100644 --- a/test/sprite/sprite_image_collection.test.cpp +++ b/test/sprite/sprite_image_collection.test.cpp @@ -14,16 +14,16 @@ TEST(SpriteImageCollection, OtherPixelRatio) { Images images; // Adding mismatched sprite image - addSpriteImage(images, "one", std::make_unique<style::Image>(PremultipliedImage({ 8, 8 }), 2)); + addSpriteImage(images, std::make_unique<style::Image>("one", PremultipliedImage({ 8, 8 }), 2)); } TEST(SpriteImageCollection, Replace) { FixtureLog log; Images images; - addSpriteImage(images, "sprite", std::make_unique<style::Image>(PremultipliedImage({ 16, 16 }), 2)); + addSpriteImage(images, std::make_unique<style::Image>("sprite", PremultipliedImage({ 16, 16 }), 2)); auto image = images.find("sprite")->second.get(); - addSpriteImage(images, "sprite", std::make_unique<style::Image>(PremultipliedImage({ 16, 16 }), 2)); + addSpriteImage(images, std::make_unique<style::Image>("sprite", PremultipliedImage({ 16, 16 }), 2)); EXPECT_NE(image, images.find("sprite")->second.get()); } @@ -31,8 +31,8 @@ TEST(SpriteImageCollection, ReplaceWithDifferentDimensions) { FixtureLog log; Images images; - addSpriteImage(images, "sprite", std::make_unique<style::Image>(PremultipliedImage({ 16, 16 }), 2)); - addSpriteImage(images, "sprite", std::make_unique<style::Image>(PremultipliedImage({ 18, 18 }), 2)); + addSpriteImage(images, std::make_unique<style::Image>("sprite", PremultipliedImage({ 16, 16 }), 2)); + addSpriteImage(images, std::make_unique<style::Image>("sprite", PremultipliedImage({ 18, 18 }), 2)); EXPECT_EQ(1u, log.count({ EventSeverity::Warning, diff --git a/test/sprite/sprite_loader.test.cpp b/test/sprite/sprite_loader.test.cpp index 99f44e57e4..3691572265 100644 --- a/test/sprite/sprite_loader.test.cpp +++ b/test/sprite/sprite_loader.test.cpp @@ -18,7 +18,7 @@ using namespace mbgl::style; class StubSpriteLoaderObserver : public SpriteLoaderObserver { public: - void onSpriteLoaded(Images&& images) override { + void onSpriteLoaded(std::vector<std::unique_ptr<style::Image>>&& images) override { if (spriteLoaded) spriteLoaded(std::move(images)); } @@ -26,7 +26,7 @@ public: if (spriteError) spriteError(error); } - std::function<void (Images&&)> spriteLoaded; + std::function<void (std::vector<std::unique_ptr<style::Image>>&&)> spriteLoaded; std::function<void (std::exception_ptr)> spriteError; }; @@ -94,8 +94,8 @@ TEST(SpriteLoader, LoadingSuccess) { test.end(); }; - test.observer.spriteLoaded = [&] (SpriteLoaderObserver::Images&& images) { - EXPECT_EQ(images.size(), Images::size_type(367)); + test.observer.spriteLoaded = [&] (std::vector<std::unique_ptr<style::Image>>&& images) { + EXPECT_EQ(images.size(), 367u); test.end(); }; @@ -171,7 +171,7 @@ TEST(SpriteLoader, LoadingCancel) { return optional<Response>(); }; - test.observer.spriteLoaded = [&] (const SpriteLoaderObserver::Images&) { + test.observer.spriteLoaded = [&] (const std::vector<std::unique_ptr<style::Image>>&) { FAIL() << "Should never be called"; }; diff --git a/test/sprite/sprite_parser.test.cpp b/test/sprite/sprite_parser.test.cpp index 19c6b914a8..aad80b3d81 100644 --- a/test/sprite/sprite_parser.test.cpp +++ b/test/sprite/sprite_parser.test.cpp @@ -27,19 +27,19 @@ TEST(Sprite, SpriteImageCreationInvalid) { ASSERT_EQ(200u, image_1x.size.width); ASSERT_EQ(299u, image_1x.size.height); - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 0, 16, 1, false)); // width == 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 16, 0, 1, false)); // height == 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, -1, 16, 1, false)); // width < 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 16, -1, 1, false)); // height < 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 1, 1, 0, false)); // ratio == 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 1, 1, -1, false)); // ratio < 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 1, 1, 23, false)); // ratio too large - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 2048, 16, 1, false)); // too wide - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 16, 1025, 1, false)); // too tall - ASSERT_EQ(nullptr, createStyleImage(image_1x, -1, 0, 16, 16, 1, false)); // srcX < 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, -1, 16, 16, 1, false)); // srcY < 0 - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, image_1x.size.width + 1, 16, 1, false)); // right edge out of bounds - ASSERT_EQ(nullptr, createStyleImage(image_1x, 0, 0, 16, image_1x.size.height + 1, 1, false)); // bottom edge out of bounds + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 0, 16, 1, false)); // width == 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 16, 0, 1, false)); // height == 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, -1, 16, 1, false)); // width < 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 16, -1, 1, false)); // height < 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 1, 1, 0, false)); // ratio == 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 1, 1, -1, false)); // ratio < 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 1, 1, 23, false)); // ratio too large + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 2048, 16, 1, false)); // too wide + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 16, 1025, 1, false)); // too tall + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, -1, 0, 16, 16, 1, false)); // srcX < 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, -1, 16, 16, 1, false)); // srcY < 0 + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, image_1x.size.width + 1, 16, 1, false)); // right edge out of bounds + ASSERT_EQ(nullptr, createStyleImage("test", image_1x, 0, 0, 16, image_1x.size.height + 1, 1, false)); // bottom edge out of bounds EXPECT_EQ(1u, log.count({ EventSeverity::Error, @@ -141,7 +141,7 @@ TEST(Sprite, SpriteImageCreation1x) { ASSERT_EQ(299u, image_1x.size.height); { // "museum_icon":{"x":177,"y":187,"width":18,"height":18,"pixelRatio":1,"sdf":false} - const auto sprite = createStyleImage(image_1x, 177, 187, 18, 18, 1, false); + const auto sprite = createStyleImage("test", image_1x, 177, 187, 18, 18, 1, false); ASSERT_TRUE(sprite.get()); EXPECT_EQ(18, sprite->getWidth()); EXPECT_EQ(18, sprite->getHeight()); @@ -157,7 +157,7 @@ TEST(Sprite, SpriteImageCreation2x) { const PremultipliedImage image_2x = decodeImage(util::read_file("test/fixtures/annotations/emerald@2x.png")); // "museum_icon":{"x":354,"y":374,"width":36,"height":36,"pixelRatio":2,"sdf":false} - const auto sprite = createStyleImage(image_2x, 354, 374, 36, 36, 2, false); + const auto sprite = createStyleImage("test", image_2x, 354, 374, 36, 36, 2, false); ASSERT_TRUE(sprite.get()); EXPECT_EQ(18, sprite->getWidth()); EXPECT_EQ(18, sprite->getHeight()); @@ -172,7 +172,7 @@ TEST(Sprite, SpriteImageCreation1_5x) { const PremultipliedImage image_2x = decodeImage(util::read_file("test/fixtures/annotations/emerald@2x.png")); // "museum_icon":{"x":354,"y":374,"width":36,"height":36,"pixelRatio":2,"sdf":false} - const auto sprite = createStyleImage(image_2x, 354, 374, 36, 36, 1.5, false); + const auto sprite = createStyleImage("test", image_2x, 354, 374, 36, 36, 1.5, false); ASSERT_TRUE(sprite.get()); EXPECT_EQ(24, sprite->getWidth()); EXPECT_EQ(24, sprite->getHeight()); @@ -183,7 +183,7 @@ TEST(Sprite, SpriteImageCreation1_5x) { sprite->getImage()); // "hospital_icon":{"x":314,"y":518,"width":36,"height":36,"pixelRatio":2,"sdf":false} - const auto sprite2 = createStyleImage(image_2x, 314, 518, 35, 35, 1.5, false); + const auto sprite2 = createStyleImage("test", image_2x, 314, 518, 35, 35, 1.5, false); ASSERT_TRUE(sprite2.get()); EXPECT_EQ(float(35 / 1.5), sprite2->getWidth()); EXPECT_EQ(float(35 / 1.5), sprite2->getHeight()); @@ -202,7 +202,7 @@ TEST(Sprite, SpriteParsing) { std::set<std::string> names; std::transform(images.begin(), images.end(), std::inserter(names, names.begin()), - [](const auto& pair) { return pair.first; }); + [](const auto& image) { return image->getID(); }); EXPECT_EQ(std::set<std::string>({ "airfield_icon", "airport_icon", @@ -280,7 +280,7 @@ TEST(Sprite, SpriteParsing) { names); { - auto& sprite = images.find("generic-metro")->second; + auto& sprite = *std::find_if(images.begin(), images.end(), [] (const auto& image) { return image->getID() == "generic-metro"; }); EXPECT_EQ(18, sprite->getWidth()); EXPECT_EQ(18, sprite->getHeight()); EXPECT_EQ(18u, sprite->getImage().size.width); diff --git a/test/style/style_image.test.cpp b/test/style/style_image.test.cpp index 34814bee88..c535397be3 100644 --- a/test/style/style_image.test.cpp +++ b/test/style/style_image.test.cpp @@ -8,7 +8,7 @@ using namespace mbgl; TEST(StyleImage, ZeroWidth) { try { - style::Image(PremultipliedImage({ 0, 16 }), 2.0); + style::Image("test", PremultipliedImage({ 0, 16 }), 2.0); FAIL() << "Expected exception"; } catch (util::SpriteImageException& ex) { EXPECT_STREQ("Sprite image dimensions may not be zero", ex.what()); @@ -17,7 +17,7 @@ TEST(StyleImage, ZeroWidth) { TEST(StyleImage, ZeroHeight) { try { - style::Image(PremultipliedImage({ 16, 0 }), 2.0); + style::Image("test", PremultipliedImage({ 16, 0 }), 2.0); FAIL() << "Expected exception"; } catch (util::SpriteImageException& ex) { EXPECT_STREQ("Sprite image dimensions may not be zero", ex.what()); @@ -26,7 +26,7 @@ TEST(StyleImage, ZeroHeight) { TEST(StyleImage, ZeroRatio) { try { - style::Image(PremultipliedImage({ 16, 16 }), 0.0); + style::Image("test", PremultipliedImage({ 16, 16 }), 0.0); FAIL() << "Expected exception"; } catch (util::SpriteImageException& ex) { EXPECT_STREQ("Sprite pixelRatio may not be <= 0", ex.what()); @@ -34,7 +34,7 @@ TEST(StyleImage, ZeroRatio) { } TEST(StyleImage, Retina) { - style::Image image(PremultipliedImage({ 32, 24 }), 2.0); + style::Image image("test", PremultipliedImage({ 32, 24 }), 2.0); EXPECT_EQ(16, image.getWidth()); EXPECT_EQ(32u, image.getImage().size.width); EXPECT_EQ(12, image.getHeight()); @@ -43,7 +43,7 @@ TEST(StyleImage, Retina) { } TEST(StyleImage, FractionalRatio) { - style::Image image(PremultipliedImage({ 20, 12 }), 1.5); + style::Image image("test", PremultipliedImage({ 20, 12 }), 1.5); EXPECT_EQ(float(20.0 / 1.5), image.getWidth()); EXPECT_EQ(20u, image.getImage().size.width); EXPECT_EQ(float(12.0 / 1.5), image.getHeight()); diff --git a/test/text/quads.test.cpp b/test/text/quads.test.cpp index 6b2b0e7586..dcc51bf6a3 100644 --- a/test/text/quads.test.cpp +++ b/test/text/quads.test.cpp @@ -14,7 +14,7 @@ TEST(getIconQuads, normal) { Anchor anchor(2.0, 3.0, 0.0, 0.5f, 0); SpriteAtlasElement image = { Rect<uint16_t>( 0, 0, 15, 11 ), - style::Image::Impl(PremultipliedImage({1,1}), 1.0), + style::Image::Impl("test", PremultipliedImage({1,1}), 1.0), { 0, 0 }, 1.0f }; @@ -47,7 +47,7 @@ TEST(getIconQuads, style) { Anchor anchor(0.0, 0.0, 0.0, 0.5f, 0); SpriteAtlasElement image = { Rect<uint16_t>( 0, 0, 20, 20 ), - style::Image::Impl(PremultipliedImage({1,1}), 1.0), + style::Image::Impl("test", PremultipliedImage({1,1}), 1.0), { 0, 0 }, 1.0f }; |