class TestEclipseControls(GuiTest): def setUp(self): GuiTest.setUp(self) self.mockController = Controller() conv = Device("Test Scan Converter") self.mockController.addDevice(conv) def testControls(self): self.mockController.toggleFade = MagicMock(return_value=1) self.mockController.toggleFreeze = MagicMock(return_value=1) self.mockController.toggleOverlay = MagicMock(return_value=1) self.mockController.toggleOverscan = MagicMock(return_value=1) ec = EclipseControls(self.mockController, "Test Scan Converter") self.findButton(ec, "Overscan").click() self.mockController.toggleOverscan.assert_called_once_with("Test Scan Converter", False) self.findButton(ec, "Overscan").click() self.mockController.toggleOverscan.assert_called_with("Test Scan Converter", True) self.findButton(ec, "Freeze").click() self.mockController.toggleFreeze.assert_called_once_with("Test Scan Converter", True) self.findButton(ec, "Freeze").click() self.mockController.toggleFreeze.assert_called_with("Test Scan Converter", False) self.findButton(ec, "Fade").click() self.mockController.toggleFade.assert_called_once_with("Test Scan Converter", True) self.findButton(ec, "Fade").click() self.mockController.toggleFade.assert_called_with("Test Scan Converter", False) self.findButton(ec, "Overlay").click() self.mockController.toggleOverlay.assert_called_once_with("Test Scan Converter", True) self.findButton(ec, "Overlay").click() self.mockController.toggleOverlay.assert_called_with("Test Scan Converter", False)
def testKramerVP88Listener(self): port = MockSerialPort() port.read = MagicMock(return_value=[chr(0x41), chr(0x82), chr(0x83), chr(0x81)]) # Notification that input 2 sent to output 3 k = KramerVP88("Test", port) c = Controller() c.addDevice(k) kl = KramerVP88Listener("TestListener", k.deviceID, c, machineNumber=1) dispatcher = NullDispatcher() dispatcher.updateOutputMappings = MagicMock() kl.registerDispatcher(dispatcher) kl.start() threading.Event().wait(0.1) kl.stop() dispatcher.updateOutputMappings.assert_called_with({'Test': {3: 2}})
def testLoadConfig(self): c = Controller() c.loadConfig(os.path.join(os.path.dirname(__file__), 'testConfig.json')) self.assertTrue(c.hasDevice("Main")) self.assertTrue(c.hasDevice("Main Listener")) self.assertTrue(isinstance(c.getDevice("Main"), KramerVP88)) self.assertTrue(isinstance(c.getDevice("Main Listener"), KramerVP88Listener))
def setUp(self): GuiTest.setUp(self) self.mockController = Controller() self.mockController.move = MagicMock(return_value=1) self.mockController.zoom = MagicMock(return_value=1) self.mockController.focus = MagicMock(return_value=1) self.mockMainWindow = MainWindow(self.mockController) cam = Device("Test Camera") self.mockController.addDevice(cam) cam.recallPreset = lambda x: {}
def testSendControlSignalsToBlinds(self): c = Controller() blinds = UpDownStopArray("Blinds", c) blinds.lower = MagicMock(return_value=0) blinds.raiseUp = MagicMock(return_value=0) blinds.stop = MagicMock(return_value=0) c.addDevice(blinds) c.lower("Blinds", 1) blinds.lower.assert_called_once_with(1) c.raiseUp("Blinds", 256) blinds.raiseUp.assert_called_once_with(256) c.stop("Blinds", 1138) blinds.stop.assert_called_once_with(1138)
class TestBlindsControl(GuiTest): def setUp(self): GuiTest.setUp(self) self.mockController = Controller() self.mockBlindsDevice = Device("Test") self.mockController.addDevice(self.mockBlindsDevice) self.mockMainWindow = MainWindow(self.mockController) def testBlinds(self): bc = BlindsControl(self.mockController, self.mockMainWindow) self.mockController.raiseUp = MagicMock() self.mockController.lower = MagicMock() self.mockController.stop = MagicMock() self.findButton(bc, "All").click() self.findButton(bc, "Raise").click() self.mockController.raiseUp.assert_called_once_with("Blinds", 0) self.findButton(bc, "Lower").click() self.mockController.lower.assert_called_once_with("Blinds", 0) self.findButton(bc, "Stop").click() self.mockController.stop.assert_called_once_with("Blinds", 0) self.mockController.raiseUp.reset_mock() self.mockController.lower.reset_mock() self.mockController.stop.reset_mock() self.findButton(bc, "3").click() self.findButton(bc, "Raise").click() self.mockController.raiseUp.assert_called_once_with("Blinds", 3) self.findButton(bc, "Lower").click() self.mockController.lower.assert_called_once_with("Blinds", 3) self.findButton(bc, "Stop").click() self.mockController.stop.assert_called_once_with("Blinds", 3) self.mockMainWindow.stepBack = MagicMock() self.findButton(bc, "Back").click() self.assertEqual(1, self.mockMainWindow.stepBack.call_count)
def setUp(self): GuiTest.setUp(self) self.mockController = Controller() self.main = Device("Main") self.mockController.addDevice(self.main) self.main.sendInputToOutput = MagicMock(return_value=1) self.preview = Device("Preview") self.mockController.addDevice(self.preview) self.preview.sendInputToOutput = MagicMock(return_value=1) self.extras = Device("Extras") self.mockController.addDevice(self.extras) self.extras.sendInputToOutput = MagicMock(return_value=1) fakeMainWindow = object() self.vs = VideoSwitcher(self.mockController, fakeMainWindow)
class TestVideoSwitcher(GuiTest): def setUp(self): GuiTest.setUp(self) self.mockController = Controller() self.main = Device("Main") self.mockController.addDevice(self.main) self.main.sendInputToOutput = MagicMock(return_value=1) self.preview = Device("Preview") self.mockController.addDevice(self.preview) self.preview.sendInputToOutput = MagicMock(return_value=1) self.extras = Device("Extras") self.mockController.addDevice(self.extras) self.extras.sendInputToOutput = MagicMock(return_value=1) fakeMainWindow = object() self.vs = VideoSwitcher(self.mockController, fakeMainWindow) def testSendInputsToOutputs(self): outputsGrid = self.vs.findChild(OutputsGrid) self.assertTrue(outputsGrid != None) self.vs.btnCamera1.click() self.preview.sendInputToOutput.assert_called_with(1, 1) # Camera 1 is previewed outputsGrid.btnChurch.click() self.main.sendInputToOutput.assert_called_with(1, 4) # Camera 1 sent to output 4 (church) self.vs.btnCamera3.click() self.preview.sendInputToOutput.assert_called_with(3, 1) # Camera 3 previewed outputsGrid.btnGallery.click() self.main.sendInputToOutput.assert_called_with(3, 6) # Camera 3 sent to output 6 (gallery) outputsGrid.btnPCMix.click() self.preview.sendInputToOutput.assert_called_with(3, 2) # Camera 3 sent to PC Mix self.vs.btnBlank.click() outputsGrid.btnAll.click() self.main.sendInputToOutput.assert_called_with(0, 0) # Everything blanked self.vs.btnExtras.click() self.preview.sendInputToOutput.assert_called_with(6, 1) # This is wired up the wrong way around - 5 on main vs 6 on preview self.vs.extrasSwitcher.inputs.buttons()[4].click() # Visuals PC video outputsGrid.btnAll.click() # This one click should trigger two takes, one on each switcher self.extras.sendInputToOutput.assert_called_with(8, 1) self.main.sendInputToOutput.assert_called_with(5, 0) # Extras to everywhere outputsGrid.btnPCMix.click() self.extras.sendInputToOutput.assert_called_with(8, 2) self.preview.sendInputToOutput.assert_called_with(6, 2) # Extras to PC Mix def testCantSendPCMixToItself(self): outputsGrid = self.vs.findChild(OutputsGrid) self.vs.btnVisualsPC.click() self.preview.sendInputToOutput.assert_called_with(5, 1) self.preview.sendInputToOutput.reset_mock() outputsGrid.btnPCMix.click() self.assertFalse(self.preview.sendInputToOutput.called) self.assertFalse(self.main.sendInputToOutput.called) self.assertFalse(outputsGrid.btnPCMix.isEnabled()) def testCantBlankPCMix(self): outputsGrid = self.vs.findChild(OutputsGrid) self.vs.btnBlank.click() outputsGrid.btnPCMix.click() self.assertFalse(self.preview.sendInputToOutput.called) self.assertFalse(self.main.sendInputToOutput.called) self.assertFalse(outputsGrid.btnPCMix.isEnabled()) def testKeyboardControls(self): QTest.keyClick(self.vs, Qt.Key_0) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(0, 0) QTest.keyClick(self.vs, Qt.Key_1) self.preview.sendInputToOutput.assert_called_with(1, 1) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(1, 0) QTest.keyClick(self.vs, Qt.Key_2) self.preview.sendInputToOutput.assert_called_with(2, 1) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(2, 0) QTest.keyClick(self.vs, Qt.Key_3) self.preview.sendInputToOutput.assert_called_with(3, 1) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(3, 0) QTest.keyClick(self.vs, Qt.Key_4) self.preview.sendInputToOutput.assert_called_with(4, 1) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(4, 0) QTest.keyClick(self.vs, Qt.Key_5) self.preview.sendInputToOutput.assert_called_with(6, 1) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(5, 0) QTest.keyClick(self.vs, Qt.Key_6) self.preview.sendInputToOutput.assert_called_with(5, 1) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(6, 0) self.main.sendInputToOutput.reset_mock() self.preview.sendInputToOutput.reset_mock() QTest.keyClick(self.vs, Qt.Key_7) self.assertFalse(self.preview.sendInputToOutput.called) QTest.keyClick(self.vs, Qt.Key_Space) self.main.sendInputToOutput.assert_called_with(6, 0) # which was the last valid input key pressed
#!/usr/bin/python from org.muscat.staldates.aldatesx.controller.Controller import Controller import Pyro4 import atexit import logging from org.muscat.staldates.aldatesx import PyroUtils def shutdownDaemon(daemon): daemon.shutdown() if __name__ == "__main__": logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.DEBUG) controller = Controller() controller.loadConfig("config.json") controller.initialise() PyroUtils.setHostname() daemon = Pyro4.Daemon() ns = Pyro4.locateNS() uri = daemon.register(controller) ns.register(Controller.pyroName, uri) atexit.register(shutdownDaemon, daemon=daemon) daemon.requestLoop()
class Test(GuiTest): def setUp(self): GuiTest.setUp(self) self.mockController = Controller() self.mockController.move = MagicMock(return_value=1) self.mockController.zoom = MagicMock(return_value=1) self.mockController.focus = MagicMock(return_value=1) self.mockMainWindow = MainWindow(self.mockController) cam = Device("Test Camera") self.mockController.addDevice(cam) cam.recallPreset = lambda x: {} def tearDown(self): self.app = None def testCannotSelectMultiplePresets(self): ''' See https://github.com/jamesremuscat/aldatesx/issues/23''' cc = CameraControl(self.mockController, "Test Camera") buttons = cc.presetGroup.buttons() self.assertEqual(-1, cc.presetGroup.checkedId()) cc.btnDown.click() buttons[1].click() self.assertTrue(buttons[1].isChecked()) self.assertFalse(buttons[0].isChecked()) buttons[0].click() self.assertEqual(0, cc.presetGroup.checkedId()) self.assertTrue(buttons[0].isChecked()) self.assertFalse(buttons[1].isChecked()) def testMoveCamera(self): cc = CameraControl(self.mockController, "Test Camera") cc.btnUp.pressed.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Up) cc.btnUp.released.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) cc.btnDown.pressed.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Down) cc.btnDown.released.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) cc.btnLeft.pressed.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Left) cc.btnLeft.released.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) cc.btnRight.pressed.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Right) cc.btnRight.released.emit() self.mockController.move.assert_called_with("Test Camera", CameraMove.Stop) 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) # Tests for advanced camera controls def testGetCameraPosition(self): fakePosition = CameraPosition(111, 222, 333) self.mockController.getPosition = MagicMock(return_value=fakePosition) acc = AdvancedCameraControl(self.mockController, "Test Camera", self.mockMainWindow) self.findButton(acc, "Get Position").click() self.mockController.getPosition.assert_called_once_with("Test Camera") self.assertEqual("111", acc.posDisplay.itemAtPosition(0, 1).widget().text()) self.assertEqual("222", acc.posDisplay.itemAtPosition(1, 1).widget().text()) self.assertEqual("333", acc.posDisplay.itemAtPosition(2, 1).widget().text()) def testChangeWhiteBalance(self): self.mockController.whiteBalance = MagicMock(return_value=1) acc = AdvancedCameraControl(self.mockController, "Test Camera", self.mockMainWindow) self.assertFalse(self.findButton(acc, "Set").isEnabled()) self.findButton(acc, "Auto").click() self.mockController.whiteBalance.assert_called_with("Test Camera", CameraWhiteBalance.Auto) self.assertFalse(self.findButton(acc, "Set").isEnabled()) self.findButton(acc, "Indoor").click() self.mockController.whiteBalance.assert_called_with("Test Camera", CameraWhiteBalance.Indoor) self.assertFalse(self.findButton(acc, "Set").isEnabled()) self.findButton(acc, "Outdoor").click() self.mockController.whiteBalance.assert_called_with("Test Camera", CameraWhiteBalance.Outdoor) self.assertFalse(self.findButton(acc, "Set").isEnabled()) self.findButton(acc, "One Push").click() self.mockController.whiteBalance.assert_called_with("Test Camera", CameraWhiteBalance.OnePush) self.assertTrue(self.findButton(acc, "Set").isEnabled()) self.findButton(acc, "Set").click() self.mockController.whiteBalance.assert_called_with("Test Camera", CameraWhiteBalance.Trigger)
def setUp(self): GuiTest.setUp(self) self.mockController = Controller() self.mockBlindsDevice = Device("Test") self.mockController.addDevice(self.mockBlindsDevice) self.mockMainWindow = MainWindow(self.mockController)
def setUp(self): GuiTest.setUp(self) self.mockController = Controller() conv = Device("Test Scan Converter") self.mockController.addDevice(conv)