diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2021-12-21 19:32:11 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2021-12-21 19:32:11 +0100 |
commit | ae8f0a04190c3d13292ad68548f5275507e5812e (patch) | |
tree | 1bc207715280e6e9a1b99a84f9435e98d15bda1b /solo_tool_integrationtest.py | |
parent | 9ee7ee992d468b4f354ac16c34747e0c31d7b656 (diff) |
Added some integration tests, refactored playlist, updated diagram
Diffstat (limited to 'solo_tool_integrationtest.py')
-rw-r--r-- | solo_tool_integrationtest.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/solo_tool_integrationtest.py b/solo_tool_integrationtest.py new file mode 100644 index 0000000..19bb406 --- /dev/null +++ b/solo_tool_integrationtest.py @@ -0,0 +1,68 @@ +from solo_tool import SoloTool +from time import sleep + +class MockPlayer(): + STOPPED = 0 + PLAYING = 1 + PAUSED = 2 + + def __init__(self): + self.state = MockPlayer.STOPPED + self.rate = 1.0 + self.position = 0.0 + self.volume = 1.0 + self.currentSong = "" + + def play(self): + self.state = MockPlayer.PLAYING + + def stop(self): + self.state = MockPlayer.STOPPED + + def pause(self): + self.state = MockPlayer.PAUSED + + def setPlaybackRate(self, rate): + self.rate = rate + + def getPlaybackRate(self): + return self.rate + + def setPlaybackPosition(self, position): + self.position = position + + def getPlaybackPosition(self): + return self.position + + def setPlaybackVolume(self, volume): + self.volume = volume + + def getPlaybackVolume(self): + return self.volume + + def setCurrentSong(self, path): + self.currentSong = path + +def test_playerControls(): + mockPlayer = MockPlayer() + uut = SoloTool(mockPlayer) + + assert mockPlayer.state == MockPlayer.STOPPED + uut.play() + assert mockPlayer.state == MockPlayer.PLAYING + uut.pause() + assert mockPlayer.state == MockPlayer.PAUSED + uut.stop() + assert mockPlayer.state == MockPlayer.STOPPED + + assert mockPlayer.rate == 1.0 + uut.setPlaybackRate(0.5) + assert mockPlayer.rate == 0.5 + + assert mockPlayer.position == 0.0 + uut.setPlaybackPosition(0.5) + assert mockPlayer.position == 0.5 + + assert mockPlayer.volume == 1.0 + uut.setPlaybackVolume(0.5) + assert mockPlayer.volume == 0.5 |