aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/test/solo_tool_integrationtest.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-02-25 14:58:30 +0100
committerEddy Pedroni <epedroni@pm.me>2025-02-25 14:58:30 +0100
commitbb94fb1ab32732a354f7df68bf0a056d233b2b69 (patch)
tree82607687a76cb1f049d225bc3151c33c54f9d61c /solo-tool-project/test/solo_tool_integrationtest.py
parent62490ac2be04aa3b819222f11389e0549f5909e9 (diff)
Refactor key point implementation and tests
Diffstat (limited to 'solo-tool-project/test/solo_tool_integrationtest.py')
-rw-r--r--solo-tool-project/test/solo_tool_integrationtest.py157
1 files changed, 0 insertions, 157 deletions
diff --git a/solo-tool-project/test/solo_tool_integrationtest.py b/solo-tool-project/test/solo_tool_integrationtest.py
index e63ea3f..fb759b0 100644
--- a/solo-tool-project/test/solo_tool_integrationtest.py
+++ b/solo-tool-project/test/solo_tool_integrationtest.py
@@ -107,95 +107,6 @@ def test_sanitizePlaybackVolume(uut):
uut.volume = 150.0
assert uut.volume == 150.0
-def test_addAndJumpToKeyPoints(uut, mockPlayer):
- def checkJump(before, expectedAfter):
- mockPlayer.position = before
- uut.jump()
- assert mockPlayer.position == expectedAfter
-
- # Key points are None as long as no song is selected
- uut.keyPoints = [0.1, 0.2]
- uut.keyPoint = 0.5
- assert uut.keyPoints is None
- assert uut.keyPoint is None
-
- uut.addSong("test.flac")
- uut.addSong("test.mp3")
-
- # Once a song is selected, jump to start by default
- assert uut.keyPoint == 0.0
- checkJump(0.5, 0.0)
-
- # By default songs have an empty list of key points
- assert uut.keyPoints == []
-
- uut.keyPoints = [0.2, 0.4, 0.1, 0.2]
-
- # Added key points are not automatically selected
- assert uut.keyPoint == 0.0
- checkJump(0.1, 0.0)
-
- # Any key point can be selected
- uut.keyPoint = uut.keyPoints[0]
- checkJump(0.0, uut.keyPoints[0])
-
- uut.keyPoint = 0.5
- checkJump(0.0, 0.5)
-
-def test_sanitizeKeyPoint(uut):
- song = "test.flac"
- uut.addSong(song)
- uut.song = 0
- uut.keyPoints = [0.2, 0.4, 0.1, 0.2, None, -0.5, 1.0, 1.5]
-
- # Added key points are automatically de-duplicated, sanitized and sorted to ascending order
- assert uut.keyPoints == [0.1, 0.2, 0.4]
-
- # Key point and key point list cannot be none
- uut.keyPoint = 0.5
-
- uut.keyPoint = None
- assert uut.keyPoint == 0.5
-
- uut.keyPoints = None
- assert uut.keyPoints == [0.1, 0.2, 0.4]
-
- # Valid key points are in [0, 1)
- uut.keyPoint = -0.1
- assert uut.keyPoint == 0.5
-
- uut.keyPoint = 1.0
- assert uut.keyPoint == 0.5
-
- uut.keyPoint = 0.999
- assert uut.keyPoint == 0.999
-
-def test_keyPointsPerSong(uut, mockPlayer):
- songs = [
- ("test.flac", [0.0, 0.5]),
- ("test.mp3", [0.1])
- ]
-
- # Key points list is set for the selected song
- for i, (song, keyPoints) in enumerate(songs):
- uut.addSong(song)
- uut.song = i
- uut.keyPoints = keyPoints
-
- # Key points list is automatically loaded when the song selection changes
- # Active key point is always reset to 0 when song selection changes
- for i, (song, keyPoints) in enumerate(songs):
- uut.keyPoint = 0.5
- uut.song = i
- assert uut.keyPoints == keyPoints
- assert uut.keyPoint == 0.0
-
- # Key points are copied, not stored by reference
- for i, (song, keyPoints) in enumerate(songs):
- uut.song = i
- keyPoints.append(1.0)
- assert 1.0 not in uut.keyPoints
-
def test_playingStateNotification(uut, mockPlayer):
song = "test.flac"
uut.addSong(song)
@@ -288,71 +199,3 @@ def test_playbackRateNotification(uut, mockPlayer):
assert not called
-def test_currentKeyPointNotification(uut):
- called = False
- receivedValue = None
- def callback(value):
- nonlocal called, receivedValue
- called = True
- receivedValue = value
-
- uut.registerCurrentKeyPointCallback(callback)
- assert not called
-
- song = "test.flac"
- uut.addSong(song)
- uut.song = 0
-
- # Selecting a song for the first time sets the key point to 0.0
- assert called
- assert receivedValue == 0.0
- called = False
-
- # Changing the key point triggers a notification
- uut.keyPoint = 0.5
- assert called
- assert receivedValue == 0.5
- called = False
-
- # Adding list of key points does not trigger a notification
- uut.keyPoints = [0.2, 0.4]
- assert not called
-
- # Assigning the same key point again does not trigger a notification
- uut.keyPoint = 0.5
- assert not called
-
-def test_keyPointsNotification(uut):
- called = False
- receivedValue = None
- def callback(value):
- nonlocal called, receivedValue
- called = True
- receivedValue = value
-
- uut.registerKeyPointsCallback(callback)
- assert not called
-
- song = "test.flac"
- uut.addSong(song)
- uut.song = 0
- assert not called
-
- # Adding list of key points triggers a notification
- uut.keyPoints = [0.2, 0.4]
- assert called
- assert receivedValue == [0.2, 0.4]
- called = False
-
- # Same list does trigger a notification again
- uut.keyPoints = [0.2, 0.4]
- assert called
- assert receivedValue == [0.2, 0.4]
- called = False
-
- # Incrementing list of key points triggers a notification after sanitization
- uut.keyPoints += [0.2, None, 0.1]
- assert called
- assert receivedValue == [0.1, 0.2, 0.4]
- called = False
-