Exemplo n.º 1
0
void InputMap_Test::pluginInputs()
{
    InputMap im(m_doc, 4);

    QVERIFY(im.pluginInputs("Foo").size() == 0);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QVERIFY(im.pluginInputs(stub->name()).size() == 4);
    QVERIFY(im.pluginInputs(stub->name()) == stub->inputs());
}
Exemplo n.º 2
0
void InputMap_Test::slotConfigurationChanged()
{
    InputMap im(m_doc, 4);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QSignalSpy spy(&im, SIGNAL(pluginConfigurationChanged(QString)));
    stub->configure();
    QCOMPARE(spy.size(), 1);
    QCOMPARE(spy.at(0).size(), 1);
    QCOMPARE(spy.at(0).at(0).toString(), QString(stub->name()));
}
Exemplo n.º 3
0
void InputMap_Test::inputSourceNames()
{
    InputMap im(m_doc, 4);

    OutputPluginStub* stub = static_cast<OutputPluginStub*> (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QDir dir(PROFILEDIR);
    dir.setFilter(QDir::Files);
    dir.setNameFilters(QStringList() << QString("*%1").arg(KExtInputProfile));
    im.loadProfiles(dir);

    QString uni, ch;
    QVERIFY(im.inputSourceNames(QLCInputSource(0, 0), uni, ch) == false);
    QCOMPARE(uni, QString());
    QCOMPARE(ch, QString());

    QVERIFY(im.setPatch(0, stub->name(), 0, QString("Generic MIDI")) == true);
    QVERIFY(im.inputSourceNames(QLCInputSource(0, 0), uni, ch) == true);
    QCOMPARE(uni, tr("%1: Generic MIDI").arg(1));
    QCOMPARE(ch, tr("%1: Bank select MSB").arg(1));

    uni.clear();
    ch.clear();
    QVERIFY(im.inputSourceNames(QLCInputSource(0, 50000), uni, ch) == true);
    QCOMPARE(uni, tr("%1: Generic MIDI").arg(1));
    QCOMPARE(ch, tr("%1: ?").arg(50001));

    QVERIFY(im.setPatch(0, stub->name(), 0, QString()) == true);

    uni.clear();
    ch.clear();
    QVERIFY(im.inputSourceNames(QLCInputSource(0, 0), uni, ch) == true);
    QCOMPARE(uni, tr("%1: %2").arg(1).arg(stub->name()));
    QCOMPARE(ch, tr("%1: ?").arg(1));

    QVERIFY(im.inputSourceNames(QLCInputSource(0, InputMap::invalidChannel()), uni, ch) == false);
    QVERIFY(im.inputSourceNames(QLCInputSource(InputMap::invalidUniverse(), 0), uni, ch) == false);
    QVERIFY(im.inputSourceNames(QLCInputSource(), uni, ch) == false);
}
Exemplo n.º 4
0
void InputPatch_Test::patch()
{
    InputMap im(m_doc, 4);

    QCOMPARE(m_doc->ioPluginCache()->plugins().size(), 1);
    OutputPluginStub* stub = static_cast<OutputPluginStub*> (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QLCInputProfile prof1;
    prof1.setManufacturer("Foo");
    prof1.setManufacturer("Bar");

    InputPatch* ip = new InputPatch(0, this);
    ip->set(stub, 0, &prof1);
    QVERIFY(ip->m_plugin == stub);
    QVERIFY(ip->m_input == 0);
    QVERIFY(ip->m_profile == &prof1);
    QVERIFY(ip->pluginName() == stub->name());
    QVERIFY(ip->inputName() == stub->inputs()[0]);
    QVERIFY(ip->profileName() == prof1.name());
    QVERIFY(stub->m_openInputs.size() == 1);
    QVERIFY(stub->m_openInputs.at(0) == 0);

    QLCInputProfile prof2;
    prof2.setManufacturer("Xyzzy");
    prof2.setManufacturer("Foobar");

    ip->set(stub, 3, &prof2);
    QVERIFY(ip->m_plugin == stub);
    QVERIFY(ip->m_input == 3);
    QVERIFY(ip->m_profile == &prof2);
    QVERIFY(ip->pluginName() == stub->name());
    QVERIFY(ip->inputName() == stub->inputs()[3]);
    QVERIFY(ip->profileName() == prof2.name());
    QVERIFY(stub->m_openInputs.size() == 1);
    QVERIFY(stub->m_openInputs.at(0) == 3);

    ip->reconnect();
    QVERIFY(ip->m_plugin == stub);
    QVERIFY(ip->m_input == 3);
    QVERIFY(ip->m_profile == &prof2);
    QVERIFY(ip->pluginName() == stub->name());
    QVERIFY(ip->inputName() == stub->inputs()[3]);
    QVERIFY(ip->profileName() == prof2.name());
    QVERIFY(stub->m_openInputs.size() == 1);
    QVERIFY(stub->m_openInputs.at(0) == 3);

    delete ip;
    QVERIFY(stub->m_openInputs.size() == 0);
}
Exemplo n.º 5
0
void InputMap_Test::pluginStatus()
{
    InputMap im(m_doc, 4);

    QVERIFY(im.pluginStatus("Foo", QLCIOPlugin::invalidLine()).contains("Nothing selected"));
    QVERIFY(im.pluginStatus("Bar", 0).contains("Nothing selected"));
    QVERIFY(im.pluginStatus("Baz", 1).contains("Nothing selected"));
    QVERIFY(im.pluginStatus("Xyzzy", 2).contains("Nothing selected"));
    QVERIFY(im.pluginStatus("AYBABTU", 3).contains("Nothing selected"));

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QVERIFY(im.pluginStatus(stub->name(), QLCIOPlugin::invalidLine()) == stub->inputInfo(QLCIOPlugin::invalidLine()));
    QVERIFY(im.pluginStatus(stub->name(), 0) == stub->inputInfo(0));
    QVERIFY(im.pluginStatus(stub->name(), 1) == stub->inputInfo(1));
    QVERIFY(im.pluginStatus(stub->name(), 2) == stub->inputInfo(2));
}
Exemplo n.º 6
0
void InputMap_Test::slotValueChanged()
{
    InputMap im(m_doc, 4);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QVERIFY(im.setPatch(0, stub->name(), 0) == true);
    QVERIFY(im.patch(0)->plugin() == stub);
    QVERIFY(im.patch(0)->input() == 0);

    QSignalSpy spy(&im, SIGNAL(inputValueChanged(quint32, quint32, uchar, const QString&)));
    stub->emitValueChanged(0, 15, UCHAR_MAX);
    QVERIFY(spy.size() == 1);
    QVERIFY(spy.at(0).at(0) == 0);
    QVERIFY(spy.at(0).at(1) == 15);
    QVERIFY(spy.at(0).at(2) == UCHAR_MAX);

    /* Invalid mapping for this plugin -> no signal */
    stub->emitValueChanged(3, 15, UCHAR_MAX);
    QVERIFY(spy.size() == 1);
    QVERIFY(spy.at(0).at(0) == 0);
    QVERIFY(spy.at(0).at(1) == 15);
    QVERIFY(spy.at(0).at(2) == UCHAR_MAX);

    /* Invalid mapping for this plugin -> no signal */
    stub->emitValueChanged(1, 15, UCHAR_MAX);
    QVERIFY(spy.size() == 1);
    QVERIFY(spy.at(0).at(0) == 0);
    QVERIFY(spy.at(0).at(1) == 15);
    QVERIFY(spy.at(0).at(2) == UCHAR_MAX);

    stub->emitValueChanged(0, 5, 127);
    QVERIFY(spy.size() == 2);
    QVERIFY(spy.at(0).at(0) == 0);
    QVERIFY(spy.at(0).at(1) == 15);
    QVERIFY(spy.at(0).at(2) == UCHAR_MAX);
    QVERIFY(spy.at(1).at(0) == 0);
    QVERIFY(spy.at(1).at(1) == 5);
    QVERIFY(spy.at(1).at(2) == 127);
}
Exemplo n.º 7
0
void OutputPatch_Test::patch()
{
    OutputMap om(m_doc, 4);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    OutputPatch* op = new OutputPatch(this);
    op->set(stub, 0);
    QVERIFY(op->m_plugin == stub);
    QVERIFY(op->m_output == 0);
    QVERIFY(op->pluginName() == stub->name());
    QVERIFY(op->outputName() == stub->outputs()[0]);
    QVERIFY(stub->m_openOutputs.size() == 1);
    QVERIFY(stub->m_openOutputs.at(0) == 0);

    op->set(stub, 3);
    QVERIFY(op->m_plugin == stub);
    QVERIFY(op->m_output == 3);
    QVERIFY(op->pluginName() == stub->name());
    QVERIFY(op->outputName() == stub->outputs()[3]);
    QVERIFY(stub->m_openOutputs.size() == 1);
    QVERIFY(stub->m_openOutputs.at(0) == 3);

    op->reconnect();
    QVERIFY(op->m_plugin == stub);
    QVERIFY(op->m_output == 3);
    QVERIFY(op->pluginName() == stub->name());
    QVERIFY(op->outputName() == stub->outputs()[3]);
    QVERIFY(stub->m_openOutputs.size() == 1);
    QVERIFY(stub->m_openOutputs.at(0) == 3);

    delete op;
    QVERIFY(stub->m_openOutputs.size() == 0);
}
Exemplo n.º 8
0
void InputMap_Test::configurePlugin()
{
    InputMap im(m_doc, 4);

    QCOMPARE(im.canConfigurePlugin("Foo"), false);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QCOMPARE(im.canConfigurePlugin("Foo"), false);
    QCOMPARE(im.canConfigurePlugin(stub->name()), false);
    stub->m_canConfigure = true;
    QCOMPARE(im.canConfigurePlugin(stub->name()), true);

    /* Must be able to call multiple times */
    im.configurePlugin(stub->name());
    QVERIFY(stub->m_configureCalled == 1);
    im.configurePlugin(stub->name());
    QVERIFY(stub->m_configureCalled == 2);
    im.configurePlugin(stub->name());
    QVERIFY(stub->m_configureCalled == 3);
}
Exemplo n.º 9
0
void InputMap_Test::setPatch()
{
    InputMap im(m_doc, 4);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QLCInputProfile* prof = new QLCInputProfile();
    prof->setManufacturer("Foo");
    prof->setModel("Bar");
    im.addProfile(prof);

    QVERIFY(im.patch(0)->plugin() == NULL);
    QVERIFY(im.patch(0)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(0)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 0) == InputMap::invalidUniverse());

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == NULL);
    QVERIFY(im.patch(2)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(2)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == InputMap::invalidUniverse());

    QVERIFY(im.setPatch(0, "Foobar", 0, prof->name()) == true);
    QVERIFY(im.patch(0)->plugin() == NULL);
    QVERIFY(im.patch(0)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(0)->profile() == prof);
    QVERIFY(im.mapping(stub->name(), 0) == InputMap::invalidUniverse());

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == NULL);
    QVERIFY(im.patch(2)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(2)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == InputMap::invalidUniverse());

    QVERIFY(im.setPatch(0, stub->name(), 0) == true);
    QVERIFY(im.patch(0)->plugin() == stub);
    QVERIFY(im.patch(0)->input() == 0);
    QVERIFY(im.patch(0)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 0) == 0);

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == NULL);
    QVERIFY(im.patch(2)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(2)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == InputMap::invalidUniverse());

    QVERIFY(im.setPatch(2, stub->name(), 3, prof->name()) == true);
    QVERIFY(im.patch(0)->plugin() == stub);
    QVERIFY(im.patch(0)->input() == 0);
    QVERIFY(im.patch(0)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 0) == 0);

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == stub);
    QVERIFY(im.patch(2)->input() == 3);
    QVERIFY(im.patch(2)->profile() == prof);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == 2);

    // Universe out of bounds
    QVERIFY(im.setPatch(im.universes(), stub->name(), 0) == false);
}