def keyRelease(self, widget, key, modifier=qt.Qt.NoModifier, delay=-1): """Sends a Qt key release event. See QTest.keyRelease for details. """ QTest.keyRelease(widget, key, modifier, delay) self.qWait(20)
def testMoveCameraWithKeyboard(self): self.cc.panSpeed = 1 self.cc.tiltSpeed = 2 QTest.keyPress(self.cc, Qt.Key_Up) self.cam.moveUp.assert_called_once_with(1, 2) QTest.keyRelease(self.cc, Qt.Key_Up) self.cam.stop.assert_called_once_with() self.cam.stop.reset_mock() QTest.keyPress(self.cc, Qt.Key_Down) self.cam.moveDown.assert_called_once_with(1, 2) QTest.keyRelease(self.cc, Qt.Key_Down) self.cam.stop.assert_called_once_with() self.cam.stop.reset_mock() QTest.keyPress(self.cc, Qt.Key_Left) self.cam.moveLeft.assert_called_once_with(1, 2) QTest.keyRelease(self.cc, Qt.Key_Left) self.cam.stop.assert_called_once_with() self.cam.stop.reset_mock() QTest.keyPress(self.cc, Qt.Key_Right) self.cam.moveRight.assert_called_once_with(1, 2) QTest.keyRelease(self.cc, Qt.Key_Right) self.cam.stop.assert_called_once_with() self.cam.stop.reset_mock()
def testMoveCameraWithKeyboard(self): cc = CameraControl(self.mockController, "Test Camera") QTest.keyPress(cc, Qt.Key_Up) self.mockController.move.assert_called_with("Test Camera", CameraMove.Up) QTest.keyRelease(cc, Qt.Key_Up) self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) QTest.keyPress(cc, Qt.Key_Down) self.mockController.move.assert_called_with("Test Camera", CameraMove.Down) QTest.keyRelease(cc, Qt.Key_Down) self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) QTest.keyPress(cc, Qt.Key_Left) self.mockController.move.assert_called_with("Test Camera", CameraMove.Left) QTest.keyRelease(cc, Qt.Key_Left) self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) QTest.keyPress(cc, Qt.Key_Right) self.mockController.move.assert_called_with("Test Camera", CameraMove.Right) QTest.keyRelease(cc, Qt.Key_Right) self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop)