From 97f3c945fe2e1369c2e21cef4a474fac3ce4d8db Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Fri, 7 Jan 2022 16:33:48 +0100 Subject: Fixed AB controller bug --- solo_tool_integrationtest.py | 62 +++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 15 deletions(-) (limited to 'solo_tool_integrationtest.py') 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) -- cgit v1.2.3