diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-07 16:33:48 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-07 16:33:48 +0100 |
commit | 97f3c945fe2e1369c2e21cef4a474fac3ce4d8db (patch) | |
tree | ba815fd14c4904bf25ef71927835888da8e62c1f /solo_tool_integrationtest.py | |
parent | 9efb5716cdbc1d0cfdcc14adc53c0a178cef951d (diff) |
Fixed AB controller bug
Diffstat (limited to 'solo_tool_integrationtest.py')
-rw-r--r-- | solo_tool_integrationtest.py | 62 |
1 files changed, 47 insertions, 15 deletions
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) |