diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2021-12-26 21:14:40 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2021-12-26 21:14:40 +0100 |
commit | 8622638f99277b43d40b61029dc3c56164d06cae (patch) | |
tree | 1a632e3b7969d780abbb0b7575964fcf63d8bb33 /abcontroller_unittest.py | |
parent | 10aa8140b5e52cc0cf8cea794daf81fb0ffdcad3 (diff) |
Changed default behaviour of AB controller
Diffstat (limited to 'abcontroller_unittest.py')
-rw-r--r-- | abcontroller_unittest.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/abcontroller_unittest.py b/abcontroller_unittest.py index 0e004ff..736ac6b 100644 --- a/abcontroller_unittest.py +++ b/abcontroller_unittest.py @@ -28,6 +28,27 @@ def checkLimits(uut, aLimit, bLimit, fail=False): uut._setPositionCallback = originalCallback +def checkDefaultLimits(uut): + tests = [ + TCase(0.0, None), + TCase(0.1, 0.0), + TCase(0.5, 0.0) + ] + + requestedPosition = None + def callback(newPosition): + nonlocal requestedPosition + requestedPosition = newPosition + + originalCallback = uut._setPositionCallback + uut._setPositionCallback = callback + + for t in tests: + uut.positionChanged(t.currentPosition) + assert requestedPosition == t.requestedPosition + + uut._setPositionCallback = originalCallback + def test_oneSetOfLimits(): song = "/path/to/song" @@ -107,7 +128,7 @@ def test_storeLimitsWithoutCurrentSong(): uut.storeLimits(abLimits.a, abLimits.b) uut.loadLimits(0) - checkLimits(uut, abLimits.a, abLimits.b, fail=True) + checkDefaultLimits(uut) def test_storeLimitsToSongWithoutCurrentSong(): song = "/path/to/song" @@ -115,11 +136,11 @@ def test_storeLimitsToSongWithoutCurrentSong(): uut.storeLimits(abLimits.a, abLimits.b, song) uut.loadLimits(0) - checkLimits(uut, abLimits.a, abLimits.b, fail=True) + checkDefaultLimits(uut) uut.setCurrentSong(song) - checkLimits(uut, abLimits.a, abLimits.b, fail=True) + checkDefaultLimits(uut) uut.loadLimits(0) @@ -131,7 +152,7 @@ def test_storeLimitsToCurrentSongButDoNotSetCurrentLimits(): uut.setCurrentSong(song) uut.storeLimits(abLimits.a, abLimits.b) - checkLimits(uut, abLimits.a, abLimits.b, fail=True) + checkDefaultLimits(uut) uut.loadLimits(0) |