diff options
-rw-r--r-- | Tests/LibGfx/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/LibGfx/TestFontHandling.cpp | 19 | ||||
-rw-r--r-- | Tests/LibGfx/test-inputs/TestFont.font (renamed from Tests/LibGfx/TestFont.font) | bin | 25200 -> 25200 bytes |
3 files changed, 16 insertions, 5 deletions
diff --git a/Tests/LibGfx/CMakeLists.txt b/Tests/LibGfx/CMakeLists.txt index 71402111d4..9345fa930c 100644 --- a/Tests/LibGfx/CMakeLists.txt +++ b/Tests/LibGfx/CMakeLists.txt @@ -8,4 +8,4 @@ foreach(source IN LISTS TEST_SOURCES) serenity_test("${source}" LibGfx LIBS LibGfx) endforeach() -install(FILES TestFont.font DESTINATION usr/Tests/LibGfx) +install(DIRECTORY test-inputs DESTINATION usr/Tests/LibGfx) diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp index e2917f038c..ac560b0940 100644 --- a/Tests/LibGfx/TestFontHandling.cpp +++ b/Tests/LibGfx/TestFontHandling.cpp @@ -12,21 +12,32 @@ #include <stdlib.h> #include <unistd.h> +#ifdef AK_OS_SERENITY +# define TEST_INPUT(x) ("/usr/Tests/LibGfx/test-inputs/" x) +#else +# define TEST_INPUT(x) ("test-inputs/" x) +#endif + TEST_CASE(test_fontdatabase_get_by_name) { - auto name = "Liza 10 400 0"sv; + Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT("")); + + auto name = "Family 12 400 0"sv; auto& font_database = Gfx::FontDatabase::the(); EXPECT(!font_database.get_by_name(name)->name().is_null()); } TEST_CASE(test_fontdatabase_get) { + Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT("")); auto& font_database = Gfx::FontDatabase::the(); - EXPECT(!font_database.get("Liza", 10, 400, 0)->name().is_null()); + EXPECT(!font_database.get("Family", 12, 400, 0)->name().is_null()); } TEST_CASE(test_fontdatabase_for_each_font) { + Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT("")); + auto& font_database = Gfx::FontDatabase::the(); font_database.for_each_font([&](Gfx::Font const& font) { EXPECT(!font.name().is_null()); @@ -119,7 +130,7 @@ TEST_CASE(test_glyph_or_emoji_width) TEST_CASE(test_load_from_file) { - auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font"); + auto font = Gfx::BitmapFont::load_from_file(TEST_INPUT("TestFont.font"sv)); EXPECT(!font->name().is_null()); } @@ -137,7 +148,7 @@ TEST_CASE(test_write_to_file) TEST_CASE(test_character_set_masking) { - auto font = Gfx::BitmapFont::try_load_from_file("/usr/Tests/LibGfx/TestFont.font"); + auto font = Gfx::BitmapFont::try_load_from_file(TEST_INPUT("TestFont.font"sv)); EXPECT(!font.is_error()); auto unmasked_font = font.value()->unmasked_character_set(); diff --git a/Tests/LibGfx/TestFont.font b/Tests/LibGfx/test-inputs/TestFont.font Binary files differindex a6423c8919..a6423c8919 100644 --- a/Tests/LibGfx/TestFont.font +++ b/Tests/LibGfx/test-inputs/TestFont.font |