|
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" |
|
19 #include "symbianstubs_helper.h" |
|
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 |
|
81 //Indicator activated, no VT running => deactivating |
|
82 SymbianStubHelper::setVtTaskExists(false); |
|
83 QVERIFY( !mLcVtIndicatorPlugin->handleInteraction( |
|
84 HbIndicatorInterface::InteractionActivated) ); |
|
85 QCOMPARE( spy.count(), 1 ); |
|
86 |
|
87 //Indicator activated, VT running => bringing to FG |
|
88 SymbianStubHelper::setVtTaskExists(true); |
|
89 spy.clear(); |
|
90 QVERIFY( mLcVtIndicatorPlugin->bringVtToForeground() ); |
|
91 QCOMPARE( spy.count(), 0 ); |
|
92 } |
|
93 |
|
94 void UT_LcVtIndicatorPlugin::testIndicatorData() |
|
95 { |
|
96 //No params defined |
|
97 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
98 HbIndicatorInterface::DecorationNameRole) == QVariant(QString()) ); |
|
99 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
100 HbIndicatorInterface::MonoDecorationNameRole) == QVariant(QString()) ); |
|
101 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
102 HbIndicatorInterface::PrimaryTextRole) == QVariant(QString()) ); |
|
103 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
104 HbIndicatorInterface::SecondaryTextRole) == QVariant() ); |
|
105 //Non-existing param role |
|
106 QVERIFY( mLcVtIndicatorPlugin->indicatorData(999) == QVariant() ); |
|
107 |
|
108 //Parameters defined |
|
109 QVariantMap parameters; |
|
110 parameters.insert( |
|
111 QVariant(HbIndicatorInterface::DecorationNameRole).toString(), |
|
112 QVariant("decoration") ); |
|
113 parameters.insert( |
|
114 QVariant(HbIndicatorInterface::MonoDecorationNameRole).toString(), |
|
115 QVariant("mono_decoration") ); |
|
116 parameters.insert( |
|
117 QVariant(HbIndicatorInterface::PrimaryTextRole ).toString(), |
|
118 QVariant("primary_text") ); |
|
119 parameters.insert( |
|
120 QVariant(HbIndicatorInterface::SecondaryTextRole ).toString(), |
|
121 QVariant("secondary_text") ); |
|
122 |
|
123 mLcVtIndicatorPlugin->mParameter = parameters; |
|
124 |
|
125 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
126 HbIndicatorInterface::DecorationNameRole) |
|
127 == QVariant("decoration") ); |
|
128 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
129 HbIndicatorInterface::MonoDecorationNameRole) |
|
130 == QVariant("mono_decoration") ); |
|
131 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
132 HbIndicatorInterface::PrimaryTextRole) |
|
133 == QVariant("primary_text") ); |
|
134 QVERIFY( mLcVtIndicatorPlugin->indicatorData( |
|
135 HbIndicatorInterface::SecondaryTextRole) |
|
136 == QVariant() ); |
|
137 } |
|
138 |
|
139 void UT_LcVtIndicatorPlugin::testHandleClientRequest() |
|
140 { |
|
141 QVariantMap parameters; |
|
142 parameters.insert("key", QVariant("value")); |
|
143 mLcVtIndicatorPlugin->mParameter = parameters; |
|
144 QSignalSpy spy(mLcVtIndicatorPlugin, SIGNAL(dataChanged())); |
|
145 |
|
146 // Deactivate, params cleareds |
|
147 QVERIFY( !mLcVtIndicatorPlugin->mParameter.isNull() ); |
|
148 QVERIFY( !mLcVtIndicatorPlugin->handleClientRequest( |
|
149 HbIndicatorInterface::RequestDeactivate, QVariant()) ); |
|
150 QCOMPARE( spy.count(), 0 ); |
|
151 QVERIFY( mLcVtIndicatorPlugin->mParameter.isNull() ); |
|
152 |
|
153 // Activate request, parameters changed |
|
154 parameters.insert("key", QVariant("value")); |
|
155 QVERIFY( mLcVtIndicatorPlugin->handleClientRequest( |
|
156 HbIndicatorInterface::RequestActivate, QVariant(parameters)) ); |
|
157 QCOMPARE( spy.count(), 1 ); |
|
158 |
|
159 // Activate request, parameters not changed |
|
160 spy.clear(); |
|
161 QVERIFY( mLcVtIndicatorPlugin->handleClientRequest( |
|
162 HbIndicatorInterface::RequestActivate, QVariant(parameters)) ); |
|
163 QCOMPARE( spy.count(), 0 ); |
|
164 } |
|
165 |
|
166 void UT_LcVtIndicatorPlugin::testBringVtToForeground() |
|
167 { |
|
168 SymbianStubHelper::setVtTaskExists(false); |
|
169 QVERIFY( !mLcVtIndicatorPlugin->bringVtToForeground() ); |
|
170 |
|
171 SymbianStubHelper::setVtTaskExists(true); |
|
172 QVERIFY( mLcVtIndicatorPlugin->bringVtToForeground() ); |
|
173 } |