def test_showFramesCheckBox(self, qtbot): cc = CameraControlWidget() cc.show() qtbot.addWidget(cc) assert cc.showFramesCheckBox.isChecked() qtbot.mouseClick(cc.showFramesCheckBox, Qt.LeftButton) assert not cc.showFramesCheckBox.isChecked()
def test_getCameraConfiguration(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") config = cc.getCameraConfiguration() assert hasattr(config, "doSpotOscillation") is True
def test_getCameraModelName(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") assert cc.getCameraModelName() == 'Gaussian'
def test_changeBufferSize(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") with qtbot.waitSignal(cc.updater.bufferSizeChanged) as blocker: cc.cameraControlWidget.bufferSizeSpinBox.stepUp() assert blocker.args == [2048]
def test_changeRoiFps(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") truthRoiFps = 70 cc.cameraControlWidget.roiFpsSpinBox.setValue(truthRoiFps) assert cc.currentRoiFps() == truthRoiFps
def test_frameChecks(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") check1, check2 = cc.getFrameChecks() assert check1(1, 1, 1, 1) is True assert check2(1) is True
def test_getUpdateFrame(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) frame = cc.getUpdateFrame() assert frame.shape == (480, 640)
def test_currentRoiFps(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) roiFps = cc.currentRoiFps() assert roiFps == 40
def test_takeScreenshot(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton) with qtbot.waitSignal(cc.updater.takeScreenshotState, timeout=250): qtbot.mouseClick(ccWidget.takeScreenshotButton, Qt.LeftButton)
def test_updateCameraOffset(self, qtbot, mocker): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) cameraOffset = mocker.patch.object(cc.camera, 'updateOffset') cc.updateCameraOffset(200, 400) assert cameraOffset.call_count == 1
def test_bufferSizeSpinBox(self, qtbot): cc = CameraControlWidget() cc.show() qtbot.addWidget(cc) assert cc.bufferSizeSpinBox.value() == 1024 cc.bufferSizeSpinBox.stepUp() assert cc.bufferSizeSpinBox.value() == 2048 cc.bufferSizeSpinBox.setValue(1024) cc.bufferSizeSpinBox.stepDown() assert cc.bufferSizeSpinBox.value() == 512
def test_currentOffset(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") cc.camera.seed = 1000 qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) offset = cc.currentOffset() assert offset == (264, 200)
def test_takeScreenshotButton(self, qtbot): cc = CameraControlWidget() cc.show() qtbot.addWidget(cc) assert cc.takeScreenshotButton.isEnabled() is False qtbot.mouseClick(cc.startStopButton, Qt.LeftButton) qtbot.mouseClick(cc.acquireFramesButton, Qt.LeftButton) assert cc.takeScreenshotButton.isEnabled() is True with qtbot.waitSignal(cc.takeScreenshotState, timeout=self.fast_timeout): qtbot.mouseClick(cc.takeScreenshotButton, Qt.LeftButton)
def test_autoRun(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") cc.doAutoRun = True cc.autoRun() fps = cc.currentCameraFps() assert fps == 40
def test_setCameraConfiguration(self, qtbot, mocker): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") mockSetCameraConfiguration = mocker.patch.object( cc.camera, 'setConfiguration') cc.setCameraConfiguration(GaussianCameraConfig()) assert mockSetCameraConfiguration.call_count == 1
def test_getCameraInformation(self, qtbot, mocker): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") mockGetCameraInformation = mocker.patch.object(cc.camera, 'getCameraInformation') cc.getCameraInformation() assert mockGetCameraInformation.call_count == 1
def test_badCameraStartup(self, qtbot, mocker): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") cc.camera.startup = mocker.Mock(side_effect=CameraNotFound) qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) assert ccWidget.startStopButton.isChecked() is True assert ccWidget.startStopButton.text() == "Stop Camera" assert ccWidget.acquireFramesButton.isEnabled() is False assert ccWidget.acquireRoiCheckBox.isEnabled() is False
def test_getAvailableCameras(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cameras = cc.getAvailableCameras() if VimbaFound: assert len(cameras) == 2 assert cameras[0] == 'Vimba' else: assert len(cameras) == 1 assert cameras[0] == 'Gaussian'
def test_cameraAcquireRejectedFrame(self, qtbot, mocker): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") cc.camera.getFullFrame = mocker.Mock(side_effect=FrameRejected) qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton) frame = cc.getFrame() assert frame is None qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton)
def test_isRoiMode(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) isRoiMode = cc.isRoiMode() assert isRoiMode is False qtbot.mouseClick(ccWidget.acquireRoiCheckBox, Qt.LeftButton) isRoiMode = cc.isRoiMode() assert isRoiMode is True
def test_roiFpsSpinBox(self, qtbot): cc = CameraControlWidget() cc.show() qtbot.addWidget(cc) assert cc.roiFpsSpinBox.value() == 40 cc.roiFpsSpinBox.setValue(0) assert cc.roiFpsSpinBox.value() == 1 cc.roiFpsSpinBox.setValue(200) assert cc.roiFpsSpinBox.value() == 150 cc.roiFpsSpinBox.stepUp() assert cc.roiFpsSpinBox.value() == 150 cc.roiFpsSpinBox.stepDown() assert cc.roiFpsSpinBox.value() == 149
def test_cameraAcquireExpectedFrame(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) frame = cc.getFrame() assert frame.shape == (480, 640) qtbot.mouseClick(ccWidget.acquireRoiCheckBox, Qt.LeftButton) frame = cc.getFrame() assert frame.shape == (50, 50)
def test_cameraCurrentFps(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) fps = cc.currentCameraFps() assert fps == 24 qtbot.mouseClick(ccWidget.acquireRoiCheckBox, Qt.LeftButton) fps = cc.currentCameraFps() assert fps == 40
def test_stateAtAcquireFramesStop(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton) qtbot.mouseClick(ccWidget.acquireRoiCheckBox, Qt.LeftButton) assert cc.isRoiMode() is True qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton) assert cc.isRoiMode() is False assert cc.currentCameraFps() == 24 assert ccWidget.acquireFramesButton.isChecked() is False
def test_cameraAcquireFrames(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton) assert cc.frameTimer.isActive() interval = int( (1 / cc.currentCameraFps()) * ONE_SECOND_IN_MILLISECONDS) assert cc.frameTimer.interval() == interval qtbot.mouseClick(ccWidget.acquireFramesButton, Qt.LeftButton) assert not cc.frameTimer.isActive()
def test_cameraStartStop(self, qtbot, mocker): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") mocker.patch( 'spot_motion_monitor.camera.gaussian_camera.GaussianCamera.startup' ) qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) assert cc.camera.startup.call_count == 1 mocker.patch( 'spot_motion_monitor.camera.gaussian_camera.GaussianCamera.shutdown' ) qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) assert cc.camera.shutdown.call_count == 1
def test_acquireRoiCheckbox(self, qtbot): cc = CameraControlWidget() cc.show() qtbot.addWidget(cc) qtbot.mouseClick(cc.startStopButton, Qt.LeftButton) assert not cc.acquireRoiCheckBox.isChecked() with qtbot.waitSignal(cc.acquireRoiState, timeout=self.fast_timeout, check_params_cb=self.stateIsTrue): qtbot.mouseClick(cc.acquireRoiCheckBox, Qt.LeftButton) assert cc.acquireRoiCheckBox.isChecked() assert not cc.roiFpsSpinBox.isEnabled() assert not cc.bufferSizeSpinBox.isEnabled() with qtbot.waitSignal(cc.acquireRoiState, timeout=self.fast_timeout, check_params_cb=self.stateIsFalse): qtbot.mouseClick(cc.acquireRoiCheckBox, Qt.LeftButton) assert not cc.acquireRoiCheckBox.isChecked() assert cc.roiFpsSpinBox.isEnabled() assert cc.bufferSizeSpinBox.isEnabled()
def test_acquireFramesButton(self, qtbot): cc = CameraControlWidget() cc.show() qtbot.addWidget(cc) qtbot.mouseClick(cc.startStopButton, Qt.LeftButton) assert not cc.acquireFramesButton.isChecked() assert cc.acquireFramesButton.text() == "Start Acquire Frames" with qtbot.waitSignal(cc.acquireFramesState, timeout=self.fast_timeout, check_params_cb=self.stateIsTrue): qtbot.mouseClick(cc.acquireFramesButton, Qt.LeftButton) assert cc.acquireFramesButton.isChecked() assert not cc.startStopButton.isEnabled() assert cc.acquireFramesButton.text() == "Stop Acquire Frames" with qtbot.waitSignal(cc.acquireFramesState, timeout=self.fast_timeout, check_params_cb=self.stateIsFalse): qtbot.mouseClick(cc.acquireFramesButton, Qt.LeftButton) assert not cc.acquireFramesButton.isChecked() assert cc.acquireFramesButton.text() == "Start Acquire Frames" assert cc.startStopButton.isEnabled()
def test_currentStatus(self, qtbot): ccWidget = CameraControlWidget() ccWidget.show() qtbot.addWidget(ccWidget) cc = CameraController(ccWidget) cc.setupCamera("GaussianCamera") cc.camera.seed = 1000 qtbot.mouseClick(ccWidget.startStopButton, Qt.LeftButton) #cc.startStopCamera(True) status = cc.currentStatus() assert status.currentFps == 24 assert status.isRoiMode is False assert status.frameOffset == (264, 200) assert status.showFrames is True qtbot.mouseClick(ccWidget.acquireRoiCheckBox, Qt.LeftButton) qtbot.mouseClick(ccWidget.showFramesCheckBox, Qt.LeftButton) status = cc.currentStatus() assert status.currentFps == 40 assert status.isRoiMode is True assert status.frameOffset == (264, 200) assert status.showFrames is False