1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // [INCLUDE FILES] - do not remove |
|
19 #include <e32svr.h> |
|
20 #include <e32base.h> |
|
21 #include <StifParser.h> |
|
22 #include <StifTestInterface.h> |
|
23 #include "CVIMPSTStorageContactList_UT.h" |
|
24 #include "vimpststorageutils.h" |
|
25 #include "vimpstdebugassert.h" |
|
26 #include "vimpststorageutils.h" |
|
27 #include "tvimpststoragepanics.h" |
|
28 #include "cvimpststoragecontact.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CCVIMPSTStorageContactList_UT::Delete |
|
35 // Delete here all resources allocated and opened from test methods. |
|
36 // Called from destructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void CCVIMPSTStorageContactList_UT::Delete() |
|
40 { |
|
41 |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CCVIMPSTStorageContactList_UT::RunMethodL |
|
46 // Run specified method. Contains also table of test mothods and their names. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 TInt CCVIMPSTStorageContactList_UT::RunMethodL( |
|
50 CStifItemParser& aItem ) |
|
51 { |
|
52 |
|
53 static TStifFunctionInfo const KFunctions[] = |
|
54 { |
|
55 // Copy this line for every implemented function. |
|
56 // First string is the function name used in TestScripter script file. |
|
57 // Second is the actual implementation member function. |
|
58 ENTRY( "Test_NewL", CCVIMPSTStorageContactList_UT::Test_NewL ), |
|
59 ENTRY( "Test_ListId", CCVIMPSTStorageContactList_UT::Test_ListId ), |
|
60 ENTRY( "Test_DisplayName", CCVIMPSTStorageContactList_UT::Test_DisplayName ), |
|
61 ENTRY( "Test_AddContactToList", CCVIMPSTStorageContactList_UT::Test_AddContactToList ), |
|
62 ENTRY( "Test_RemoveContactFromList", CCVIMPSTStorageContactList_UT::Test_RemoveContactFromList ), |
|
63 ENTRY( "Test_Count", CCVIMPSTStorageContactList_UT::Test_Count ), |
|
64 ENTRY( "Test_FilteredContact", CCVIMPSTStorageContactList_UT::Test_FilteredContact ), |
|
65 ENTRY( "Test_FilterAllowsContact", CCVIMPSTStorageContactList_UT::Test_FilterAllowsContact ), |
|
66 ENTRY( "Test_FilteredCount", CCVIMPSTStorageContactList_UT::Test_FilteredCount ), |
|
67 ENTRY( "Test_FindIndexOfContact", CCVIMPSTStorageContactList_UT::Test_FindIndexOfContact ), |
|
68 |
|
69 //ADD NEW ENTRY HERE |
|
70 // [test cases entries] - Do not remove |
|
71 |
|
72 }; |
|
73 |
|
74 const TInt count = sizeof( KFunctions ) / |
|
75 sizeof( TStifFunctionInfo ); |
|
76 |
|
77 return RunInternalL( KFunctions, count, aItem ); |
|
78 |
|
79 } |
|
80 //----------------------------------------------------------------- |
|
81 // CCVIMPSTStorageContactList_UT::Test_NewL |
|
82 // Function to test the NewL function of StorageContactList. |
|
83 //----------------------------------------------------------------- |
|
84 // |
|
85 TInt CCVIMPSTStorageContactList_UT::Test_NewL( CStifItemParser& aItem ) |
|
86 { |
|
87 |
|
88 TInt result = KErrGeneral; |
|
89 |
|
90 TPtrC listId; |
|
91 TPtrC displayName; |
|
92 |
|
93 aItem.GetNextString( listId ); |
|
94 if( listId.Compare( _L("null") ) == 0 ) |
|
95 { |
|
96 listId.Set( KNullDesC ); |
|
97 } |
|
98 |
|
99 aItem.GetNextString( displayName ); |
|
100 if( displayName.Compare( _L("null") ) == 0 ) |
|
101 { |
|
102 displayName.Set( KNullDesC ); |
|
103 } |
|
104 |
|
105 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
106 |
|
107 CVIMPSTStorageContactList* contactList = |
|
108 CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
109 |
|
110 if( contactList ) |
|
111 { |
|
112 result = KErrNone; |
|
113 delete contactList; |
|
114 } |
|
115 |
|
116 return result; |
|
117 |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------- |
|
121 // CCVIMPSTStorageContactList_UT::Test_ListId |
|
122 // Function to test the ListId function of StorageContactList. |
|
123 // ----------------------------------------------------------- |
|
124 // |
|
125 TInt CCVIMPSTStorageContactList_UT::Test_ListId( CStifItemParser& aItem ) |
|
126 { |
|
127 TInt result = KErrGeneral; |
|
128 |
|
129 TPtrC listId; |
|
130 TPtrC displayName; |
|
131 |
|
132 aItem.GetNextString( listId ); |
|
133 if( listId.Compare( _L("null") ) == 0 ) |
|
134 { |
|
135 listId.Set( KNullDesC ); |
|
136 } |
|
137 |
|
138 displayName.Set( KNullDesC ); |
|
139 |
|
140 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
141 |
|
142 CVIMPSTStorageContactList* contactList = |
|
143 CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
144 |
|
145 TPtrC resultListId; |
|
146 resultListId.Set(contactList->ListId()); |
|
147 |
|
148 if( listId.Compare( resultListId ) == 0 ) |
|
149 { |
|
150 result = KErrNone; |
|
151 } |
|
152 |
|
153 if( contactList ) |
|
154 delete contactList; |
|
155 |
|
156 return result; |
|
157 |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------- |
|
161 // CCVIMPSTStorageContactList_UT::Test_DisplayName |
|
162 // Function to test the ListId function of StorageContactList. |
|
163 // ----------------------------------------------------------- |
|
164 // |
|
165 TInt CCVIMPSTStorageContactList_UT::Test_DisplayName( CStifItemParser& aItem ) |
|
166 { |
|
167 TInt result = KErrGeneral; |
|
168 |
|
169 TPtrC listId; |
|
170 TPtrC displayName; |
|
171 |
|
172 aItem.GetNextString( displayName ); |
|
173 if( displayName.Compare( _L("null") ) == 0 ) |
|
174 { |
|
175 displayName.Set( KNullDesC ); |
|
176 } |
|
177 aItem.GetNextString( listId ); |
|
178 if( listId.Compare( _L("null") ) == 0 ) |
|
179 { |
|
180 listId.Set( KNullDesC ); |
|
181 } |
|
182 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
183 |
|
184 CVIMPSTStorageContactList* contactList = |
|
185 CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
186 |
|
187 TPtrC resultDisplayName; |
|
188 resultDisplayName.Set(contactList->DisplayName() ); |
|
189 |
|
190 if( displayName.Compare( resultDisplayName ) == 0 ) |
|
191 { |
|
192 result = KErrNone; |
|
193 } |
|
194 |
|
195 if( contactList ) |
|
196 delete contactList; |
|
197 |
|
198 return result; |
|
199 |
|
200 } |
|
201 |
|
202 // ---------------------------------------------------------- |
|
203 // CCVIMPSTStorageContactList_UT::Test_AddContactToList |
|
204 // Function to test the AddStorageContactToCacheL function of StorageContactList. |
|
205 // ----------------------------------------------------------- |
|
206 // |
|
207 |
|
208 TInt CCVIMPSTStorageContactList_UT::Test_AddContactToList( CStifItemParser& aItem ) |
|
209 { |
|
210 TInt result = KErrNotFound; |
|
211 |
|
212 TInt flag; |
|
213 |
|
214 aItem.GetNextInt( flag ); |
|
215 |
|
216 CVIMPSTStorageContact* contact = NULL; |
|
217 |
|
218 //TVIMPSTEnums::TOnlineStatus status; |
|
219 TBuf<64> userId; |
|
220 TBuf<64> displayName; |
|
221 |
|
222 TBuf<64> listId; |
|
223 |
|
224 |
|
225 userId.Copy( _L("jbl@nokia.com") ); |
|
226 displayName.Copy( _L("Jabber Limited") ); |
|
227 listId.Copy( _L("mycontacts") ); |
|
228 |
|
229 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
230 |
|
231 displayName.Copy( _L("my list") ); |
|
232 CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
233 |
|
234 TInt index = 0; // first element. |
|
235 TInt err = 0; // no error |
|
236 switch( flag ) |
|
237 { |
|
238 case 1: |
|
239 { |
|
240 // this case tests addition of a normal contact to |
|
241 // the contactlist. |
|
242 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
243 err = list->AddStorageContactToCacheL( contact, index ); |
|
244 |
|
245 if( 0 == err ) |
|
246 result = KErrNone; |
|
247 |
|
248 break; |
|
249 } |
|
250 case 2: |
|
251 { |
|
252 // this case tests addition of a null contact to the |
|
253 // contactlist. |
|
254 err = list->AddStorageContactToCacheL( contact, index ); |
|
255 |
|
256 if( KErrArgument == err ) |
|
257 result = KErrNone; |
|
258 |
|
259 break; |
|
260 } |
|
261 case 3: |
|
262 { |
|
263 // this case tests addition of a contact by passing |
|
264 // positive index. |
|
265 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
266 index = 2; |
|
267 |
|
268 err = list->AddStorageContactToCacheL( contact, index ); |
|
269 |
|
270 if( 0 == err ) |
|
271 result = KErrNone; |
|
272 |
|
273 break; |
|
274 } |
|
275 case 4: |
|
276 { |
|
277 // this case tests addition of a contact by passing negative |
|
278 // index. |
|
279 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
280 index = -2; |
|
281 |
|
282 err = list->AddStorageContactToCacheL( contact, index ); |
|
283 |
|
284 if( 0 == err ) |
|
285 result = KErrNone; |
|
286 |
|
287 break; |
|
288 } |
|
289 case 5: |
|
290 { |
|
291 // this case tests addition of a contact by passing zero |
|
292 // index. |
|
293 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
294 index = 0; |
|
295 |
|
296 err = list->AddStorageContactToCacheL( contact, index ); |
|
297 |
|
298 if( 0 == err ) |
|
299 result = KErrNone; |
|
300 |
|
301 break; |
|
302 } |
|
303 case 6: |
|
304 { |
|
305 // This case adds same contact twice. |
|
306 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
307 list->AddStorageContactToCacheL( contact, index ); |
|
308 |
|
309 index++; |
|
310 |
|
311 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
312 err = list->AddStorageContactToCacheL( contact, index ); |
|
313 |
|
314 if( KErrAlreadyExists == err ) |
|
315 result = KErrNone; |
|
316 |
|
317 break; |
|
318 } |
|
319 case 7: |
|
320 { |
|
321 |
|
322 TInt err1, err2, err3; |
|
323 |
|
324 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
325 err1 = list->AddStorageContactToCacheL( contact, index ); |
|
326 |
|
327 userId.Copy( _L("bose@nokia.com") ); |
|
328 displayName.Copy( _L("Boss") ); |
|
329 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
330 err2 = list->AddStorageContactToCacheL( contact, index ); |
|
331 |
|
332 userId.Copy( _L("logitect@nokia.com") ); |
|
333 displayName.Copy( _L("Logis") ); |
|
334 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
335 err3 = list->AddStorageContactToCacheL( contact, index ); |
|
336 |
|
337 if( !err1 && !err2 && !err3) |
|
338 result = KErrNone; |
|
339 |
|
340 break; |
|
341 } |
|
342 |
|
343 } |
|
344 return result; |
|
345 |
|
346 } |
|
347 |
|
348 // ---------------------------------------------------------- |
|
349 // CCVIMPSTStorageContactList_UT::Test_RemoveContactFromList |
|
350 // Function to test the RemoveContactFromList function of StorageContactList. |
|
351 // ----------------------------------------------------------- |
|
352 // |
|
353 |
|
354 TInt CCVIMPSTStorageContactList_UT::Test_RemoveContactFromList( CStifItemParser& aItem ) |
|
355 { |
|
356 TInt result = KErrGeneral; |
|
357 |
|
358 /* Currently no test cases related to this function |
|
359 * because we phonebook is stubbed and contactlink |
|
360 * is always returned as null. |
|
361 * Once corrected, test cases can be written. |
|
362 */ |
|
363 |
|
364 return result; |
|
365 } |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 TInt CCVIMPSTStorageContactList_UT::Test_Count( CStifItemParser& aItem ) |
|
369 { |
|
370 |
|
371 TInt result = KErrGeneral; |
|
372 |
|
373 TInt flag; |
|
374 |
|
375 aItem.GetNextInt( flag ); |
|
376 |
|
377 TBuf<64> userId; |
|
378 TBuf<64> listId; |
|
379 TBuf<64> displayName; |
|
380 CVIMPSTStorageContact* contact = NULL; |
|
381 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
382 listId.Copy( _L("mycontacts") ); |
|
383 displayName.Copy( _L("my list") ); |
|
384 CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
385 |
|
386 TInt count = 0; // contacts count |
|
387 TInt index = 0; |
|
388 |
|
389 switch( flag ) |
|
390 { |
|
391 case 1: |
|
392 { |
|
393 userId.Copy( _L("logitect@nokia.com") ); |
|
394 displayName.Copy( _L("Logis") ); |
|
395 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
396 if( !list->AddStorageContactToCacheL( contact, index ) ) |
|
397 { |
|
398 count++; |
|
399 } |
|
400 |
|
401 userId.Copy( _L("bose@nokia.com") ); |
|
402 displayName.Copy( _L("Boss") ); |
|
403 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
404 if( !list->AddStorageContactToCacheL( contact, index ) ) |
|
405 { |
|
406 count++; |
|
407 } |
|
408 |
|
409 // adding same contact, won't be added to list. |
|
410 userId.Copy( _L("logitect@nokia.com") ); |
|
411 displayName.Copy( _L("argen") ); |
|
412 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
413 if( !list->AddStorageContactToCacheL( contact, index ) ) |
|
414 { |
|
415 count++; |
|
416 } |
|
417 |
|
418 break; |
|
419 } |
|
420 case 2: |
|
421 default: |
|
422 { |
|
423 // No contacts added |
|
424 break; |
|
425 } |
|
426 } |
|
427 |
|
428 TInt listCount = list->Count(); |
|
429 |
|
430 if( listCount == count ) |
|
431 { |
|
432 result = KErrNone; |
|
433 } |
|
434 |
|
435 delete list; |
|
436 delete sorter; |
|
437 |
|
438 return result; |
|
439 |
|
440 } |
|
441 // ---------------------------------------------------------- |
|
442 // CCVIMPSTStorageContactList_UT::Test_Count |
|
443 // Function to test the Count function of StorageContactList. |
|
444 // ----------------------------------------------------------- |
|
445 // |
|
446 |
|
447 TInt CCVIMPSTStorageContactList_UT::Test_FilteredContact( CStifItemParser& aItem ) |
|
448 { |
|
449 TInt result = KErrGeneral; |
|
450 |
|
451 MVIMPSTStorageContactList* list = GetList(); |
|
452 |
|
453 TInt flag; |
|
454 aItem.GetNextInt( flag ); |
|
455 |
|
456 switch( flag ) |
|
457 { |
|
458 case 1: |
|
459 { |
|
460 // Variant 1. |
|
461 MVIMPSTStorageContact& filteredContact = |
|
462 list->FilteredContact( 0, TVIMPSTEnums::EFilterNonOffline); |
|
463 //MVIMPSTStorageContact& filteredContact = (*list[0] |
|
464 TInt compare = ( (*list)[0].UserId() ).Compare( filteredContact.UserId() ); |
|
465 if( compare == 0 ) |
|
466 result = KErrNone; |
|
467 break; |
|
468 } |
|
469 case 2: |
|
470 { |
|
471 // Variant 2. |
|
472 MVIMPSTStorageContact& filteredContact = |
|
473 list->FilteredContact( 5, TVIMPSTEnums::EFilterNonOffline); |
|
474 TInt compare = ( (*list)[5].UserId() ).Compare( filteredContact.UserId() ); |
|
475 if( compare == 0 ) |
|
476 result = KErrNone; |
|
477 break; |
|
478 } |
|
479 case 3: |
|
480 { |
|
481 // Variant 3. |
|
482 delete (CVIMPSTStorageContactSorter *) list; |
|
483 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
484 list = CVIMPSTStorageContactList::NewL( *sorter, _L("MyList"), _L("display") ); |
|
485 MVIMPSTStorageContact& filteredContact = |
|
486 list->FilteredContact( 1, TVIMPSTEnums::EFilterAway); |
|
487 TInt compare = ( (*list)[6].UserId() ).Compare( filteredContact.UserId() ); |
|
488 if( compare == 0 ) |
|
489 result = KErrNone; |
|
490 break; |
|
491 } |
|
492 } |
|
493 |
|
494 delete (CVIMPSTStorageContactSorter *) list; |
|
495 |
|
496 return result; |
|
497 } |
|
498 |
|
499 // ---------------------------------------------------------- |
|
500 // CCVIMPSTStorageContactList_UT::Test_Count |
|
501 // Function to test the Count function of StorageContactList. |
|
502 // ----------------------------------------------------------- |
|
503 // |
|
504 |
|
505 TInt CCVIMPSTStorageContactList_UT::Test_FilterAllowsContact( CStifItemParser& aItem ) |
|
506 { |
|
507 TInt result = KErrGeneral; |
|
508 |
|
509 TInt inputFilter; |
|
510 TInt testCaseNumber; |
|
511 TPtrC inputString; |
|
512 TVIMPSTEnums::TFilterType filter; |
|
513 |
|
514 aItem.GetNextString( inputString ); |
|
515 aItem.GetNextInt( inputFilter ); |
|
516 aItem.GetNextInt( testCaseNumber ); |
|
517 |
|
518 CVIMPSTStorageContact* contact = NULL; |
|
519 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
520 |
|
521 // Creating a contactList |
|
522 TBuf<64> listId; |
|
523 TBuf<64> displayName; |
|
524 |
|
525 listId.Copy( _L("contacts.manu") ); |
|
526 displayName.Copy( _L("Personal Contacts") ); |
|
527 CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
528 |
|
529 TVIMPSTEnums::TOnlineStatus status; |
|
530 // Create a list of 8 contacts |
|
531 |
|
532 filter = GetFilter( inputFilter ); |
|
533 |
|
534 if( inputString.Compare( _L("null") ) != 0 ) |
|
535 { |
|
536 TBuf<64> userId; |
|
537 TInt index = 0; |
|
538 // contact number 1 |
|
539 userId.Copy( _L("prashanth.ds@infosys.com") ); |
|
540 if( 31 != testCaseNumber ) |
|
541 { |
|
542 status = TVIMPSTEnums::EOnline; |
|
543 } |
|
544 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
545 contact->SetOnlineStatus( status ); |
|
546 list->AddStorageContactToCacheL( contact, index ); |
|
547 } |
|
548 |
|
549 TBool funcValue; |
|
550 funcValue = list->FilterAllowsContact( contact, filter ); |
|
551 |
|
552 if( !funcValue && testCaseNumber == 28 ) |
|
553 result = KErrNone; |
|
554 |
|
555 if( funcValue && testCaseNumber == 29 ) |
|
556 result = KErrNone; |
|
557 |
|
558 if( !funcValue && testCaseNumber == 30 ) |
|
559 result = KErrNone; |
|
560 |
|
561 if( funcValue && testCaseNumber == 31 ) |
|
562 result = KErrNone; |
|
563 |
|
564 delete sorter; |
|
565 delete list; |
|
566 |
|
567 return result; |
|
568 } |
|
569 |
|
570 // ---------------------------------------------------------- |
|
571 // CCVIMPSTStorageContactList_UT::FilteredCount |
|
572 // ----------------------------------------------------------- |
|
573 // |
|
574 |
|
575 TInt CCVIMPSTStorageContactList_UT::Test_FilteredCount( CStifItemParser& aItem ) |
|
576 { |
|
577 TInt result = KErrGeneral; |
|
578 |
|
579 MVIMPSTStorageContactList* list = GetList(); |
|
580 |
|
581 TInt inputFilter; |
|
582 |
|
583 aItem.GetNextInt( inputFilter ); |
|
584 |
|
585 TVIMPSTEnums::TFilterType filter; |
|
586 |
|
587 switch( inputFilter ) |
|
588 { |
|
589 case 1: |
|
590 { |
|
591 filter = TVIMPSTEnums::EFilterNotDefined; |
|
592 if( 0 == list->FilteredCount( filter ) ) |
|
593 { |
|
594 result = KErrNone; |
|
595 } |
|
596 } |
|
597 break; |
|
598 case 2: |
|
599 { |
|
600 filter = TVIMPSTEnums::EFilterOnline; |
|
601 if( 4 == list->FilteredCount( filter ) ) |
|
602 { |
|
603 result = KErrNone; |
|
604 } |
|
605 } |
|
606 break; |
|
607 case 3: |
|
608 { |
|
609 if( list->FilteredCount( filter ) ) |
|
610 { |
|
611 result = KErrNone; |
|
612 } |
|
613 } |
|
614 break; |
|
615 } |
|
616 delete (CVIMPSTStorageContactSorter *)list; |
|
617 return result; |
|
618 } |
|
619 |
|
620 |
|
621 TInt CCVIMPSTStorageContactList_UT::Test_FindIndexOfContact( CStifItemParser& aItem ) |
|
622 { |
|
623 TInt result = KErrGeneral; |
|
624 |
|
625 CVIMPSTStorageContactList* list = (CVIMPSTStorageContactList *) GetList(); |
|
626 |
|
627 MVIMPSTStorageContact* contact = NULL; |
|
628 |
|
629 contact = CVIMPSTStorageContact::NewL( KNullDesC, KNullDesC ); |
|
630 |
|
631 TInt inputFilter; |
|
632 |
|
633 aItem.GetNextInt( inputFilter ); |
|
634 |
|
635 TVIMPSTEnums::TFilterType filter; |
|
636 |
|
637 filter = TVIMPSTEnums::EFilterOnline; |
|
638 |
|
639 switch( inputFilter ) |
|
640 { |
|
641 case 1: |
|
642 { |
|
643 MVIMPSTStorageContact& contact1 = (*list)[0]; |
|
644 |
|
645 if( 0 == list->FindIndexOfContact( &contact1 ) ) |
|
646 { |
|
647 result = KErrNone; |
|
648 } |
|
649 } |
|
650 break; |
|
651 case 2: |
|
652 { |
|
653 MVIMPSTStorageContact& contact1 = (*list)[2]; |
|
654 |
|
655 if( 2 == list->FindIndexOfContact( &contact1, filter ) ) |
|
656 { |
|
657 result = KErrNone; |
|
658 } |
|
659 } |
|
660 break; |
|
661 case 3: |
|
662 { |
|
663 MVIMPSTStorageContact& contact1 = (*list)[5]; |
|
664 |
|
665 if( KErrNotFound == list->FindIndexOfContact( &contact1, filter ) ) |
|
666 { |
|
667 result = KErrNone; |
|
668 } |
|
669 } |
|
670 break; |
|
671 } |
|
672 |
|
673 delete (CVIMPSTStorageContact *) contact; |
|
674 delete (CVIMPSTStorageContactSorter *)list; |
|
675 |
|
676 return result; |
|
677 } |
|
678 |
|
679 // ---------------------------------------------------------- |
|
680 // CCVIMPSTStorageContactList_UT::GetFilter |
|
681 // ----------------------------------------------------------- |
|
682 // |
|
683 |
|
684 TVIMPSTEnums::TFilterType CCVIMPSTStorageContactList_UT::GetFilter( TInt aFilter ) |
|
685 { |
|
686 TVIMPSTEnums::TFilterType filter; |
|
687 switch( aFilter ) |
|
688 { |
|
689 case -1: |
|
690 { |
|
691 filter = TVIMPSTEnums::EFilterNotDefined; |
|
692 } |
|
693 break; |
|
694 case 0: |
|
695 { |
|
696 filter = TVIMPSTEnums::EFilterAll; |
|
697 } |
|
698 break; |
|
699 case 1: |
|
700 { |
|
701 filter = TVIMPSTEnums::EFilterAndOperation; |
|
702 } |
|
703 break; |
|
704 case 2: |
|
705 { |
|
706 filter = TVIMPSTEnums::EFilterOnline; |
|
707 } |
|
708 break; |
|
709 case 4: |
|
710 { |
|
711 filter = TVIMPSTEnums::EFilterNonBlocked; |
|
712 } |
|
713 break; |
|
714 case 8: |
|
715 { |
|
716 filter = TVIMPSTEnums::EFilterAway; |
|
717 } |
|
718 break; |
|
719 case 16: |
|
720 { |
|
721 filter = TVIMPSTEnums::EFilterNonOffline; |
|
722 } |
|
723 break; |
|
724 |
|
725 } |
|
726 |
|
727 return filter; |
|
728 |
|
729 } |
|
730 |
|
731 // ---------------------------------------------------------- |
|
732 // CCVIMPSTStorageContactList_UT::GetStatus |
|
733 // ----------------------------------------------------------- |
|
734 // |
|
735 TVIMPSTEnums::TOnlineStatus CCVIMPSTStorageContactList_UT::GetStatus( TInt aStatus ) |
|
736 { |
|
737 TVIMPSTEnums::TOnlineStatus status; |
|
738 switch( aStatus ) |
|
739 { |
|
740 case 0: |
|
741 { |
|
742 status = TVIMPSTEnums::EUnknown; |
|
743 } |
|
744 break; |
|
745 case 1: |
|
746 { |
|
747 status = TVIMPSTEnums::EOffline; |
|
748 } |
|
749 break; |
|
750 case 2: |
|
751 { |
|
752 status = TVIMPSTEnums::EOnline; |
|
753 } |
|
754 break; |
|
755 case 3: |
|
756 { |
|
757 status = TVIMPSTEnums::EInvisible; |
|
758 } |
|
759 break; |
|
760 case 4: |
|
761 { |
|
762 status = TVIMPSTEnums::EAway; |
|
763 } |
|
764 break; |
|
765 case 5: |
|
766 { |
|
767 status = TVIMPSTEnums::EBusy; |
|
768 } |
|
769 break; |
|
770 case 6: |
|
771 { |
|
772 status = TVIMPSTEnums::EOnPhone; |
|
773 } |
|
774 break; |
|
775 case 7: |
|
776 { |
|
777 status = TVIMPSTEnums::EDoNotDisturb; |
|
778 } |
|
779 break; |
|
780 case 8: |
|
781 { |
|
782 status = TVIMPSTEnums::EPending; |
|
783 } |
|
784 break; |
|
785 case 9: |
|
786 { |
|
787 status = TVIMPSTEnums::EBlocked; |
|
788 } |
|
789 break; |
|
790 } |
|
791 return status; |
|
792 |
|
793 } |
|
794 |
|
795 MVIMPSTStorageContactList* CCVIMPSTStorageContactList_UT::GetList( ) |
|
796 { |
|
797 CVIMPSTStorageContact* contact = NULL; |
|
798 CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL(); |
|
799 |
|
800 // Creating a contactList |
|
801 TBuf<64> listId; |
|
802 TBuf<64> displayName; |
|
803 |
|
804 listId.Copy( _L("contacts.manu") ); |
|
805 displayName.Copy( _L("Personal Contacts") ); |
|
806 |
|
807 CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *sorter, listId, displayName ); |
|
808 |
|
809 // Create a list of 8 contacts |
|
810 |
|
811 TBuf<64> userId; |
|
812 TVIMPSTEnums::TOnlineStatus status; |
|
813 TInt index = 0; |
|
814 // contact number 1 |
|
815 userId.Copy( _L("prashanth.ds@infosys.com") ); |
|
816 displayName.Copy( _L("prashanth") ); |
|
817 status = TVIMPSTEnums::EOnline; |
|
818 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
819 contact->SetOnlineStatus( status ); |
|
820 list->AddStorageContactToCacheL( contact, index ); |
|
821 |
|
822 // contact number 2 |
|
823 userId.Copy( _L("dovin.fern@tcs.com") ); |
|
824 displayName.Copy( _L("dovin") ); |
|
825 status = TVIMPSTEnums::EOnline; |
|
826 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
827 contact->SetOnlineStatus( status ); |
|
828 list->AddStorageContactToCacheL( contact, index ); |
|
829 |
|
830 // contact number 3 |
|
831 userId.Copy( _L("basavaraj.hn@accenture.com") ); |
|
832 displayName.Copy( _L("basava") ); |
|
833 status = TVIMPSTEnums::EOnline; |
|
834 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
835 contact->SetOnlineStatus( status ); |
|
836 list->AddStorageContactToCacheL( contact, index ); |
|
837 |
|
838 // contact number 4 |
|
839 userId.Copy( _L("nandan.av@tcs.com") ); |
|
840 displayName.Copy( _L("nandan") ); |
|
841 status = TVIMPSTEnums::EOnline; |
|
842 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
843 contact->SetOnlineStatus( status ); |
|
844 list->AddStorageContactToCacheL( contact, index ); |
|
845 |
|
846 // contact number 5 |
|
847 userId.Copy( _L("mithun.shettigara@tataelxsi.com") ); |
|
848 displayName.Copy( _L("Mithun") ); |
|
849 status = TVIMPSTEnums::EOffline; |
|
850 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
851 contact->SetOnlineStatus( status ); |
|
852 list->AddStorageContactToCacheL( contact, index ); |
|
853 |
|
854 // contact number 6 |
|
855 userId.Copy( _L("santosh.wagle@bel.com") ); |
|
856 displayName.Copy( _L("Santhosh") ); |
|
857 status = TVIMPSTEnums::EAway; |
|
858 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
859 contact->SetOnlineStatus( status ); |
|
860 list->AddStorageContactToCacheL( contact, index ); |
|
861 |
|
862 // contact number 7 |
|
863 userId.Copy( _L("sandeep.hebbar@tcs.com") ); |
|
864 displayName.Copy( _L("Sandeep") ); |
|
865 status = TVIMPSTEnums::EPending; |
|
866 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
867 contact->SetOnlineStatus( status ); |
|
868 list->AddStorageContactToCacheL( contact, index ); |
|
869 |
|
870 // contact number 8 |
|
871 userId.Copy( _L("niranjan.murthy@mindtree.com") ); |
|
872 displayName.Copy( _L("Niranjan") ); |
|
873 status = TVIMPSTEnums::EBusy; |
|
874 contact = CVIMPSTStorageContact::NewL( userId, displayName ); |
|
875 contact->SetOnlineStatus( status ); |
|
876 list->AddStorageContactToCacheL( contact, index ); |
|
877 |
|
878 |
|
879 return list; |
|
880 |
|
881 } |
|
882 // [End of File] - Do not remove |
|