def test_cameraObject(self, qtbot):
     ccWidget = CameraControlWidget()
     qtbot.addWidget(ccWidget)
     cc = CameraController(ccWidget)
     cc.setupCamera("GaussianCamera")
     assert cc.camera is not None
     assert hasattr(cc.camera, "seed")
 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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