def testSimpleEvents(self): def getMouseState(): Event = player.getMouseState() self.assertEqual(Event.pos, avg.Point2D(10,10)) root = self.loadEmptyScene() img1 = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root) handlerTester1 = NodeHandlerTester(self, img1) img2 = avg.ImageNode(pos=(64,0), href="rgb24-65x65.png", parent=root) handlerTester2 = NodeHandlerTester(self, img2) self.start(False, (# down, getMouseState(), move, up. # events are inside img1 but outside img2. lambda: self.assert_(not(player.isMultitouchAvailable())), lambda: self._sendMouseEvent(avg.Event.CURSOR_DOWN, 10, 10), lambda: handlerTester1.assertState( (avg.Node.CURSOR_DOWN, avg.Node.CURSOR_OVER)), lambda: handlerTester2.assertState(()), getMouseState, lambda: self._sendMouseEvent(avg.Event.CURSOR_MOTION, 12, 12), lambda: handlerTester1.assertState((avg.Node.CURSOR_MOTION,)), lambda: self._sendMouseEvent(avg.Event.CURSOR_UP, 12, 12), lambda: handlerTester1.assertState((avg.Node.CURSOR_UP,)) ))
def testTangibleEvents(self): root = self.loadEmptyScene() img1 = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root) handlerTester1 = NodeHandlerTester(self, img1) self.start(False, (# down, move, up. lambda: self.assert_(not(player.isMultitouchAvailable())), lambda: self._sendTangibleEvent(1, 3, avg.Event.CURSOR_DOWN, 10, 10), lambda: handlerTester1.assertState( (avg.Node.TANGIBLE_DOWN, avg.Node.TANGIBLE_OVER)), lambda: self._sendTangibleEvent(1, 3, avg.Event.CURSOR_MOTION, 12, 12), lambda: handlerTester1.assertState((avg.Node.TANGIBLE_MOTION,)), lambda: self._sendTangibleEvent(1, 3, avg.Event.CURSOR_UP, 12, 12), lambda: handlerTester1.assertState( (avg.Node.TANGIBLE_UP, avg.Node.TANGIBLE_OUT)) ))