diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-03 15:45:32 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-03 15:45:32 +0100 |
commit | 3472fa7854b575d0d08b4baa23a672cccd1ccaab (patch) | |
tree | 34014edd506970595fe904c8ddc13b8a7371c0a8 /midi_launchpad_mini_integrationtest.py | |
parent | e2d0e84992c539d0aa249483cad3ceca96bb03d9 (diff) |
Added LED feedback for start/pause/stop, implementation is hacky but passes test
Diffstat (limited to 'midi_launchpad_mini_integrationtest.py')
-rw-r--r-- | midi_launchpad_mini_integrationtest.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py index 13b18e7..e5b757c 100644 --- a/midi_launchpad_mini_integrationtest.py +++ b/midi_launchpad_mini_integrationtest.py @@ -10,6 +10,7 @@ class MidiWrapperMock: self.callback = None self.connectedDevice = None self.sentMessages = SimpleQueue() + self.latestMessage = None def setCallback(self, callback): self.callback = callback @@ -18,7 +19,8 @@ class MidiWrapperMock: self.connectedDevice = deviceName def sendMessage(self, note, velocity, channel): - self.sentMessages.put((note, velocity, channel)) + self.latestMessage = (note, velocity, channel) + self.sentMessages.put(self.latestMessage) def simulateInput(self, note, velocity=127, channel=0): if self.callback is not None: @@ -26,6 +28,9 @@ class MidiWrapperMock: msg = Message("note_on", note=note, velocity=velocity, channel=channel) self.callback(msg) + def getLatestMessage(self): + return self.latestMessage + @pytest.fixture def playerMock(): return PlayerMock() @@ -54,21 +59,30 @@ def test_startStopAndPauseButtons(uut, midiWrapperMock, playerMock): uut.connect() assert playerMock.state == PlayerMock.STOPPED - + midiWrapperMock.simulateInput(playPauseButton) assert playerMock.state == PlayerMock.PLAYING + msg = midiWrapperMock.getLatestMessage() + assert msg == (playPauseButton, MidiController.LED_GREEN, 0) midiWrapperMock.simulateInput(stopButton) assert playerMock.state == PlayerMock.STOPPED + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_YELLOW, 0) midiWrapperMock.simulateInput(playPauseButton) + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_GREEN, 0) + midiWrapperMock.simulateInput(playPauseButton) + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_YELLOW, 0) assert playerMock.state == PlayerMock.PAUSED midiWrapperMock.simulateInput(playPauseButton) + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_GREEN, 0) assert playerMock.state == PlayerMock.PLAYING midiWrapperMock.simulateInput(playPauseButton) + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_YELLOW, 0) + midiWrapperMock.simulateInput(stopButton) assert playerMock.state == PlayerMock.STOPPED @@ -209,7 +223,7 @@ def test_initializationMessages(uut, midiWrapperMock): (101, yellow, 0), (102, red, 0), (103, green, 0), - (112, green, 0), + (112, yellow, 0), (118, red, 0), (119, green, 0) ] |