mirror of
https://github.com/SerenityOS/serenity
synced 2024-11-05 17:46:52 +00:00
Tests: Load Resources via Core::Resource URIs in FontHandling tests
This commit is contained in:
parent
2e759656de
commit
09e3921ff8
1 changed files with 12 additions and 4 deletions
|
@ -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 a new issue