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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/*
Q Light Controller - Unit test
inputpatch_test.cpp
Copyright (c) Heikki Junnila
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <QtTest>
#define private public
#include "iopluginstub.h"
#include "inputpatch_test.h"
#include "qlcioplugin.h"
#include "inputpatch.h"
#include "qlcfile.h"
#include "doc.h"
#undef private
#define TESTPLUGINDIR "../iopluginstub"
static QDir testPluginDir()
{
QDir dir(TESTPLUGINDIR);
dir.setFilter(QDir::Files);
dir.setNameFilters(QStringList() << QString("*%1").arg(KExtPlugin));
return dir;
}
void InputPatch_Test::initTestCase()
{
m_doc = new Doc(this);
m_doc->ioPluginCache()->load(testPluginDir());
QVERIFY(m_doc->ioPluginCache()->plugins().size() != 0);
}
void InputPatch_Test::cleanupTestCase()
{
delete m_doc;
m_doc = NULL;
}
void InputPatch_Test::defaults()
{
InputPatch ip(0, this);
QVERIFY(ip.m_plugin == NULL);
QVERIFY(ip.m_pluginLine == QLCIOPlugin::invalidLine());
QVERIFY(ip.m_profile == NULL);
QVERIFY(ip.m_pageSetCh == USHRT_MAX);
QVERIFY(ip.pluginName() == KInputNone);
QVERIFY(ip.inputName() == KInputNone);
QVERIFY(ip.profileName() == KInputNone);
QVERIFY(ip.isPatched() == false);
QVERIFY(ip.input() == QLCIOPlugin::invalidLine());
InputPatch ip2(this);
QVERIFY(ip2.m_plugin == NULL);
QVERIFY(ip2.m_pluginLine == QLCIOPlugin::invalidLine());
QVERIFY(ip2.m_profile == NULL);
QVERIFY(ip2.m_pageSetCh == USHRT_MAX);
QVERIFY(ip2.pluginName() == KInputNone);
QVERIFY(ip2.inputName() == KInputNone);
QVERIFY(ip2.profileName() == KInputNone);
QVERIFY(ip2.isPatched() == false);
QVERIFY(ip2.input() == QLCIOPlugin::invalidLine());
}
void InputPatch_Test::patch()
{
QCOMPARE(m_doc->ioPluginCache()->plugins().size(), 1);
IOPluginStub* stub = static_cast<IOPluginStub*> (m_doc->ioPluginCache()->plugins().at(0));
QVERIFY(stub != NULL);
QLCInputProfile prof1;
prof1.setManufacturer("Foo");
prof1.setManufacturer("Bar");
InputPatch* ip = new InputPatch(0, this);
QVERIFY(ip->set(stub, 0, &prof1) == true);
QVERIFY(ip->m_plugin == stub);
QVERIFY(ip->m_pluginLine == 0);
QVERIFY(ip->m_profile == &prof1);
QVERIFY(ip->pluginName() == stub->name());
QVERIFY(ip->inputName() == stub->inputs()[0]);
QVERIFY(ip->profileName() == prof1.name());
QVERIFY(ip->isPatched() == true);
QVERIFY(stub->m_openInputs.size() == 1);
QVERIFY(stub->m_openInputs.at(0) == 0);
QLCInputProfile prof2;
prof2.setManufacturer("Xyzzy");
prof2.setManufacturer("Foobar");
QVERIFY(ip->set(stub, 3, &prof2) == true);
QVERIFY(ip->m_plugin == stub);
QVERIFY(ip->m_pluginLine == 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_pluginLine == 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);
QVERIFY(ip->set(&prof1) == true);
QVERIFY(ip->m_plugin == stub);
QVERIFY(ip->m_pluginLine == 3);
QVERIFY(ip->m_profile == &prof1);
QVERIFY(ip->pluginName() == stub->name());
QVERIFY(ip->inputName() == stub->inputs()[3]);
QVERIFY(ip->profileName() == prof1.name());
QVERIFY(stub->m_openInputs.size() == 1);
QVERIFY(stub->m_openInputs.at(0) == 3);
delete ip;
QVERIFY(stub->m_openInputs.size() == 0);
InputPatch* ip2 = new InputPatch(0, this);
QVERIFY(ip2->set(&prof1) == false);
}
void InputPatch_Test::parameters()
{
InputPatch* ip = new InputPatch(0, this);
IOPluginStub* stub = static_cast<IOPluginStub*> (m_doc->ioPluginCache()->plugins().at(0));
QVERIFY(stub != NULL);
QVERIFY(ip->set(stub, 0, NULL) == true);
QVERIFY(ip->m_plugin == stub);
ip->setPluginParameter("Foo", 42);
QVERIFY(ip->m_parametersCache.count() == 1);
QVERIFY(ip->getPluginParameters().count() == 1);
QVERIFY(ip->getPluginParameters().key(42) == "Foo");
QVERIFY(ip->getPluginParameters().value("Foo") == 42);
delete ip;
}
QTEST_APPLESS_MAIN(InputPatch_Test)
|