aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-10 12:00:23 +0200
committerThéo de la Hogue2023-05-10 12:00:23 +0200
commit44bf76527e59dafc46e2075605454bf23523a666 (patch)
treee07dbf8b305bb24e9c9e3ab6701c87128a7c618b /src/argaze.test
parent6a77674c4c7b0589ffa7b13edbbde41c371b3d4f (diff)
downloadargaze-44bf76527e59dafc46e2075605454bf23523a666.zip
argaze-44bf76527e59dafc46e2075605454bf23523a666.tar.gz
argaze-44bf76527e59dafc46e2075605454bf23523a666.tar.bz2
argaze-44bf76527e59dafc46e2075605454bf23523a666.tar.xz
Adding VisualScanStep and VisualScanPath tests.
Diffstat (limited to 'src/argaze.test')
-rw-r--r--src/argaze.test/GazeFeatures.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/argaze.test/GazeFeatures.py b/src/argaze.test/GazeFeatures.py
index cbe6056..dd3c49b 100644
--- a/src/argaze.test/GazeFeatures.py
+++ b/src/argaze.test/GazeFeatures.py
@@ -209,6 +209,96 @@ class TestTimeStampedGazePositionsClass(unittest.TestCase):
self.assertEqual(ts_gaze_positions_dataframe["value"].dtype, 'object')
self.assertEqual(ts_gaze_positions_dataframe["precision"].dtype, 'O') # Python object type
+class TestVisualScanStepClass(unittest.TestCase):
+ """Test VisualScanStep class."""
+
+ def test_new(self):
+ """Test VisualScanStep creation."""
+
+ movements = GazeFeatures.TimeStampedGazeMovements()
+
+ fixation = GazeFeatures.Fixation(random_gaze_positions(10))
+ ts, _ = fixation.positions.first
+ movements[ts] = fixation
+
+ saccade = GazeFeatures.Saccade(random_gaze_positions(2))
+ ts, _ = saccade.positions.first
+ movements[ts] = saccade
+
+ visual_scan_step = GazeFeatures.VisualScanStep(movements, 'Test')
+
+ # Check visual scan step creation
+ self.assertEqual(len(visual_scan_step.movements), 2)
+ self.assertEqual(visual_scan_step.aoi, 'Test')
+ self.assertEqual(visual_scan_step.first_fixation, fixation)
+ self.assertEqual(visual_scan_step.last_saccade, saccade)
+ self.assertGreater(visual_scan_step.duration, 0)
+
+ def test_error(self):
+ """Test VisualScanStep creation error."""
+
+ movements = GazeFeatures.TimeStampedGazeMovements()
+
+ saccade = GazeFeatures.Saccade(random_gaze_positions(2))
+ ts, _ = saccade.positions.first
+ movements[ts] = saccade
+
+ fixation = GazeFeatures.Fixation(random_gaze_positions(10))
+ ts, _ = fixation.positions.first
+ movements[ts] = fixation
+
+ # Check that visual scan step creation fail
+ with self.assertRaises(GazeFeatures.VisualScanStepError):
+
+ visual_scan_step = GazeFeatures.VisualScanStep(movements, 'Test')
+
+class TestVisualScanPathClass(unittest.TestCase):
+ """Test VisualScanPath class."""
+
+ def test_new(self):
+ """Test VisualScanPath creation."""
+
+ # Check visual scan step creation
+ visual_scan_path = GazeFeatures.VisualScanPath()
+
+ self.assertEqual(len(visual_scan_path), 0)
+
+ def test_append(self):
+ """Test VisualScanPath append methods."""
+
+ visual_scan_path = GazeFeatures.VisualScanPath()
+
+ # Append fixation on A aoi
+ fixation = GazeFeatures.Fixation(random_gaze_positions(10))
+ ts, _ = fixation.positions.first
+
+ new_step = visual_scan_path.append_fixation(ts, fixation, 'A')
+
+ # Check that no visual scan step have been created yet
+ self.assertEqual(len(visual_scan_path), 0)
+ self.assertEqual(new_step, None)
+
+ # Append saccade
+ saccade = GazeFeatures.Saccade(random_gaze_positions(2))
+ ts, _ = saccade.positions.first
+
+ new_step = visual_scan_path.append_saccade(ts, saccade)
+
+ # Check that no visual scan step have been created yet
+ self.assertEqual(len(visual_scan_path), 0)
+ self.assertEqual(new_step, None)
+
+ # Append fixation on B aoi
+ fixation = GazeFeatures.Fixation(random_gaze_positions(10))
+ ts, _ = fixation.positions.first
+
+ new_step = visual_scan_path.append_fixation(ts, fixation, 'B')
+
+ # Check a new visual scan step have been created
+ self.assertEqual(len(visual_scan_path), 1)
+ self.assertEqual(len(new_step.movements), 2)
+ self.assertEqual(new_step.aoi, 'A')
+
if __name__ == '__main__':
unittest.main() \ No newline at end of file