Beispiel #1
0
 def testCallWithMonitorName(self):
     tobii_helper = calibrator.TobiiHelper()
     tobii_helper.disableLogging()
     tobii_helper.setMonitor(monitors.getAllMonitors()[0])
     self.assertEqual(monitors.getAllMonitors()[0], tobii_helper.getMonitorName())
     screen = pyglet.window.get_platform().get_default_display().get_default_screen();
     self.assertEqual((screen.width, screen.height), tobii_helper.getMonitorDimensions())
 def testPointCenter(self):
     tobii_helper = calibrator.TobiiHelper()
     self.initTrackBox(tobii_helper)
     result = tobii_helper._TobiiHelper__trackBox2VirtualTrackBox(
         (0.5, 0.5))
     self.assertAlmostEqual(0.0, result[0], delta=0.001)
     self.assertAlmostEqual(0.0, result[1], delta=0.001)
    def testSmoothingLimitReached(self):
        tobii_helper = calibrator.TobiiHelper()
        point_list = []
        result = tobii_helper._TobiiHelper__smoothing(
            (1.0, 1.0), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (1.1, 1.3), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (0.8, 0.7), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (1.0, 1.0), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (1.1, 1.3), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (0.8, 0.7), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (1.0, 1.0), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (1.1, 1.3), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)
        result = tobii_helper._TobiiHelper__smoothing(
            (0.8, 0.7), point_list, (0.99, 0.99),
            tobii_helper._TobiiHelper__calcMeanOfPointList)

        self.assertEqual([(1.1, 1.3), (0.8, 0.7), (1.0, 1.0), (1.1, 1.3),
                          (0.8, 0.7)], point_list)
        self.assertAlmostEqual(0.966, result[0], delta=0.001)
        self.assertAlmostEqual(1.0, result[1], delta=0.001)
 def testCallWithPointZero(self):
     tobii_helper = calibrator.TobiiHelper()
     self.initTrackBox(tobii_helper)
     result = tobii_helper._TobiiHelper__trackBox2VirtualTrackBox(
         (0.0, 0.0))
     self.assertAlmostEqual(256.125, result[0], delta=0.001)
     self.assertAlmostEqual(206.607, result[1], delta=0.001)
    def testTwoCalibPoints(self):
        tobii_helper = calibrator.TobiiHelper()
        tobii_helper.disableLogging()
        tobii_helper.setMonitor()
        calibResult = self.initCalibPoints()
        calibData = tobii_helper._TobiiHelper__calculateCalibration(calibResult)
        self.assertEqual(2, len(calibData))
        self.assertEqual(4, len(calibData[0]))
        self.assertEqual(4, len(calibData[1]))

        # (0.1,0.1)
        # average sample point
        self.assertEqual(-546, calibData[0][0][0])
        self.assertEqual(307, calibData[0][0][1])
        # average left eye sample point
        self.assertEqual(-541, calibData[0][1][0])
        self.assertEqual(304, calibData[0][1][1])
        # average right eye sample point
        self.assertEqual(-514, calibData[0][2][0])
        self.assertEqual(307, calibData[0][2][1])

        # (0.9,0.9)
        # average sample point
        self.assertEqual(546, calibData[1][0][0])
        self.assertEqual(-307, calibData[1][0][1])
        # average left eye sample point
        self.assertEqual(582, calibData[1][1][0])
        self.assertEqual(-320, calibData[1][1][1])
        # average right eye sample point
        self.assertEqual(623, calibData[1][2][0])
        self.assertEqual(-368, calibData[1][2][1])
    def testRigthEyeFailure(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        def returnFailure(*args):
            return tobii.CalibrationResult(
                tobii.CALIBRATION_STATUS_SUCCESS_LEFT_EYE, ())

        DummyCalibration.compute_and_apply = returnFailure

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c', 'c'])
        tobii_helper._TobiiHelper__drawCalibrationScreen(
            self.calibDict, self.calibWin)
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(5 * 150 + 2, len(drawing_list))
        # 5 * 150 is drawn by __getCalibrationData() (tested in another test)

        # calibration message
        message = drawing_list[0]
        self.assertTrue(isinstance(message, pvm.TextStim))
        self.assertEqual(str("Please focus your eyes on the red dot " + \
                             "and follow it with your eyes as closely as " + \
                             "possible.\n\nPress 'c' to continue."), message.text)

        # doing __getCalibrationData()

        # then message about the failure
        message = drawing_list[751]
        self.assertTrue(isinstance(message, pvm.TextStim))
        self.assertEqual(str("Calibration was not successful.\n\n" + \
                             "Closing the calibration window."), message.text)
    def testLeftEyeOutOnBottom(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        tobii_helper.gazeData['left_gaze_origin_in_trackbox_coordinate_system'] = (0.34, -1.001, 0.81)
        tobii_helper.gazeData['right_gaze_origin_in_trackbox_coordinate_system'] = (0.32, 0.11, 0.815)
        tobii_helper.gazeData['left_gaze_origin_in_user_coordinate_system'] = (102.0, 135.52, 650.0)
        tobii_helper.gazeData['right_gaze_origin_in_user_coordinate_system'] = (96.0, 147.62, 652.2)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c', 'c'])
        tobii_helper.runTrackBox()
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(5, len(drawing_list))

        left_eye = drawing_list[2]
        self.assertTrue(isinstance(left_eye, pvm.Circle))
        # color
        self.assertEqual(red_color, left_eye.fillColor.tolist())
        self.assertEqual(red_color, left_eye.lineColor.tolist())

        #third object is the right eye
        right_eye = drawing_list[3]
        self.assertTrue(isinstance(right_eye, pvm.Circle))
        # color
        self.assertEqual(yellow_color, right_eye.fillColor.tolist())
        self.assertEqual(yellow_color, right_eye.lineColor.tolist())
    def testOneEyeIsFar(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        tobii_helper.gazeData['left_gaze_origin_in_trackbox_coordinate_system'] = (0.34, 0.56, 0.97)
        tobii_helper.gazeData['right_gaze_origin_in_trackbox_coordinate_system'] = (0.32, 0.61, 1.00)
        tobii_helper.gazeData['left_gaze_origin_in_user_coordinate_system'] = (102.0, 135.52, 798.8)
        tobii_helper.gazeData['right_gaze_origin_in_user_coordinate_system'] = (96.0, 147.62, 812.5)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c', 'c'])
        tobii_helper.runTrackBox()
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(5, len(drawing_list))

        # left eye
        left_eye = drawing_list[2]
        self.assertTrue(isinstance(left_eye, pvm.Circle))
        # pos
        self.assertAlmostEqual(81.959, left_eye.pos[0], delta = 0.001)
        self.assertAlmostEqual(-24.792, left_eye.pos[1], delta = 0.001)
        # color
        self.assertEqual(red_color, left_eye.fillColor.tolist())
        self.assertEqual(red_color, left_eye.lineColor.tolist())

        # right eye
        right_eye = drawing_list[3]
        self.assertTrue(isinstance(right_eye, pvm.Circle))
        # pos
        self.assertAlmostEqual(92.204, right_eye.pos[0], delta = 0.001)
        self.assertAlmostEqual(-45.453, right_eye.pos[1], delta = 0.001)
        # color
        self.assertEqual(red_color, right_eye.fillColor.tolist())
        self.assertEqual(red_color, right_eye.lineColor.tolist())
Beispiel #9
0
    def testNotInitedThings(self):
        tobii_helper = calibrator.TobiiHelper()
        tobii_helper.disableLogging()

        # wrong param
        with self.assertRaises(TypeError):
            tobii_helper.runFullCalibration([])

        # wrong param
        with self.assertRaises(ValueError):
            tobii_helper.runFullCalibration(13)

        # wrong param
        with self.assertRaises(TypeError):
            tobii_helper.runFullCalibration(calibWin=13)

        # missing eye tracker
        with self.assertRaises(RuntimeError):
            tobii_helper.runFullCalibration()

        tobii_helper.eyetracker = "dummy"

        # no monitor
        with self.assertRaises(RuntimeError):
            tobii_helper.runFullCalibration()

        tobii_helper.setMonitor()
 def testNormalCall(self):
     tobii_helper = calibrator.TobiiHelper()
     self.initTrackBox(tobii_helper)
     result = tobii_helper._TobiiHelper__trackBox2VirtualTrackBox(
         (0.34, 0.45))
     self.assertAlmostEqual(81.959, result[0], delta=0.001)
     self.assertAlmostEqual(20.660, result[1], delta=0.001)
    def testDifferentBackDistance(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)
        tobii_helper.tbCoordinates['frontDistance'] = 300.0
        tobii_helper.tbCoordinates['backDistance'] = 500.0

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c', 'c'])
        tobii_helper.runTrackBox()
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(5, len(drawing_list))

        # left eye
        left_eye = drawing_list[2]
        self.assertTrue(isinstance(left_eye, pvm.Circle))
        # pos
        self.assertAlmostEqual(81.959, left_eye.pos[0], delta = 0.001)
        self.assertAlmostEqual(-24.792, left_eye.pos[1], delta = 0.001)
        # color
        self.assertEqual(red_color, left_eye.fillColor.tolist())
        self.assertEqual(red_color, left_eye.lineColor.tolist())

        # right eye
        right_eye = drawing_list[3]
        self.assertTrue(isinstance(right_eye, pvm.Circle))
        # pos
        self.assertAlmostEqual(92.204, right_eye.pos[0], delta = 0.001)
        self.assertAlmostEqual(-45.453, right_eye.pos[1], delta = 0.001)
        # color
        self.assertEqual(red_color, right_eye.fillColor.tolist())
        self.assertEqual(red_color, right_eye.lineColor.tolist())
    def testNotInitedThings(self):
        tobii_helper = calibrator.TobiiHelper()
        tobii_helper.disableLogging()

        # no monitor
        with self.assertRaises(RuntimeError):
            tobii_helper.runValidation()

        tobii_helper.setMonitor()

        # no eye tracker
        with self.assertRaises(RuntimeError):
            tobii_helper.runValidation()

        tobii_helper.eyetracker = "dummy"

        # no tracking
        with self.assertRaises(RuntimeError):
            tobii_helper.runValidation()

        tobii_helper.tracking = True

        # no gaze data
        with self.assertRaises(RuntimeError):
            tobii_helper.runValidation()

        tobii_helper.gazeData = {}
        tobii_helper.gazeData['left_gaze_point_on_display_area'] = (0.34, 0.56)
        tobii_helper.gazeData['right_gaze_point_on_display_area'] = (0.32, 0.6)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c'])
        tobii_helper.runValidation()
 def testRandomPoint(self):
     tobii_helper = calibrator.TobiiHelper()
     tobii_helper.disableLogging()
     tobii_helper.setMonitor()
     pixResult = tobii_helper._TobiiHelper__ada2PsychoPix((0.234, 0.52))
     self.assertAlmostEqual(-363, pixResult[0], delta=0.001)
     self.assertAlmostEqual(-15, pixResult[1], delta=0.001)
    def testDefaultFiveCalibPoints(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)
        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c'])
        tobii_helper.runValidation()
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(7, len(drawing_list))

        # first object is the gaze point
        eye_circle = drawing_list[0]
        self.assertTrue(isinstance(eye_circle, pvm.Circle))
        # size
        self.assertAlmostEqual(50, eye_circle.radius, delta = 0.001)
        # pos
        self.assertAlmostEqual(-232.0, eye_circle.pos[0], delta = 0.001)
        self.assertAlmostEqual(-65.0, eye_circle.pos[1], delta = 0.001)
        # color
        self.assertEqual([1.0, 1.0, 0.55], eye_circle.fillColor.tolist())
        self.assertEqual([1.0, 0.95, 0.0], eye_circle.lineColor.tolist())

        # the next five objects are the calibration points
        for i in range(1,6):
            calib_point = drawing_list[i]
            self.assertTrue(isinstance(calib_point, pvm.Circle))
            # size
            self.assertAlmostEqual(15, calib_point.radius, delta = 0.001)
             # pos
            if i == 1:
                self.assertAlmostEqual(-546.00, calib_point.pos[0], delta = 0.001)
                self.assertAlmostEqual(307.00, calib_point.pos[1], delta = 0.001)
            elif i == 2:
                self.assertAlmostEqual(546.00, calib_point.pos[0], delta = 0.001)
                self.assertAlmostEqual(307.00, calib_point.pos[1], delta = 0.001)
            elif i == 3:
                self.assertAlmostEqual(0.00, calib_point.pos[0], delta = 0.001)
                self.assertAlmostEqual(0.00, calib_point.pos[1], delta = 0.001)
            elif i == 4:
                self.assertAlmostEqual(-546.00, calib_point.pos[0], delta = 0.001)
                self.assertAlmostEqual(-307.00, calib_point.pos[1], delta = 0.001)
            elif i == 5:
                self.assertAlmostEqual(546.00, calib_point.pos[0], delta = 0.001)
                self.assertAlmostEqual(-307.00, calib_point.pos[1], delta = 0.001)
            # color
            self.assertEqual([1.0, -1.0, -1.0], calib_point.fillColor.tolist())
            self.assertEqual([1.0, -1.0, -1.0], calib_point.lineColor.tolist())

        # last object is the text
        feedback_text = drawing_list[6]
        self.assertTrue(isinstance(feedback_text, pvm.TextStim))
        # size
        self.assertAlmostEqual(0.07, feedback_text.height, delta = 0.001)
        # pos
        self.assertAlmostEqual(0.0, feedback_text.pos[0], delta = 0.001)
        self.assertAlmostEqual(-0.5, feedback_text.pos[1], delta = 0.001)
        # color
        self.assertEqual([1.0, 1.0, 1.0], feedback_text.color.tolist())
        # text
        self.assertEqual(str("Wait for the experimenter.") , feedback_text.text)
Beispiel #15
0
    def testOneCalibPoint(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        self.pointList = [(0.9, 0.9)]

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['x'])
        tobii_helper._TobiiHelper__getCalibrationData(self.calibWin,
                                                      self.pointList)
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(150, len(drawing_list))

        # first 50 frames are about moving the circle to the next calib point
        for i in range(0, 50):
            calibPoint = drawing_list[i]
            self.assertTrue(isinstance(calibPoint, pvm.Circle))
            # size
            self.assertEqual(50, calibPoint.radius)
            # pos
            self.assertAlmostEqual(-524 + i * 22,
                                   calibPoint.pos[0],
                                   delta=10.0)
            self.assertAlmostEqual(295 - i * 12.5,
                                   calibPoint.pos[1],
                                   delta=13.0)
            # color
            self.assertEqual([1.0, -1.0, -1.0], calibPoint.fillColor.tolist())
            self.assertEqual([1.0, -1.0, -1.0], calibPoint.lineColor.tolist())

        # after the moving, circle is at the first calib point
        self.assertEqual(546, drawing_list[49].pos[0])
        self.assertEqual(-307, drawing_list[49].pos[1])
    def testOneCalibPoint(self):
        tobii_helper = calibrator.TobiiHelper()
        tobii_helper.disableLogging()
        tobii_helper.setMonitor()
        
        calibration_point0 = tobii.CalibrationPoint((0.0, 0.0),(
                                    tobii.CalibrationSample(tobii.CalibrationEyeData((0.0, 0.0), True),
                                                            tobii.CalibrationEyeData((0.0, 0.0), True)),))
        calibration_point = tobii.CalibrationPoint((0.1, 0.1),(
                                    tobii.CalibrationSample(tobii.CalibrationEyeData((0.08, 0.08), True),
                                                            tobii.CalibrationEyeData((0.09, 0.08), True)),))
        calibration_points = (calibration_point0, calibration_point)
        calibResult = tobii.CalibrationResult(tobii.CALIBRATION_STATUS_SUCCESS, calibration_points)                                                               
        calibData = tobii_helper._TobiiHelper__calculateCalibration(calibResult)
        self.assertEqual(1, len(calibData))
        self.assertEqual(4, len(calibData[0]))

        # (0.1,0.1)
        # average sample point
        self.assertEqual(-546, calibData[0][0][0])
        self.assertEqual(307, calibData[0][0][1])
        # average left eye sample point
        self.assertEqual(-573, calibData[0][1][0])
        self.assertEqual(322, calibData[0][1][1])
        # average right eye sample point
        self.assertEqual(-560, calibData[0][2][0])
        self.assertEqual(322, calibData[0][2][1])
 def testWrongParam(self):
     tobii_helper = calibrator.TobiiHelper()
     tobii_helper.disableLogging()
     with self.assertRaises(TypeError):
         tobii_helper._TobiiHelper__calculateCalibration(None)
     with self.assertRaises(TypeError):
         tobii_helper._TobiiHelper__calculateCalibration([])            
Beispiel #18
0
    def testDefaultCalibPoints(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c'])
        tobii_helper.runFullCalibration()
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(1, len(drawing_list))
        message = drawing_list[0]
        self.assertTrue(isinstance(message, pvm.TextStim))
        self.assertEqual(str("Finished validating the calibration.\n\n" +\
                             "Calibration is complete. Closing window."), message.text)

        # default is five calib points
        self.assertEqual(5, len(self.calibDict))
        self.assertTrue('1' in self.calibDict)
        self.assertTrue('2' in self.calibDict)
        self.assertTrue('3' in self.calibDict)
        self.assertTrue('4' in self.calibDict)
        self.assertTrue('5' in self.calibDict)
        self.assertEqual((0.1, 0.1), self.calibDict['1'])
        self.assertEqual((0.9, 0.1), self.calibDict['2'])
        self.assertEqual((0.5, 0.5), self.calibDict['3'])
        self.assertEqual((0.1, 0.9), self.calibDict['4'])
        self.assertEqual((0.9, 0.9), self.calibDict['5'])
Beispiel #19
0
 def testNoParam(self):
     tobii_helper = calibrator.TobiiHelper()
     if self.hasEyeTrackerConnected():
         tobii_helper.setEyeTracker()
     else:
         with self.assertRaises(RuntimeError):
             tobii_helper.setEyeTracker()
 def testOnePoint(self):
     tobii_helper = calibrator.TobiiHelper()
     tobii_helper.disableLogging()
     tobii_helper.setMonitor()
     pixResult = tobii_helper._TobiiHelper__ada2PsychoPix((1.0, 1.0))
     self.assertAlmostEqual(683, pixResult[0], delta=0.001)
     self.assertAlmostEqual(-384, pixResult[1], delta=0.001)
    def testQuitByQ(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['q'])
        with self.assertRaises(SystemExit):
            tobii_helper.runValidation()
 def testSmoothingOneItem(self):
     tobii_helper = calibrator.TobiiHelper()
     point_list = []
     result = tobii_helper._TobiiHelper__smoothing(
         (1.0, 1.0), point_list, (0.99, 0.99),
         tobii_helper._TobiiHelper__calcMeanOfPointList)
     self.assertEqual([(1.0, 1.0)], point_list)
     self.assertEqual((1.0, 1.0), result)
    def testWrongWindowParam(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c', 'c'])

        with self.assertRaises(TypeError):
            tobii_helper.runTrackBox(trackWin = [])
    def testEyePosInTrackbox(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)
        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c', 'c'])
        tobii_helper.runTrackBox()
        drawing_list = visual_mock.getListOfDrawings()

        self.assertEqual(5, len(drawing_list))

        # second object is the background of the virtual trackbox
        background_rect = drawing_list[1]
        self.assertTrue(isinstance(background_rect, pvm.Rect))
        # size
        self.assertAlmostEqual(512.25, background_rect.width, delta = 0.001)
        self.assertAlmostEqual(413.215, background_rect.height, delta = 0.001)
        # pos
        self.assertAlmostEqual(0.0, background_rect.pos[0], delta = 0.001)
        self.assertAlmostEqual(0.0, background_rect.pos[1], delta = 0.001)

        # third object is the left eye
        left_eye = drawing_list[2]
        self.assertTrue(isinstance(left_eye, pvm.Circle))
        # size
        self.assertAlmostEqual(30, left_eye.radius, delta = 0.001)
        # pos
        self.assertAlmostEqual(81.959, left_eye.pos[0], delta = 0.001)
        self.assertAlmostEqual(-24.792, left_eye.pos[1], delta = 0.001)
        # color
        self.assertEqual(green_color, left_eye.fillColor.tolist())
        self.assertEqual(green_color, left_eye.lineColor.tolist())

        # forth object is the right eye
        right_eye = drawing_list[3]
        self.assertTrue(isinstance(right_eye, pvm.Circle))
        # size
        self.assertAlmostEqual(30, right_eye.radius, delta = 0.001)
        # pos
        self.assertAlmostEqual(92.204, right_eye.pos[0], delta = 0.001)
        self.assertAlmostEqual(-45.453, right_eye.pos[1], delta = 0.001)
        # color
        self.assertEqual(green_color, right_eye.fillColor.tolist())
        self.assertEqual(green_color, right_eye.lineColor.tolist())

        # fifth object is the text about the distance
        feedback_text = drawing_list[4]
        self.assertTrue(isinstance(feedback_text, pvm.TextStim))
        # size
        self.assertAlmostEqual(0.07, feedback_text.height, delta = 0.001)
        # pos
        self.assertAlmostEqual(0.0, feedback_text.pos[0], delta = 0.001)
        self.assertAlmostEqual(-0.638, feedback_text.pos[1], delta = 0.001)
        # color
        self.assertEqual([1.0, 1.0, 1.0], feedback_text.color.tolist())
        # text
        self.assertEqual(str("Press 'c' to calibrate or 'q' to abort.") , feedback_text.text)
Beispiel #25
0
    def testNoReturnedValues(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['c'])

        result = tobii_helper._TobiiHelper__drawCalibrationResults(
            self.calibResult, self.calibWin, self.calibDict)
        self.assertEqual(0, len(result))
Beispiel #26
0
    def testQuitByQ(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['q'])

        with self.assertRaises(SystemExit):
            tobii_helper._TobiiHelper__drawCalibrationResults(
                self.calibResult, self.calibWin, self.calibDict)
Beispiel #27
0
    def testNoReturnedValues(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['x'])

        result = tobii_helper._TobiiHelper__getCalibrationData(
            self.calibWin, self.pointList)
        self.assertEqual(0, len(result))
Beispiel #28
0
    def testQuitByQ(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['q'])

        with self.assertRaises(SystemExit):
            tobii_helper._TobiiHelper__getCalibrationData(
                self.calibWin, self.pointList)
    def testNotInitedThings(self):
        tobii_helper = calibrator.TobiiHelper()
        tobii_helper.disableLogging()

        tobii_helper._TobiiHelper__startGazeData = DummyFunction
        tobii_helper._TobiiHelper__stopGazeData = DummyFunction

        # no window
        with self.assertRaises(TypeError):
            tobii_helper._TobiiHelper__drawEyePositions([])

        # ok init the window
        with visual.Window(size = [1366, 768],
                                 pos = [0, 0],
                                 units = 'pix',
                                 fullscr = True,
                                 allowGUI = True,
                                 monitor = tobii_helper.win,
                                 winType = 'pyglet',
                                 color = [0.4, 0.4, 0.4]) as trackWin:

            # now we don't have tracker box coordinates
            with self.assertRaises(RuntimeError):
                tobii_helper._TobiiHelper__drawEyePositions(trackWin)

            self.initTrackBox(tobii_helper)

            # no eyetracker
            with self.assertRaises(RuntimeError):
                tobii_helper._TobiiHelper__drawEyePositions(trackWin)

            tobii_helper.eyetracker = "dummy"

            # no tracking
            with self.assertRaises(RuntimeError):
                tobii_helper._TobiiHelper__drawEyePositions(trackWin)

            tobii_helper.tracking = True

            # no gaze data
            with self.assertRaises(RuntimeError):
                tobii_helper._TobiiHelper__drawEyePositions(trackWin)

            tobii_helper.gazeData = {}
            tobii_helper.gazeData['left_gaze_origin_in_trackbox_coordinate_system'] = (0.34, 0.56, 0.81)
            tobii_helper.gazeData['right_gaze_origin_in_trackbox_coordinate_system'] = (0.32, 0.61, 0.815)
            tobii_helper.gazeData['left_gaze_origin_in_user_coordinate_system'] = (102.0, 135.52, 650.0)
            tobii_helper.gazeData['right_gaze_origin_in_user_coordinate_system'] = (96.0, 147.62, 652.0)
            tobii_helper.gazeData['left_gaze_origin_validity'] = True
            tobii_helper.gazeData['right_gaze_origin_validity'] = True

            visual_mock = pvm.PsychoPyVisualMock()
            visual_mock.setReturnKeyList(['c', 'c'])
            tobii_helper._TobiiHelper__drawEyePositions(trackWin)
            trackWin.close()
Beispiel #30
0
    def testHasOneRedoPoint(self):
        tobii_helper = calibrator.TobiiHelper()
        self.initAll(tobii_helper)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['3', 'c'])

        result = tobii_helper._TobiiHelper__drawCalibrationResults(
            self.calibResult, self.calibWin, self.calibDict)
        self.assertEqual(1, len(result))
        self.assertEqual(collections.OrderedDict([('3', (0.5, 0.5))]), result)