ya2 · news · projects · code · about

8a8a011e9b1c2d53f0b92bf5a2f80e104c37c096
[pmachines.git] / tests / ya2 / utils / gui / test_cursor.py
1 from panda3d.core import load_prc_file_data
2 load_prc_file_data('', 'window-type none')
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 direct.showbase.ShowBase import ShowBase
9 from ya2.utils.gui.cursor import MouseCursor, MouseCursorInfo
10
11
12 class CursorTests(TestCase):
13
14 def setUp(self):
15 self.__app = ShowBase()
16
17 def tearDown(self):
18 self.__app.destroy()
19
20 def test_cursor(self):
21 i = MouseCursorInfo('tests/assets/images/icon16.png', False, (1, 1, 1), (1, 1, 1, 1), (0, 0))
22 c = MouseCursor(i)
23 c.set_image('tests/assets/images/icon32.png')
24 self.assertEqual('tests/assets/images/icon32.png', c._MouseCursor__image.get_texture().get_filename())
25 c.set_color((0, 1, 0, 1))
26 self.assertEqual((0, 1, 0, 1), c._MouseCursor__image.get_color())
27 c.show()
28 self.assertFalse(c._MouseCursor__image.is_hidden())
29 c.hide()
30 self.assertTrue(c._MouseCursor__image.is_hidden())
31 c.destroy()
32 self.assertNotIn('on_frame_cursor', [t.name for t in taskMgr.getTasks() + taskMgr.getDoLaters()])
33 self.assertTrue(c._MouseCursor__image.is_empty())