#include "ControllerController.h" #include class ControllerControllerTest : public QObject { Q_OBJECT private slots: void commandModelFiltersByCommandType(); void deviceModelExposesControllerCapabilities(); void controllerReturnsButtonPageData(); void contextMenuExposesGraphicsButtonOptions(); }; void ControllerControllerTest::commandModelFiltersByCommandType() { QVector commands; commands.append(COMMAND(0, "None", commandAny, funcNone, 0)); commands.append(COMMAND(1, "Button Only", commandButton, funcTransceiverStatus, 1)); commands.append(COMMAND(2, "Knob Only", commandKnob, funcAfGain, 1)); CommandModel buttonModel; buttonModel.setCommands(&commands, true); QCOMPARE(buttonModel.rowCount(), 2); QCOMPARE(buttonModel.data(buttonModel.index(0, 0), CommandModel::TextRole).toString(), QString("None")); QCOMPARE(buttonModel.data(buttonModel.index(1, 0), CommandModel::TextRole).toString(), QString("Button Only")); CommandModel knobModel; knobModel.setCommands(&commands, false); QCOMPARE(knobModel.rowCount(), 2); QCOMPARE(knobModel.data(knobModel.index(0, 0), CommandModel::TextRole).toString(), QString("None")); QCOMPARE(knobModel.data(knobModel.index(1, 0), CommandModel::TextRole).toString(), QString("Knob Only")); } void ControllerControllerTest::deviceModelExposesControllerCapabilities() { USBDEVICE streamDeck(USBTYPE(StreamDeckMini, 0x0fd9, 0x0063, 0, 0, 6, 0, 0, 0, 1024, 80)); streamDeck.product = "Stream Deck Mini"; streamDeck.path = "streamdeck"; streamDeck.connected = true; USBDEVICE shuttle(USBTYPE(shuttleXpress, 0x0b33, 0x0020, 0, 0, 15, 0, 2, 0, 5, 0)); shuttle.product = "Shuttle Xpress"; shuttle.path = "shuttle"; shuttle.connected = true; DeviceModel model; model.addDevice(&streamDeck); model.addDevice(&shuttle); const QVariantMap streamDeckData = model.get(0); QCOMPARE(streamDeckData.value("deviceName").toString(), QString("Stream Deck Mini")); QCOMPARE(streamDeckData.value("showSensitivity").toBool(), false); QCOMPARE(streamDeckData.value("showBrightness").toBool(), true); QCOMPARE(streamDeckData.value("showSpeed").toBool(), false); QCOMPARE(streamDeckData.value("showOrientation").toBool(), false); QCOMPARE(streamDeckData.value("showColor").toBool(), true); QCOMPARE(streamDeckData.value("showTimeout").toBool(), false); const QVariantMap shuttleData = model.get(1); QCOMPARE(shuttleData.value("showSensitivity").toBool(), true); QCOMPARE(shuttleData.value("showBrightness").toBool(), false); QCOMPARE(shuttleData.value("showSpeed").toBool(), false); QCOMPARE(shuttleData.value("showOrientation").toBool(), false); QCOMPARE(shuttleData.value("showColor").toBool(), false); QCOMPARE(shuttleData.value("showTimeout").toBool(), false); } void ControllerControllerTest::controllerReturnsButtonPageData() { QVector commands; commands.append(COMMAND(0, "None", commandAny, funcNone, 0)); commands.append(COMMAND(1, "PTT On", commandButton, funcTransceiverStatus, 1)); commands.append(COMMAND(2, "PTT Off", commandButton, funcTransceiverStatus, 0)); usbDevMap devices; devices.insert("streamdeck", USBDEVICE(USBTYPE(StreamDeckMini, 0x0fd9, 0x0063, 0, 0, 6, 0, 0, 0, 1024, 80))); USBDEVICE &device = devices["streamdeck"]; device.path = "streamdeck"; device.product = "Stream Deck Mini"; device.detected = true; device.connected = true; device.currentPage = 1; QVector