ya2 · news · projects · code · about

removed uml diagrams
[pmachines.git] / tests / lib / engine / test_engine.py
1 from pathlib import Path
2 import sys
3 if '' in sys.path: sys.path.remove('')
4 sys.path.append(str(Path(__file__).parent.parent.parent))
5 from unittest.mock import create_autospec
6 from unittest import TestCase
7 from panda3d.core import loadPrcFileData, NodePath, ConfigVariableBool
8 from ya2.engine.engine import Engine
9 from ya2.engine.configuration import Cfg, CursorCfg
10
11
12 class ConfigurationTests(TestCase):
13
14 def setUp(self):
15 loadPrcFileData('', 'window-type none')
16 loadPrcFileData('', 'audio-library-name null')
17
18 def tearDown(self):
19 self.engine.destroy()
20
21 def test_init(self):
22 self.engine = Engine(Cfg(cursor_cfg=CursorCfg(cursor_hidden=True)))
23 self.assertTrue(ConfigVariableBool('cursor-hidden'))
24 self.assertFalse(ConfigVariableBool('fullscreen'))
25
26
27 class EngineTests(TestCase):
28
29 def setUp(self):
30 loadPrcFileData('', 'window-type none')
31 loadPrcFileData('', 'audio-library-name null')
32
33 def tearDown(self):
34 self.engine.destroy()
35
36 def test_init(self):
37 self.engine = Engine()
38 self.engine.camera = create_autospec(NodePath)
39 self.assertIsInstance(self.engine, Engine)
40
41
42 # class Accepter(DirectObject):
43 #
44 # def __init__(self):
45 # self = evt_dec(self)
46 #
47 # def evt_MouseClick(self, arg):
48 # self.button = arg.button, 0
49 #
50 # def evt_MouseClickUp(self, arg):
51 # self.button = arg.button, 1
52 #
53 #
54 # class EventsTests(TestCase):
55 #
56 # def setUp(self):
57 # loadPrcFileData('', 'window-type none')
58 # self.engine = Engine()
59 # self.engine.mouseWatcherNode = create_autospec(MouseWatcher)
60 # self.engine.camLens = create_autospec(Lens)
61 # self.engine.camera = create_autospec(NodePath)
62 # self.engine.cam = NodePath()
63 #
64 # def tearDown(self):
65 # self.engine.destroy()
66 #
67 # def test_init(self):
68 # self.assertIsInstance(self.engine, Engine)
69 # mouse_move = MouseMove(0, 0)
70 # self.assertIsInstance(mouse_move, MouseMove)
71 # mouse_enter = MouseEnter(0, 0)
72 # self.assertIsInstance(mouse_enter, MouseEnter)
73 # mouse_exit = MouseExit(0, 0, 0)
74 # self.assertIsInstance(mouse_exit, MouseExit)
75 # mouse_click = MouseClick(0, 0, 0)
76 # self.assertIsInstance(mouse_click, MouseClick)
77 # mouse_clickup = MouseClickUp(0, 0, 0)
78 # self.assertIsInstance(mouse_clickup, MouseClickUp)
79 # mouse_mgr = MouseMgr(self.engine)
80 # self.assertIsInstance(mouse_mgr, MouseMgr)
81 # self.assertEqual(mouse_mgr.pt_from_to, (0, 0))
82 # self.assertEqual(mouse_mgr.pt_from, (0, 0, 0))
83 # self.assertEqual(mouse_mgr.pt_to, (0, 0, 0))
84 # acc = Accepter()
85 # self.engine.messenger.send('mouse1')
86 # self.assertEqual(acc.button, (0, 0))
87 # self.engine.messenger.send('mouse1-up')
88 # self.assertEqual(acc.button, (0, 1))
89 # self.engine.messenger.send('mouse3')
90 # self.assertEqual(acc.button, (1, 0))
91 # self.engine.messenger.send('mouse3-up')
92 # self.assertEqual(acc.button, (1, 1))