mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +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 <AK/Utf8View.h>
|
||||||
|
#include <LibCore/ResourceImplementationFile.h>
|
||||||
#include <LibGfx/Font/BitmapFont.h>
|
#include <LibGfx/Font/BitmapFont.h>
|
||||||
#include <LibGfx/Font/FontDatabase.h>
|
#include <LibGfx/Font/FontDatabase.h>
|
||||||
#include <LibTest/TestCase.h>
|
#include <LibTest/TestCase.h>
|
||||||
|
@ -19,25 +20,32 @@
|
||||||
# define TEST_INPUT(x) ("test-inputs/" x)
|
# define TEST_INPUT(x) ("test-inputs/" x)
|
||||||
#endif
|
#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)
|
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& font_database = Gfx::FontDatabase::the();
|
||||||
|
auto name = "Family 12 400 0"sv;
|
||||||
EXPECT(!font_database.get_by_name(name)->name().is_empty());
|
EXPECT(!font_database.get_by_name(name)->name().is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(test_fontdatabase_get)
|
TEST_CASE(test_fontdatabase_get)
|
||||||
{
|
{
|
||||||
Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
|
init_font_database();
|
||||||
|
|
||||||
auto& font_database = Gfx::FontDatabase::the();
|
auto& font_database = Gfx::FontDatabase::the();
|
||||||
EXPECT(!font_database.get("Family"_fly_string, 12, 400, Gfx::FontWidth::Normal, 0)->name().is_empty());
|
EXPECT(!font_database.get("Family"_fly_string, 12, 400, Gfx::FontWidth::Normal, 0)->name().is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(test_fontdatabase_for_each_font)
|
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();
|
auto& font_database = Gfx::FontDatabase::the();
|
||||||
font_database.for_each_font([&](Gfx::Font const& font) {
|
font_database.for_each_font([&](Gfx::Font const& font) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue