1 # from pathlib import Path
3 # if '' in sys.path: sys.path.remove('')
4 # sys.path.append(str(Path(__file__).parent.parent.parent))
5 # from unittest import TestCase
6 # from panda3d.core import loadPrcFileData
7 # from ya2.gameobject import GameObject
8 # from ya2.engine.engine import Engine
9 # from ya2.computer_proxy import ComputerProxy, compute_once, once_a_frame
12 # class ExampleProxy(GameObject, ComputerProxy):
15 # GameObject.__init__(self)
16 # ComputerProxy.__init__(self)
19 # def reset(self): self.cnt = 0
22 # def inc_cnt(self): self.cnt += 1
25 # def inc_cnt_frame(self): self.cnt += 1
28 # class ComputerProxyTests(TestCase):
31 # loadPrcFileData('', 'window-type none')
32 # loadPrcFileData('', 'audio-library-name null')
33 # self.engine = Engine()
34 # self.example_proxy = ExampleProxy()
37 # self.engine.destroy()
39 # def test_init(self):
40 # self.assertIsInstance(self.example_proxy, ExampleProxy)
42 # def test_compute_once(self):
43 # self.example_proxy.reset()
44 # self.example_proxy.inc_cnt()
45 # self.example_proxy.inc_cnt()
46 # self.assertEqual(self.example_proxy.cnt, 1)
48 # def test_compute_once_a_frame(self):
49 # self.example_proxy.reset()
50 # self.example_proxy.on_start_frame()
51 # self.example_proxy.inc_cnt_frame()
52 # self.example_proxy.inc_cnt_frame()
53 # self.assertEqual(self.example_proxy.cnt, 1)
54 # self.example_proxy.on_start_frame()
55 # self.example_proxy.inc_cnt_frame()
56 # self.example_proxy.inc_cnt_frame()
57 # self.assertEqual(self.example_proxy.cnt, 2)