From 430466b0e3a4dd762d8c4a44403437691d9d6118 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Sun, 2 Jan 2022 09:34:37 +0100 Subject: Added basic LED support for launchpad, removed old MIDI code --- midi_launchpad_mini_integrationtest.py | 36 +++++++++++++++++++++++++++++++--- 1 file changed, 33 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 275bd33..13b18e7 100644 --- a/midi_launchpad_mini_integrationtest.py +++ b/midi_launchpad_mini_integrationtest.py @@ -6,9 +6,10 @@ from player_mock import Player as PlayerMock class MidiWrapperMock: def __init__(self): + from queue import SimpleQueue self.callback = None self.connectedDevice = None - self.lastMessageSent = None + self.sentMessages = SimpleQueue() def setCallback(self, callback): self.callback = callback @@ -16,8 +17,8 @@ class MidiWrapperMock: def connect(self, deviceName): self.connectedDevice = deviceName - def sendMessage(self, note, velocity=127, channel=0): - pass + def sendMessage(self, note, velocity, channel): + self.sentMessages.put((note, velocity, channel)) def simulateInput(self, note, velocity=127, channel=0): if self.callback is not None: @@ -193,3 +194,32 @@ def test_unassignedButton(uut, midiWrapperMock): midiWrapperMock.simulateInput(unassignedButton) # XXX would be better to assert that nothing changed in the solo tool +def test_initializationMessages(uut, midiWrapperMock): + green = 124 + yellow = 126 + red = 3 + off = 0 + + expectedMessages = set( + [(int(i / 8) * 16 + (i % 8), off, 0) for i in range(0, 64)] + # clear all + [(i, green, 0) for i in range(0, 8)] + # volume row + [(i, yellow, 0) for i in range(16, 22)] + # playback rate row + [ + (96, red, 0), + (101, yellow, 0), + (102, red, 0), + (103, green, 0), + (112, green, 0), + (118, red, 0), + (119, green, 0) + ] + ) + + uut.connect() + + sentMessages = set() + while (not midiWrapperMock.sentMessages.empty()): + sentMessages.add(midiWrapperMock.sentMessages.get()) + + assert sentMessages == expectedMessages + -- cgit v1.2.3