From 328d9ae201cabe8e4189736cd806ecea7b675200 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Sat, 1 Jan 2022 15:49:06 +0100 Subject: Added previous/next song buttons to MIDI interface, updated known issues --- midi_launchpad_mini_unittest.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'midi_launchpad_mini_unittest.py') diff --git a/midi_launchpad_mini_unittest.py b/midi_launchpad_mini_unittest.py index 09f12df..55ca6c8 100644 --- a/midi_launchpad_mini_unittest.py +++ b/midi_launchpad_mini_unittest.py @@ -30,6 +30,8 @@ class SoloToolMock: self.state = SoloToolMock.STOPPED self.position = 0.0 self.currentAbLimit = (0.0, 0.0) + self.currentLoadedAbLimitIndex = None + self.currentSong = None def play(self): self.state = SoloToolMock.PLAYING @@ -46,6 +48,24 @@ class SoloToolMock: def jumpToA(self): self.position = self.currentAbLimit[0] + def loadAbLimits(self, index): + self.currentLoadedAbLimitIndex = index + + def setSong(self, index): + self.currentSong = index + + def nextSong(self): + if self.currentSong is None: + self.currentSong = 0 + else: + self.currentSong += 1 + + def previousSong(self): + if self.currentSong is None: + self.currentSong = 0 + else: + self.currentSong = max(self.currentSong - 1, 0) + def test_connect(): expectedDevice = "Launchpad Mini MIDI 1" @@ -97,6 +117,26 @@ def test_jumpToAButton(): midiWrapperMock.simulateInput(101) assert soloToolMock.position == ab[0] +def test_previousAndNextSongButtons(): + soloToolMock = SoloToolMock() + midiWrapperMock = MidiWrapperMock() + uut = MidiController(soloToolMock, midiWrapperMock) + uut.connect() + + assert soloToolMock.currentSong == None + midiWrapperMock.simulateInput(119) + assert soloToolMock.currentSong == 0 + + midiWrapperMock.simulateInput(119) + assert soloToolMock.currentSong == 1 + + midiWrapperMock.simulateInput(118) + assert soloToolMock.currentSong == 0 + + midiWrapperMock.simulateInput(118) + assert soloToolMock.currentSong == 0 + +""" def test_unprogrammedButton(): unusedButton = 48 midiWrapperMock = MidiWrapperMock() @@ -105,3 +145,4 @@ def test_unprogrammedButton(): # expect no crash midiWrapperMock.simulateInput(48) +""" -- cgit v1.2.3