1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*
Copyright (C) 2008-2024, Pedro Lopez-Cabanillas <plcl@users.sf.net>
This file is part of the Drumstick project, see https://sf.net/p/drumstick
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; If not, see <http://www.gnu.org/licenses/>.
*/
#include <QString>
#include <QStringList>
#include <QtTest>
#include <drumstick/backendmanager.h>
#include <drumstick/rtmidiinput.h>
#include <drumstick/rtmidioutput.h>
#if defined(LINUX_BACKEND)
Q_IMPORT_PLUGIN(ALSAMIDIInput)
Q_IMPORT_PLUGIN(ALSAMIDIOutput)
Q_IMPORT_PLUGIN(SynthController)
#endif
#if defined(MAC_BACKEND)
Q_IMPORT_PLUGIN(MacMIDIInput)
Q_IMPORT_PLUGIN(MacMIDIOutput)
Q_IMPORT_PLUGIN(MacSynthOutput)
#endif
#if defined(WIN_BACKEND)
Q_IMPORT_PLUGIN(WinMIDIInput)
Q_IMPORT_PLUGIN(WinMIDIOutput)
#endif
#if defined(NET_BACKEND)
Q_IMPORT_PLUGIN(NetMIDIInput)
Q_IMPORT_PLUGIN(NetMIDIOutput)
#endif
#if defined(DUMMY_BACKEND)
Q_IMPORT_PLUGIN(DummyInput)
Q_IMPORT_PLUGIN(DummyOutput)
#endif
#if defined(FLUIDSYNTH_BACKEND)
Q_IMPORT_PLUGIN(FluidSynthOutput)
#endif
#if defined(OSS_BACKEND)
Q_IMPORT_PLUGIN(OSSInput)
Q_IMPORT_PLUGIN(OSSOutput)
#endif
using namespace drumstick::rt;
class RtTest : public QObject
{
Q_OBJECT
public:
RtTest();
private:
QString joinConns(QList<MIDIConnection> conns);
private Q_SLOTS:
void testRT();
};
RtTest::RtTest() = default;
void RtTest::testRT()
{
QSettings settings;
QList<MIDIInput*> inputsList;
QList<MIDIOutput*> outputsList;
BackendManager man;
man.refresh(&settings);
QStringList paths = man.defaultPaths();
#if !defined(DRUMSTICK_STATIC)
QVERIFY2(paths.length() > 0, "Plugins path is empty");
foreach(const QString& p, paths) {
qDebug() << "path:" << p;
}
#endif
inputsList = man.availableInputs();
QVERIFY2(inputsList.length() > 0, "There aren't input backends");
foreach(MIDIInput* input, inputsList) {
QList<MIDIConnection> conns = input->connections();
qDebug() << "input:" << input->backendName() << input->publicName();
qDebug() << " connections:" << (conns.isEmpty() ? "none" : joinConns(conns));
QCOMPARE(input->backendName().isEmpty(), false );
QCOMPARE(input->publicName().isEmpty(), false );
/*QVERIFY2(conns.length() > 0, "Backend without any connection");
QStringList avconns = input->connections(true);
QVERIFY2(avconns.length() > 0, "Backend without any advanced connection");
QVERIFY2(avconns.length() >= conns.length(), "unexpected connections number");*/
}
outputsList = man.availableOutputs();
QVERIFY2(outputsList.length() > 0, "There aren't output backends");
foreach(MIDIOutput* output, outputsList) {
QList<MIDIConnection> conns = output->connections();
qDebug() << "output:" << output->backendName() << output->publicName();
qDebug() << " connections:" << (conns.isEmpty() ? "none" : joinConns(conns));
/*QVERIFY2(conns.length() > 0, "Backend without any connection");
QStringList avconns = output->connections(true);
QVERIFY2(avconns.length() > 0, "Backend without any advanced connection");
QVERIFY2(avconns.length() >= conns.length(), "unexpected connections number");*/
}
}
QString RtTest::joinConns(QList<MIDIConnection> conns)
{
QString res;
for(const MIDIConnection& c : conns) {
res += c.first + ", ";
}
return res;
}
QTEST_GUILESS_MAIN(RtTest)
#include "rttest.moc"
|