mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-03 16:58:30 +03:00
LibGfx: Move TestFontHandling over to input file approach in 8cfabbcd93
Rather than reading files out of /res, put them in a subfolder of Tests/LibGfx/ and pick the path based on AK_OS_SERENITY. That way, the tests can also pass when run under lagom.
This commit is contained in:
parent
389224c2d2
commit
b8b5e0f680
Notes:
sideshowbarker
2024-07-17 00:57:47 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/b8b5e0f680 Pull-request: https://github.com/SerenityOS/serenity/pull/17261
@ -8,4 +8,4 @@ foreach(source IN LISTS TEST_SOURCES)
|
|||||||
serenity_test("${source}" LibGfx LIBS LibGfx)
|
serenity_test("${source}" LibGfx LIBS LibGfx)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
install(FILES TestFont.font DESTINATION usr/Tests/LibGfx)
|
install(DIRECTORY test-inputs DESTINATION usr/Tests/LibGfx)
|
||||||
|
@ -12,21 +12,32 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.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)
|
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();
|
auto& font_database = Gfx::FontDatabase::the();
|
||||||
EXPECT(!font_database.get_by_name(name)->name().is_null());
|
EXPECT(!font_database.get_by_name(name)->name().is_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(test_fontdatabase_get)
|
TEST_CASE(test_fontdatabase_get)
|
||||||
{
|
{
|
||||||
|
Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
|
||||||
auto& font_database = Gfx::FontDatabase::the();
|
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)
|
TEST_CASE(test_fontdatabase_for_each_font)
|
||||||
{
|
{
|
||||||
|
Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
|
||||||
|
|
||||||
auto& font_database = Gfx::FontDatabase::the();
|
auto& font_database = Gfx::FontDatabase::the();
|
||||||
font_database.for_each_font([&](Gfx::Font const& font) {
|
font_database.for_each_font([&](Gfx::Font const& font) {
|
||||||
EXPECT(!font.name().is_null());
|
EXPECT(!font.name().is_null());
|
||||||
@ -119,7 +130,7 @@ TEST_CASE(test_glyph_or_emoji_width)
|
|||||||
|
|
||||||
TEST_CASE(test_load_from_file)
|
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());
|
EXPECT(!font->name().is_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +148,7 @@ TEST_CASE(test_write_to_file)
|
|||||||
|
|
||||||
TEST_CASE(test_character_set_masking)
|
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());
|
EXPECT(!font.is_error());
|
||||||
|
|
||||||
auto unmasked_font = font.value()->unmasked_character_set();
|
auto unmasked_font = font.value()->unmasked_character_set();
|
||||||
|
Loading…
Reference in New Issue
Block a user