Commit | Line | Data |
---|---|---|
bf77b5d5 FC |
1 | from panda3d.core import load_prc_file_data |
2 | load_prc_file_data('', 'window-type offscreen') | |
3 | from pathlib import Path | |
4 | import sys | |
5 | if '' in sys.path: sys.path.remove('') | |
6 | sys.path.append(str(Path(__file__).parent.parent.parent)) | |
7 | from unittest import TestCase | |
8 | from unittest.mock import patch | |
7ac52030 | 9 | from panda3d.core import get_model_path, Texture |
bf77b5d5 FC |
10 | from direct.showbase.ShowBase import ShowBase |
11 | from ya2.utils.gui import GuiTools | |
12 | import ya2 | |
13 | ||
14 | ||
15 | class TestApp(ShowBase): pass | |
16 | ||
17 | ||
18 | class GraphicsToolsTests(TestCase): | |
19 | ||
20 | def setUp(self): | |
21 | self.__app = TestApp() | |
22 | get_model_path().append_directory(str(Path(__file__).parent.parent.parent)) | |
23 | ||
24 | def tearDown(self): | |
25 | self.__app.destroy() | |
26 | ||
27 | @patch.object(ya2.utils.gui, 'load_prc_file_data') | |
28 | def test_no_window(self, l_mock): | |
29 | GuiTools.no_window() | |
30 | l_mock.assert_called_once() | |
31 | l_args = l_mock.call_args_list[0].args | |
32 | self.assertEqual(l_args[0], '') | |
33 | self.assertEqual(l_args[1], 'window-type none') | |
34 | self.assertEqual(len(l_args), 2) | |
7ac52030 FC |
35 | |
36 | def test_font(self): | |
37 | f = GuiTools.load_font('assets/fonts/Hanken-Book.ttf') | |
38 | self.assertEqual(f.get_pixels_per_unit(), 60) | |
39 | self.assertEqual(f.get_minfilter(), Texture.FTLinearMipmapLinear) | |
40 | self.assertEqual(f.get_outline_color(), (0, 0, 0, 1)) | |
41 | self.assertAlmostEqual(f.get_outline_feather(), .2, delta=.01) | |
42 | self.assertAlmostEqual(f.get_outline_width(), .8, delta=.01) |