aboutsummaryrefslogtreecommitdiffstats
path: root/midi_launchpad_mini_integrationtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'midi_launchpad_mini_integrationtest.py')
-rw-r--r--midi_launchpad_mini_integrationtest.py66
1 files changed, 31 insertions, 35 deletions
diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py
index 4400695..beeee51 100644
--- a/midi_launchpad_mini_integrationtest.py
+++ b/midi_launchpad_mini_integrationtest.py
@@ -4,6 +4,11 @@ from midi_controller_launchpad_mini import MidiController
from solo_tool import SoloTool
from player_mock import Player as PlayerMock
+LED_RED = 3
+LED_YELLOW = 126
+LED_GREEN = 124
+LED_OFF = 0
+
class MidiWrapperMock:
def __init__(self):
self.callback = None
@@ -162,17 +167,15 @@ def test_previousAndNextAbButtons(uut, midiWrapperMock, soloTool, playerMock):
checkLimit(abLimits[0][0], abLimits[0][1])
def test_playbackRateButtons(uut, midiWrapperMock, soloTool, playerMock):
- ledYellow = 126
- ledOff = 0
playbackRateOptions = {
- 16 : (0.5, [ledYellow] * 1 + [ledOff] * 7),
- 17 : (0.6, [ledYellow] * 2 + [ledOff] * 6),
- 18 : (0.7, [ledYellow] * 3 + [ledOff] * 5),
- 19 : (0.8, [ledYellow] * 4 + [ledOff] * 4),
- 20 : (0.9, [ledYellow] * 5 + [ledOff] * 3),
- 21 : (1.0, [ledYellow] * 6 + [ledOff] * 2),
- 22 : (1.1, [ledYellow] * 7 + [ledOff] * 1),
- 23 : (1.2, [ledYellow] * 8)
+ 16 : (0.5, [LED_YELLOW] * 1 + [LED_OFF] * 7),
+ 17 : (0.6, [LED_YELLOW] * 2 + [LED_OFF] * 6),
+ 18 : (0.7, [LED_YELLOW] * 3 + [LED_OFF] * 5),
+ 19 : (0.8, [LED_YELLOW] * 4 + [LED_OFF] * 4),
+ 20 : (0.9, [LED_YELLOW] * 5 + [LED_OFF] * 3),
+ 21 : (1.0, [LED_YELLOW] * 6 + [LED_OFF] * 2),
+ 22 : (1.1, [LED_YELLOW] * 7 + [LED_OFF] * 1),
+ 23 : (1.2, [LED_YELLOW] * 8)
}
uut.connect()
assert playerMock.rate == 1.0
@@ -187,17 +190,15 @@ def test_playbackRateButtons(uut, midiWrapperMock, soloTool, playerMock):
assert midiWrapperMock.sentMessages[i] == (16 + i, colour, 0)
def test_playbackVolumeButtons(uut, midiWrapperMock, soloTool, playerMock):
- ledGreen = 124
- ledOff = 0
playbackVolumeOptions = {
- 0 : (0.125, [ledGreen] * 1 + [ledOff] * 7),
- 1 : (0.250, [ledGreen] * 2 + [ledOff] * 6),
- 2 : (0.375, [ledGreen] * 3 + [ledOff] * 5),
- 3 : (0.500, [ledGreen] * 4 + [ledOff] * 4),
- 4 : (0.625, [ledGreen] * 5 + [ledOff] * 3),
- 5 : (0.750, [ledGreen] * 6 + [ledOff] * 2),
- 6 : (0.875, [ledGreen] * 7 + [ledOff] * 1),
- 7 : (1.000, [ledGreen] * 8)
+ 0 : (0.125, [LED_GREEN] * 1 + [LED_OFF] * 7),
+ 1 : (0.250, [LED_GREEN] * 2 + [LED_OFF] * 6),
+ 2 : (0.375, [LED_GREEN] * 3 + [LED_OFF] * 5),
+ 3 : (0.500, [LED_GREEN] * 4 + [LED_OFF] * 4),
+ 4 : (0.625, [LED_GREEN] * 5 + [LED_OFF] * 3),
+ 5 : (0.750, [LED_GREEN] * 6 + [LED_OFF] * 2),
+ 6 : (0.875, [LED_GREEN] * 7 + [LED_OFF] * 1),
+ 7 : (1.000, [LED_GREEN] * 8)
}
uut.connect()
assert playerMock.volume == 1.0
@@ -220,23 +221,18 @@ def test_unassignedButton(uut, midiWrapperMock):
# 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
+ [(int(i / 8) * 16 + (i % 8), LED_OFF, 0) for i in range(0, 64)] + # clear all
+ [(i, LED_GREEN, 0) for i in range(0, 8)] + # volume row
+ [(i, LED_YELLOW, 0) for i in range(16, 22)] + # playback rate row
[
- (96, red, 0),
- (101, yellow, 0),
- (102, red, 0),
- (103, green, 0),
- (112, yellow, 0),
- (118, red, 0),
- (119, green, 0)
+ (96, LED_RED, 0),
+ (101, LED_YELLOW, 0),
+ (102, LED_RED, 0),
+ (103, LED_GREEN, 0),
+ (112, LED_YELLOW, 0),
+ (118, LED_RED, 0),
+ (119, LED_GREEN, 0)
]
)