mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-09 04:37:52 +03:00
Tests: Load Resources via Core::Resource URIs in FontHandling tests
This commit is contained in:
parent
2e759656de
commit
09e3921ff8
Notes:
sideshowbarker
2024-07-16 20:08:14 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/09e3921ff8 Pull-request: https://github.com/SerenityOS/serenity/pull/21302 Reviewed-by: https://github.com/kleinesfilmroellchen Reviewed-by: https://github.com/trflynn89
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/ResourceImplementationFile.h>
|
||||
#include <LibGfx/Font/BitmapFont.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
@ -19,25 +20,32 @@
|
||||
# define TEST_INPUT(x) ("test-inputs/" x)
|
||||
#endif
|
||||
|
||||
static void init_font_database()
|
||||
{
|
||||
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(TEST_INPUT(""_string)));
|
||||
Gfx::FontDatabase::the().load_all_fonts_from_uri("resource:///"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(test_fontdatabase_get_by_name)
|
||||
{
|
||||
Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
|
||||
init_font_database();
|
||||
|
||||
auto name = "Family 12 400 0"sv;
|
||||
auto& font_database = Gfx::FontDatabase::the();
|
||||
auto name = "Family 12 400 0"sv;
|
||||
EXPECT(!font_database.get_by_name(name)->name().is_empty());
|
||||
}
|
||||
|
||||
TEST_CASE(test_fontdatabase_get)
|
||||
{
|
||||
Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
|
||||
init_font_database();
|
||||
|
||||
auto& font_database = Gfx::FontDatabase::the();
|
||||
EXPECT(!font_database.get("Family"_fly_string, 12, 400, Gfx::FontWidth::Normal, 0)->name().is_empty());
|
||||
}
|
||||
|
||||
TEST_CASE(test_fontdatabase_for_each_font)
|
||||
{
|
||||
Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
|
||||
init_font_database();
|
||||
|
||||
auto& font_database = Gfx::FontDatabase::the();
|
||||
font_database.for_each_font([&](Gfx::Font const& font) {
|
||||
|
Loading…
Reference in New Issue
Block a user