From 3472fa7854b575d0d08b4baa23a672cccd1ccaab Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 3 Jan 2022 15:45:32 +0100 Subject: Added LED feedback for start/pause/stop, implementation is hacky but passes test --- midi_launchpad_mini_integrationtest.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'midi_launchpad_mini_integrationtest.py') 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) ] -- cgit v1.2.3