aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abcontroller.py1
-rw-r--r--known-issues.md4
-rw-r--r--solo_tool_integrationtest.py62
3 files changed, 50 insertions, 17 deletions
diff --git a/abcontroller.py b/abcontroller.py
index 5c9bda7..99bd9d7 100644
--- a/abcontroller.py
+++ b/abcontroller.py
@@ -18,6 +18,7 @@ class ABController:
def setCurrentSong(self, path):
self._ensureSongExists(path)
self._songLimits = self._limits[path]
+ self._loadedIndex = None
def storeLimits(self, aLimit, bLimit, song=None):
if song is not None:
diff --git a/known-issues.md b/known-issues.md
index a9f5bbe..f11e0f0 100644
--- a/known-issues.md
+++ b/known-issues.md
@@ -8,8 +8,6 @@
* automatically play next song when current song ends
* playback doesn't stop when jumping to next/previous song
* should this be the default anyway?
-* Switching between songs and AB limits does not work properly
- * AB controller only keeps track of limit index, not current song => when song changes, index is invalid but not properly reset
# Closed Issues
@@ -19,6 +17,8 @@
* When switching between songs, AB limit selection is not reset, this means that if the song has only one limit, it is not possible to load it anymore
* No GUI to control playback speed
* Add buttons to write current playback position to A or B limit sliders
+* Switching between songs and AB limits does not work properly
+ * AB controller only keeps track of limit index, not current song => when song changes, index is invalid but not properly reset
# Use Cases
diff --git a/solo_tool_integrationtest.py b/solo_tool_integrationtest.py
index 2ee4719..ee99303 100644
--- a/solo_tool_integrationtest.py
+++ b/solo_tool_integrationtest.py
@@ -25,6 +25,15 @@ def prepared_tmp_path(tmp_path):
return tmp_path
+def checkLimit(uut, mockPlayer, aLimit, bLimit):
+ mockPlayer.position = bLimit - 0.1
+ uut.tick()
+ assert mockPlayer.position == bLimit - 0.1
+
+ mockPlayer.position = bLimit + 0.1
+ uut.tick()
+ assert mockPlayer.position == aLimit
+
def test_playerControls(uut, mockPlayer):
assert mockPlayer.state == MockPlayer.STOPPED
assert uut.isPlaying() == False
@@ -213,15 +222,6 @@ def test_nextAndPreviousAbLimit(uut, mockPlayer):
[0.1, 0.3]
]
- def checkLimit(aLimit, bLimit):
- mockPlayer.position = bLimit - 0.1
- uut.tick()
- assert mockPlayer.position == bLimit - 0.1
-
- mockPlayer.position = bLimit + 0.1
- uut.tick()
- assert mockPlayer.position == aLimit
-
uut.addSong(song)
uut.setSong(0)
uut.setAbLimitEnable(True)
@@ -229,23 +229,55 @@ def test_nextAndPreviousAbLimit(uut, mockPlayer):
for ab in abLimits:
uut.storeAbLimits(ab[0], ab[1])
- checkLimit(0.0, 0.0) # default limits
+ checkLimit(uut, mockPlayer, 0.0, 0.0) # default limits
uut.nextStoredAbLimits()
- checkLimit(abLimits[0][0], abLimits[0][1])
+ checkLimit(uut, mockPlayer, abLimits[0][0], abLimits[0][1])
uut.nextStoredAbLimits()
- checkLimit(abLimits[1][0], abLimits[1][1])
+ checkLimit(uut, mockPlayer, abLimits[1][0], abLimits[1][1])
uut.nextStoredAbLimits()
- checkLimit(abLimits[1][0], abLimits[1][1])
+ checkLimit(uut, mockPlayer, abLimits[1][0], abLimits[1][1])
uut.previousStoredAbLimits()
- checkLimit(abLimits[0][0], abLimits[0][1])
+ checkLimit(uut, mockPlayer, abLimits[0][0], abLimits[0][1])
uut.previousStoredAbLimits()
- checkLimit(abLimits[0][0], abLimits[0][1])
+ checkLimit(uut, mockPlayer, abLimits[0][0], abLimits[0][1])
+
+def test_abLimitsWhenChangingSongs(uut, mockPlayer):
+ songs = [
+ "test.flac",
+ "test.mp3"
+ ]
+ abLimits = [
+ [0.2, 0.4],
+ [0.1, 0.3],
+ [0.7, 0.8]
+ ]
+ uut.setAbLimitEnable(True)
+ for s in songs:
+ uut.addSong(s)
+
+ uut.setSong(0)
+ for ab in abLimits:
+ uut.storeAbLimits(ab[0], ab[1])
+
+ uut.setSong(1)
+ uut.storeAbLimits(abLimits[0][0], abLimits[0][1])
+
+ uut.setSong(0)
+ uut.loadAbLimits(len(abLimits) - 1)
+ checkLimit(uut, mockPlayer, abLimits[-1][0], abLimits[-1][1])
+
+ uut.setSong(1)
+ checkLimit(uut, mockPlayer, abLimits[-1][0], abLimits[-1][1])
+
+ uut.previousStoredAbLimits()
+ checkLimit(uut, mockPlayer, abLimits[0][0], abLimits[0][1])
+
def test_loadAndSaveSession(prepared_tmp_path):
mockPlayer = MockPlayer()
uut = SoloTool(mockPlayer)