From bfa2abe556269de927e399a0547b18126a78ff96 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 3 Jan 2022 19:14:04 +0100 Subject: Added test, some error checking in Qt interface --- midi_launchpad_mini_integrationtest.py | 26 ++++++++++++++++++++++++-- solo_tool_qt.py | 6 +++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py index beeee51..0bb9a82 100644 --- a/midi_launchpad_mini_integrationtest.py +++ b/midi_launchpad_mini_integrationtest.py @@ -64,8 +64,7 @@ def test_startStopAndPauseButtons(uut, midiWrapperMock, playerMock): midiWrapperMock.simulateInput(playPauseButton) assert playerMock.state == PlayerMock.PLAYING - msg = midiWrapperMock.getLatestMessage() - assert msg == (playPauseButton, MidiController.LED_GREEN, 0) + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_GREEN, 0) midiWrapperMock.simulateInput(stopButton) assert playerMock.state == PlayerMock.STOPPED @@ -88,6 +87,29 @@ def test_startStopAndPauseButtons(uut, midiWrapperMock, playerMock): midiWrapperMock.simulateInput(stopButton) assert playerMock.state == PlayerMock.STOPPED +def test_startPauseButtonLed(uut, midiWrapperMock, playerMock, soloTool): + playPauseButton = 112 + stopButton = 96 + uut.connect() + + assert playerMock.state == PlayerMock.STOPPED + + soloTool.play() + assert playerMock.state == PlayerMock.PLAYING + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_GREEN, 0) + + soloTool.stop() + assert playerMock.state == PlayerMock.STOPPED + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_YELLOW, 0) + + soloTool.pause() + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_YELLOW, 0) + assert playerMock.state == PlayerMock.PAUSED + + soloTool.play() + assert midiWrapperMock.getLatestMessage() == (playPauseButton, MidiController.LED_GREEN, 0) + assert playerMock.state == PlayerMock.PLAYING + def test_jumpToAButton(uut, midiWrapperMock, soloTool, playerMock): ab = (0.5, 0.6) uut.connect() diff --git a/solo_tool_qt.py b/solo_tool_qt.py index 44f2ee4..2ae75a5 100644 --- a/solo_tool_qt.py +++ b/solo_tool_qt.py @@ -165,7 +165,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.bSlider.setValue(int(ab[1] * POSITION_FACTOR)) def initMidi(self): - self.midiController.connect() + try: + self.midiController.connect() + except Exception as e: + print("Error: could not connect to MIDI controller") + print(e) if __name__ == '__main__': app = QApplication([]) -- cgit v1.2.3