From 88d34ded021ac61e2440720fd3deb2cf3eef21e4 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 4 Jan 2022 14:05:24 +0100 Subject: Added playback volume notification to player mock --- notifier.py | 5 +++++ notifier_unittest.py | 2 +- player_mock.py | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) 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() -- cgit v1.2.3