|
1 /* |
|
2 * Copyright (c) 2005-2006 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 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "UT_aiprofile.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #define protected public |
|
24 #define private public |
|
25 #include "caiprofileplugin.h" |
|
26 #include "caiprofileengine.h" |
|
27 #undef private |
|
28 #undef protected |
|
29 |
|
30 #include <digia/eunit/eunitmacros.h> |
|
31 #include <GSPrivatePluginProviderIds.h> |
|
32 #include <aknappui.h> |
|
33 #include <aknviewappui.h> |
|
34 #include <eikenv.h> |
|
35 #include <CentralRepository.h> |
|
36 #include <apgcli.h> //RApaLsSession |
|
37 #include <w32std.h> // For RWsSession |
|
38 |
|
39 // INTERNAL INCLUDES |
|
40 #include <aicontentobserver.h> |
|
41 #include <aiutility.h> |
|
42 #include <puacodes.hrh> |
|
43 |
|
44 #include "profileobserver.h" |
|
45 #include "aiprofileplugincontentmodel.h" |
|
46 #include "aiprofilepluginuids.hrh" |
|
47 #include "caiprofileplugin.h" |
|
48 #include "caiprofileengine.h" |
|
49 #include "aipluginsettings.h" |
|
50 |
|
51 |
|
52 // CONSTRUCTION |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 UT_aiprofile* UT_aiprofile::NewL() |
|
59 { |
|
60 UT_aiprofile* self = UT_aiprofile::NewLC(); |
|
61 CleanupStack::Pop(); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 UT_aiprofile* UT_aiprofile::NewLC() |
|
71 { |
|
72 UT_aiprofile* self = new(ELeave) UT_aiprofile(); |
|
73 CleanupStack::PushL(self); |
|
74 |
|
75 self->ConstructL(); |
|
76 |
|
77 return self; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Destructor (virtual by CBase) |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 UT_aiprofile::~UT_aiprofile() |
|
85 { |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // Default constructor |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 UT_aiprofile::UT_aiprofile() |
|
93 { |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Second phase construct |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void UT_aiprofile::ConstructL() |
|
101 { |
|
102 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
103 // It generates the test case table. |
|
104 CEUnitTestSuiteClass::ConstructL(); |
|
105 } |
|
106 |
|
107 // METHODS |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void UT_aiprofile::SetupL() |
|
114 { |
|
115 _LIT( KProfilePluginName, "profileplugin" ); |
|
116 |
|
117 _LIT8( KNameSpace, "1" ); |
|
118 TUid uid = { AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_PROFILEPLUGIN }; |
|
119 THsPublisherInfo pubInfo( uid, KProfilePluginName, KNameSpace ); |
|
120 |
|
121 CHsContentPublisher* pubType = CHsContentPublisher::NewL( pubInfo ); |
|
122 iProfilePlugin = static_cast<CAiProfilePlugin*>( pubType ); |
|
123 |
|
124 // iProfilePlugin = CHsContentPublisher::NewL( pubInfo ); |
|
125 EUNIT_ASSERT( iProfilePlugin ); |
|
126 |
|
127 iContentObserver = ProfileObserver::NewL(); |
|
128 |
|
129 RAiSettingsItemArray settings; |
|
130 iProfilePlugin->ConfigureL( settings ); |
|
131 |
|
132 iProfilePlugin->SubscribeL( *iContentObserver ); |
|
133 iProfilePlugin->Start( CHsContentPublisher::ESystemStartup ); |
|
134 |
|
135 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
136 |
|
137 /* |
|
138 // iGs = CGSPluginInterface::NewL(TUid::Uid(AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_PROFILEPLUGIN), NULL); |
|
139 iProfilePlugin = CAiProfilePlugin::NewL(); |
|
140 EUNIT_ASSERT(iProfilePlugin); |
|
141 iContentObserver = iContentObserver->NewL(); |
|
142 EUNIT_ASSERT(iContentObserver); |
|
143 iProfilePlugin->SubscribeL( *iContentObserver ); |
|
144 */ |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void UT_aiprofile::Teardown() |
|
152 { |
|
153 if( iProfilePlugin ) |
|
154 { |
|
155 iProfilePlugin->Stop( CHsContentPublisher::ESystemShutdown ); |
|
156 delete iProfilePlugin; |
|
157 iProfilePlugin = NULL; |
|
158 } |
|
159 |
|
160 delete iContentObserver; |
|
161 } |
|
162 |
|
163 |
|
164 //------------------------------------------------------------------------------------------- |
|
165 // Tests for CAiProfilePlugin |
|
166 //------------------------------------------------------------------------------------------- |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void UT_aiprofile::UT_resumeL() |
|
173 { |
|
174 iProfilePlugin->Suspend( CHsContentPublisher::EBackground ); |
|
175 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
176 |
|
177 iProfilePlugin->Suspend(CHsContentPublisher::EBackupRestore ); |
|
178 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
179 |
|
180 iProfilePlugin->Suspend(CHsContentPublisher::EGeneralThemeChange ); |
|
181 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
182 |
|
183 iProfilePlugin->Suspend( CHsContentPublisher::EBackground ); |
|
184 } |
|
185 |
|
186 void UT_aiprofile::UT_HandleEventL() |
|
187 { |
|
188 |
|
189 iProfilePlugin->HandleEvent(EAiProfileEventSwitchByName, KNullDesC); |
|
190 |
|
191 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
192 iProfilePlugin->HandleEvent(EAiProfileEventSwitchByName, KNullDesC); |
|
193 |
|
194 iProfilePlugin->HandleEvent(EAiProfileEventSwitchByName, _L("Silent")); |
|
195 iProfilePlugin->iEngine->UpdateProfileNamesL(); |
|
196 EUNIT_ASSERT_EQUALS( iProfilePlugin->iEngine->ActiveProfileName(), _L("Silent") ); |
|
197 |
|
198 //EUNIT_ASSERT_EQUALS(iProfilePlugin->iEngine->IsActiveProfileSilentL(), 1); |
|
199 |
|
200 //iProfilePlugin->iEngine->SetActiveProfileNameL( _L("Silent") ); |
|
201 //EUNIT_ASSERT_EQUALS(iProfilePlugin->iEngine->ActiveProfileName(),_L("Silent")); |
|
202 |
|
203 //iProfilePlugin->iEngine->SetSwapProfileNameL(_L("General")); |
|
204 //EUNIT_ASSERT_EQUALS(iProfilePlugin->iEngine->SwapProfileName(),_L("General")); |
|
205 |
|
206 iProfilePlugin->HandleEvent(EAiProfileEventSwitchByIndex, _L("0")); |
|
207 //EUNIT_ASSERT_EQUALS(iProfilePlugin->iEngine->IsActiveProfileSilentL(), 0); |
|
208 //EUNIT_ASSERT_EQUALS(_L("Silent"),iProfilePlugin->iEngine->ActiveProfileName()); |
|
209 |
|
210 iProfilePlugin->HandleEvent(EAiProfileEventSwap, _L("1")); |
|
211 //EUNIT_ASSERT_EQUALS(iProfilePlugin->iEngine->IsActiveProfileSilentL(), 1); |
|
212 |
|
213 iProfilePlugin->HandleEvent(EAiProfileEventSwap, _L("0")); |
|
214 //EUNIT_ASSERT_EQUALS(iProfilePlugin->iEngine->IsActiveProfileSilentL(), 0); |
|
215 |
|
216 iProfilePlugin->iEngine->ProfileNameByIndex( 0 ); |
|
217 |
|
218 iProfilePlugin->iEngine->SwapProfileName(); |
|
219 |
|
220 /* |
|
221 EUNIT_ASSERT_NO_LEAVE(iProfilePlugin->iEngine-> |
|
222 HandleActiveProfileEventL(EProfileNewActiveProfile, 0)); |
|
223 */ |
|
224 // iProfilePlugin->iEngine->ShowOfflineMessageL(); |
|
225 |
|
226 } |
|
227 |
|
228 void UT_aiprofile::UT_NotifyContentUpdateL() |
|
229 { |
|
230 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
231 |
|
232 iProfilePlugin->iEngine->PhoneSettingChanged(ESSSettingsCug,1); |
|
233 |
|
234 iProfilePlugin->iEngine->PhoneSettingChanged(ESSSettingsAls, 1); |
|
235 } |
|
236 |
|
237 |
|
238 void UT_aiprofile::UT_ExtensionL() |
|
239 { |
|
240 /* |
|
241 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
242 |
|
243 TAny* anyPtr = NULL; |
|
244 |
|
245 EUNIT_ASSERT_NO_LEAVE(anyPtr = iProfilePlugin->Extension(KExtensionUidEventHandler)); |
|
246 |
|
247 EUNIT_ASSERT_NO_LEAVE(anyPtr = iProfilePlugin->Extension(KExtensionUidProperty)); |
|
248 |
|
249 TUid wrongUid = { 0x3 }; |
|
250 |
|
251 EUNIT_ASSERT(!iProfilePlugin->Extension(wrongUid)); |
|
252 |
|
253 MAiPropertyExtension* propertyExtension = static_cast<MAiPropertyExtension*>(anyPtr); |
|
254 EUNIT_ASSERT(propertyExtension); |
|
255 |
|
256 EUNIT_ASSERT_NO_LEAVE(anyPtr = propertyExtension->GetPropertyL(EAiPublisherInfo)); |
|
257 EUNIT_ASSERT(anyPtr != NULL); |
|
258 |
|
259 EUNIT_ASSERT_NO_LEAVE(anyPtr = propertyExtension->GetPropertyL(EAiPublisherContent)); |
|
260 EUNIT_ASSERT(anyPtr); |
|
261 |
|
262 // Discover resources |
|
263 EUNIT_ASSERT_NO_LEAVE(anyPtr = propertyExtension->GetPropertyL(EAiPublisherResources)); |
|
264 EUNIT_ASSERT(anyPtr); |
|
265 |
|
266 // Discover event iterator |
|
267 EUNIT_ASSERT_NO_LEAVE(anyPtr = propertyExtension->GetPropertyL(EAiPublisherEvents)); |
|
268 EUNIT_ASSERT(anyPtr); |
|
269 |
|
270 EUNIT_ASSERT_NO_LEAVE(anyPtr = propertyExtension->GetPropertyL(-1)); |
|
271 EUNIT_ASSERT(!anyPtr); |
|
272 |
|
273 //iProfilePlugin->Stop(EAiSystemStartup); |
|
274 */ |
|
275 } |
|
276 |
|
277 |
|
278 void UT_aiprofile::UT_ConfigureLL() |
|
279 { |
|
280 RAiSettingsItemArray defaultSettingArray; |
|
281 |
|
282 // Profiles settings view |
|
283 AddSettingL(defaultSettingArray, 0x00000001, _L("localapp:0x100058F8?view=0x02")); |
|
284 EUNIT_ASSERT_NO_LEAVE(iProfilePlugin->ConfigureL(defaultSettingArray)); |
|
285 |
|
286 iProfilePlugin->Resume( CHsContentPublisher::EForeground ); |
|
287 EUNIT_ASSERT_NO_LEAVE(iProfilePlugin->PublishL()); |
|
288 iProfilePlugin->Suspend(CHsContentPublisher::EBackground ); |
|
289 |
|
290 } |
|
291 |
|
292 void UT_aiprofile::AddSettingL(RAiSettingsItemArray& aArray, const TInt32 aKey, const TDesC& aValue) |
|
293 { |
|
294 MAiPluginSettings* setting = AiUtility::CreatePluginSettingsL(); |
|
295 if (aArray.Append(setting) == KErrNone) |
|
296 { |
|
297 MAiPluginSettingsItem& item = setting->AiPluginSettingsItem(); |
|
298 item.SetKey(aKey); |
|
299 item.SetValueL(aValue); |
|
300 } |
|
301 else |
|
302 { |
|
303 delete setting; |
|
304 } |
|
305 } |
|
306 |
|
307 |
|
308 // TEST TABLE |
|
309 |
|
310 EUNIT_BEGIN_TEST_TABLE(UT_aiprofile, "Profile plugin tests.", "UNIT") |
|
311 |
|
312 EUNIT_TEST( "Resume", "CAiProfilePlugin", "resume", |
|
313 "FUNCTIONALITY", SetupL, UT_resumeL, Teardown) |
|
314 /* |
|
315 EUNIT_TEST( "SetPropertyL", "CAiProfilePlugin", "SetPropertyL", |
|
316 "FUNCTIONALITY", SetupL, UT_SetPropertyLL, Teardown) |
|
317 */ |
|
318 EUNIT_TEST( "HandleEventL", "CAiProfilePlugin", "HandleEventL", |
|
319 "FUNCTIONALITY", SetupL, UT_HandleEventL, Teardown) |
|
320 |
|
321 EUNIT_TEST( "NotifyContentUpdate", "CAiProfilePlugin", "NotifyContentUpdate", |
|
322 "FUNCTIONALITY", SetupL, UT_NotifyContentUpdateL, Teardown) |
|
323 |
|
324 EUNIT_TEST( "Extension", "CAiProfilePlugin", "Extension", |
|
325 "FUNCTIONALITY", SetupL, UT_ExtensionL, Teardown) |
|
326 |
|
327 EUNIT_TEST( "ConfigureL", "CAiProfilePlugin", "ConfigureL", |
|
328 "FUNCTIONALITY", SetupL, UT_ConfigureLL, Teardown) |
|
329 |
|
330 EUNIT_END_TEST_TABLE |
|
331 |
|
332 // END OF FILE |