Skip to content

Truly independent web browser

Tests/LibWebView: Find the catalog face by its file in the font test

Andreas Kling818e1d47324f
diff --git a/Tests/LibWebView/TestFontService.cpp b/Tests/LibWebView/TestFontService.cpp
index 9948f831fe3..2a301fb97c2 100644
--- a/Tests/LibWebView/TestFontService.cpp
+++ b/Tests/LibWebView/TestFontService.cpp
@@ -34,6 +34,13 @@ struct FontServiceTestAccess {
MUST(service.wait_until_ready());
return service.materialize(move(match), move(key));
}
+
+ static Optional<u64> catalog_face_id(FontService& service, Gfx::SystemFontFile const& file)
+ {
+ MutexLocker locker(service.m_mutex);
+ MUST(service.wait_until_ready());
+ return service.m_face_id_by_source.get({ .path = file.path, .ttc_index = file.ttc_index, .format = file.format });
+ }
};
}
@@ -83,12 +90,10 @@ TEST_CASE(dynamic_matches_of_a_catalog_face_use_its_catalog_id)
auto directory = MUST(FileSystem::real_path("../LibGfx/test-inputs/fonts"sv));
auto service = WebView::FontService::create({ MUST(String::from_byte_string(directory)) });
- auto file = MUST(Core::MappedFile::map("../LibGfx/test-inputs/fonts/text.ttf"sv));
- auto postscript_name = MUST(Gfx::Typeface::try_load_from_temporary_memory(file->bytes()))->postscript_name();
- EXPECT(postscript_name.has_value());
- auto catalog_face = service->match_local_font(*postscript_name);
- EXPECT_NE(catalog_face.face_id, 0u);
+ // NB: The face is found by its file, as its name may belong to the same font installed on the system.
+ auto catalog_face_id = WebView::FontServiceTestAccess::catalog_face_id(*service, test_font_file("text.ttf"sv));
+ EXPECT(catalog_face_id.has_value());
auto match = WebView::FontServiceTestAccess::materialize(*service, test_font_file("text.ttf"sv), "catalog-face"_string);
- EXPECT_EQ(match.face_id, catalog_face.face_id);
+ EXPECT_EQ(match.face_id, *catalog_face_id);
}