Start/ | End/ | |||
True | False | - | Line | Source |
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: This file contains STIFUnit implementation. | |||
15 | * | |||
16 | */ | |||
17 | ||||
18 | /** | |||
19 | * STIF_UNIT_INCLUDE SECTION - put all #includes between STIF_UNIT_INCLUDE_SECTION | |||
20 | * and STIF_UNIT_INCLUDE_SECTION_END | |||
21 | */ | |||
22 | #ifdef STIF_UNIT_INCLUDE_SECTION | |||
23 | #include <QObject> | |||
24 | #include <QVariant> | |||
25 | #include <e32des16.h> | |||
26 | ||||
27 | #include <hbindicatorinterface.h> | |||
28 | #include "accindicator.h" | |||
29 | #include <accpolgenericiddefinitions.h> | |||
30 | ||||
31 | #include "utslot.h" | |||
32 | #endif //STIF_UNIT_INCLUDE_SECTION_END | |||
33 | ||||
34 | /** | |||
35 | * GLOBAL VARIABLES SECTION | |||
36 | */ | |||
37 | #ifdef TEST_VAR_DECLARATIONS | |||
38 | AccIndicatorPlugin* accIndicatorPlugin; | |||
39 | #endif | |||
40 | /** | |||
41 | * END OF GLOBAL VARIABLES SECTION | |||
42 | */ | |||
43 | ||||
44 | ||||
45 | /** | |||
46 | * TEST CASES SECTION | |||
47 | */ | |||
48 | #ifdef TEST_CASES | |||
49 | /** | |||
50 | * STIF_SETUP defines activities needed before every test case. | |||
51 | */ | |||
52 | STIF_SETUP | |||
53 | { | |||
54 | accIndicatorPlugin = new (ELeave) AccIndicatorPlugin(); | |||
55 | CleanupStack::PushL(accIndicatorPlugin); | |||
56 | } | |||
57 | ||||
58 | /** | |||
59 | * STIF_TEARDOWN defines activities needed after every test case | |||
60 | */ | |||
61 | STIF_TEARDOWN | |||
62 | { | |||
63 | CleanupStack::PopAndDestroy(accIndicatorPlugin); | |||
64 | } | |||
65 | ||||
66 | /** | |||
67 | * STIF_TESTDEFINE defines a test case | |||
68 | * | |||
69 | * Example test case - length of string is checked. | |||
70 | * The only argument of macro is a name of test case. | |||
71 | */ | |||
72 | ||||
73 | ||||
74 | STIF_TESTDEFINE(createIndicator) | |||
75 | { | |||
76 | // | |||
77 | QString par1; | |||
78 | STIF_ASSERT_EQUALS((HbIndicatorInterface*)accIndicatorPlugin, accIndicatorPlugin->createIndicator(par1)); | |||
79 | } | |||
80 | ||||
81 | STIF_TESTDEFINE(indicatorTypes) | |||
82 | { | |||
83 | QString KIndicatorType = "com.nokia.accessory.indicatorplugin/1.0"; | |||
84 | QStringList qStringList = accIndicatorPlugin->indicatorTypes(); | |||
85 | STIF_ASSERT_EQUALS(KIndicatorType, qStringList[0]); | |||
86 | } | |||
87 | ||||
88 | STIF_TESTDEFINE(accessAllowed) | |||
89 | { | |||
90 | QVariantMap mapValues; | |||
91 | QString KAccMode = "AccMode"; | |||
92 | QString KAccType = "AccType"; | |||
93 | mapValues[KAccMode] = (TInt)EAccModeWiredHeadset; | |||
94 | mapValues[KAccType] = (TInt)KPCWired; | |||
95 | QString par1; | |||
96 | ||||
97 | bool expectedResult = true; | |||
98 | STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->accessAllowed(par1, mapValues)); | |||
99 | } | |||
100 | ||||
101 | STIF_TESTDEFINE(handleClientRequest_indicatorData) | |||
102 | { | |||
103 | // connect test slot to signal | |||
104 | UTSlot *utSlot = new (ELeave) UTSlot(); | |||
105 | CleanupStack::PushL(utSlot); | |||
106 | QObject::connect( accIndicatorPlugin, SIGNAL(dataChanged()), | |||
107 | utSlot, SLOT(dataChangedSlot())); | |||
108 | QObject::connect( accIndicatorPlugin, SIGNAL(deactivate()), | |||
109 | utSlot, SLOT(deactivateSlot())); | |||
110 | utSlot->iDataChangedSlotCalled = EFalse; | |||
111 | ||||
112 | // make a qmap to pass parameters | |||
113 | QVariantMap mapValues; | |||
114 | QString KAccMode = "AccMode"; | |||
115 | QString KAccType = "AccType"; | |||
116 | mapValues[KAccMode] = (TInt)EAccModeWiredHeadset; | |||
117 | mapValues[KAccType] = (TInt)KPCWired; | |||
118 | ||||
119 | // handleclientrequest activate | |||
120 | HbIndicatorInterface::RequestType requestType = HbIndicatorInterface::RequestActivate; | |||
121 | accIndicatorPlugin->handleClientRequest(requestType, mapValues); | |||
122 | ||||
123 | // verify that slot had been called | |||
124 | TBool expectedResult = ETrue; | |||
125 | STIF_ASSERT_EQUALS(expectedResult, utSlot->iDataChangedSlotCalled); | |||
126 | ||||
127 | // verify data values | |||
128 | QString displayName = accIndicatorPlugin->indicatorData(HbIndicatorInterface::PrimaryTextRole).toString(); | |||
129 | QString iconName = accIndicatorPlugin->indicatorData(HbIndicatorInterface::MonoDecorationNameRole).toString(); | |||
130 | QString KDisplayName = "Wired Headset"; | |||
131 | QString KIconName = "z:/resource/accindicator/wired_accessory.svg"; | |||
132 | STIF_ASSERT_EQUALS(KDisplayName, displayName); | |||
133 | STIF_ASSERT_EQUALS(KIconName, iconName); | |||
134 | ||||
135 | // handleClientReqeust deactive | |||
136 | utSlot->iDeactiveSlotCalled = EFalse; | |||
137 | requestType = HbIndicatorInterface::RequestDeactivate; | |||
138 | accIndicatorPlugin->handleClientRequest(requestType, mapValues); | |||
139 | ||||
140 | // verify that slot had been called | |||
141 | expectedResult = ETrue; | |||
142 | STIF_ASSERT_EQUALS(expectedResult, utSlot->iDeactiveSlotCalled); | |||
143 | // verify data values | |||
144 | QString emptyString; | |||
145 | displayName = accIndicatorPlugin->indicatorData(HbIndicatorInterface::PrimaryTextRole).toString(); | |||
146 | STIF_ASSERT_EQUALS(emptyString, displayName); | |||
147 | ||||
148 | CleanupStack::PopAndDestroy(utSlot); | |||
149 | } | |||
150 | ||||
151 | STIF_TESTDEFINE(handleInteraction_EAccModeWiredHeadset) | |||
152 | { | |||
153 | // make a qmap to pass parameters | |||
154 | QVariantMap mapValues; | |||
155 | QString KAccMode = "AccMode"; | |||
156 | QString KAccType = "AccType"; | |||
157 | mapValues[KAccMode] = (TInt)EAccModeWiredHeadset; | |||
158 | mapValues[KAccType] = (TInt)KPCWired; | |||
159 | ||||
160 | // handleclientrequest activate | |||
161 | HbIndicatorInterface::RequestType requestType = HbIndicatorInterface::RequestActivate; | |||
162 | accIndicatorPlugin->handleClientRequest(requestType, mapValues); | |||
163 | ||||
164 | HbIndicatorInterface::InteractionType interactionType; | |||
165 | interactionType = HbIndicatorInterface::NoInteraction; | |||
166 | ||||
167 | // NoInteraction, handled = false | |||
168 | bool expectedResult = false; | |||
169 | STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->handleInteraction(interactionType)); | |||
170 | ||||
171 | // InteractionActivated, handled = true | |||
172 | interactionType = HbIndicatorInterface::InteractionActivated; | |||
173 | expectedResult = true; | |||
174 | STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->handleInteraction(interactionType)); | |||
175 | QProcess::ProcessState currState = QProcess::Running; | |||
176 | STIF_ASSERT_EQUALS(currState, accIndicatorPlugin->mProcess.state()); | |||
177 | iLog->Log(_L("interface application started.")); | |||
178 | accIndicatorPlugin->mProcess.kill(); | |||
179 | accIndicatorPlugin->mProcess.waitForFinished(); | |||
180 | iLog->Log(_L("interface application killed.")); | |||
181 | ||||
182 | } | |||
183 | STIF_TESTDEFINE(handleInteraction_EAccModeTVOut) | |||
184 | { | |||
185 | // make a qmap to pass parameters | |||
186 | QVariantMap mapValues; | |||
187 | QString KAccMode = "AccMode"; | |||
188 | QString KAccType = "AccType"; | |||
189 | mapValues[KAccMode] = (TInt)EAccModeTVOut; | |||
190 | mapValues[KAccType] = (TInt)KPCHDMI; | |||
191 | // handleclientrequest activate | |||
192 | HbIndicatorInterface::RequestType requestType = HbIndicatorInterface::RequestActivate; | |||
193 | accIndicatorPlugin->handleClientRequest(requestType, mapValues); | |||
194 | ||||
195 | HbIndicatorInterface::InteractionType interactionType; | |||
196 | interactionType = HbIndicatorInterface::NoInteraction; | |||
197 | ||||
198 | // NoInteraction, handled = false | |||
199 | bool expectedResult = false; | |||
200 | STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->handleInteraction(interactionType)); | |||
201 | ||||
202 | // InteractionActivated, handled = true | |||
203 | interactionType = HbIndicatorInterface::InteractionActivated; | |||
204 | expectedResult = true; | |||
205 | STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->handleInteraction(interactionType)); | |||
206 | QProcess::ProcessState currState = QProcess::Running; | |||
207 | STIF_ASSERT_EQUALS(currState, accIndicatorPlugin->mProcess.state()); | |||
208 | iLog->Log(_L("interface application started.")); | |||
209 | accIndicatorPlugin->mProcess.kill(); | |||
210 | accIndicatorPlugin->mProcess.waitForFinished(); | |||
211 | iLog->Log(_L("interface application killed.")); | |||
212 | } | |||
213 | ||||
214 | #endif | |||
215 | /** | |||
216 | * END OF TEST CASES SECTION | |||
217 | */ | |||
218 | ||||
219 | // End of File | |||
***TER 100% (0/0) of SOURCE FILE utaccindicatorplugincases.cpp |