diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-02-03 20:20:30 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-02-03 20:20:30 +0100 |
commit | b609b4ce55104c77a3f69366874a3e25e3061172 (patch) | |
tree | db0095a810acc63d34e1719f59fca668fa693bf0 /midi_launchpad_mini_integrationtest.py | |
parent | 6debe39546e62d5796f22db2388341ae9132042d (diff) |
Added AB toggle button to MIDI interface
Diffstat (limited to 'midi_launchpad_mini_integrationtest.py')
-rw-r--r-- | midi_launchpad_mini_integrationtest.py | 57 |
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" |