da34e569f112f87c8fdaed0b252e80c7abc49aa5
1 from panda3d
.core
import load_prc_file_data
2 load_prc_file_data('', 'window-type offscreen')
3 from pathlib
import Path
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
9 from panda3d
.core
import get_model_path
, Texture
10 from direct
.showbase
.ShowBase
import ShowBase
11 from ya2
.utils
.gui
import GuiTools
15 class TestApp(ShowBase
): pass
18 class GraphicsToolsTests(TestCase
):
21 self
.__app
= TestApp()
22 get_model_path().append_directory(str(Path(__file__
).parent
.parent
.parent
))
27 @patch.object(ya2
.utils
.gui
, 'load_prc_file_data')
28 def test_no_window(self
, l_mock
):
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)
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)