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
|
#include "ut_mkeyoverride.h"
#include <maliit/plugins/keyoverride.h>
#include <QFile>
#include <QDir>
#include <QSignalSpy>
#include <QVariant>
#include <QDebug>
namespace {
}
Q_DECLARE_METATYPE(MKeyOverride::KeyOverrideAttributes)
void Ut_MKeyOverride::initTestCase()
{
qRegisterMetaType< MKeyOverride::KeyOverrideAttribute >("MKeyOverride::KeyOverrideAttribute");
qRegisterMetaType< MKeyOverride::KeyOverrideAttributes >("MKeyOverride::KeyOverrideAttributes");
}
void Ut_MKeyOverride::cleanupTestCase()
{
}
void Ut_MKeyOverride::init()
{
keyId = QString("testKey");
subject = new MKeyOverride(keyId);
}
void Ut_MKeyOverride::cleanup()
{
delete subject;
subject = 0;
}
void Ut_MKeyOverride::testSetProperty()
{
QSignalSpy spy(subject, SIGNAL(keyAttributesChanged(QString, MKeyOverride::KeyOverrideAttributes)));
QVERIFY(spy.isValid());
subject->setProperty("label", QVariant(QString("some text")));
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().count(), 2);
QCOMPARE(spy.first().first().toString(), keyId);
QCOMPARE(spy.first().last().value<MKeyOverride::KeyOverrideAttributes>(),
MKeyOverride::KeyOverrideAttributes(MKeyOverride::Label));
QCOMPARE(subject->label(), QString("some text"));
spy.clear();
subject->setProperty("icon", QVariant(QString("some text")));
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().count(), 2);
QCOMPARE(spy.first().first().toString(), keyId);
QCOMPARE(spy.first().last().value<MKeyOverride::KeyOverrideAttributes>(),
MKeyOverride::KeyOverrideAttributes(MKeyOverride::Icon));
QCOMPARE(subject->icon(), QString("some text"));
spy.clear();
subject->setProperty("highlighted", QVariant(true));
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().count(), 2);
QCOMPARE(spy.first().first().toString(), keyId);
QCOMPARE(spy.first().last().value<MKeyOverride::KeyOverrideAttributes>(),
MKeyOverride::KeyOverrideAttributes(MKeyOverride::Highlighted));
QCOMPARE(subject->highlighted(), true);
spy.clear();
subject->setProperty("enabled", QVariant(false));
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().count(), 2);
QCOMPARE(spy.first().first().toString(), keyId);
QCOMPARE(spy.first().last().value<MKeyOverride::KeyOverrideAttributes>(),
MKeyOverride::KeyOverrideAttributes(MKeyOverride::Enabled));
QCOMPARE(subject->enabled(), false);
spy.clear();
}
QTEST_MAIN(Ut_MKeyOverride)
|