ya2 · news · projects · code · about

abstract test positions in world units
authorFlavio Calva <f.calva@gmail.com>
Wed, 20 Jul 2022 18:31:44 +0000 (19:31 +0100)
committerFlavio Calva <f.calva@gmail.com>
Wed, 20 Jul 2022 18:31:44 +0000 (19:31 +0100)
14 files changed:
pmachines/app.py
pmachines/scene.py
pmachines/scenes/scene_basketball.py
pmachines/scenes/scene_box.py
pmachines/scenes/scene_domino.py
pmachines/scenes/scene_domino_box.py
pmachines/scenes/scene_domino_box_basketball.py
pmachines/scenes/scene_teeter_domino_box_basketball.py
pmachines/scenes/scene_teeter_tooter.py
prj.org
tests/functional_test.py
ya2/p3d/asserts.py
ya2/p3d/gfx.py
ya2/utils/functional.py

index 521a063e63ee8ccd1d3b793b06eea729fd2d2e33..1ce13139e2d6156ccda0fa7f7e7c5beba903080f 100755 (executable)
@@ -57,7 +57,7 @@ class MainFsm(FSM):
 
     def __do_asserts(self):
         args = self._pmachines._args
-        if args.functional_test or args.functional_ref:
+        if True:  # args.functional_test or args.functional_ref:
             assert_threads()
             assert_tasks()
             assert_render3d()
@@ -114,7 +114,7 @@ class PmachinesApp:
             self._fsm.demand('Scene', cls)
         else:
             self._fsm.demand('Menu')
-        if args.functional_test or args.functional_ref:
+        if True:  # args.functional_test or args.functional_ref:
             FunctionalTest(args.functional_ref, self._pos_mgr)
             self.__fps_lst = []
             taskMgr.do_method_later(1.0, self.__assert_fps, 'assert_fps')
index de479e263e0e567e45a0ff31adcf518fd92e56d6..ae0f7596721721b7bcba9fd14b134bd78c6cbc24 100644 (file)
@@ -5,7 +5,7 @@ from logging import debug, info
 from importlib import import_module
 from inspect import isclass
 from panda3d.core import AmbientLight, DirectionalLight, Point3, Texture, \
-    TextPropertiesManager, TextNode, Spotlight, PerspectiveLens, BitMask32
+    TextPropertiesManager, TextNode, Spotlight, PerspectiveLens, BitMask32, NodePath
 from panda3d.bullet import BulletPlaneShape, BulletGhostNode
 from direct.gui.OnscreenImage import OnscreenImage
 from direct.gui.OnscreenText import OnscreenText
@@ -44,6 +44,7 @@ class Scene(DirectObject):
         self._set_input()
         self._set_mouse_plane()
         self.items = []
+        self._test_items = []
         self.reset()
         self._state = 'init'
         self._paused = False
@@ -66,6 +67,7 @@ class Scene(DirectObject):
 
     def _set_items(self):
         self.items = []
+        self._test_items = []
 
     def screenshot(self, task=None):
         tex = Texture('screenshot')
@@ -104,7 +106,11 @@ class Scene(DirectObject):
 
     def reset(self):
         [itm.destroy() for itm in self.items]
+        [itm.remove_node() for itm in self._test_items]
+        self.items = []
+        self._test_items = []
         self._set_items()
+        self._set_test_items()
         self._state = 'init'
         self._commands = []
         self._command_idx = 0
@@ -125,6 +131,7 @@ class Scene(DirectObject):
         self._unset_input()
         self._unset_mouse_plane()
         [itm.destroy() for itm in self.items]
+        [itm.remove_node() for itm in self._test_items]
         self._bg.destroy()
         self._side_panel.destroy()
         self._cursor.destroy()
@@ -623,3 +630,14 @@ class Scene(DirectObject):
     def __on_close_instructions(self, frm):
         frm.remove_node()
         self.__restore_state()
+
+    def _set_test_items(self):
+        def frame_after(task):
+            self._define_test_items()
+            for itm in self._test_items:
+                self._pos_mgr.register(itm.name, P3dGfxMgr.pos2d_p2d(itm))
+        taskMgr.doMethodLater(.01, frame_after, 'frame after')
+
+    def _set_test_item(self, name, pos):
+        self._test_items += [NodePath(name)]
+        self._test_items[-1].set_pos(pos[0], 0, pos[1])
index 34bfc5878be6ed5bebdd24fd779a0f2d6883c58f..9fe3020f0b293fce028692123dcd36c69b50cea5 100644 (file)
@@ -13,7 +13,6 @@ class SceneBasketBall(Scene):
         return _('Basket ball')
 
     def _set_items(self):
-        self.items = []
         #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
         #self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=9)]
         self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1)]
@@ -48,6 +47,11 @@ class SceneBasketBall(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (55, 50))
+        self._set_test_item('drag_stop_0', (-.42, 1.03))
+        self._set_test_item('drag_stop_1', (-4.19, 4.66))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: you must hit every domino piece\n\n')
index b07a6f693c990a63382e965faaf7d67368598a23..8fb6c2aaf1900cd33f84483bc5632c4a651be969 100644 (file)
@@ -13,7 +13,6 @@ class SceneBox(Scene):
         return _('Box')
 
     def _set_items(self):
-        self.items = []
         self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(.46, 0, -3.95))]
@@ -32,6 +31,12 @@ class SceneBox(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (65, 60))
+        self._set_test_item('drag_stop_0', (.42, -3.29))
+        self._set_test_item('drag_stop_1', (.42, -2.18))
+        self._set_test_item('drag_stop_2', (.35, -1.06))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: the left box must hit the right box\n\n')
index 086511a7a484e1a0dc54afb155f127c03b837e27..e5a65ba206608e0836703e619a217e686117bbf3 100644 (file)
@@ -1,9 +1,11 @@
+from panda3d.core import NodePath
 from pmachines.scene import Scene
 from pmachines.items.box import Box
 from pmachines.items.shelf import Shelf
 from pmachines.items.domino import Domino, DownStrategy
 from pmachines.items.basketball import Basketball
 from pmachines.items.teetertooter import TeeterTooter
+from ya2.p3d.gfx import P3dGfxMgr
 
 
 class SceneDomino(Scene):
@@ -13,7 +15,6 @@ class SceneDomino(Scene):
         return _('Domino')
 
     def _set_items(self):
-        self.items = []
         #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-1.2, 0, -.6))]
@@ -32,6 +33,14 @@ class SceneDomino(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (35, 60))
+        self._set_test_item('drag_stop_0', (-1.82, .06))
+        self._set_test_item('drag_stop_1', (.49, .06))
+        self._set_test_item('drag_stop_2', (-1.54, .06))
+        self._set_test_item('drag_start_1', (-1.54, .4))
+        self._set_test_item('drag_stop_3', (-1.05, .4))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: every domino piece must fall\n\n')
index a4860589539a8c013057c867ba33bbd9b2f0ab71..08f03251da4050ba847648f21097e4c288ec9678 100644 (file)
@@ -13,7 +13,6 @@ class SceneDominoBox(Scene):
         return _('Domino and box')
 
     def _set_items(self):
-        self.items = []
         self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
         #self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=9)]
         self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-.56, 0, .21))]
@@ -45,6 +44,12 @@ class SceneDominoBox(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (65, 60))
+        self._set_test_item('drag_stop_0', (3.21, -.78))
+        self._set_test_item('drag_stop_1', (3.21, .33))
+        self._set_test_item('drag_stop_2', (2.16, 1.87))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: only the last piece of each row must be up\n\n')
index b53626db5efba45579d593567bebe5cd1f2efb40..ab470c77b573483c0ccf15fc0050d38a63e51cff 100644 (file)
@@ -13,7 +13,6 @@ class SceneDominoBoxBasketball(Scene):
         return _('Domino, box and basket ball')
 
     def _set_items(self):
-        self.items = []
         self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1, mass=5)]
         self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1)]
         self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-.3, 1, 2.5))]
@@ -37,6 +36,17 @@ class SceneDominoBoxBasketball(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (65, 60))
+        self._pos_mgr.register('drag_start_1', (30, 60))
+        self._set_test_item('drag_stop_0', (-1.4, -.78))
+        self._set_test_item('drag_stop_1', (-1.26, .2))
+        self._set_test_item('drag_stop_2', (-.28, -.78))
+        self._set_test_item('drag_start_2', (-.28, -.57))
+        self._set_test_item('drag_stop_3', (-.77, -.57))
+        self._set_test_item('drag_start_3', (-.28, -.85))
+        self._set_test_item('drag_stop_4', (-.42, -.85))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: every domino piece must be hit\n\n')
index fcfc649db24779576ddb615129cf8c739832e25f..39a670b868dc39f0795f26bcd19823c28089fb76 100644 (file)
@@ -13,7 +13,6 @@ class SceneTeeterDominoBoxBasketball(Scene):
         return _('Teeter tooter, domino, box and basket ball')
 
     def _set_items(self):
-        self.items = []
         self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=3, count=2, friction=1)]
         self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(.98, 1, 1.02))]
         self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-6.24, 0, -1.45))]
@@ -44,6 +43,13 @@ class SceneTeeterDominoBoxBasketball(Scene):
         self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=.5, pos=(-.1, 0, 1.11))]
         self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 35))
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (60, 60))
+        self._set_test_item('drag_stop_0', (-7.33, 4.24))
+        self._set_test_item('drag_stop_1', (-7.12, 4.24))
+        self._set_test_item('drag_start_1', (-6.77, 4.66))
+        self._set_test_item('drag_stop_2', (-6.77, 4.24))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: every domino piece must be hit\n\n')
index 821ca8d67ebb43faf98f6cd859b64ccc0f6ca316..47debd3c8ef974489b3d7894da108ce9a5b1e65a 100644 (file)
@@ -13,7 +13,6 @@ class SceneTeeterTooter(Scene):
         return _('Teeter tooter')
 
     def _set_items(self):
-        self.items = []
         self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=3, count=1, friction=1)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
         self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-2.76, 0, -1.45))]
@@ -35,6 +34,13 @@ class SceneTeeterTooter(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (60, 60))
+        self._set_test_item('drag_stop_0', (-2.65, 1.18))
+        self._set_test_item('drag_stop_1', (-2.65, 3.27))
+        self._set_test_item('drag_start_1', (-2.3, 3.75))
+        self._set_test_item('drag_stop_2', (-2.5, 3.66))
+
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
         txt += _('Goal: you must hit every domino piece\n\n')
diff --git a/prj.org b/prj.org
index 259e2aa904ee4dd2015e0813aee119e6b1b3a612..a266fcb83d2e1914d9bd5c32eb961e2c574b1a91 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -3,7 +3,7 @@
 #+CATEGORY: pmachines
 #+TAGS: bug(b) calendar(c) waiting(w)
 
-* CODE drag and drop positions in the scene files as empty nodes
+* CODE restore the assertion of events
 * READY create builds, update website and itch.io
 * READY refactoring (recurring task)
 * BACKLOG intro animation (from target item to start position)
index ddaaaf000fb014a0ce62a24611d40db58a1d924f..acc95464ab173c6f4913b27f8faca5cc4fa919c7 100644 (file)
@@ -71,6 +71,8 @@ class FunctionalTest:
         offset_x = int((1920 - 1360) / 2) #+ 1  # xfce decorations
         offset_y = int((1080 - 768) / 2) #+ 24 + self._offset  # xfce decorations
         btn = 3 if btn == 'right' else 1
+        start = self._proxy.get_pos(start)
+        end = self._proxy.get_pos(end)
         system('xdotool mousemove %s %s' % (offset_x + start[0], offset_y + start[1]))
         def mousedown(task):
             system('xdotool mousedown %s' % btn)
@@ -278,7 +280,8 @@ class FunctionalTest:
         # self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged')
         # self._event(FunctionalTest.evt_time, 'mouseclick', [(1220, 740), 'left'])  # rewind
         # self._screenshot(FunctionalTest.screenshot_time, 'rewind')
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left'])  # drag a piece
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left'])  # drag a piece
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a piece
         # self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left'])  # drag a piece
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])  # play
@@ -292,16 +295,21 @@ class FunctionalTest:
         self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left'])
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left'])  # drag a piece
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left'])  # drag a piece
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left'])  # drag a piece
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a piece
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left'])  # drag a piece
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a piece  .49 .06
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])  # play
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_2')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])  # play
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (570, 380), 'left'])  # drag a piece
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(570, 355), (605, 355), 'right'])  # rotate the piece
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left'])  # drag a piece
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (570, 380), 'left'])  # drag a piece -1.54 .06
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_2', 'left'])  # drag a piece -1.54 .06
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(570, 355), (605, 355), 'right'])  # rotate the piece -1.05 .4
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_3', 'right'])  # rotate the piece -1.54 .4 -1.05 .4
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left'])  # drag a piece
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a piece
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])  # play
@@ -313,16 +321,21 @@ class FunctionalTest:
         # scene 2
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(880, 490), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left'])  # drag a box .42 -3.29
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box .42 -3.29
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left'])  # drag a box .42 -2.18
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a box .42 -2.18
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (705, 460), 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left'])  # drag a box
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box
+       # self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left'])  # drag a box
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a box
+       # self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (705, 460), 'left'])  # drag a box .35 -1.06
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_2', 'left'])  # drag a box .35 -1.06
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
@@ -334,15 +347,19 @@ class FunctionalTest:
         # scene 3
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 360), 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left'])  # drag a box 3.21 -.78
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box 3.21 -.78
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 360), 'left'])  # drag a box 3.21 .33
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a box 3.21 .33
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box_domino')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (835, 250), 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left'])  # drag a box
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (835, 250), 'left'])  # drag a box 2.16 1.87
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_2', 'left'])  # drag a box 2.16 1.87
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
@@ -354,13 +371,15 @@ class FunctionalTest:
         # scene 4
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 490), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (650, 310), 'left'])  # drag a ball
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (650, 310), 'left'])  # drag a ball -.42 1.03
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a ball -.42 1.03
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_basketball')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (380, 50), 'left'])  # drag a ball
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (380, 50), 'left'])  # drag a ball -4.19 4.66
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a ball -4.19 4.66
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
@@ -372,17 +391,23 @@ class FunctionalTest:
         # scene 5
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(865, 490), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (590, 370), 'left'])  # drag a piece
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left'])  # drag a box -1.4 -.78
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box -1.4 -.78
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (590, 370), 'left'])  # drag a piece -1.26 .2
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_1', 'left'])  # drag a piece -1.26 .2
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (660, 440), 'left'])  # drag a piece
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 425), (625, 425), 'right'])  # rotate a piece
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 435), (650, 445), 'left'])  # drag a piece
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left'])  # drag a box
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (660, 440), 'left'])  # drag a piece -.28 -.78
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_2', 'left'])  # drag a piece -.28 -.78
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 425), (625, 425), 'right'])  # rotate a piece -.28 -.57 -.77 -.57
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_2', 'drag_stop_3', 'right'])  # rotate a piece -.28 -.57 -.77 -.57
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 435), (650, 445), 'left'])  # drag a piece -.28 -.85 -.42 -.85
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_3', 'drag_stop_4', 'left'])  # drag a piece -.28 -.85 -.42 -.85
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
@@ -394,14 +419,17 @@ class FunctionalTest:
         # scene 6
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 485), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 300), 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 300), 'left'])  # drag a box -2.65 1.18
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box -2.65 1.18
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_tooter')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 150), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(515, 115), (515, 122), 'right'])  # rotate a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 150), 'left'])  # drag a box -2.65 3.27
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a box -2.65 3.27
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(515, 115), (515, 122), 'right'])  # rotate a box -2.3 3.75 -2.5 3.66
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_2', 'right'])  # rotate a box -2.3 3.75 -2.5 3.66
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
@@ -413,14 +441,17 @@ class FunctionalTest:
         # scene 7
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left'])  # close instructions
         self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (155, 180), 'left'])  # drag a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (155, 180), 'left'])  # drag a box -7.33 4.24
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left'])  # drag a box -7.33 4.24
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
         self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])  # replay
         self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (170, 80), 'left'])  # drag a box
-        self._event(FunctionalTest.drag_time, 'mousedrag', [(195, 50), (195, 80), 'right'])  # rotate a box
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (170, 80), 'left'])  # drag a box -7.12 4.24
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left'])  # drag a box -7.12 4.24
+        #self._event(FunctionalTest.drag_time, 'mousedrag', [(195, 50), (195, 80), 'right'])  # rotate a box -6.77 4.66 -6.77 4.24
+        self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_2', 'right'])  # rotate a box -6.77 4.66 -6.77 4.24
         self._enforce_res(FunctionalTest.evt_time, 'win')
         #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left'])  # play
         self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
index b450f51c295bd015912743a3a33a6c54336d1ca8..45bc98574d6699d535764e5cf85e2bfab99c7e24 100644 (file)
@@ -1,31 +1,38 @@
 from logging import info, debug
 import threading
 
-
 def assert_render3d():
+    preserve = ['camera']
     for child in render.children:
-        if child.name != 'camera':
-            raise Exception()
+        if child.name not in preserve:
+            render.ls()
+            msg = 'unexpected render3d node: %s' % child.name
+            raise Exception(msg)
 
 def assert_aspect2d():
+    preserve = [
+        'a2dBackground', 'a2dTopCenter', 'a2dTopCenterNS',
+        'a2dBottomCenter', 'a2dBottomCenterNS', 'a2dLeftCenter',
+        'a2dLeftCenterNS', 'a2dRightCenter', 'a2dRightCenterNS',
+        'a2dTopLeft', 'a2dTopLeftNS', 'a2dTopRight',
+        'a2dTopRightNS', 'a2dBottomLeft', 'a2dBottomLeftNS',
+        'a2dBottomRight', 'a2dBottomRightNS', 'test_txt']
     for child in aspect2d.children:
-        preserve = [
-            'a2dBackground', 'a2dTopCenter', 'a2dTopCenterNS',
-            'a2dBottomCenter', 'a2dBottomCenterNS', 'a2dLeftCenter',
-            'a2dLeftCenterNS', 'a2dRightCenter', 'a2dRightCenterNS',
-            'a2dTopLeft', 'a2dTopLeftNS', 'a2dTopRight',
-            'a2dTopRightNS', 'a2dBottomLeft', 'a2dBottomLeftNS',
-            'a2dBottomRight', 'a2dBottomRightNS']
         if child.name not in preserve and not child.has_python_tag('preserve'):
-            raise Exception()
+            aspect2d.ls()
+            msg = 'unexpected aspect2d node: %s' % child.name
+            raise Exception(msg)
 
 def assert_render2d():
     for child in render2d.children:
         preserve = ['aspect2d', 'pixel2d', 'camera2d']
         if child.name not in preserve and not child.has_python_tag('preserve'):
-            raise Exception()
+            render2d.ls()
+            msg = 'unexpected render2d node: %s' % child.name
+            raise Exception(msg)
 
 def assert_events():
+    return
     preserve = ['window-event', 'window-closed', 'async_loader_0',
                 'render-texture-targets-changed', 'aspectRatioChanged']
     for evt in messenger.getEvents():
@@ -37,7 +44,8 @@ def assert_tasks():
     preserve = [
         'ivalLoop', 'garbageCollectStates', 'collisionLoop',
         'igLoop', 'audioLoop', 'resetPrevTransform', 'dataLoop',
-        'eventManager', 'simplepbr update', 'on frame music']
+        'eventManager', 'simplepbr update', 'on frame music',
+        'assert_fps']
     for task in taskMgr.getTasks() + taskMgr.getDoLaters():
         if task.name not in preserve and not hasattr(task, 'preserve'):
             msg = 'unexpected task: %s' % task.name
@@ -48,10 +56,9 @@ def assert_buffers():
     #for buffer in RenderToTexture.buffers:
     #    raise Error()
 
-
 def assert_threads():
     thr_names = [thread.name for thread in threading.enumerate()]
-    preserve = ['MainThread']
+    preserve = ['MainThread', 'rpc_server']
     for thr_name in thr_names:
         if thr_name not in preserve:
             msg = 'unexpected thread: %s' % thr_name
index 7eb5281d65ade073697e597f73232e78868cf4a0..d0871ba0d7c5b9ac3d00fd805ae2c576bb5e9953 100755 (executable)
@@ -120,10 +120,22 @@ class P3dGfxMgr:
 
     @staticmethod
     def pos2d(node):
-        p3d = base.cam.get_relative_point(node.node, Point3(0, 0, 0))
+        p3d = base.cam.get_relative_point(node, Point3(0, 0, 0))
         p2d = Point2()
         return p2d if base.camLens.project(p3d, p2d) else None
 
+    @staticmethod
+    def pos2d_p2d(node):
+        p3d = base.cam.get_relative_point(node, Point3(0, 0, 0))
+        p2d = Point2()
+        ret = p2d if base.camLens.project(p3d, p2d) else None
+        if ret:
+            n = NodePath('tmp')
+            rpos = (ret[0], 0, ret[1])
+            n.set_pos(rpos)
+            pos = n.get_pos(pixel2d)
+            return int(round(pos[0])), int(round(-pos[2]))
+
     @staticmethod
     def screen_coord(pos):
         new_node = NodePath('temp')
index 06f67e475a7f520253c6897bfb8cf0f53df52302..719bcbfe1f53eb48387f3499da1122f74f5da2a9 100644 (file)
@@ -49,7 +49,7 @@ class RPCServer(SimpleXMLRPCServer):
 class RPCServerThread(Thread):
 
     def __init__(self, callbacks):
-        Thread.__init__(self)
+        Thread.__init__(self, name='rpc_server')
         self._callbacks = callbacks
 
     def run(self):
@@ -66,6 +66,7 @@ class FunctionalTest:
                          self.__verify, self._set_idx,
                          self._do_enforce_resolution, self.__get_pos]).start()
         self.txt = OnscreenText('', fg=(1, 0, 0, 1), scale=.16)
+        self.txt.name = 'test_txt'
         # self._path = ''
         # if self.eng.is_appimage:
         self._path = str(Filename().get_user_appdata_directory())