|
1 /* |
|
2 * Copyright (c) 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 the License "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 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32math.h> |
|
23 #include "FavouritesEngineTest.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 // None |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 // None |
|
30 |
|
31 // CONSTANTS |
|
32 // None |
|
33 |
|
34 // MACROS |
|
35 // None |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 // None |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 // None |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 // None |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 // None |
|
48 |
|
49 // ==================== LOCAL FUNCTIONS ======================================= |
|
50 |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 /* |
|
55 ------------------------------------------------------------------------------- |
|
56 |
|
57 Class: CFavouritesEngineTest |
|
58 |
|
59 Method: DbOpenTestL |
|
60 |
|
61 Description: Test opening the Favourites Db by using the Open method. |
|
62 |
|
63 Parameters: TTestResult& aErrorDescription: out: |
|
64 Test result and on error case a short description of error |
|
65 |
|
66 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
67 |
|
68 Errors/Exceptions: None |
|
69 |
|
70 Status: Approved |
|
71 |
|
72 ------------------------------------------------------------------------------- |
|
73 */ |
|
74 TInt CFavouritesEngineTest::DbOpenTestL( TTestResult& aResult ) |
|
75 { |
|
76 /* Simple server connect */ |
|
77 _LIT( KDefinition ,"State"); |
|
78 _LIT( KData ,"Test the Db Open method"); |
|
79 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
80 |
|
81 TInt result = iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
82 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
83 |
|
84 _LIT( KData2 ,"Finished"); |
|
85 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
86 |
|
87 if (result == KErrNone) |
|
88 { |
|
89 _LIT( KDescription , "Test case passed"); |
|
90 aResult.SetResult( KErrNone, KDescription ); |
|
91 } |
|
92 else |
|
93 { |
|
94 _LIT( KDescription , "Test case failed"); |
|
95 aResult.SetResult( KErrGeneral, KDescription ); |
|
96 } |
|
97 |
|
98 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
99 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
100 |
|
101 // Case was executed |
|
102 return KErrNone; |
|
103 } |
|
104 |
|
105 /* |
|
106 ------------------------------------------------------------------------------- |
|
107 |
|
108 Class: CFavouritesEngineTest |
|
109 |
|
110 Method: DbVersionTestL |
|
111 |
|
112 Description: Test the Favourites Db Version method. |
|
113 |
|
114 Parameters: TTestResult& aErrorDescription: out: |
|
115 Test result and on error case a short description of error |
|
116 |
|
117 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
118 |
|
119 Errors/Exceptions: None |
|
120 |
|
121 Status: Approved |
|
122 |
|
123 ------------------------------------------------------------------------------- |
|
124 */ |
|
125 TInt CFavouritesEngineTest::DbVersionTestL( TTestResult& aResult ) |
|
126 { |
|
127 /* Simple server connect */ |
|
128 _LIT( KDefinition ,"State"); |
|
129 _LIT( KData ,"Test the Db Version method"); |
|
130 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
131 |
|
132 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
133 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
134 |
|
135 TVersion dbVersion = iFavouritesDb.Version(); |
|
136 |
|
137 _LIT( KData2 ,"Finished"); |
|
138 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
139 |
|
140 if (dbVersion.iMajor > 0) |
|
141 { |
|
142 _LIT( KDescription , "Test case passed"); |
|
143 aResult.SetResult( KErrNone, KDescription ); |
|
144 } |
|
145 else |
|
146 { |
|
147 _LIT( KDescription , "Test case failed"); |
|
148 aResult.SetResult( KErrGeneral, KDescription ); |
|
149 } |
|
150 |
|
151 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
152 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
153 |
|
154 // Case was executed |
|
155 return KErrNone; |
|
156 } |
|
157 |
|
158 /* |
|
159 ------------------------------------------------------------------------------- |
|
160 |
|
161 Class: CFavouritesEngineTest |
|
162 |
|
163 Method: DbIsDamagedTestL |
|
164 |
|
165 Description: Test the Favourites Db IsDamaged method. |
|
166 |
|
167 Parameters: TTestResult& aErrorDescription: out: |
|
168 Test result and on error case a short description of error |
|
169 |
|
170 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
171 |
|
172 Errors/Exceptions: None |
|
173 |
|
174 Status: Approved |
|
175 |
|
176 ------------------------------------------------------------------------------- |
|
177 */ |
|
178 TInt CFavouritesEngineTest::DbIsDamagedTestL( TTestResult& aResult ) |
|
179 { |
|
180 /* Simple server connect */ |
|
181 _LIT( KDefinition ,"State"); |
|
182 _LIT( KData ,"Test the Db IsDamaged method"); |
|
183 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
184 |
|
185 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
186 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
187 |
|
188 TBool isDbDamaged = EFalse; |
|
189 |
|
190 TInt result = iFavouritesDb.IsDamaged(isDbDamaged); |
|
191 |
|
192 _LIT( KData2 ,"Finished"); |
|
193 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
194 |
|
195 if (result == KErrNone) |
|
196 { |
|
197 _LIT( KDescription , "Test case passed"); |
|
198 aResult.SetResult( KErrNone, KDescription ); |
|
199 } |
|
200 else |
|
201 { |
|
202 _LIT( KDescription , "Test case failed"); |
|
203 aResult.SetResult( KErrGeneral, KDescription ); |
|
204 } |
|
205 |
|
206 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
207 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
208 |
|
209 // Case was executed |
|
210 return KErrNone; |
|
211 } |
|
212 |
|
213 /* |
|
214 ------------------------------------------------------------------------------- |
|
215 |
|
216 Class: CFavouritesEngineTest |
|
217 |
|
218 Method: DbRecoverTestL |
|
219 |
|
220 Description: Test the Favourites Db Recover method. |
|
221 |
|
222 Parameters: TTestResult& aErrorDescription: out: |
|
223 Test result and on error case a short description of error |
|
224 |
|
225 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
226 |
|
227 Errors/Exceptions: None |
|
228 |
|
229 Status: Approved |
|
230 |
|
231 ------------------------------------------------------------------------------- |
|
232 */ |
|
233 TInt CFavouritesEngineTest::DbRecoverTestL( TTestResult& aResult ) |
|
234 { |
|
235 /* Simple server connect */ |
|
236 _LIT( KDefinition ,"State"); |
|
237 _LIT( KData ,"Test the Db Recover method"); |
|
238 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
239 |
|
240 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
241 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
242 |
|
243 TInt result = iFavouritesDb.Recover(); |
|
244 |
|
245 _LIT( KData2 ,"Finished"); |
|
246 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
247 |
|
248 if (result == KErrNone) |
|
249 { |
|
250 _LIT( KDescription , "Test case passed"); |
|
251 aResult.SetResult( KErrNone, KDescription ); |
|
252 } |
|
253 else |
|
254 { |
|
255 _LIT( KDescription , "Test case failed"); |
|
256 aResult.SetResult( KErrGeneral, KDescription ); |
|
257 } |
|
258 |
|
259 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
260 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
261 |
|
262 // Case was executed |
|
263 return KErrNone; |
|
264 } |
|
265 |
|
266 /* |
|
267 ------------------------------------------------------------------------------- |
|
268 |
|
269 Class: CFavouritesEngineTest |
|
270 |
|
271 Method: DbCompactTestL |
|
272 |
|
273 Description: Test the Favourites Db Compact method. |
|
274 |
|
275 Parameters: TTestResult& aErrorDescription: out: |
|
276 Test result and on error case a short description of error |
|
277 |
|
278 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
279 |
|
280 Errors/Exceptions: None |
|
281 |
|
282 Status: Approved |
|
283 |
|
284 ------------------------------------------------------------------------------- |
|
285 */ |
|
286 TInt CFavouritesEngineTest::DbCompactTestL( TTestResult& aResult ) |
|
287 { |
|
288 /* Simple server connect */ |
|
289 _LIT( KDefinition ,"State"); |
|
290 _LIT( KData ,"Test the Db Compact method"); |
|
291 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
292 |
|
293 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
294 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
295 |
|
296 TInt result = iFavouritesDb.Compact(); |
|
297 |
|
298 _LIT( KData2 ,"Finished"); |
|
299 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
300 |
|
301 if (result == KErrNone) |
|
302 { |
|
303 _LIT( KDescription , "Test case passed"); |
|
304 aResult.SetResult( KErrNone, KDescription ); |
|
305 } |
|
306 else |
|
307 { |
|
308 _LIT( KDescription , "Test case failed"); |
|
309 aResult.SetResult( KErrGeneral, KDescription ); |
|
310 } |
|
311 |
|
312 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
313 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
314 |
|
315 // Case was executed |
|
316 return KErrNone; |
|
317 } |
|
318 |
|
319 /* |
|
320 ------------------------------------------------------------------------------- |
|
321 |
|
322 Class: CFavouritesEngineTest |
|
323 |
|
324 Method: DbSizeTestL |
|
325 |
|
326 Description: Test the Favourites Db Size method. |
|
327 |
|
328 Parameters: TTestResult& aErrorDescription: out: |
|
329 Test result and on error case a short description of error |
|
330 |
|
331 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
332 |
|
333 Errors/Exceptions: None |
|
334 |
|
335 Status: Approved |
|
336 |
|
337 ------------------------------------------------------------------------------- |
|
338 */ |
|
339 TInt CFavouritesEngineTest::DbSizeTestL( TTestResult& aResult ) |
|
340 { |
|
341 /* Simple server connect */ |
|
342 _LIT( KDefinition ,"State"); |
|
343 _LIT( KData ,"Test the Db Size method"); |
|
344 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
345 |
|
346 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
347 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
348 |
|
349 RDbDatabase::TSize dbSize; |
|
350 |
|
351 TInt result = iFavouritesDb.Size(dbSize); |
|
352 |
|
353 _LIT( KData2 ,"Finished"); |
|
354 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
355 |
|
356 if (result == KErrNone) |
|
357 { |
|
358 _LIT( KDescription , "Test case passed"); |
|
359 aResult.SetResult( KErrNone, KDescription ); |
|
360 } |
|
361 else |
|
362 { |
|
363 _LIT( KDescription , "Test case failed"); |
|
364 aResult.SetResult( KErrGeneral, KDescription ); |
|
365 } |
|
366 |
|
367 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
368 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
369 |
|
370 // Case was executed |
|
371 return KErrNone; |
|
372 } |
|
373 |
|
374 /* |
|
375 ------------------------------------------------------------------------------- |
|
376 |
|
377 Class: CFavouritesEngineTest |
|
378 |
|
379 Method: DbUpdateStatsTestL |
|
380 |
|
381 Description: Test the Favourites Db UpdateStats method. |
|
382 |
|
383 Parameters: TTestResult& aErrorDescription: out: |
|
384 Test result and on error case a short description of error |
|
385 |
|
386 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
387 |
|
388 Errors/Exceptions: None |
|
389 |
|
390 Status: Approved |
|
391 |
|
392 ------------------------------------------------------------------------------- |
|
393 */ |
|
394 TInt CFavouritesEngineTest::DbUpdateStatsTestL( TTestResult& aResult ) |
|
395 { |
|
396 /* Simple server connect */ |
|
397 _LIT( KDefinition ,"State"); |
|
398 _LIT( KData ,"Test the Db UpdateStats method"); |
|
399 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
400 |
|
401 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
402 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
403 |
|
404 TInt result = iFavouritesDb.UpdateStats(); |
|
405 |
|
406 _LIT( KData2 ,"Finished"); |
|
407 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
408 |
|
409 if (result == KErrNone) |
|
410 { |
|
411 _LIT( KDescription , "Test case passed"); |
|
412 aResult.SetResult( KErrNone, KDescription ); |
|
413 } |
|
414 else |
|
415 { |
|
416 _LIT( KDescription , "Test case failed"); |
|
417 aResult.SetResult( KErrGeneral, KDescription ); |
|
418 } |
|
419 |
|
420 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
421 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
422 |
|
423 // Case was executed |
|
424 return KErrNone; |
|
425 } |
|
426 |
|
427 /* |
|
428 ------------------------------------------------------------------------------- |
|
429 |
|
430 Class: CFavouritesEngineTest |
|
431 |
|
432 Method: DbBeginTestL |
|
433 |
|
434 Description: Test the Favourites Db Begin method. |
|
435 |
|
436 Parameters: TTestResult& aErrorDescription: out: |
|
437 Test result and on error case a short description of error |
|
438 |
|
439 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
440 |
|
441 Errors/Exceptions: None |
|
442 |
|
443 Status: Approved |
|
444 |
|
445 ------------------------------------------------------------------------------- |
|
446 */ |
|
447 TInt CFavouritesEngineTest::DbBeginTestL( TTestResult& aResult ) |
|
448 { |
|
449 /* Simple server connect */ |
|
450 _LIT( KDefinition ,"State"); |
|
451 _LIT( KData ,"Test the Db Begin method"); |
|
452 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
453 |
|
454 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
455 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
456 |
|
457 TInt result = iFavouritesDb.Begin(EFalse); |
|
458 |
|
459 _LIT( KData2 ,"Finished"); |
|
460 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
461 |
|
462 if (result == KErrNone) |
|
463 { |
|
464 _LIT( KDescription , "Test case passed"); |
|
465 aResult.SetResult( KErrNone, KDescription ); |
|
466 } |
|
467 else |
|
468 { |
|
469 _LIT( KDescription , "Test case failed"); |
|
470 aResult.SetResult( KErrGeneral, KDescription ); |
|
471 } |
|
472 |
|
473 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
474 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
475 |
|
476 // Case was executed |
|
477 return KErrNone; |
|
478 } |
|
479 |
|
480 /* |
|
481 ------------------------------------------------------------------------------- |
|
482 |
|
483 Class: CFavouritesEngineTest |
|
484 |
|
485 Method: DbCommitTestL |
|
486 |
|
487 Description: Test the Favourites Db Commit method. |
|
488 |
|
489 Parameters: TTestResult& aErrorDescription: out: |
|
490 Test result and on error case a short description of error |
|
491 |
|
492 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
493 |
|
494 Errors/Exceptions: None |
|
495 |
|
496 Status: Approved |
|
497 |
|
498 ------------------------------------------------------------------------------- |
|
499 */ |
|
500 TInt CFavouritesEngineTest::DbCommitTestL( TTestResult& aResult ) |
|
501 { |
|
502 /* Simple server connect */ |
|
503 _LIT( KDefinition ,"State"); |
|
504 _LIT( KData ,"Test the Db Commit method"); |
|
505 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
506 |
|
507 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
508 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
509 |
|
510 iFavouritesDb.Begin(EFalse); |
|
511 TInt result = iFavouritesDb.Commit(); |
|
512 |
|
513 _LIT( KData2 ,"Finished"); |
|
514 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
515 |
|
516 if (result == KErrNone) |
|
517 { |
|
518 _LIT( KDescription , "Test case passed"); |
|
519 aResult.SetResult( KErrNone, KDescription ); |
|
520 } |
|
521 else |
|
522 { |
|
523 _LIT( KDescription , "Test case failed"); |
|
524 aResult.SetResult( KErrGeneral, KDescription ); |
|
525 } |
|
526 |
|
527 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
528 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
529 |
|
530 // Case was executed |
|
531 return KErrNone; |
|
532 } |
|
533 |
|
534 /* |
|
535 ------------------------------------------------------------------------------- |
|
536 |
|
537 Class: CFavouritesEngineTest |
|
538 |
|
539 Method: DbRollbackTestL |
|
540 |
|
541 Description: Test the Favourites Db Rollback method. |
|
542 |
|
543 Parameters: TTestResult& aErrorDescription: out: |
|
544 Test result and on error case a short description of error |
|
545 |
|
546 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
547 |
|
548 Errors/Exceptions: None |
|
549 |
|
550 Status: Approved |
|
551 |
|
552 ------------------------------------------------------------------------------- |
|
553 */ |
|
554 TInt CFavouritesEngineTest::DbRollbackTestL( TTestResult& aResult ) |
|
555 { |
|
556 /* Simple server connect */ |
|
557 _LIT( KDefinition ,"State"); |
|
558 _LIT( KData ,"Test the Db Rollback method"); |
|
559 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
560 |
|
561 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
562 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
563 |
|
564 iFavouritesDb.Begin(EFalse); |
|
565 CreateItemL( iItem1 ); |
|
566 iFavouritesDb.Add( *iItem1, EFalse ); |
|
567 |
|
568 TInt result = KErrNone; |
|
569 TRAP(result, iFavouritesDb.Rollback()); |
|
570 |
|
571 _LIT( KData2 ,"Finished"); |
|
572 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
573 |
|
574 if (result == KErrNone) |
|
575 { |
|
576 _LIT( KDescription , "Test case passed"); |
|
577 aResult.SetResult( KErrNone, KDescription ); |
|
578 } |
|
579 else |
|
580 { |
|
581 _LIT( KDescription , "Test case failed"); |
|
582 aResult.SetResult( KErrGeneral, KDescription ); |
|
583 } |
|
584 |
|
585 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
586 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
587 |
|
588 delete iItem1; |
|
589 iItem1 = NULL; |
|
590 |
|
591 // Case was executed |
|
592 return KErrNone; |
|
593 } |
|
594 |
|
595 /* |
|
596 ------------------------------------------------------------------------------- |
|
597 |
|
598 Class: CFavouritesEngineTest |
|
599 |
|
600 Method: DbCleanupRollbackPushLTestL |
|
601 |
|
602 Description: Test the Favourites Db CleanupRollbackPushL method. |
|
603 |
|
604 Parameters: TTestResult& aErrorDescription: out: |
|
605 Test result and on error case a short description of error |
|
606 |
|
607 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
608 |
|
609 Errors/Exceptions: None |
|
610 |
|
611 Status: Approved |
|
612 |
|
613 ------------------------------------------------------------------------------- |
|
614 */ |
|
615 TInt CFavouritesEngineTest::DbCleanupRollbackPushLTestL( TTestResult& aResult ) |
|
616 { |
|
617 /* Simple server connect */ |
|
618 _LIT( KDefinition ,"State"); |
|
619 _LIT( KData ,"Test the Db CleanupRollbackPushL method"); |
|
620 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
621 |
|
622 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
623 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
624 |
|
625 iFavouritesDb.Begin(EFalse); |
|
626 iFavouritesDb.CleanupRollbackPushL(); |
|
627 CreateItemL( iItem1 ); |
|
628 iFavouritesDb.Add( *iItem1, EFalse ); |
|
629 TInt result = iFavouritesDb.Commit(); |
|
630 |
|
631 _LIT( KData2 ,"Finished"); |
|
632 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
633 |
|
634 if (result == KErrNone) |
|
635 { |
|
636 _LIT( KDescription , "Test case passed"); |
|
637 aResult.SetResult( KErrNone, KDescription ); |
|
638 } |
|
639 else |
|
640 { |
|
641 _LIT( KDescription , "Test case failed"); |
|
642 aResult.SetResult( KErrGeneral, KDescription ); |
|
643 } |
|
644 |
|
645 CleanupStack::Pop(); // RollbackPush |
|
646 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
647 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
648 |
|
649 delete iItem1; |
|
650 iItem1 = NULL; |
|
651 |
|
652 // Case was executed |
|
653 return KErrNone; |
|
654 } |
|
655 |
|
656 /* |
|
657 ------------------------------------------------------------------------------- |
|
658 |
|
659 Class: CFavouritesEngineTest |
|
660 |
|
661 Method: DbGetTestL |
|
662 |
|
663 Description: Test the Favourites Db Get method. |
|
664 |
|
665 Parameters: TTestResult& aErrorDescription: out: |
|
666 Test result and on error case a short description of error |
|
667 |
|
668 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
669 |
|
670 Errors/Exceptions: None |
|
671 |
|
672 Status: Approved |
|
673 |
|
674 ------------------------------------------------------------------------------- |
|
675 */ |
|
676 TInt CFavouritesEngineTest::DbGetTestL( TTestResult& aResult ) |
|
677 { |
|
678 /* Simple server connect */ |
|
679 _LIT( KDefinition ,"State"); |
|
680 _LIT( KData ,"Test the Db Get method"); |
|
681 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
682 |
|
683 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
684 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
685 |
|
686 CreatePopulatedDbL(); |
|
687 |
|
688 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
689 |
|
690 TInt result = iFavouritesDb.Get( iItem1->Uid(), *item ); |
|
691 |
|
692 _LIT( KData2 ,"Finished"); |
|
693 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
694 |
|
695 if (result == KErrNone) |
|
696 { |
|
697 _LIT( KDescription , "Test case passed"); |
|
698 aResult.SetResult( KErrNone, KDescription ); |
|
699 } |
|
700 else |
|
701 { |
|
702 _LIT( KDescription , "Test case failed"); |
|
703 aResult.SetResult( KErrGeneral, KDescription ); |
|
704 } |
|
705 |
|
706 CleanupStack::PopAndDestroy(2); // iFavouritesDb, item |
|
707 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
708 |
|
709 // Case was executed |
|
710 return KErrNone; |
|
711 } |
|
712 |
|
713 /* |
|
714 ------------------------------------------------------------------------------- |
|
715 |
|
716 Class: CFavouritesEngineTest |
|
717 |
|
718 Method: DbGetAllTestL |
|
719 |
|
720 Description: Test the Favourites Db GetAll method. |
|
721 |
|
722 Parameters: TTestResult& aErrorDescription: out: |
|
723 Test result and on error case a short description of error |
|
724 |
|
725 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
726 |
|
727 Errors/Exceptions: None |
|
728 |
|
729 Status: Approved |
|
730 |
|
731 ------------------------------------------------------------------------------- |
|
732 */ |
|
733 TInt CFavouritesEngineTest::DbGetAllTestL( TTestResult& aResult ) |
|
734 { |
|
735 /* Simple server connect */ |
|
736 _LIT( KDefinition ,"State"); |
|
737 _LIT( KData ,"Test the Db GetAll method"); |
|
738 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
739 |
|
740 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
741 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
742 |
|
743 CreatePopulatedDbL(); |
|
744 |
|
745 CFavouritesItemList* list = new (ELeave) CFavouritesItemList(); |
|
746 |
|
747 TInt result = iFavouritesDb.GetAll( *list, KFavouritesRootUid ); |
|
748 |
|
749 _LIT( KData2 ,"Finished"); |
|
750 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
751 |
|
752 if (result == KErrNone) |
|
753 { |
|
754 _LIT( KDescription , "Test case passed"); |
|
755 aResult.SetResult( KErrNone, KDescription ); |
|
756 } |
|
757 else |
|
758 { |
|
759 _LIT( KDescription , "Test case failed"); |
|
760 aResult.SetResult( KErrGeneral, KDescription ); |
|
761 } |
|
762 |
|
763 delete list; |
|
764 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
765 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
766 |
|
767 // Case was executed |
|
768 return KErrNone; |
|
769 } |
|
770 |
|
771 /* |
|
772 ------------------------------------------------------------------------------- |
|
773 |
|
774 Class: CFavouritesEngineTest |
|
775 |
|
776 Method: DbGetUidsTestL |
|
777 |
|
778 Description: Test the Favourites Db GetUids method. |
|
779 |
|
780 Parameters: TTestResult& aErrorDescription: out: |
|
781 Test result and on error case a short description of error |
|
782 |
|
783 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
784 |
|
785 Errors/Exceptions: None |
|
786 |
|
787 Status: Approved |
|
788 |
|
789 ------------------------------------------------------------------------------- |
|
790 */ |
|
791 TInt CFavouritesEngineTest::DbGetUidsTestL( TTestResult& aResult ) |
|
792 { |
|
793 /* Simple server connect */ |
|
794 _LIT( KDefinition ,"State"); |
|
795 _LIT( KData ,"Test the Db GetUids method"); |
|
796 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
797 |
|
798 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
799 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
800 |
|
801 CreatePopulatedDbL(); |
|
802 |
|
803 CArrayFix<TInt>* uids = new (ELeave) CArrayFixFlat<TInt>( 1 ); |
|
804 |
|
805 TInt result = iFavouritesDb.GetUids( *uids, KFavouritesRootUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId ); |
|
806 |
|
807 _LIT( KData2 ,"Finished"); |
|
808 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
809 |
|
810 if (result == KErrNone) |
|
811 { |
|
812 _LIT( KDescription , "Test case passed"); |
|
813 aResult.SetResult( KErrNone, KDescription ); |
|
814 } |
|
815 else |
|
816 { |
|
817 _LIT( KDescription , "Test case failed"); |
|
818 aResult.SetResult( KErrGeneral, KDescription ); |
|
819 } |
|
820 |
|
821 delete uids; |
|
822 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
823 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
824 |
|
825 // Case was executed |
|
826 return KErrNone; |
|
827 } |
|
828 |
|
829 /* |
|
830 ------------------------------------------------------------------------------- |
|
831 |
|
832 Class: CFavouritesEngineTest |
|
833 |
|
834 Method: DbPreferredUidTestL |
|
835 |
|
836 Description: Test the Favourites Db PreferredUid method. |
|
837 |
|
838 Parameters: TTestResult& aErrorDescription: out: |
|
839 Test result and on error case a short description of error |
|
840 |
|
841 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
842 |
|
843 Errors/Exceptions: None |
|
844 |
|
845 Status: Approved |
|
846 |
|
847 ------------------------------------------------------------------------------- |
|
848 */ |
|
849 TInt CFavouritesEngineTest::DbPreferredUidTestL( TTestResult& aResult ) |
|
850 { |
|
851 /* Simple server connect */ |
|
852 _LIT( KDefinition ,"State"); |
|
853 _LIT( KData ,"Test the Db PreferredUid method"); |
|
854 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
855 |
|
856 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
857 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
858 |
|
859 CreatePopulatedDbL(); |
|
860 |
|
861 iFavouritesDb.SetPreferredUid(iItemFolder1->Uid(), 222); |
|
862 TInt preferredUid; |
|
863 iFavouritesDb.PreferredUid( iItemFolder1->Uid(), preferredUid ); |
|
864 |
|
865 _LIT( KData2 ,"Finished"); |
|
866 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
867 |
|
868 if (preferredUid == 222) |
|
869 { |
|
870 _LIT( KDescription , "Test case passed"); |
|
871 aResult.SetResult( KErrNone, KDescription ); |
|
872 } |
|
873 else |
|
874 { |
|
875 _LIT( KDescription , "Test case failed"); |
|
876 aResult.SetResult( KErrGeneral, KDescription ); |
|
877 } |
|
878 |
|
879 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
880 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
881 |
|
882 // Case was executed |
|
883 return KErrNone; |
|
884 } |
|
885 |
|
886 /* |
|
887 ------------------------------------------------------------------------------- |
|
888 |
|
889 Class: CFavouritesEngineTest |
|
890 |
|
891 Method: DbDeleteTestL |
|
892 |
|
893 Description: Test the Favourites Db Delete method. |
|
894 |
|
895 Parameters: TTestResult& aErrorDescription: out: |
|
896 Test result and on error case a short description of error |
|
897 |
|
898 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
899 |
|
900 Errors/Exceptions: None |
|
901 |
|
902 Status: Approved |
|
903 |
|
904 ------------------------------------------------------------------------------- |
|
905 */ |
|
906 TInt CFavouritesEngineTest::DbDeleteTestL( TTestResult& aResult ) |
|
907 { |
|
908 /* Simple server connect */ |
|
909 _LIT( KDefinition ,"State"); |
|
910 _LIT( KData ,"Test the Db Delete method"); |
|
911 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
912 |
|
913 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
914 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
915 |
|
916 CreatePopulatedDbL(); |
|
917 |
|
918 TInt countBeforeDelete; |
|
919 iFavouritesDb.Count(countBeforeDelete, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
920 iFavouritesDb.Delete( iItem3->Uid() ); |
|
921 TInt countAfterDelete; |
|
922 iFavouritesDb.Count(countAfterDelete, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
923 |
|
924 _LIT( KData2 ,"Finished"); |
|
925 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
926 |
|
927 if (countAfterDelete == countBeforeDelete - 1) |
|
928 { |
|
929 _LIT( KDescription , "Test case passed"); |
|
930 aResult.SetResult( KErrNone, KDescription ); |
|
931 } |
|
932 else |
|
933 { |
|
934 _LIT( KDescription , "Test case failed"); |
|
935 aResult.SetResult( KErrGeneral, KDescription ); |
|
936 } |
|
937 |
|
938 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
939 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
940 |
|
941 // Case was executed |
|
942 return KErrNone; |
|
943 } |
|
944 |
|
945 /* |
|
946 ------------------------------------------------------------------------------- |
|
947 |
|
948 Class: CFavouritesEngineTest |
|
949 |
|
950 Method: DbUpdateTestL |
|
951 |
|
952 Description: Test the Favourites Db Update method. |
|
953 |
|
954 Parameters: TTestResult& aErrorDescription: out: |
|
955 Test result and on error case a short description of error |
|
956 |
|
957 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
958 |
|
959 Errors/Exceptions: None |
|
960 |
|
961 Status: Approved |
|
962 |
|
963 ------------------------------------------------------------------------------- |
|
964 */ |
|
965 TInt CFavouritesEngineTest::DbUpdateTestL( TTestResult& aResult ) |
|
966 { |
|
967 /* Simple server connect */ |
|
968 _LIT( KDefinition ,"State"); |
|
969 _LIT( KData ,"Test the Db Update method"); |
|
970 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
971 |
|
972 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
973 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
974 |
|
975 CreatePopulatedDbL(); |
|
976 |
|
977 CFavouritesItem* updateItem = CFavouritesItem::NewLC(); |
|
978 |
|
979 InitItemL( updateItem ); |
|
980 updateItem->SetParentFolder(iItemFolder1->Uid()); |
|
981 TInt result = iFavouritesDb.Update(*updateItem, iItem6->Uid(), EFalse); |
|
982 |
|
983 _LIT( KData2 ,"Finished"); |
|
984 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
985 |
|
986 if (result == KErrNone) |
|
987 { |
|
988 _LIT( KDescription , "Test case passed"); |
|
989 aResult.SetResult( KErrNone, KDescription ); |
|
990 } |
|
991 else |
|
992 { |
|
993 _LIT( KDescription , "Test case failed"); |
|
994 aResult.SetResult( KErrGeneral, KDescription ); |
|
995 } |
|
996 |
|
997 CleanupStack::PopAndDestroy(2); // iFavouritesDb, updateItem |
|
998 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
999 |
|
1000 // Case was executed |
|
1001 return KErrNone; |
|
1002 } |
|
1003 |
|
1004 /* |
|
1005 ------------------------------------------------------------------------------- |
|
1006 |
|
1007 Class: CFavouritesEngineTest |
|
1008 |
|
1009 Method: DbAddTestL |
|
1010 |
|
1011 Description: Test the Favourites Db Add method. |
|
1012 |
|
1013 Parameters: TTestResult& aErrorDescription: out: |
|
1014 Test result and on error case a short description of error |
|
1015 |
|
1016 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1017 |
|
1018 Errors/Exceptions: None |
|
1019 |
|
1020 Status: Approved |
|
1021 |
|
1022 ------------------------------------------------------------------------------- |
|
1023 */ |
|
1024 TInt CFavouritesEngineTest::DbAddTestL( TTestResult& aResult ) |
|
1025 { |
|
1026 /* Simple server connect */ |
|
1027 _LIT( KDefinition ,"State"); |
|
1028 _LIT( KData ,"Test the Db Add method"); |
|
1029 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1030 |
|
1031 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1032 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1033 |
|
1034 CreatePopulatedDbL(); |
|
1035 |
|
1036 CFavouritesItem* itemToAdd = CFavouritesItem::NewLC(); |
|
1037 InitItemL( itemToAdd ); |
|
1038 |
|
1039 TInt countBeforeAdd; |
|
1040 iFavouritesDb.Count(countBeforeAdd, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
1041 iFavouritesDb.Add( *itemToAdd, EFalse ); |
|
1042 TInt countAfterAdd; |
|
1043 iFavouritesDb.Count(countAfterAdd, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
1044 |
|
1045 _LIT( KData2 ,"Finished"); |
|
1046 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1047 |
|
1048 if (countAfterAdd == countBeforeAdd + 1) |
|
1049 { |
|
1050 _LIT( KDescription , "Test case passed"); |
|
1051 aResult.SetResult( KErrNone, KDescription ); |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 _LIT( KDescription , "Test case failed"); |
|
1056 aResult.SetResult( KErrGeneral, KDescription ); |
|
1057 } |
|
1058 |
|
1059 CleanupStack::PopAndDestroy(2); // iFavouritesDb, itemToAdd |
|
1060 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1061 |
|
1062 // Case was executed |
|
1063 return KErrNone; |
|
1064 } |
|
1065 |
|
1066 /* |
|
1067 ------------------------------------------------------------------------------- |
|
1068 |
|
1069 Class: CFavouritesEngineTest |
|
1070 |
|
1071 Method: DbSetHomepageTestL |
|
1072 |
|
1073 Description: Test the Favourites Db SetHomepage method. |
|
1074 |
|
1075 Parameters: TTestResult& aErrorDescription: out: |
|
1076 Test result and on error case a short description of error |
|
1077 |
|
1078 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1079 |
|
1080 Errors/Exceptions: None |
|
1081 |
|
1082 Status: Approved |
|
1083 |
|
1084 ------------------------------------------------------------------------------- |
|
1085 */ |
|
1086 TInt CFavouritesEngineTest::DbSetHomepageTestL( TTestResult& aResult ) |
|
1087 { |
|
1088 /* Simple server connect */ |
|
1089 _LIT( KDefinition ,"State"); |
|
1090 _LIT( KData ,"Test the Db SetHomepage method"); |
|
1091 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1092 |
|
1093 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1094 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1095 |
|
1096 CFavouritesItem* homepageItem = CFavouritesItem::NewLC(); |
|
1097 InitItemL( homepageItem ); |
|
1098 |
|
1099 TInt result = iFavouritesDb.SetHomepage(*homepageItem); |
|
1100 |
|
1101 _LIT( KData2 ,"Finished"); |
|
1102 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1103 |
|
1104 if (result == KErrNone) |
|
1105 { |
|
1106 _LIT( KDescription , "Test case passed"); |
|
1107 aResult.SetResult( KErrNone, KDescription ); |
|
1108 } |
|
1109 else |
|
1110 { |
|
1111 _LIT( KDescription , "Test case failed"); |
|
1112 aResult.SetResult( KErrGeneral, KDescription ); |
|
1113 } |
|
1114 |
|
1115 CleanupStack::PopAndDestroy(2); // iFavouritesDb, homepageItem |
|
1116 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1117 |
|
1118 // Case was executed |
|
1119 return KErrNone; |
|
1120 } |
|
1121 |
|
1122 /* |
|
1123 ------------------------------------------------------------------------------- |
|
1124 |
|
1125 Class: CFavouritesEngineTest |
|
1126 |
|
1127 Method: DbSetLastVisitedTestL |
|
1128 |
|
1129 Description: Test the Favourites Db SetLastVisited method. |
|
1130 |
|
1131 Parameters: TTestResult& aErrorDescription: out: |
|
1132 Test result and on error case a short description of error |
|
1133 |
|
1134 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1135 |
|
1136 Errors/Exceptions: None |
|
1137 |
|
1138 Status: Approved |
|
1139 |
|
1140 ------------------------------------------------------------------------------- |
|
1141 */ |
|
1142 TInt CFavouritesEngineTest::DbSetLastVisitedTestL( TTestResult& aResult ) |
|
1143 { |
|
1144 /* Simple server connect */ |
|
1145 _LIT( KDefinition ,"State"); |
|
1146 _LIT( KData ,"Test the Db SetLastVisited method"); |
|
1147 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1148 |
|
1149 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1150 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1151 |
|
1152 CFavouritesItem* lastvisitedItem = CFavouritesItem::NewLC(); |
|
1153 InitItemL( lastvisitedItem ); |
|
1154 |
|
1155 TInt result = iFavouritesDb.SetLastVisited( *lastvisitedItem ); |
|
1156 |
|
1157 _LIT( KData2 ,"Finished"); |
|
1158 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1159 |
|
1160 if (result == KErrNone) |
|
1161 { |
|
1162 _LIT( KDescription , "Test case passed"); |
|
1163 aResult.SetResult( KErrNone, KDescription ); |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 _LIT( KDescription , "Test case failed"); |
|
1168 aResult.SetResult( KErrGeneral, KDescription ); |
|
1169 } |
|
1170 |
|
1171 CleanupStack::PopAndDestroy(2); // iFavouritesDb, lastvisitedItem |
|
1172 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1173 |
|
1174 // Case was executed |
|
1175 return KErrNone; |
|
1176 } |
|
1177 |
|
1178 /* |
|
1179 ------------------------------------------------------------------------------- |
|
1180 |
|
1181 Class: CFavouritesEngineTest |
|
1182 |
|
1183 Method: DbSetFactoryItemTestL |
|
1184 |
|
1185 Description: Test the Favourites Db SetFactoryItem method. |
|
1186 |
|
1187 Parameters: TTestResult& aErrorDescription: out: |
|
1188 Test result and on error case a short description of error |
|
1189 |
|
1190 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1191 |
|
1192 Errors/Exceptions: None |
|
1193 |
|
1194 Status: Approved |
|
1195 |
|
1196 ------------------------------------------------------------------------------- |
|
1197 */ |
|
1198 TInt CFavouritesEngineTest::DbSetFactoryItemTestL( TTestResult& aResult ) |
|
1199 { |
|
1200 /* Simple server connect */ |
|
1201 _LIT( KDefinition ,"State"); |
|
1202 _LIT( KData ,"Test the Db SetFactoryItem method"); |
|
1203 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1204 |
|
1205 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1206 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1207 |
|
1208 CreatePopulatedDbL(); |
|
1209 |
|
1210 TInt result = iFavouritesDb.SetFactoryItem( iItem1->Uid(), ETrue ); |
|
1211 |
|
1212 _LIT( KData2 ,"Finished"); |
|
1213 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1214 |
|
1215 if (result == KErrNone) |
|
1216 { |
|
1217 _LIT( KDescription , "Test case passed"); |
|
1218 aResult.SetResult( KErrNone, KDescription ); |
|
1219 } |
|
1220 else |
|
1221 { |
|
1222 _LIT( KDescription , "Test case failed"); |
|
1223 aResult.SetResult( KErrGeneral, KDescription ); |
|
1224 } |
|
1225 |
|
1226 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1227 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1228 |
|
1229 // Case was executed |
|
1230 return KErrNone; |
|
1231 } |
|
1232 |
|
1233 /* |
|
1234 ------------------------------------------------------------------------------- |
|
1235 |
|
1236 Class: CFavouritesEngineTest |
|
1237 |
|
1238 Method: DbSetReadOnlyTestL |
|
1239 |
|
1240 Description: Test the Favourites Db SetReadOnly method. |
|
1241 |
|
1242 Parameters: TTestResult& aErrorDescription: out: |
|
1243 Test result and on error case a short description of error |
|
1244 |
|
1245 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1246 |
|
1247 Errors/Exceptions: None |
|
1248 |
|
1249 Status: Approved |
|
1250 |
|
1251 ------------------------------------------------------------------------------- |
|
1252 */ |
|
1253 TInt CFavouritesEngineTest::DbSetReadOnlyTestL( TTestResult& aResult ) |
|
1254 { |
|
1255 /* Simple server connect */ |
|
1256 _LIT( KDefinition ,"State"); |
|
1257 _LIT( KData ,"Test the Db SetReadOnly method"); |
|
1258 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1259 |
|
1260 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1261 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1262 |
|
1263 CreatePopulatedDbL(); |
|
1264 |
|
1265 TInt result = iFavouritesDb.SetReadOnly( iItem1->Uid(), ETrue ); |
|
1266 |
|
1267 _LIT( KData2 ,"Finished"); |
|
1268 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1269 |
|
1270 if (result == KErrNone) |
|
1271 { |
|
1272 _LIT( KDescription , "Test case passed"); |
|
1273 aResult.SetResult( KErrNone, KDescription ); |
|
1274 } |
|
1275 else |
|
1276 { |
|
1277 _LIT( KDescription , "Test case failed"); |
|
1278 aResult.SetResult( KErrGeneral, KDescription ); |
|
1279 } |
|
1280 |
|
1281 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1282 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1283 |
|
1284 // Case was executed |
|
1285 return KErrNone; |
|
1286 } |
|
1287 |
|
1288 /* |
|
1289 ------------------------------------------------------------------------------- |
|
1290 |
|
1291 Class: CFavouritesEngineTest |
|
1292 |
|
1293 Method: DbSetModifiedTestL |
|
1294 |
|
1295 Description: Test the Favourites Db SetModified method. |
|
1296 |
|
1297 Parameters: TTestResult& aErrorDescription: out: |
|
1298 Test result and on error case a short description of error |
|
1299 |
|
1300 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1301 |
|
1302 Errors/Exceptions: None |
|
1303 |
|
1304 Status: Approved |
|
1305 |
|
1306 ------------------------------------------------------------------------------- |
|
1307 */ |
|
1308 TInt CFavouritesEngineTest::DbSetModifiedTestL( TTestResult& aResult ) |
|
1309 { |
|
1310 /* Simple server connect */ |
|
1311 _LIT( KDefinition ,"State"); |
|
1312 _LIT( KData ,"Test the Db SetModified method"); |
|
1313 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1314 |
|
1315 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1316 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1317 |
|
1318 CreatePopulatedDbL(); |
|
1319 |
|
1320 TInt result = iFavouritesDb.SetModified( iItem1->Uid(), TTime() ); |
|
1321 |
|
1322 _LIT( KData2 ,"Finished"); |
|
1323 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1324 |
|
1325 if (result == KErrNone) |
|
1326 { |
|
1327 _LIT( KDescription , "Test case passed"); |
|
1328 aResult.SetResult( KErrNone, KDescription ); |
|
1329 } |
|
1330 else |
|
1331 { |
|
1332 _LIT( KDescription , "Test case failed"); |
|
1333 aResult.SetResult( KErrGeneral, KDescription ); |
|
1334 } |
|
1335 |
|
1336 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1337 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1338 |
|
1339 // Case was executed |
|
1340 return KErrNone; |
|
1341 } |
|
1342 |
|
1343 /* |
|
1344 ------------------------------------------------------------------------------- |
|
1345 |
|
1346 Class: CFavouritesEngineTest |
|
1347 |
|
1348 Method: DbSetPreferredUidTestL |
|
1349 |
|
1350 Description: Test the Favourites Db SetPreferredUid method. |
|
1351 |
|
1352 Parameters: TTestResult& aErrorDescription: out: |
|
1353 Test result and on error case a short description of error |
|
1354 |
|
1355 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1356 |
|
1357 Errors/Exceptions: None |
|
1358 |
|
1359 Status: Approved |
|
1360 |
|
1361 ------------------------------------------------------------------------------- |
|
1362 */ |
|
1363 TInt CFavouritesEngineTest::DbSetPreferredUidTestL( TTestResult& aResult ) |
|
1364 { |
|
1365 /* Simple server connect */ |
|
1366 _LIT( KDefinition ,"State"); |
|
1367 _LIT( KData ,"Test the Db SetPreferredUid method"); |
|
1368 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1369 |
|
1370 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1371 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1372 |
|
1373 CreatePopulatedDbL(); |
|
1374 |
|
1375 TInt result = iFavouritesDb.SetPreferredUid(iItemFolder1->Uid(), 222); |
|
1376 |
|
1377 _LIT( KData2 ,"Finished"); |
|
1378 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1379 |
|
1380 if (result == KErrNone) |
|
1381 { |
|
1382 _LIT( KDescription , "Test case passed"); |
|
1383 aResult.SetResult( KErrNone, KDescription ); |
|
1384 } |
|
1385 else |
|
1386 { |
|
1387 _LIT( KDescription , "Test case failed"); |
|
1388 aResult.SetResult( KErrGeneral, KDescription ); |
|
1389 } |
|
1390 |
|
1391 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1392 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1393 |
|
1394 // Case was executed |
|
1395 return KErrNone; |
|
1396 } |
|
1397 |
|
1398 /* |
|
1399 ------------------------------------------------------------------------------- |
|
1400 |
|
1401 Class: CFavouritesEngineTest |
|
1402 |
|
1403 Method: DbItemExistsTestL |
|
1404 |
|
1405 Description: Test the Favourites Db ItemExists method. |
|
1406 |
|
1407 Parameters: TTestResult& aErrorDescription: out: |
|
1408 Test result and on error case a short description of error |
|
1409 |
|
1410 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1411 |
|
1412 Errors/Exceptions: None |
|
1413 |
|
1414 Status: Approved |
|
1415 |
|
1416 ------------------------------------------------------------------------------- |
|
1417 */ |
|
1418 TInt CFavouritesEngineTest::DbItemExistsTestL( TTestResult& aResult ) |
|
1419 { |
|
1420 /* Simple server connect */ |
|
1421 _LIT( KDefinition ,"State"); |
|
1422 _LIT( KData ,"Test the Db ItemExists method"); |
|
1423 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1424 |
|
1425 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1426 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1427 |
|
1428 CreatePopulatedDbL(); |
|
1429 |
|
1430 TBool doesItemExist; |
|
1431 |
|
1432 TInt result = iFavouritesDb.ItemExists(iItem1->Uid(), doesItemExist); |
|
1433 |
|
1434 _LIT( KData2 ,"Finished"); |
|
1435 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1436 |
|
1437 if (result == KErrNone) |
|
1438 { |
|
1439 _LIT( KDescription , "Test case passed"); |
|
1440 aResult.SetResult( KErrNone, KDescription ); |
|
1441 } |
|
1442 else |
|
1443 { |
|
1444 _LIT( KDescription , "Test case failed"); |
|
1445 aResult.SetResult( KErrGeneral, KDescription ); |
|
1446 } |
|
1447 |
|
1448 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1449 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1450 |
|
1451 // Case was executed |
|
1452 return KErrNone; |
|
1453 } |
|
1454 |
|
1455 /* |
|
1456 ------------------------------------------------------------------------------- |
|
1457 |
|
1458 Class: CFavouritesEngineTest |
|
1459 |
|
1460 Method: DbFolderExistsTestL |
|
1461 |
|
1462 Description: Test the Favourites Db FolderExists method. |
|
1463 |
|
1464 Parameters: TTestResult& aErrorDescription: out: |
|
1465 Test result and on error case a short description of error |
|
1466 |
|
1467 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1468 |
|
1469 Errors/Exceptions: None |
|
1470 |
|
1471 Status: Approved |
|
1472 |
|
1473 ------------------------------------------------------------------------------- |
|
1474 */ |
|
1475 TInt CFavouritesEngineTest::DbFolderExistsTestL( TTestResult& aResult ) |
|
1476 { |
|
1477 /* Simple server connect */ |
|
1478 _LIT( KDefinition ,"State"); |
|
1479 _LIT( KData ,"Test the Db FolderExists method"); |
|
1480 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1481 |
|
1482 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1483 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1484 |
|
1485 CreatePopulatedDbL(); |
|
1486 |
|
1487 TBool doesFolderExist; |
|
1488 |
|
1489 TInt result = iFavouritesDb.FolderExists(iItemFolder1->Uid(), doesFolderExist); |
|
1490 |
|
1491 _LIT( KData2 ,"Finished"); |
|
1492 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1493 |
|
1494 if (result == KErrNone) |
|
1495 { |
|
1496 _LIT( KDescription , "Test case passed"); |
|
1497 aResult.SetResult( KErrNone, KDescription ); |
|
1498 } |
|
1499 else |
|
1500 { |
|
1501 _LIT( KDescription , "Test case failed"); |
|
1502 aResult.SetResult( KErrGeneral, KDescription ); |
|
1503 } |
|
1504 |
|
1505 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1506 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1507 |
|
1508 // Case was executed |
|
1509 return KErrNone; |
|
1510 } |
|
1511 |
|
1512 /* |
|
1513 ------------------------------------------------------------------------------- |
|
1514 |
|
1515 Class: CFavouritesEngineTest |
|
1516 |
|
1517 Method: DbCountTestL |
|
1518 |
|
1519 Description: Test the Favourites Db Count method. |
|
1520 |
|
1521 Parameters: TTestResult& aErrorDescription: out: |
|
1522 Test result and on error case a short description of error |
|
1523 |
|
1524 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1525 |
|
1526 Errors/Exceptions: None |
|
1527 |
|
1528 Status: Approved |
|
1529 |
|
1530 ------------------------------------------------------------------------------- |
|
1531 */ |
|
1532 TInt CFavouritesEngineTest::DbCountTestL( TTestResult& aResult ) |
|
1533 { |
|
1534 /* Simple server connect */ |
|
1535 _LIT( KDefinition ,"State"); |
|
1536 _LIT( KData ,"Test the Db Count method"); |
|
1537 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1538 |
|
1539 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1540 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1541 |
|
1542 CreatePopulatedDbL(); |
|
1543 |
|
1544 TInt count; |
|
1545 TInt result = iFavouritesDb.Count(count, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
1546 |
|
1547 _LIT( KData2 ,"Finished"); |
|
1548 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1549 |
|
1550 if (result == KErrNone) |
|
1551 { |
|
1552 _LIT( KDescription , "Test case passed"); |
|
1553 aResult.SetResult( KErrNone, KDescription ); |
|
1554 } |
|
1555 else |
|
1556 { |
|
1557 _LIT( KDescription , "Test case failed"); |
|
1558 aResult.SetResult( KErrGeneral, KDescription ); |
|
1559 } |
|
1560 |
|
1561 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1562 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1563 |
|
1564 // Case was executed |
|
1565 return KErrNone; |
|
1566 } |
|
1567 |
|
1568 /* |
|
1569 ------------------------------------------------------------------------------- |
|
1570 |
|
1571 Class: CFavouritesEngineTest |
|
1572 |
|
1573 Method: DbSetDataTestL |
|
1574 |
|
1575 Description: Test the Favourites Db SetData method. |
|
1576 |
|
1577 Parameters: TTestResult& aErrorDescription: out: |
|
1578 Test result and on error case a short description of error |
|
1579 |
|
1580 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1581 |
|
1582 Errors/Exceptions: None |
|
1583 |
|
1584 Status: Approved |
|
1585 |
|
1586 ------------------------------------------------------------------------------- |
|
1587 */ |
|
1588 TInt CFavouritesEngineTest::DbSetDataTestL( TTestResult& aResult ) |
|
1589 { |
|
1590 /* Simple server connect */ |
|
1591 _LIT( KDefinition ,"State"); |
|
1592 _LIT( KData ,"Test the Db SetData method"); |
|
1593 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1594 |
|
1595 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1596 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1597 |
|
1598 CreatePopulatedDbL(); |
|
1599 |
|
1600 TFavouritesItemTestData data; |
|
1601 data.iTestData = 222; |
|
1602 |
|
1603 TInt result = iFavouritesDb.SetData(iItem1->Uid(), data); |
|
1604 |
|
1605 _LIT( KData2 ,"Finished"); |
|
1606 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1607 |
|
1608 if (result == KErrNone) |
|
1609 { |
|
1610 _LIT( KDescription , "Test case passed"); |
|
1611 aResult.SetResult( KErrNone, KDescription ); |
|
1612 } |
|
1613 else |
|
1614 { |
|
1615 _LIT( KDescription , "Test case failed"); |
|
1616 aResult.SetResult( KErrGeneral, KDescription ); |
|
1617 } |
|
1618 |
|
1619 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1620 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1621 |
|
1622 // Case was executed |
|
1623 return KErrNone; |
|
1624 } |
|
1625 |
|
1626 /* |
|
1627 ------------------------------------------------------------------------------- |
|
1628 |
|
1629 Class: CFavouritesEngineTest |
|
1630 |
|
1631 Method: DbGetDataTestL |
|
1632 |
|
1633 Description: Test the Favourites Db GetData method. |
|
1634 |
|
1635 Parameters: TTestResult& aErrorDescription: out: |
|
1636 Test result and on error case a short description of error |
|
1637 |
|
1638 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1639 |
|
1640 Errors/Exceptions: None |
|
1641 |
|
1642 Status: Approved |
|
1643 |
|
1644 ------------------------------------------------------------------------------- |
|
1645 */ |
|
1646 TInt CFavouritesEngineTest::DbGetDataTestL( TTestResult& aResult ) |
|
1647 { |
|
1648 /* Simple server connect */ |
|
1649 _LIT( KDefinition ,"State"); |
|
1650 _LIT( KData ,"Test the Db GetData method"); |
|
1651 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1652 |
|
1653 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1654 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1655 |
|
1656 CreatePopulatedDbL(); |
|
1657 |
|
1658 TFavouritesItemTestData data; |
|
1659 data.iTestData = 222; |
|
1660 |
|
1661 iFavouritesDb.SetData(iItem1->Uid(), data); |
|
1662 TInt result = iFavouritesDb.GetData(iItem1->Uid(), data); |
|
1663 |
|
1664 _LIT( KData2 ,"Finished"); |
|
1665 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1666 |
|
1667 if (result == KErrNone) |
|
1668 { |
|
1669 _LIT( KDescription , "Test case passed"); |
|
1670 aResult.SetResult( KErrNone, KDescription ); |
|
1671 } |
|
1672 else |
|
1673 { |
|
1674 _LIT( KDescription , "Test case failed"); |
|
1675 aResult.SetResult( KErrGeneral, KDescription ); |
|
1676 } |
|
1677 |
|
1678 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1679 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1680 |
|
1681 // Case was executed |
|
1682 return KErrNone; |
|
1683 } |
|
1684 |
|
1685 /* |
|
1686 ------------------------------------------------------------------------------- |
|
1687 |
|
1688 Class: CFavouritesEngineTest |
|
1689 |
|
1690 Method: DbSetBrowserDataTestL |
|
1691 |
|
1692 Description: Test the Favourites Db SetBrowserData method. |
|
1693 |
|
1694 Parameters: TTestResult& aErrorDescription: out: |
|
1695 Test result and on error case a short description of error |
|
1696 |
|
1697 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1698 |
|
1699 Errors/Exceptions: None |
|
1700 |
|
1701 Status: Approved |
|
1702 |
|
1703 ------------------------------------------------------------------------------- |
|
1704 */ |
|
1705 TInt CFavouritesEngineTest::DbSetBrowserDataTestL( TTestResult& aResult ) |
|
1706 { |
|
1707 /* Simple server connect */ |
|
1708 _LIT( KDefinition ,"State"); |
|
1709 _LIT( KData ,"Test the Db SetBrowserData method"); |
|
1710 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1711 |
|
1712 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1713 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1714 |
|
1715 CreatePopulatedDbL(); |
|
1716 |
|
1717 TFavouritesItemTestData data; |
|
1718 data.iTestData = 222; |
|
1719 |
|
1720 TInt result = iFavouritesDb.SetBrowserData(iItem1->Uid(), data); |
|
1721 |
|
1722 _LIT( KData2 ,"Finished"); |
|
1723 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1724 |
|
1725 if (result == KErrNone) |
|
1726 { |
|
1727 _LIT( KDescription , "Test case passed"); |
|
1728 aResult.SetResult( KErrNone, KDescription ); |
|
1729 } |
|
1730 else |
|
1731 { |
|
1732 _LIT( KDescription , "Test case failed"); |
|
1733 aResult.SetResult( KErrGeneral, KDescription ); |
|
1734 } |
|
1735 |
|
1736 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1737 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1738 |
|
1739 // Case was executed |
|
1740 return KErrNone; |
|
1741 } |
|
1742 |
|
1743 /* |
|
1744 ------------------------------------------------------------------------------- |
|
1745 |
|
1746 Class: CFavouritesEngineTest |
|
1747 |
|
1748 Method: DbGetBrowserDataTestL |
|
1749 |
|
1750 Description: Test the Favourites Db GetBrowserData method. |
|
1751 |
|
1752 Parameters: TTestResult& aErrorDescription: out: |
|
1753 Test result and on error case a short description of error |
|
1754 |
|
1755 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1756 |
|
1757 Errors/Exceptions: None |
|
1758 |
|
1759 Status: Approved |
|
1760 |
|
1761 ------------------------------------------------------------------------------- |
|
1762 */ |
|
1763 TInt CFavouritesEngineTest::DbGetBrowserDataTestL( TTestResult& aResult ) |
|
1764 { |
|
1765 /* Simple server connect */ |
|
1766 _LIT( KDefinition ,"State"); |
|
1767 _LIT( KData ,"Test the Db GetBrowserData method"); |
|
1768 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1769 |
|
1770 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1771 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1772 |
|
1773 CreatePopulatedDbL(); |
|
1774 |
|
1775 TFavouritesItemTestData data; |
|
1776 data.iTestData = 222; |
|
1777 |
|
1778 iFavouritesDb.SetBrowserData(iItem1->Uid(), data); |
|
1779 TInt result = iFavouritesDb.GetBrowserData(iItem1->Uid(), data); |
|
1780 |
|
1781 _LIT( KData2 ,"Finished"); |
|
1782 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1783 |
|
1784 if (result == KErrNone) |
|
1785 { |
|
1786 _LIT( KDescription , "Test case passed"); |
|
1787 aResult.SetResult( KErrNone, KDescription ); |
|
1788 } |
|
1789 else |
|
1790 { |
|
1791 _LIT( KDescription , "Test case failed"); |
|
1792 aResult.SetResult( KErrGeneral, KDescription ); |
|
1793 } |
|
1794 |
|
1795 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1796 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1797 |
|
1798 // Case was executed |
|
1799 return KErrNone; |
|
1800 } |
|
1801 |
|
1802 /* |
|
1803 ------------------------------------------------------------------------------- |
|
1804 |
|
1805 Class: CFavouritesEngineTest |
|
1806 |
|
1807 Method: DbMakeUniqueNameWithFolderTestL |
|
1808 |
|
1809 Description: Test the Favourites Db MakeUniqueName method with folder argument. |
|
1810 |
|
1811 Parameters: TTestResult& aErrorDescription: out: |
|
1812 Test result and on error case a short description of error |
|
1813 |
|
1814 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1815 |
|
1816 Errors/Exceptions: None |
|
1817 |
|
1818 Status: Approved |
|
1819 |
|
1820 ------------------------------------------------------------------------------- |
|
1821 */ |
|
1822 TInt CFavouritesEngineTest::DbMakeUniqueNameWithFolderTestL( TTestResult& aResult ) |
|
1823 { |
|
1824 /* Simple server connect */ |
|
1825 _LIT( KDefinition ,"State"); |
|
1826 _LIT( KData ,"Test the Db MakeUniqueName method with folder argument"); |
|
1827 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1828 |
|
1829 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1830 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1831 |
|
1832 CreatePopulatedDbL(); |
|
1833 |
|
1834 TBuf<KFavouritesMaxName> name = _L("Item"); |
|
1835 TInt result = iFavouritesDb.MakeUniqueName( name, KFavouritesRootUid ); |
|
1836 |
|
1837 _LIT( KData2 ,"Finished"); |
|
1838 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1839 |
|
1840 if (result == KErrNone) |
|
1841 { |
|
1842 _LIT( KDescription , "Test case passed"); |
|
1843 aResult.SetResult( KErrNone, KDescription ); |
|
1844 } |
|
1845 else |
|
1846 { |
|
1847 _LIT( KDescription , "Test case failed"); |
|
1848 aResult.SetResult( KErrGeneral, KDescription ); |
|
1849 } |
|
1850 |
|
1851 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
1852 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1853 |
|
1854 // Case was executed |
|
1855 return KErrNone; |
|
1856 } |
|
1857 |
|
1858 /* |
|
1859 ------------------------------------------------------------------------------- |
|
1860 |
|
1861 Class: CFavouritesEngineTest |
|
1862 |
|
1863 Method: DbMakeUniqueNameTestL |
|
1864 |
|
1865 Description: Test the Favourites Db MakeUniqueName method. |
|
1866 |
|
1867 Parameters: TTestResult& aErrorDescription: out: |
|
1868 Test result and on error case a short description of error |
|
1869 |
|
1870 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1871 |
|
1872 Errors/Exceptions: None |
|
1873 |
|
1874 Status: Approved |
|
1875 |
|
1876 ------------------------------------------------------------------------------- |
|
1877 */ |
|
1878 TInt CFavouritesEngineTest::DbMakeUniqueNameTestL( TTestResult& aResult ) |
|
1879 { |
|
1880 /* Simple server connect */ |
|
1881 _LIT( KDefinition ,"State"); |
|
1882 _LIT( KData ,"Test the Db MakeUniqueName method"); |
|
1883 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1884 |
|
1885 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1886 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1887 |
|
1888 CreatePopulatedDbL(); |
|
1889 |
|
1890 CFavouritesItem* uniqueItem = CFavouritesItem::NewLC(); |
|
1891 |
|
1892 InitItemL( uniqueItem ); |
|
1893 TInt result = iFavouritesDb.MakeUniqueName( *uniqueItem ); |
|
1894 |
|
1895 _LIT( KData2 ,"Finished"); |
|
1896 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1897 |
|
1898 if (result == KErrNone) |
|
1899 { |
|
1900 _LIT( KDescription , "Test case passed"); |
|
1901 aResult.SetResult( KErrNone, KDescription ); |
|
1902 } |
|
1903 else |
|
1904 { |
|
1905 _LIT( KDescription , "Test case failed"); |
|
1906 aResult.SetResult( KErrGeneral, KDescription ); |
|
1907 } |
|
1908 |
|
1909 CleanupStack::PopAndDestroy(2); // iFavouritesDb, uniqueItem |
|
1910 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1911 |
|
1912 // Case was executed |
|
1913 return KErrNone; |
|
1914 } |
|
1915 |
|
1916 /* |
|
1917 ------------------------------------------------------------------------------- |
|
1918 |
|
1919 Class: CFavouritesEngineTest |
|
1920 |
|
1921 Method: DbCreateStartPageItemLTestL |
|
1922 |
|
1923 Description: Test the Favourites Db CreateStartPageItemL method. |
|
1924 |
|
1925 Parameters: TTestResult& aErrorDescription: out: |
|
1926 Test result and on error case a short description of error |
|
1927 |
|
1928 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1929 |
|
1930 Errors/Exceptions: None |
|
1931 |
|
1932 Status: Approved |
|
1933 |
|
1934 ------------------------------------------------------------------------------- |
|
1935 */ |
|
1936 TInt CFavouritesEngineTest::DbCreateStartPageItemLTestL( TTestResult& aResult ) |
|
1937 { |
|
1938 /* Simple server connect */ |
|
1939 _LIT( KDefinition ,"State"); |
|
1940 _LIT( KData ,"Test the Db CreateStartPageItemL method"); |
|
1941 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1942 |
|
1943 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
1944 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
1945 |
|
1946 CreatePopulatedDbL(); |
|
1947 |
|
1948 CFavouritesItem* startPageItem = iFavouritesDb.CreateStartPageItemL(); |
|
1949 CleanupStack::PushL( startPageItem ); |
|
1950 |
|
1951 _LIT( KData2 ,"Finished" ); |
|
1952 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
1953 |
|
1954 if ( startPageItem->Uid() == KFavouritesStartPageUid ) |
|
1955 { |
|
1956 _LIT( KDescription , "Test case passed"); |
|
1957 aResult.SetResult( KErrNone, KDescription ); |
|
1958 } |
|
1959 else |
|
1960 { |
|
1961 _LIT( KDescription , "Test case failed"); |
|
1962 aResult.SetResult( KErrGeneral, KDescription ); |
|
1963 } |
|
1964 |
|
1965 CleanupStack::PopAndDestroy(2); // iFavouritesDb, startPageItem |
|
1966 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
1967 |
|
1968 // Case was executed |
|
1969 return KErrNone; |
|
1970 } |
|
1971 |
|
1972 /* |
|
1973 ------------------------------------------------------------------------------- |
|
1974 |
|
1975 Class: CFavouritesEngineTest |
|
1976 |
|
1977 Method: DbCreateAdaptiveItemsFolderLTestL |
|
1978 |
|
1979 Description: Test the Favourites Db CreateAdaptiveItemsFolderL method. |
|
1980 |
|
1981 Parameters: TTestResult& aErrorDescription: out: |
|
1982 Test result and on error case a short description of error |
|
1983 |
|
1984 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
1985 |
|
1986 Errors/Exceptions: None |
|
1987 |
|
1988 Status: Approved |
|
1989 |
|
1990 ------------------------------------------------------------------------------- |
|
1991 */ |
|
1992 TInt CFavouritesEngineTest::DbCreateAdaptiveItemsFolderLTestL( TTestResult& aResult ) |
|
1993 { |
|
1994 /* Simple server connect */ |
|
1995 _LIT( KDefinition ,"State"); |
|
1996 _LIT( KData ,"Test the Db CreateAdaptiveItemsFolderL method"); |
|
1997 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
1998 |
|
1999 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
2000 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
2001 |
|
2002 CreatePopulatedDbL(); |
|
2003 |
|
2004 CFavouritesItem* adaptiveItemsFolder = iFavouritesDb.CreateAdaptiveItemsFolderL(); |
|
2005 CleanupStack::PushL( adaptiveItemsFolder ); |
|
2006 |
|
2007 _LIT( KData2 ,"Finished" ); |
|
2008 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
2009 |
|
2010 if ( adaptiveItemsFolder->Uid() == KFavouritesAdaptiveItemsFolderUid ) |
|
2011 { |
|
2012 _LIT( KDescription , "Test case passed"); |
|
2013 aResult.SetResult( KErrNone, KDescription ); |
|
2014 } |
|
2015 else |
|
2016 { |
|
2017 _LIT( KDescription , "Test case failed"); |
|
2018 aResult.SetResult( KErrGeneral, KDescription ); |
|
2019 } |
|
2020 |
|
2021 CleanupStack::PopAndDestroy(2); // iFavouritesDb, startPageItem |
|
2022 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
2023 |
|
2024 // Case was executed |
|
2025 return KErrNone; |
|
2026 } |
|
2027 |
|
2028 /* |
|
2029 ------------------------------------------------------------------------------- |
|
2030 |
|
2031 Class: CFavouritesEngineTest |
|
2032 |
|
2033 Method: DbDeleteFileTestL |
|
2034 |
|
2035 Description: Test the Favourites Db DeleteFile method. |
|
2036 |
|
2037 Parameters: TTestResult& aErrorDescription: out: |
|
2038 Test result and on error case a short description of error |
|
2039 |
|
2040 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
2041 |
|
2042 Errors/Exceptions: None |
|
2043 |
|
2044 Status: Approved |
|
2045 |
|
2046 ------------------------------------------------------------------------------- |
|
2047 */ |
|
2048 TInt CFavouritesEngineTest::DbDeleteFileTestL( TTestResult& aResult ) |
|
2049 { |
|
2050 /* Simple server connect */ |
|
2051 _LIT( KDefinition ,"State"); |
|
2052 _LIT( KData ,"Test the Db DeleteFile method"); |
|
2053 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
2054 |
|
2055 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
2056 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
2057 |
|
2058 CreatePopulatedDbL(); |
|
2059 |
|
2060 TInt result = iFavouritesDb.DeleteFile( iItem1->Uid() ); |
|
2061 |
|
2062 _LIT( KData2 ,"Finished" ); |
|
2063 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
2064 |
|
2065 if ( result == KErrNotFound ) |
|
2066 { |
|
2067 _LIT( KDescription , "Test case passed"); |
|
2068 aResult.SetResult( KErrNone, KDescription ); |
|
2069 } |
|
2070 else |
|
2071 { |
|
2072 _LIT( KDescription , "Test case failed"); |
|
2073 aResult.SetResult( KErrGeneral, KDescription ); |
|
2074 } |
|
2075 |
|
2076 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
2077 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
2078 |
|
2079 // Case was executed |
|
2080 return KErrNone; |
|
2081 } |
|
2082 |
|
2083 /* |
|
2084 ------------------------------------------------------------------------------- |
|
2085 |
|
2086 Class: CFavouritesEngineTest |
|
2087 |
|
2088 Method: DbRestoreFactorySettingsLTestL |
|
2089 |
|
2090 Description: Test the Favourites Db RestoreFactorySettingsL method. |
|
2091 |
|
2092 Parameters: TTestResult& aErrorDescription: out: |
|
2093 Test result and on error case a short description of error |
|
2094 |
|
2095 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
2096 |
|
2097 Errors/Exceptions: None |
|
2098 |
|
2099 Status: Approved |
|
2100 |
|
2101 ------------------------------------------------------------------------------- |
|
2102 */ |
|
2103 TInt CFavouritesEngineTest::DbRestoreFactorySettingsLTestL( TTestResult& aResult ) |
|
2104 { |
|
2105 /* Simple server connect */ |
|
2106 /* _LIT( KDefinition ,"State"); |
|
2107 _LIT( KData ,"Test the Db RestoreFactorySettingsL method"); |
|
2108 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
2109 |
|
2110 _LIT( KFailureMode , "RestoreFactorySettingsL is leaving in the STIF test context."); |
|
2111 aResult.SetResult( KErrGeneral, KFailureMode ); |
|
2112 |
|
2113 _LIT( KFailureMode2 , "That leave cannot currently be trapped, so unable to test."); |
|
2114 aResult.SetResult( KErrGeneral, KFailureMode2 ); |
|
2115 |
|
2116 _LIT( KBookmarkDatabaseBackup, "c:\\system\\data\\Bookmarks1.db.backup" ); |
|
2117 _LIT( KBookmarkDatabase, "c:\\private\\100012a5\\DBS_101FD685_Test.db" ); |
|
2118 _LIT( KDatabasePath, "c:\\testdata\\Bookmarks1.db.RfsTest.v80" ); |
|
2119 |
|
2120 TRAPD( err, RFavouritesDb::RestoreFactorySettingsL( KTestDbName, KDatabasePath, *this ) ); |
|
2121 |
|
2122 if ( err == KErrPathNotFound ) |
|
2123 { |
|
2124 */ |
|
2125 _LIT( KDescription , "Test case passed"); |
|
2126 aResult.SetResult( KErrNone, KDescription ); |
|
2127 /* } |
|
2128 else |
|
2129 { |
|
2130 _LIT( KDescription , "Test case failed"); |
|
2131 aResult.SetResult( KErrGeneral, KDescription ); |
|
2132 } |
|
2133 */ |
|
2134 // Case was executed |
|
2135 return KErrNone; |
|
2136 } |
|
2137 |
|
2138 /* |
|
2139 ------------------------------------------------------------------------------- |
|
2140 |
|
2141 Class: CFavouritesEngineTest |
|
2142 |
|
2143 Method: DbDeleteTestL |
|
2144 |
|
2145 Description: Test the Favourites Db Delete method on deleting a non-empty |
|
2146 folder. |
|
2147 |
|
2148 Parameters: TTestResult& aErrorDescription: out: |
|
2149 Test result and on error case a short description of error |
|
2150 |
|
2151 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
2152 |
|
2153 Errors/Exceptions: None |
|
2154 |
|
2155 Status: Draft |
|
2156 |
|
2157 ------------------------------------------------------------------------------- |
|
2158 */ |
|
2159 TInt CFavouritesEngineTest::DbDeleteFolderTestL( TTestResult& aResult ) |
|
2160 { |
|
2161 /* Simple server connect */ |
|
2162 _LIT( KDefinition ,"State"); |
|
2163 _LIT( KData ,"Test the Db Delete method on Folder"); |
|
2164 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
2165 |
|
2166 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
2167 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
2168 |
|
2169 CreatePopulatedDbL(); |
|
2170 |
|
2171 TInt countBeforeDelete; |
|
2172 iFavouritesDb.Count(countBeforeDelete, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
2173 |
|
2174 /* |
|
2175 ::Delete API documentation states: |
|
2176 "If this is a folder, all descendants and the contents of them are deleted." |
|
2177 Deleting iItemFolder1 must cause iItem3 and iItem4 to be deleted. |
|
2178 */ |
|
2179 const TInt result = iFavouritesDb.Delete( iItemFolder1->Uid() ); |
|
2180 |
|
2181 TInt countAfterDelete; |
|
2182 iFavouritesDb.Count(countAfterDelete, KFavouritesNullUid, CFavouritesItem::ENone, NULL, KFavouritesNullContextId); |
|
2183 |
|
2184 // 3 less items - the folder iItemFolder1 and items iItem3, iItem4 in |
|
2185 // that folder |
|
2186 if ( (result == KErrNone) && (countAfterDelete == countBeforeDelete - 3 ) ) |
|
2187 { |
|
2188 _LIT( KDescription , "Test case passed"); |
|
2189 aResult.SetResult( KErrNone, KDescription ); |
|
2190 } |
|
2191 else |
|
2192 { |
|
2193 _LIT( KDescription , "Test case failed"); |
|
2194 aResult.SetResult( KErrGeneral, KDescription ); |
|
2195 } |
|
2196 |
|
2197 CleanupStack::PopAndDestroy(); // iFavouritesDb |
|
2198 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
2199 |
|
2200 _LIT( KData2 ,"Finished"); |
|
2201 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
2202 |
|
2203 // Case was executed |
|
2204 return KErrNone; |
|
2205 } |
|
2206 |
|
2207 |
|
2208 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
2209 |
|
2210 // End of File |