diff --git a/src/python/magnum/test/test_text.py b/src/python/magnum/test/test_text.py index f441eca..9c19962 100644 --- a/src/python/magnum/test/test_text.py +++ b/src/python/magnum/test/test_text.py @@ -66,8 +66,8 @@ class Font(unittest.TestCase): font.glyph_size(0) with self.assertRaisesRegex(AssertionError, "no file opened"): font.glyph_advance(0) - # fill_glyph_cache() not tested as it needs a GL context; assuming it's - # correct + # fill_glyph_cache() not tested as it needs a GL context; verified in + # test_text_gl instead def test_open_failed(self): font = text.FontManager().load_and_instantiate('StbTrueTypeFont') diff --git a/src/python/magnum/test/test_text_gl.py b/src/python/magnum/test/test_text_gl.py index 09e205b..b6e6d7e 100644 --- a/src/python/magnum/test/test_text_gl.py +++ b/src/python/magnum/test/test_text_gl.py @@ -63,6 +63,26 @@ class GlyphCacheGL(GLTestCase): cache = text.GlyphCacheGL(PixelFormat.R8_UNORM, (128, 128)) self.assertEqual(cache.padding, (1, 1)) + def test_fill(self): + # Tested here and not in test_text.Font as the AbstractGlyphCache base + # isn't instantiable + cache = text.GlyphCacheGL(PixelFormat.R8_UNORM, (128, 128)) + font = text.FontManager().load_and_instantiate('StbTrueTypeFont') + + font.open_file(os.path.join(os.path.dirname(__file__), 'Oxygen.ttf'), 16.0) + self.assertTrue(font.is_opened) + self.assertTrue(font.fill_glyph_cache(cache, "abcd")) + + def test_fill_no_file_opened(self): + # Tested here and not in test_text.Font as the AbstractGlyphCache base + # isn't instantiable + cache = text.GlyphCacheGL(PixelFormat.R8_UNORM, (128, 128)) + font = text.FontManager().load_and_instantiate('StbTrueTypeFont') + self.assertFalse(font.is_opened) + + with self.assertRaisesRegex(AssertionError, "no file opened"): + font.fill_glyph_cache(cache, "abcd") + class DistanceFieldGlyphCacheGL(GLTestCase): def test(self): cache = text.DistanceFieldGlyphCacheGL((1024, 1024), (128, 128), 2)