From 9e3cb67d1cdf1da5dbc22ab45ff8765576e3d87d Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Sun, 25 Aug 2019 09:45:48 +0300 Subject: [core][qt] Update unit tests and include Korean symbols - Decrease pixelmatch tolerance for local glyph rasterizer - Add Korean symbols to test fixture - Fix ifdefs, as the QT and Apple related blocks were using same results - Add NotoSansCJK test for QT / Linux platform --- test/fixtures/local_glyphs/mixed.json | 4 ++-- test/fixtures/local_glyphs/no_local/expected.png | Bin 6963 -> 8855 bytes .../no_local_with_content_insets/expected.png | Bin 6784 -> 8823 bytes .../expected.png | Bin 6026 -> 7537 bytes .../noto_sans_cjk_kr_regular_qt/expected.png | Bin 0 -> 27980 bytes test/fixtures/local_glyphs/ping_fang/expected.png | Bin 18019 -> 18174 bytes .../fixtures/local_glyphs/ping_fang_qt/expected.png | Bin 25026 -> 28524 bytes test/text/local_glyph_rasterizer.test.cpp | 20 ++++++++++++++++++-- 8 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/local_glyphs/noto_sans_cjk_kr_regular_qt/expected.png diff --git a/test/fixtures/local_glyphs/mixed.json b/test/fixtures/local_glyphs/mixed.json index b982fd9641..3d943084e4 100644 --- a/test/fixtures/local_glyphs/mixed.json +++ b/test/fixtures/local_glyphs/mixed.json @@ -68,7 +68,7 @@ { "type": "Feature", "properties": { - "name": "身什戰アあ" + "name": "안녕 세상 KR" }, "geometry": { "type": "LineString", @@ -144,7 +144,7 @@ { "type": "Feature", "properties": { - "name": "8身什戰アあ" + "name": "안녕 세상8" }, "geometry": { "type": "LineString", diff --git a/test/fixtures/local_glyphs/no_local/expected.png b/test/fixtures/local_glyphs/no_local/expected.png index 77552c32fa..7e2049518b 100644 Binary files a/test/fixtures/local_glyphs/no_local/expected.png and b/test/fixtures/local_glyphs/no_local/expected.png differ diff --git a/test/fixtures/local_glyphs/no_local_with_content_insets/expected.png b/test/fixtures/local_glyphs/no_local_with_content_insets/expected.png index 52ef264590..da5e6957dd 100644 Binary files a/test/fixtures/local_glyphs/no_local_with_content_insets/expected.png and b/test/fixtures/local_glyphs/no_local_with_content_insets/expected.png differ diff --git a/test/fixtures/local_glyphs/no_local_with_content_insets_and_pitch/expected.png b/test/fixtures/local_glyphs/no_local_with_content_insets_and_pitch/expected.png index a1aa5fcb52..2501471562 100644 Binary files a/test/fixtures/local_glyphs/no_local_with_content_insets_and_pitch/expected.png and b/test/fixtures/local_glyphs/no_local_with_content_insets_and_pitch/expected.png differ diff --git a/test/fixtures/local_glyphs/noto_sans_cjk_kr_regular_qt/expected.png b/test/fixtures/local_glyphs/noto_sans_cjk_kr_regular_qt/expected.png new file mode 100644 index 0000000000..0d69075172 Binary files /dev/null and b/test/fixtures/local_glyphs/noto_sans_cjk_kr_regular_qt/expected.png differ diff --git a/test/fixtures/local_glyphs/ping_fang/expected.png b/test/fixtures/local_glyphs/ping_fang/expected.png index 44c24c276a..2ec62e1bc6 100644 Binary files a/test/fixtures/local_glyphs/ping_fang/expected.png and b/test/fixtures/local_glyphs/ping_fang/expected.png differ diff --git a/test/fixtures/local_glyphs/ping_fang_qt/expected.png b/test/fixtures/local_glyphs/ping_fang_qt/expected.png index 465bce5b77..0ede615967 100644 Binary files a/test/fixtures/local_glyphs/ping_fang_qt/expected.png and b/test/fixtures/local_glyphs/ping_fang_qt/expected.png differ diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp index 3f0fa1b91f..2722ee5849 100644 --- a/test/text/local_glyph_rasterizer.test.cpp +++ b/test/text/local_glyph_rasterizer.test.cpp @@ -43,7 +43,7 @@ public: MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())}; - void checkRendering(const char * name, double imageMatchPixelsThreshold = 0.05, double pixelMatchThreshold = 0.1) { + void checkRendering(const char * name, double imageMatchPixelsThreshold = 0.015, double pixelMatchThreshold = 0.1) { test::checkImage(std::string("test/fixtures/local_glyphs/") + name, frontend.render(map), imageMatchPixelsThreshold, pixelMatchThreshold); } @@ -64,7 +64,7 @@ TEST(LocalGlyphRasterizer, PingFang) { return response; }; test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__QT__) test.checkRendering("ping_fang"); #elif defined(__QT__) test.checkRendering("ping_fang_qt"); @@ -73,6 +73,22 @@ TEST(LocalGlyphRasterizer, PingFang) { #endif // defined(__APPLE__) +#if defined(__linux__) && defined(__QT__) +TEST(LocalGlyphRasterizer, NotoSansCJK) { + LocalGlyphRasterizerTest test(std::string("Noto Sans CJK KR Regular")); + + test.fileSource->glyphsResponse = [&] (const Resource& resource) { + EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); + Response response; + response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + return response; + }; + + test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); + test.checkRendering("noto_sans_cjk_kr_regular_qt"); +} +#endif // defined(__linux__) && defined(__QT__) + TEST(LocalGlyphRasterizer, NoLocal) { // Expectation: without any local fonts set, and without any CJK glyphs provided, // the output should just contain basic latin characters. -- cgit v1.2.1