77
|
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::DecorationNameRole).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 |
|
|
176 |
}
|
|
177 |
STIF_TESTDEFINE(handleInteraction_EAccModeTVOut)
|
|
178 |
{
|
|
179 |
// make a qmap to pass parameters
|
|
180 |
QVariantMap mapValues;
|
|
181 |
QString KAccMode = "AccMode";
|
|
182 |
QString KAccType = "AccType";
|
|
183 |
mapValues[KAccMode] = (TInt)EAccModeTVOut;
|
|
184 |
mapValues[KAccType] = (TInt)KPCHDMI;
|
|
185 |
// handleclientrequest activate
|
|
186 |
HbIndicatorInterface::RequestType requestType = HbIndicatorInterface::RequestActivate;
|
|
187 |
accIndicatorPlugin->handleClientRequest(requestType, mapValues);
|
|
188 |
|
|
189 |
HbIndicatorInterface::InteractionType interactionType;
|
|
190 |
interactionType = HbIndicatorInterface::NoInteraction;
|
|
191 |
|
|
192 |
// NoInteraction, handled = false
|
|
193 |
bool expectedResult = false;
|
|
194 |
STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->handleInteraction(interactionType));
|
|
195 |
|
|
196 |
// InteractionActivated, handled = true
|
|
197 |
interactionType = HbIndicatorInterface::InteractionActivated;
|
|
198 |
expectedResult = true;
|
|
199 |
STIF_ASSERT_EQUALS(expectedResult, accIndicatorPlugin->handleInteraction(interactionType));
|
|
200 |
}
|
|
201 |
|
|
202 |
#endif
|
|
203 |
/**
|
|
204 |
* END OF TEST CASES SECTION
|
|
205 |
*/
|
|
206 |
|
|
207 |
// End of File
|