diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-04 14:05:24 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-04 14:05:24 +0100 |
commit | 88d34ded021ac61e2440720fd3deb2cf3eef21e4 (patch) | |
tree | bbd56cf7361f8a4b5dccc21f71c0baba48d5c85a | |
parent | c75f1ef702b1a3b5cdbbe7f1a87e0f0fbfa80e39 (diff) |
Added playback volume notification to player mock
-rw-r--r-- | notifier.py | 5 | ||||
-rw-r--r-- | notifier_unittest.py | 2 | ||||
-rw-r--r-- | player_mock.py | 7 |
3 files changed, 13 insertions, 1 deletions
diff --git a/notifier.py b/notifier.py index 42ab529..99be1ce 100644 --- a/notifier.py +++ b/notifier.py @@ -8,6 +8,7 @@ class Notifier: self._callbacks = dict() self._player = player self._player.setPlayingStateChangedCallback(self._playingStateChangedCallback) + self._player.setPlaybackVolumeChangedCallback(self._playbackVolumeChangedCallback) def registerCallback(self, event, callback): if event not in self._callbacks: @@ -20,3 +21,7 @@ class Notifier: def _playingStateChangedCallback(self, *args): self.notify(Notifier.PLAYING_STATE_EVENT) + + def _playbackVolumeChangedCallback(self, *args): + self.notify(Notifier.PLAYBACK_VOLUME_EVENT) + diff --git a/notifier_unittest.py b/notifier_unittest.py index 79b2787..9f37992 100644 --- a/notifier_unittest.py +++ b/notifier_unittest.py @@ -51,7 +51,7 @@ def test_eventsWithMockPlayer(uut, mockPlayer): assert called testEvent(Notifier.PLAYING_STATE_EVENT, mockPlayer.simulatePlayingStateChanged) - #testEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged) + testEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged) def test_singleEventNotification(uut): playingStateCalled = False diff --git a/player_mock.py b/player_mock.py index 92da675..2fd343f 100644 --- a/player_mock.py +++ b/player_mock.py @@ -10,6 +10,7 @@ class Player(): self.volume = 1.0 self.currentSong = None self.playingStateChangedCallback = None + self.playbackVolumeChangedCallback = None def play(self): previousState = self.state @@ -58,3 +59,9 @@ class Player(): def simulatePlayingStateChanged(self): self.playingStateChangedCallback() + + def setPlaybackVolumeChangedCallback(self, callback): + self.playbackVolumeChangedCallback = callback + + def simulatePlaybackVolumeChanged(self): + self.playbackVolumeChangedCallback() |