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.py57
1 files changed, 38 insertions, 19 deletions
diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py
index 615ef49..e9bc6b5 100644
--- a/midi_launchpad_mini_integrationtest.py
+++ b/midi_launchpad_mini_integrationtest.py
@@ -9,6 +9,15 @@ LED_YELLOW = 126
LED_GREEN = 124
LED_OFF = 0
+nextSongButton = 119
+previousSongButton = 118
+playPauseButton = 112
+stopButton = 96
+nextLimitButton = 103
+previousLimitButton = 102
+abToggleButton = 101
+jumpToAButton = 99
+
class MidiWrapperMock:
def __init__(self):
self.callback = None
@@ -56,8 +65,6 @@ def test_connect(uut, midiWrapperMock):
assert midiWrapperMock.connectedDevice == expectedDevice
def test_startStopAndPauseButtons(uut, midiWrapperMock, playerMock):
- playPauseButton = 112
- stopButton = 96
uut.connect()
assert playerMock.state == PlayerMock.STOPPED
@@ -88,8 +95,6 @@ def test_startStopAndPauseButtons(uut, midiWrapperMock, playerMock):
assert playerMock.state == PlayerMock.STOPPED
def test_startPauseButtonLed(uut, midiWrapperMock, playerMock, soloTool):
- playPauseButton = 112
- stopButton = 96
uut.connect()
assert playerMock.state == PlayerMock.STOPPED
@@ -110,6 +115,26 @@ def test_startPauseButtonLed(uut, midiWrapperMock, playerMock, soloTool):
playerMock.simulatePlayingStateChanged()
assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_GREEN, 0)
+def test_abToggleButton(uut, midiWrapperMock, soloTool):
+ uut.connect()
+
+ midiWrapperMock.simulateInput(abToggleButton)
+ assert soloTool.isAbLimitEnabled()
+ assert midiWrapperMock.getLatestMessage() == (abToggleButton, MidiController.LED_GREEN, 0)
+
+ midiWrapperMock.simulateInput(abToggleButton)
+ assert not soloTool.isAbLimitEnabled()
+ assert midiWrapperMock.getLatestMessage() == (abToggleButton, MidiController.LED_RED, 0)
+
+def test_abToggleButtonLed(uut, midiWrapperMock, soloTool):
+ uut.connect()
+
+ soloTool.setAbLimitEnable(True)
+ assert midiWrapperMock.getLatestMessage() == (abToggleButton, MidiController.LED_GREEN, 0)
+
+ soloTool.setAbLimitEnable(False)
+ assert midiWrapperMock.getLatestMessage() == (abToggleButton, MidiController.LED_RED, 0)
+
def test_jumpToAButton(uut, midiWrapperMock, soloTool, playerMock):
ab = (0.5, 0.6)
uut.connect()
@@ -117,12 +142,10 @@ def test_jumpToAButton(uut, midiWrapperMock, soloTool, playerMock):
soloTool.setAbLimits(ab[0], ab[1])
assert playerMock.position == 0.0
- midiWrapperMock.simulateInput(101)
+ midiWrapperMock.simulateInput(jumpToAButton)
assert playerMock.position == ab[0]
def test_previousAndNextSongButtons(uut, midiWrapperMock, soloTool, playerMock):
- nextSongButton = 119
- previousSongButton = 118
songs = [
"test.flac",
"test.mp3"
@@ -145,8 +168,6 @@ def test_previousAndNextSongButtons(uut, midiWrapperMock, soloTool, playerMock):
assert playerMock.currentSong == songs[0]
def test_previousAndNextAbButtons(uut, midiWrapperMock, soloTool, playerMock):
- nextLimitButton = 103
- previousLimitButton = 102
song = "test.flac"
abLimits = [
[0.2, 0.4],
@@ -330,13 +351,14 @@ def test_initializationMessages(uut, midiWrapperMock):
[(i, LED_GREEN, 0) for i in range(0, 6)] + # volume row
[(i, LED_YELLOW, 0) for i in range(16, 22)] + # playback rate row
[
- (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)
+ (stopButton, LED_RED, 0),
+ (playPauseButton, LED_YELLOW, 0),
+ (abToggleButton, LED_RED, 0),
+ (jumpToAButton, LED_YELLOW, 0),
+ (previousLimitButton, LED_RED, 0),
+ (nextLimitButton, LED_GREEN, 0),
+ (previousSongButton, LED_RED, 0),
+ (nextSongButton, LED_GREEN, 0)
]
)
@@ -346,9 +368,6 @@ def test_initializationMessages(uut, midiWrapperMock):
assert sentMessagesSet == expectedMessages
def test_playingFeedbackWhenChangingSong(uut, midiWrapperMock, soloTool, playerMock):
- nextSongButton = 119
- previousSongButton = 118
- playPauseButton = 112
songs = [
"test.flac",
"test.mp3"