|
1 /* |
|
2 * Copyright (c) 2010 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 #include "mt_wrtdataplugin.h" |
|
19 #include "wrtdatapluginobserver.h" |
|
20 #include <digia/eunit/eunitmacros.h> |
|
21 #include <digia/eunit/eunitdecorators.h> |
|
22 #include <hscontentpublisher.h> |
|
23 #include <wrtdatapluginuids.hrh> |
|
24 |
|
25 _LIT( KWRTPublisherName,"WRTWidget" ); |
|
26 _LIT8( KNameSpace, "5" ); |
|
27 |
|
28 |
|
29 // - Construction ----------------------------------------------------------- |
|
30 |
|
31 MT_wrtdataplugin* MT_wrtdataplugin::NewL() |
|
32 { |
|
33 MT_wrtdataplugin* self = MT_wrtdataplugin::NewLC(); |
|
34 CleanupStack::Pop(); |
|
35 return self; |
|
36 } |
|
37 |
|
38 MT_wrtdataplugin* MT_wrtdataplugin::NewLC() |
|
39 { |
|
40 MT_wrtdataplugin* self = new( ELeave ) MT_wrtdataplugin(); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 MT_wrtdataplugin::~MT_wrtdataplugin() |
|
47 { |
|
48 if ( iPlugin ) |
|
49 { |
|
50 delete iPlugin; |
|
51 } |
|
52 if ( iContentObserver ) |
|
53 { |
|
54 delete iContentObserver; |
|
55 } |
|
56 |
|
57 } |
|
58 |
|
59 MT_wrtdataplugin::MT_wrtdataplugin() |
|
60 { |
|
61 } |
|
62 |
|
63 void MT_wrtdataplugin::ConstructL() |
|
64 { |
|
65 CEUnitTestSuiteClass::ConstructL(); |
|
66 } |
|
67 |
|
68 // - Test methods ----------------------------------------------------------- |
|
69 |
|
70 |
|
71 |
|
72 void MT_wrtdataplugin::SetupL( ) |
|
73 { |
|
74 |
|
75 |
|
76 TUid uid = { WRTDP_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_DATAPLUGIN }; |
|
77 THsPublisherInfo pubInfo( uid, KWRTPublisherName, KNameSpace ); |
|
78 iPlugin = CHsContentPublisher::NewL( pubInfo ); |
|
79 iContentObserver = CWrtDataPluginObserver::NewL(); |
|
80 |
|
81 EUNIT_ASSERT( iPlugin ); |
|
82 EUNIT_ASSERT( iContentObserver ); |
|
83 __UHEAP_MARK; |
|
84 |
|
85 } |
|
86 |
|
87 |
|
88 void MT_wrtdataplugin::Teardown( ) |
|
89 { |
|
90 __UHEAP_MARKEND; |
|
91 if ( iPlugin ) |
|
92 { |
|
93 delete iPlugin; |
|
94 iPlugin = NULL; |
|
95 } |
|
96 if ( iContentObserver ) |
|
97 { |
|
98 delete iContentObserver; |
|
99 iPlugin = NULL; |
|
100 } |
|
101 |
|
102 |
|
103 } |
|
104 |
|
105 |
|
106 void MT_wrtdataplugin::TestStartL() |
|
107 { |
|
108 TInt loop = 10000; |
|
109 |
|
110 for ( TInt i = 0; i< loop ; i++ ) |
|
111 { |
|
112 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
113 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
114 } |
|
115 for ( TInt i = 0; i< loop ; i++ ) |
|
116 { |
|
117 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
118 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
119 } |
|
120 for ( TInt i = 0; i< loop ; i++ ) |
|
121 { |
|
122 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
123 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
124 } |
|
125 |
|
126 EUNIT_ASSERT( ETrue ); |
|
127 } |
|
128 |
|
129 |
|
130 void MT_wrtdataplugin::TestStopL() |
|
131 { |
|
132 TInt loop = 10000; |
|
133 |
|
134 for ( TInt i = 0; i< loop ; i++ ) |
|
135 { |
|
136 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
137 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
138 } |
|
139 for ( TInt i = 0; i< loop ; i++ ) |
|
140 { |
|
141 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
142 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
143 } |
|
144 for ( TInt i = 0; i< loop ; i++ ) |
|
145 { |
|
146 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
147 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
148 } |
|
149 |
|
150 EUNIT_ASSERT( ETrue ); |
|
151 } |
|
152 |
|
153 |
|
154 void MT_wrtdataplugin::TestResumeL() |
|
155 { |
|
156 TInt loop = 10000; |
|
157 |
|
158 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
159 for ( TInt i = 0; i< loop ; i++ ) |
|
160 { |
|
161 iPlugin->Suspend(CHsContentPublisher::EBackground); |
|
162 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
163 } |
|
164 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
165 |
|
166 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
167 for ( TInt i = 0; i< loop ; i++ ) |
|
168 { |
|
169 iPlugin->Suspend(CHsContentPublisher::EBackground); |
|
170 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
171 } |
|
172 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
173 |
|
174 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
175 for ( TInt i = 0; i< loop ; i++ ) |
|
176 { |
|
177 iPlugin->Suspend(CHsContentPublisher::EBackground); |
|
178 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
179 } |
|
180 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
181 |
|
182 |
|
183 |
|
184 // Suspend - Resume (EBackupRestore) |
|
185 |
|
186 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
187 for ( TInt i = 0; i< loop ; i++ ) |
|
188 { |
|
189 iPlugin->Suspend(CHsContentPublisher::EBackupRestore); |
|
190 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
191 } |
|
192 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
193 |
|
194 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
195 for ( TInt i = 0; i< loop ; i++ ) |
|
196 { |
|
197 iPlugin->Suspend(CHsContentPublisher::EBackupRestore); |
|
198 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
199 } |
|
200 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
201 |
|
202 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
203 for ( TInt i = 0; i< loop ; i++ ) |
|
204 { |
|
205 iPlugin->Suspend(CHsContentPublisher::EBackupRestore); |
|
206 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
207 } |
|
208 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
209 |
|
210 |
|
211 // Suspend - Resume (EGeneralThemeChange) |
|
212 |
|
213 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
214 for ( TInt i = 0; i< loop ; i++ ) |
|
215 { |
|
216 iPlugin->Suspend(CHsContentPublisher::EGeneralThemeChange); |
|
217 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
218 } |
|
219 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
220 |
|
221 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
222 for ( TInt i = 0; i< loop ; i++ ) |
|
223 { |
|
224 iPlugin->Suspend(CHsContentPublisher::EGeneralThemeChange); |
|
225 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
226 } |
|
227 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
228 |
|
229 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
230 for ( TInt i = 0; i< loop ; i++ ) |
|
231 { |
|
232 iPlugin->Suspend(CHsContentPublisher::EGeneralThemeChange); |
|
233 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
234 } |
|
235 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
236 |
|
237 EUNIT_ASSERT( ETrue ); |
|
238 } |
|
239 |
|
240 |
|
241 void MT_wrtdataplugin::TestSuspendL() |
|
242 { |
|
243 TInt loop = 10000; |
|
244 |
|
245 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
246 for ( TInt i = 0; i< loop ; i++ ) |
|
247 { |
|
248 iPlugin->Suspend(CHsContentPublisher::EBackground); |
|
249 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
250 } |
|
251 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
252 |
|
253 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
254 for ( TInt i = 0; i< loop ; i++ ) |
|
255 { |
|
256 iPlugin->Suspend(CHsContentPublisher::EBackground); |
|
257 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
258 } |
|
259 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
260 |
|
261 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
262 for ( TInt i = 0; i< loop ; i++ ) |
|
263 { |
|
264 iPlugin->Suspend(CHsContentPublisher::EBackground); |
|
265 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
266 } |
|
267 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
268 |
|
269 |
|
270 |
|
271 // Suspend - Resume (EBackupRestore) |
|
272 |
|
273 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
274 for ( TInt i = 0; i< loop ; i++ ) |
|
275 { |
|
276 iPlugin->Suspend(CHsContentPublisher::EBackupRestore); |
|
277 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
278 } |
|
279 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
280 |
|
281 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
282 for ( TInt i = 0; i< loop ; i++ ) |
|
283 { |
|
284 iPlugin->Suspend(CHsContentPublisher::EBackupRestore); |
|
285 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
286 } |
|
287 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
288 |
|
289 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
290 for ( TInt i = 0; i< loop ; i++ ) |
|
291 { |
|
292 iPlugin->Suspend(CHsContentPublisher::EBackupRestore); |
|
293 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
294 } |
|
295 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
296 |
|
297 |
|
298 // Suspend - Resume (EGeneralThemeChange) |
|
299 |
|
300 iPlugin->Start(CHsContentPublisher::ESystemStartup); |
|
301 for ( TInt i = 0; i< loop ; i++ ) |
|
302 { |
|
303 iPlugin->Suspend(CHsContentPublisher::EGeneralThemeChange); |
|
304 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
305 } |
|
306 iPlugin->Stop(CHsContentPublisher::ESystemShutdown); |
|
307 |
|
308 iPlugin->Start(CHsContentPublisher::EPageStartup); |
|
309 for ( TInt i = 0; i< loop ; i++ ) |
|
310 { |
|
311 iPlugin->Suspend(CHsContentPublisher::EGeneralThemeChange); |
|
312 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
313 } |
|
314 iPlugin->Stop(CHsContentPublisher::EPageShutdown); |
|
315 |
|
316 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
317 for ( TInt i = 0; i< loop ; i++ ) |
|
318 { |
|
319 iPlugin->Suspend(CHsContentPublisher::EGeneralThemeChange); |
|
320 iPlugin->Resume(CHsContentPublisher::EForeground); |
|
321 } |
|
322 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
323 |
|
324 EUNIT_ASSERT( ETrue ); |
|
325 |
|
326 } |
|
327 |
|
328 void MT_wrtdataplugin::TestSetOnlineL() |
|
329 { |
|
330 TInt loop = 10000; |
|
331 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
332 for ( TInt i = 0; i< loop ; i++ ) |
|
333 { |
|
334 iPlugin->SetOnline(); |
|
335 iPlugin->SetOffline(); |
|
336 } |
|
337 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
338 EUNIT_ASSERT( ETrue ); |
|
339 } |
|
340 |
|
341 void MT_wrtdataplugin::TestSetOfflineL() |
|
342 { |
|
343 TInt loop = 10000; |
|
344 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
345 for ( TInt i = 0; i< loop ; i++ ) |
|
346 { |
|
347 iPlugin->SetOnline(); |
|
348 iPlugin->SetOffline(); |
|
349 } |
|
350 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
351 EUNIT_ASSERT( ETrue ); |
|
352 } |
|
353 |
|
354 |
|
355 void MT_wrtdataplugin::TestSubscribeL() |
|
356 { |
|
357 iPlugin->SubscribeL(*iContentObserver); |
|
358 // TODO: do some operations and check observer |
|
359 EUNIT_ASSERT_DESC( EFalse, "Test not implemeted."); |
|
360 } |
|
361 |
|
362 |
|
363 void MT_wrtdataplugin::TestConfigureL() |
|
364 { |
|
365 EUNIT_ASSERT_DESC( EFalse, "Test not implemeted."); |
|
366 } |
|
367 |
|
368 void MT_wrtdataplugin::TestSetPropertyL() |
|
369 { |
|
370 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
371 iPlugin->SetProperty(CHsContentPublisher::EPublisherContent,NULL); |
|
372 TAny* any = iPlugin->GetProperty(CHsContentPublisher::EPublisherContent); |
|
373 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
374 EUNIT_ASSERT( any == NULL ); |
|
375 } |
|
376 |
|
377 |
|
378 void MT_wrtdataplugin::TestGetPropertyL() |
|
379 { |
|
380 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
381 iPlugin->SetProperty(CHsContentPublisher::EPublisherContent,NULL); |
|
382 TAny* any = iPlugin->GetProperty(CHsContentPublisher::EPublisherContent); |
|
383 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
384 EUNIT_ASSERT( any == NULL ); |
|
385 } |
|
386 |
|
387 |
|
388 void MT_wrtdataplugin::TestHandleEventL() |
|
389 { |
|
390 EUNIT_ASSERT_DESC( EFalse, "Test not implemeted."); |
|
391 } |
|
392 |
|
393 |
|
394 |
|
395 void MT_wrtdataplugin::TestHasMenuItemL() |
|
396 { |
|
397 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
398 iPlugin->HasMenuItem(KNullDesC); |
|
399 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
400 |
|
401 EUNIT_ASSERT( ETrue ); |
|
402 } |
|
403 |
|
404 void MT_wrtdataplugin::TestExtensionL() |
|
405 { |
|
406 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
407 iPlugin->Extension(KNullUid); |
|
408 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
409 |
|
410 EUNIT_ASSERT( ETrue ); |
|
411 |
|
412 } |
|
413 |
|
414 void MT_wrtdataplugin::TestPublisherInfoL() |
|
415 { |
|
416 iPlugin->Start(CHsContentPublisher::EPluginStartup); |
|
417 const THsPublisherInfo& publisherInfo = iPlugin->PublisherInfo(); |
|
418 // TODO: check publisherInfo.Uid(), publisherInfo.Name(), publisherInfo.Namespace() |
|
419 iPlugin->Stop(CHsContentPublisher::EPluginShutdown); |
|
420 |
|
421 EUNIT_ASSERT( ETrue ); |
|
422 |
|
423 } |
|
424 |
|
425 |
|
426 // - EUnit test table ------------------------------------------------------- |
|
427 |
|
428 EUNIT_BEGIN_TEST_TABLE( |
|
429 MT_wrtdataplugin, |
|
430 "Add test suite description here.", |
|
431 "MODULE" ) |
|
432 |
|
433 EUNIT_TEST( |
|
434 "StartL", |
|
435 "WRTDataPlugin", |
|
436 "StartL", |
|
437 "FUNCTIONALITY", |
|
438 SetupL, TestStartL, Teardown) |
|
439 |
|
440 |
|
441 EUNIT_TEST( |
|
442 "StopL", |
|
443 "WRTDataPlugin", |
|
444 "StopL", |
|
445 "FUNCTIONALITY", |
|
446 SetupL, TestStopL, Teardown) |
|
447 |
|
448 EUNIT_TEST( |
|
449 "ResumeL", |
|
450 "WRTDataPlugin", |
|
451 "ResumeL", |
|
452 "FUNCTIONALITY", |
|
453 SetupL, TestResumeL, Teardown) |
|
454 |
|
455 EUNIT_TEST( |
|
456 "SuspendL", |
|
457 "WRTDataPlugin", |
|
458 "SuspendL", |
|
459 "FUNCTIONALITY", |
|
460 SetupL, TestSuspendL, Teardown) |
|
461 |
|
462 EUNIT_TEST( |
|
463 "SetOnlineL", |
|
464 "WRTDataPlugin", |
|
465 "SetOnlineL", |
|
466 "FUNCTIONALITY", |
|
467 SetupL, TestSetOnlineL, Teardown) |
|
468 |
|
469 EUNIT_TEST( |
|
470 "SetOfflineL", |
|
471 "WRTDataPlugin", |
|
472 "SetOfflineL", |
|
473 "FUNCTIONALITY", |
|
474 SetupL, TestSetOfflineL, Teardown) |
|
475 |
|
476 EUNIT_TEST( |
|
477 "SubscribeL", |
|
478 "WRTDataPlugin", |
|
479 "SubscribeL", |
|
480 "FUNCTIONALITY", |
|
481 SetupL, TestSubscribeL, Teardown) |
|
482 |
|
483 EUNIT_TEST( |
|
484 "ConfigureL", |
|
485 "WRTDataPlugin", |
|
486 "ConfigureL", |
|
487 "FUNCTIONALITY", |
|
488 SetupL, TestConfigureL, Teardown) |
|
489 |
|
490 EUNIT_TEST( |
|
491 "SetPropertyL", |
|
492 "WRTDataPlugin", |
|
493 "SetPropertyL", |
|
494 "FUNCTIONALITY", |
|
495 SetupL, TestSetPropertyL, Teardown) |
|
496 |
|
497 EUNIT_TEST( |
|
498 "GetPropertyL", |
|
499 "WRTDataPlugin", |
|
500 "GetPropertyL", |
|
501 "FUNCTIONALITY", |
|
502 SetupL, TestGetPropertyL, Teardown) |
|
503 |
|
504 EUNIT_TEST( |
|
505 "HandleEventL", |
|
506 "WRTDataPlugin", |
|
507 "HandleEventL", |
|
508 "FUNCTIONALITY", |
|
509 SetupL, TestHandleEventL, Teardown) |
|
510 |
|
511 EUNIT_TEST( |
|
512 "HasMenuItem", |
|
513 "WRTDataPlugin", |
|
514 "HasMenuItem", |
|
515 "FUNCTIONALITY", |
|
516 SetupL, TestHasMenuItemL, Teardown) |
|
517 |
|
518 EUNIT_TEST( |
|
519 "Extension", |
|
520 "WRTDataPlugin", |
|
521 "Extension", |
|
522 "FUNCTIONALITY", |
|
523 SetupL, TestExtensionL, Teardown) |
|
524 |
|
525 EUNIT_TEST( |
|
526 "PublisherInfo", |
|
527 "WRTDataPlugin", |
|
528 "PublisherInfo", |
|
529 "FUNCTIONALITY", |
|
530 SetupL, TestPublisherInfoL, Teardown) |
|
531 |
|
532 EUNIT_END_TEST_TABLE |