From 3c1ea2861b6885fb43272da8de76bf3cb4913472 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Sat, 30 Jul 2022 07:19:22 -0400 Subject: [PATCH] Tests: Update TestFontHandling and add new test Updates BitmapFont testing for fallible writes and adds a new test font file for use in a new un/masking test. --- Tests/LibGfx/CMakeLists.txt | 2 ++ Tests/LibGfx/TestFont.font | Bin 0 -> 25200 bytes Tests/LibGfx/TestFontHandling.cpp | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Tests/LibGfx/TestFont.font diff --git a/Tests/LibGfx/CMakeLists.txt b/Tests/LibGfx/CMakeLists.txt index cf18c0e1624..e60333f25fa 100644 --- a/Tests/LibGfx/CMakeLists.txt +++ b/Tests/LibGfx/CMakeLists.txt @@ -7,3 +7,5 @@ set(TEST_SOURCES foreach(source IN LISTS TEST_SOURCES) serenity_test("${source}" LibGfx LIBS LibGUI) endforeach() + +install(FILES TestFont.font DESTINATION usr/Tests/LibGfx) diff --git a/Tests/LibGfx/TestFont.font b/Tests/LibGfx/TestFont.font new file mode 100644 index 0000000000000000000000000000000000000000..a6423c8919037836c6341a19a3205b911ed3cf0a GIT binary patch literal 25200 zcmeI)u?oU45C-6j)Ili)H#hZVI{FSB90cp+;^rgx$R^+rgm#s}cW`jz&v1O%bL#Jp zZF`KAHmmlX;yjF(n5ljkueay)g)|+N z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfWSWm>i;wMd6DMZWv4PP Orq+wu)S|xv`RzWRk_UeP literal 0 HcmV?d00001 diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp index 72ed49460f3..e2917f038c2 100644 --- a/Tests/LibGfx/TestFontHandling.cpp +++ b/Tests/LibGfx/TestFontHandling.cpp @@ -131,6 +131,24 @@ TEST_CASE(test_write_to_file) char path[] = "/tmp/new.font.XXXXXX"; EXPECT(mkstemp(path) != -1); - EXPECT(font->write_to_file(path)); + EXPECT(!font->write_to_file(path).is_error()); unlink(path); } + +TEST_CASE(test_character_set_masking) +{ + auto font = Gfx::BitmapFont::try_load_from_file("/usr/Tests/LibGfx/TestFont.font"); + EXPECT(!font.is_error()); + + auto unmasked_font = font.value()->unmasked_character_set(); + EXPECT(!unmasked_font.is_error()); + EXPECT(unmasked_font.value()->glyph_index(0x0041).value() == 0x0041); + EXPECT(unmasked_font.value()->glyph_index(0x0100).value() == 0x0100); + EXPECT(unmasked_font.value()->glyph_index(0xFFFD).value() == 0xFFFD); + + auto masked_font = unmasked_font.value()->masked_character_set(); + EXPECT(!masked_font.is_error()); + EXPECT(masked_font.value()->glyph_index(0x0041).value() == 0x0041); + EXPECT(!masked_font.value()->glyph_index(0x0100).has_value()); + EXPECT(masked_font.value()->glyph_index(0xFFFD).value() == 0x1FD); +}