aboutsummaryrefslogtreecommitdiffstats
path: root/notifier_unittest.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-04 14:58:39 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-04 14:58:39 +0100
commit3eed7537f8cc0221a81951b24ef965f6b7f35d6e (patch)
tree11158ffd5c6d4d7403e6bde07308b0c3c4e65999 /notifier_unittest.py
parent3066dbcdd863342d3c9534886434d6e8aaa45367 (diff)
Added song and AB limits change notification
Diffstat (limited to 'notifier_unittest.py')
-rw-r--r--notifier_unittest.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/notifier_unittest.py b/notifier_unittest.py
index 9f37992..13f2285 100644
--- a/notifier_unittest.py
+++ b/notifier_unittest.py
@@ -11,34 +11,36 @@ def mockPlayer():
def uut(mockPlayer):
return Notifier(mockPlayer)
-def checkEvent(uut, event):
- callbacks = 2
- calledFlags = [False] * 2
+def test_allEvents(uut):
+ def checkEvent(uut, event):
+ callbacks = 2
+ calledFlags = [False] * 2
- def createCallback(i):
- def cb():
- nonlocal calledFlags
- calledFlags[i] = True
- return cb
+ def createCallback(i):
+ def cb():
+ nonlocal calledFlags
+ calledFlags[i] = True
+ return cb
- for i in range(0, callbacks):
- uut.registerCallback(event, createCallback(i))
+ for i in range(0, callbacks):
+ uut.registerCallback(event, createCallback(i))
- assert not any(calledFlags)
- uut.notify(event)
- assert all(calledFlags)
+ assert not any(calledFlags)
+ uut.notify(event)
+ assert all(calledFlags)
-def test_allEvents(uut):
checkEvent(uut, Notifier.PLAYING_STATE_EVENT)
checkEvent(uut, Notifier.PLAYBACK_VOLUME_EVENT)
checkEvent(uut, Notifier.PLAYBACK_RATE_EVENT)
+ checkEvent(uut, Notifier.CURRENT_SONG_EVENT)
+ checkEvent(uut, Notifier.CURRENT_AB_EVENT)
def test_eventWithoutRegisteredCallbacks(uut):
uut.notify(Notifier.PLAYING_STATE_EVENT)
# expect no crash
def test_eventsWithMockPlayer(uut, mockPlayer):
- def testEvent(eventCode, simulateEvent):
+ def checkEvent(eventCode, simulateEvent):
called = False
def callback():
nonlocal called
@@ -50,8 +52,8 @@ def test_eventsWithMockPlayer(uut, mockPlayer):
simulateEvent()
assert called
- testEvent(Notifier.PLAYING_STATE_EVENT, mockPlayer.simulatePlayingStateChanged)
- testEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged)
+ checkEvent(Notifier.PLAYING_STATE_EVENT, mockPlayer.simulatePlayingStateChanged)
+ checkEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged)
def test_singleEventNotification(uut):
playingStateCalled = False