41
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "ut_lcvtindicatorplugin.h"
|
|
18 |
#include "lcvtindicatorplugin.h"
|
43
|
19 |
#include "qprocess.h"
|
41
|
20 |
|
|
21 |
#include <QtTest/QtTest>
|
|
22 |
|
|
23 |
const static QString lcVtIndicator = "com.nokia.hb.indicator.lcvtindicatorplugin/1.0";
|
|
24 |
|
|
25 |
|
|
26 |
void UT_LcVtIndicatorPlugin::initTestCase()
|
|
27 |
{
|
|
28 |
|
|
29 |
}
|
|
30 |
|
|
31 |
void UT_LcVtIndicatorPlugin::cleanupTestCase()
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
void UT_LcVtIndicatorPlugin::init()
|
|
36 |
{
|
|
37 |
mLcVtIndicatorPlugin = new LcVtIndicatorPlugin();
|
|
38 |
}
|
|
39 |
|
|
40 |
void UT_LcVtIndicatorPlugin::cleanup()
|
|
41 |
{
|
|
42 |
delete mLcVtIndicatorPlugin;
|
|
43 |
mLcVtIndicatorPlugin = 0;
|
|
44 |
}
|
|
45 |
|
|
46 |
void UT_LcVtIndicatorPlugin::testLcVtIndicatorPlugin()
|
|
47 |
{
|
|
48 |
QVERIFY( mLcVtIndicatorPlugin );
|
|
49 |
}
|
|
50 |
|
|
51 |
void UT_LcVtIndicatorPlugin::testIndicatorTypes()
|
|
52 |
{
|
|
53 |
QCOMPARE(mLcVtIndicatorPlugin->indicatorTypes()[0], lcVtIndicator);
|
|
54 |
}
|
|
55 |
|
|
56 |
void UT_LcVtIndicatorPlugin::testAccessAllowed()
|
|
57 |
{
|
|
58 |
QVERIFY( mLcVtIndicatorPlugin->accessAllowed(QString(), QVariantMap()) );
|
|
59 |
}
|
|
60 |
|
|
61 |
void UT_LcVtIndicatorPlugin::testCreateIndicator()
|
|
62 |
{
|
|
63 |
mLcVtIndicatorPlugin->createIndicator(lcVtIndicator);
|
|
64 |
}
|
|
65 |
|
|
66 |
void UT_LcVtIndicatorPlugin::testError()
|
|
67 |
{
|
|
68 |
QVERIFY( !mLcVtIndicatorPlugin->error() );
|
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
void UT_LcVtIndicatorPlugin::testHandleInteraction()
|
|
73 |
{
|
|
74 |
QSignalSpy spy(mLcVtIndicatorPlugin, SIGNAL(deactivate()));
|
|
75 |
|
|
76 |
//No interation requered
|
|
77 |
QVERIFY( !mLcVtIndicatorPlugin->handleInteraction(
|
|
78 |
HbIndicatorInterface::NoInteraction) );
|
|
79 |
QCOMPARE( spy.count(), 0 );
|
|
80 |
|
43
|
81 |
//Indicator activated, no VT running => deactivating
|
41
|
82 |
QVERIFY( !mLcVtIndicatorPlugin->handleInteraction(
|
|
83 |
HbIndicatorInterface::InteractionActivated) );
|
|
84 |
QCOMPARE( spy.count(), 1 );
|
|
85 |
|
43
|
86 |
//Indicator activated, VT running => bringing to FG
|
41
|
87 |
spy.clear();
|
|
88 |
QVERIFY( mLcVtIndicatorPlugin->bringVtToForeground() );
|
43
|
89 |
QVERIFY( QProcess::isRunning );
|
41
|
90 |
QCOMPARE( spy.count(), 0 );
|
|
91 |
}
|
|
92 |
|
|
93 |
void UT_LcVtIndicatorPlugin::testIndicatorData()
|
|
94 |
{
|
|
95 |
//No params defined
|
|
96 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
97 |
HbIndicatorInterface::DecorationNameRole) == QVariant(QString()) );
|
|
98 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
99 |
HbIndicatorInterface::MonoDecorationNameRole) == QVariant(QString()) );
|
|
100 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
101 |
HbIndicatorInterface::PrimaryTextRole) == QVariant(QString()) );
|
|
102 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
103 |
HbIndicatorInterface::SecondaryTextRole) == QVariant() );
|
|
104 |
//Non-existing param role
|
|
105 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(999) == QVariant() );
|
|
106 |
|
|
107 |
//Parameters defined
|
|
108 |
QVariantMap parameters;
|
|
109 |
parameters.insert(
|
|
110 |
QVariant(HbIndicatorInterface::DecorationNameRole).toString(),
|
|
111 |
QVariant("decoration") );
|
|
112 |
parameters.insert(
|
|
113 |
QVariant(HbIndicatorInterface::MonoDecorationNameRole).toString(),
|
|
114 |
QVariant("mono_decoration") );
|
|
115 |
parameters.insert(
|
|
116 |
QVariant(HbIndicatorInterface::PrimaryTextRole ).toString(),
|
|
117 |
QVariant("primary_text") );
|
|
118 |
parameters.insert(
|
|
119 |
QVariant(HbIndicatorInterface::SecondaryTextRole ).toString(),
|
|
120 |
QVariant("secondary_text") );
|
|
121 |
|
|
122 |
mLcVtIndicatorPlugin->mParameter = parameters;
|
|
123 |
|
|
124 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
125 |
HbIndicatorInterface::DecorationNameRole)
|
|
126 |
== QVariant("decoration") );
|
|
127 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
128 |
HbIndicatorInterface::MonoDecorationNameRole)
|
|
129 |
== QVariant("mono_decoration") );
|
|
130 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
131 |
HbIndicatorInterface::PrimaryTextRole)
|
|
132 |
== QVariant("primary_text") );
|
|
133 |
QVERIFY( mLcVtIndicatorPlugin->indicatorData(
|
|
134 |
HbIndicatorInterface::SecondaryTextRole)
|
|
135 |
== QVariant() );
|
|
136 |
}
|
|
137 |
|
|
138 |
void UT_LcVtIndicatorPlugin::testHandleClientRequest()
|
|
139 |
{
|
|
140 |
QVariantMap parameters;
|
|
141 |
parameters.insert("key", QVariant("value"));
|
|
142 |
mLcVtIndicatorPlugin->mParameter = parameters;
|
|
143 |
QSignalSpy spy(mLcVtIndicatorPlugin, SIGNAL(dataChanged()));
|
|
144 |
|
|
145 |
// Deactivate, params cleareds
|
|
146 |
QVERIFY( !mLcVtIndicatorPlugin->mParameter.isNull() );
|
|
147 |
QVERIFY( !mLcVtIndicatorPlugin->handleClientRequest(
|
|
148 |
HbIndicatorInterface::RequestDeactivate, QVariant()) );
|
|
149 |
QCOMPARE( spy.count(), 0 );
|
|
150 |
QVERIFY( mLcVtIndicatorPlugin->mParameter.isNull() );
|
|
151 |
|
|
152 |
// Activate request, parameters changed
|
|
153 |
parameters.insert("key", QVariant("value"));
|
|
154 |
QVERIFY( mLcVtIndicatorPlugin->handleClientRequest(
|
|
155 |
HbIndicatorInterface::RequestActivate, QVariant(parameters)) );
|
|
156 |
QCOMPARE( spy.count(), 1 );
|
|
157 |
|
|
158 |
// Activate request, parameters not changed
|
|
159 |
spy.clear();
|
|
160 |
QVERIFY( mLcVtIndicatorPlugin->handleClientRequest(
|
|
161 |
HbIndicatorInterface::RequestActivate, QVariant(parameters)) );
|
|
162 |
QCOMPARE( spy.count(), 0 );
|
|
163 |
}
|
|
164 |
|
|
165 |
void UT_LcVtIndicatorPlugin::testBringVtToForeground()
|
43
|
166 |
{
|
41
|
167 |
QVERIFY( !mLcVtIndicatorPlugin->bringVtToForeground() );
|
43
|
168 |
QVERIFY( QProcess::isRunning );
|
41
|
169 |
}
|
43
|
170 |
|