|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32std.h> |
|
17 #include <e32test.h> |
|
18 #include <cntdb.h> |
|
19 #include <cntitem.h> |
|
20 #include <cntfldst.h> |
|
21 #include "t_utils2.h" |
|
22 #include "t_groupview.h" |
|
23 #include "CContactDbEventQueue.h" |
|
24 |
|
25 // Test Macro |
|
26 LOCAL_D RTest test(_L("T_GROUPVIEW")); |
|
27 |
|
28 // |
|
29 // Constants. |
|
30 // |
|
31 |
|
32 _LIT(KTestName,"@SYMTESTCaseID:PIM-T-GROUPVIEW-0001 t_groupview"); |
|
33 _LIT(KLogFileName,"t_groupview.log"); |
|
34 |
|
35 _LIT(KDbFileName,"c:t_groupview.cdb"); |
|
36 |
|
37 _LIT(KTextDefSeparator,""); |
|
38 |
|
39 const TInt KNumContacts = 100; |
|
40 const TInt KNumGroups = 1; |
|
41 const TInt KNumContactsInGroupOne = 25; |
|
42 const TInt KNumMaxEventRequests = 1000; |
|
43 _LIT(KGroupOneName,"GroupOne"); |
|
44 |
|
45 |
|
46 // |
|
47 // CTestConductor. |
|
48 // |
|
49 |
|
50 CTestConductor* CTestConductor::NewL() |
|
51 { |
|
52 CTestConductor* self=new(ELeave) CTestConductor(); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(); |
|
55 self->RunTestsL(); |
|
56 CleanupStack::Pop(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 CTestConductor::~CTestConductor() |
|
61 { |
|
62 delete iLog; |
|
63 delete iDb; |
|
64 delete iRandomGenerator; |
|
65 TRAP_IGNORE(CContactDatabase::DeleteDatabaseL(KDbFileName)); |
|
66 iFs.Close(); |
|
67 } |
|
68 |
|
69 CTestConductor::CTestConductor() |
|
70 { |
|
71 } |
|
72 |
|
73 void CTestConductor::ConstructL() |
|
74 { |
|
75 User::LeaveIfError(iFs.Connect()); |
|
76 iLog=CLog::NewL(test,KLogFileName); |
|
77 iDb=CContactDatabase::ReplaceL(KDbFileName); |
|
78 iRandomGenerator=CRandomContactGenerator::NewL(); |
|
79 iRandomGenerator->SetDbL(*iDb); |
|
80 AddContactsL(); |
|
81 } |
|
82 |
|
83 void CTestConductor::AddContactsL() |
|
84 { |
|
85 iTotalContacts = 0; |
|
86 TInt loop; |
|
87 for (loop = 0;loop < KNumContacts; ++loop) |
|
88 { |
|
89 iRandomGenerator->AddTypicalRandomContactL(); |
|
90 ++iTotalContacts; |
|
91 test.Printf(_L("Adding %d "),loop); |
|
92 } |
|
93 |
|
94 // consume any outstanding database events before creating |
|
95 // the views to stop these events later being sent to them. |
|
96 CContactDbEventQueue* dbEventQueue = CContactDbEventQueue::NewL(iDb, KNumMaxEventRequests); |
|
97 TContactDbObserverEvent dbEvent; |
|
98 TBool expectingEvent = ETrue; |
|
99 const TInt KTimeOutInSeconds = 5; |
|
100 |
|
101 for(loop = 0; expectingEvent; ++loop) |
|
102 { |
|
103 expectingEvent = dbEventQueue->ListenForEvent(KTimeOutInSeconds, dbEvent); |
|
104 if (expectingEvent) // meaning if we've just received one |
|
105 { |
|
106 test.Printf(_L("Consumed db event #%d: %d\n"), loop, dbEvent.iType); |
|
107 } |
|
108 } |
|
109 delete dbEventQueue; |
|
110 } |
|
111 |
|
112 void CTestConductor::RunTestsL() |
|
113 { |
|
114 CGroupViewTester* tester=CGroupViewTester::NewL(*iLog,this,*iDb); |
|
115 CleanupStack::PushL(tester); |
|
116 CActiveScheduler::Start(); |
|
117 CleanupStack::Pop(tester); |
|
118 // error from CGroupViewTester? |
|
119 User::LeaveIfError(iTestError); |
|
120 } |
|
121 |
|
122 void CTestConductor::SetTestError(TInt aTestError) |
|
123 { |
|
124 iTestError = aTestError; |
|
125 } |
|
126 |
|
127 |
|
128 // |
|
129 // CGroupViewTester. |
|
130 // |
|
131 |
|
132 CGroupViewTester* CGroupViewTester::NewL(CLog& aLog,CTestConductor* aTestConductor,CContactDatabase& aDb) |
|
133 { |
|
134 CGroupViewTester* self=new(ELeave) CGroupViewTester(aLog,aTestConductor,aDb); |
|
135 CleanupStack::PushL(self); |
|
136 self->ConstructL(); |
|
137 CleanupStack::Pop(); |
|
138 return self; |
|
139 } |
|
140 |
|
141 CGroupViewTester::~CGroupViewTester() |
|
142 { |
|
143 iGroupViewOne->Close(*this); |
|
144 iGroupViewOneByName->Close(*this); |
|
145 iGroupViewOneNotInGroup->Close(*this); |
|
146 iGroupViewUnfiled->Close(*this); |
|
147 iLocalView->Close(*this); |
|
148 iSortOrder_1.Close(); |
|
149 delete iTextDef; |
|
150 delete iGroupView_One_Name; |
|
151 delete iIdsInGroupViewOne; |
|
152 delete iGroupOne; |
|
153 delete iEventConsumer; |
|
154 } |
|
155 |
|
156 CGroupViewTester::CGroupViewTester(CLog& aLog,CTestConductor* aTestConductor,CContactDatabase& aDb) |
|
157 : CActive(EPriorityStandard),iLog(aLog),iTestConductor(aTestConductor),iDb(aDb),iCurrentTest(-1) |
|
158 { |
|
159 CActiveScheduler::Add(this); |
|
160 } |
|
161 |
|
162 void CGroupViewTester::ConstructL() |
|
163 { |
|
164 iSortOrder_1.AppendL(KUidContactFieldGivenName); |
|
165 iSortOrder_1.AppendL(KUidContactFieldFamilyName); |
|
166 iSortOrder_1.AppendL(KUidContactFieldCompanyName); |
|
167 |
|
168 iTextDef=CContactTextDef::NewL(); |
|
169 iTextDef->AppendL(TContactTextDefItem(KUidContactFieldGivenName,KTextDefSeparator)); |
|
170 iTextDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName,KTextDefSeparator)); |
|
171 iTextDef->AppendL(TContactTextDefItem(KUidContactFieldCompanyName,KTextDefSeparator)); |
|
172 CreateGroupTestDataL(); |
|
173 NextTest(); |
|
174 } |
|
175 |
|
176 void CGroupViewTester::CreateGroupTestDataL() |
|
177 { |
|
178 TInt loop; |
|
179 iGroupOne = STATIC_CAST(CContactGroup*,iDb.CreateContactGroupL(KGroupOneName)); |
|
180 for (loop = 1;loop <= KNumContactsInGroupOne;++loop) |
|
181 { |
|
182 iDb.AddContactToGroupL(loop,iGroupOne->Id()); |
|
183 } |
|
184 iGroupOneId = iGroupOne->Id(); |
|
185 delete iGroupOne; |
|
186 iGroupOne = NULL; |
|
187 iGroupOne = STATIC_CAST(CContactGroup*,iDb.ReadContactL(iGroupOneId)); |
|
188 iIdsInGroupViewOne = iGroupOne->ItemsContainedLC(); |
|
189 CleanupStack::Pop();//iIdsInGroupViewOne:( |
|
190 |
|
191 // consume any outstanding database events before creating |
|
192 // the views to stop these events later being sent to them. |
|
193 CContactDbEventQueue* dbEventQueue = CContactDbEventQueue::NewL(&iDb, KNumMaxEventRequests); |
|
194 TContactDbObserverEvent dbEvent; |
|
195 TBool expectingEvent = ETrue; |
|
196 const TInt KTimeOutInSeconds = 5; |
|
197 for(loop = 0; expectingEvent; ++loop) |
|
198 { |
|
199 expectingEvent = dbEventQueue->ListenForEvent(KTimeOutInSeconds, dbEvent); |
|
200 if (expectingEvent) // meaning if we've just received one |
|
201 { |
|
202 test.Printf(_L("Consumed db event #%d: %d\n"), loop, dbEvent.iType); |
|
203 } |
|
204 } |
|
205 delete dbEventQueue; |
|
206 } |
|
207 |
|
208 void CGroupViewTester::RunL() |
|
209 { |
|
210 switch (iCurrentTest) |
|
211 { |
|
212 case ECreateLocalView: |
|
213 iLog.LogLine(_L("=== Create local view")); |
|
214 iLocalView=CContactLocalView::NewL(*this,iDb,iSortOrder_1,EContactAndGroups/*EContactsOnly*/); |
|
215 break; |
|
216 case EExerciseLocalView: |
|
217 iLog.LogLine(_L("=== Exercise local view")); |
|
218 ExceriseViewL(*iLocalView); |
|
219 NextTest(); |
|
220 break; |
|
221 case ECreateGroupOneView: |
|
222 { |
|
223 iLog.LogLine(_L("=== GroupOneView")); |
|
224 iGroupViewOne=CContactGroupView::NewL(iDb,*iLocalView,*this,iGroupOne->Id(),CContactGroupView::EShowContactsInGroup); |
|
225 } |
|
226 break; |
|
227 case ETestGroupOneView: |
|
228 { |
|
229 iLog.LogLine(_L("==== Exercise ETestGroupOneView")); |
|
230 TInt groupCount = iGroupOne->ItemsContained()->Count(); |
|
231 test(iGroupViewOne->CountL()==groupCount); |
|
232 const CContactIdArray* array= iGroupOne->ItemsContained(); |
|
233 for (TInt ii=0;ii<groupCount;ii++) |
|
234 { |
|
235 test(iGroupViewOne->FindL((*array)[ii])!=KErrNotFound); |
|
236 } |
|
237 TestGroupViewSortOrderL(*iGroupViewOne); |
|
238 NextTest(); |
|
239 } |
|
240 break; |
|
241 case ECreateGroupOneViewByName: |
|
242 { |
|
243 iLog.LogLine(_L("=== Create GroupOneView By Name")); |
|
244 iGroupViewOneByName=CContactGroupView::NewL(iDb,*iLocalView,*this,KGroupOneName,CContactGroupView::EShowContactsInGroup); |
|
245 } |
|
246 break; |
|
247 case ETestGroupOneViewByName: |
|
248 { |
|
249 iLog.LogLine(_L("==== Exercise ETestGroupOneView By Name")); |
|
250 TInt groupCount = iGroupOne->ItemsContained()->Count(); |
|
251 test(iGroupViewOneByName->CountL()==groupCount); |
|
252 const CContactIdArray* array= iGroupOne->ItemsContained(); |
|
253 for (TInt ii=0;ii<groupCount;ii++) |
|
254 { |
|
255 test(iGroupViewOneByName->FindL((*array)[ii])!=KErrNotFound); |
|
256 } |
|
257 TestGroupViewSortOrderL(*iGroupViewOneByName); |
|
258 NextTest(); |
|
259 break; |
|
260 } |
|
261 case ECreateGroupOneViewNotInGroup: |
|
262 { |
|
263 iLog.LogLine(_L("=== Create GroupOneViewNotInGroup By Name")); |
|
264 iGroupViewOneNotInGroup=CContactGroupView::NewL(iDb,*iLocalView,*this,KGroupOneName,CContactGroupView::EShowContactsNotInGroup); |
|
265 } |
|
266 break; |
|
267 case ETestGroupOneViewNotInGroup: |
|
268 { |
|
269 iLog.LogLine(_L("==== Exercise GroupOneViewNotInGroup By Name")); |
|
270 TInt totalContacts = iLocalView->CountL(); |
|
271 TInt totalNotInGroup = totalContacts - KNumContactsInGroupOne; |
|
272 test(iGroupViewOneNotInGroup->CountL()==totalNotInGroup); |
|
273 const CContactIdArray* array= iGroupOne->ItemsContained(); |
|
274 TInt groupCount = array->Count(); |
|
275 for (TInt ii=0;ii<groupCount;ii++) |
|
276 { |
|
277 test(iGroupViewOneNotInGroup->FindL((*array)[ii])==KErrNotFound); |
|
278 } |
|
279 TestGroupViewSortOrderL(*iGroupViewOneNotInGroup); |
|
280 NextTest(); |
|
281 break; |
|
282 } |
|
283 case EAllViewsOutOfBoundsAccess: |
|
284 { |
|
285 //Views depend on their underlying views being in a good state, however |
|
286 //as some base views are potentially in other processes they must be resistant |
|
287 //to out of date views accessesing out of bound members, views, should not |
|
288 //panic but should leave with KErrNotFound; |
|
289 //local view |
|
290 TInt err=0; |
|
291 iLog.LogLine(_L("=== Test views for out of bounds access")); |
|
292 TInt outCount = iGroupViewOneByName->CountL(); |
|
293 TRAP(err,iGroupViewOneByName->AtL(outCount)); |
|
294 test(err==KErrNotFound); |
|
295 TRAP(err,iGroupViewOneByName->ContactAtL(outCount)); |
|
296 test(err==KErrNotFound); |
|
297 NextTest(); |
|
298 } |
|
299 break; |
|
300 case ECreateUnfiledGroupView: |
|
301 { |
|
302 iLog.LogLine(_L("=== Create Unfiled group view")); |
|
303 iGroupViewUnfiled=CContactGroupView::NewL(iDb,*iLocalView,*this,KNullContactId,CContactGroupView::EShowContactsNotInAnyGroup); |
|
304 } |
|
305 break; |
|
306 case ETestUnfiledGroupView: |
|
307 { |
|
308 iLog.LogLine(_L("==== Exercise Unfiled group")); |
|
309 const TInt totalContacts = iLocalView->CountL(); |
|
310 const TInt totalUnfiled = totalContacts - KNumContactsInGroupOne - KNumGroups; |
|
311 test(iGroupViewUnfiled->CountL()==totalUnfiled); |
|
312 test(iGroupViewUnfiled->FindL(iGroupOneId)); |
|
313 TestGroupViewSortOrderL(*iGroupViewUnfiled); |
|
314 |
|
315 CRandomContactGenerator* generator = CRandomContactGenerator::NewL(); |
|
316 CleanupStack::PushL(generator); |
|
317 generator->SetDbL(iDb); |
|
318 generator->AddTypicalRandomContactL(); |
|
319 CleanupStack::PopAndDestroy(generator); |
|
320 iNumNotificationExpected=5; |
|
321 } |
|
322 break; |
|
323 case ETestUnfiledGroupAddition: |
|
324 { |
|
325 iLog.LogLine(_L("==== Exercise Unfiled group addition")); |
|
326 TInt revisedCount = iGroupViewUnfiled->CountL(); |
|
327 CContactIdArray* unfiled = iDb.UnfiledContactsL(); |
|
328 test(revisedCount == unfiled->Count()); |
|
329 delete unfiled; |
|
330 ExceriseViewL(*iGroupViewUnfiled); |
|
331 // Test that adding contact which currently forms part of |
|
332 // iGroupViewUnfiled to iGroupOne causes update of |
|
333 // iGroupViewUnfiled such that the contact no longer forms |
|
334 // part of iGroupViewUnfiled (i.e. by adding the contact to the |
|
335 // group it is no longer unfiled and should not appear in the |
|
336 // unfiled view). The update to iGroupViewUnfiled will not take |
|
337 // place until the view receives the change event so wait until the |
|
338 // view observer method HandleContactViewEvent() is called before |
|
339 // testing that the expected change to iGroupViewUnfiled has taken |
|
340 // place. |
|
341 iDb.AddContactToGroupL(KNumContacts,iGroupOne->Id()); |
|
342 // Expect (ESortOrderChanged x 4) + EGroupChanged + (EItemRemoved x |
|
343 // 4) + (EItemAdded x 4). |
|
344 iNumNotificationExpected=13; |
|
345 } |
|
346 break; |
|
347 case ENumTests: |
|
348 iLog.LogLine(_L("==== Group View Tests Finished, All Passed...\n")); |
|
349 CActiveScheduler::Stop(); |
|
350 delete this; |
|
351 break; |
|
352 default: |
|
353 ASSERT(EFalse); |
|
354 break; |
|
355 } |
|
356 } |
|
357 |
|
358 TInt CGroupViewTester::RunError(TInt aError) |
|
359 { |
|
360 // propagate error |
|
361 iTestConductor->SetTestError(aError); |
|
362 |
|
363 switch (iCurrentTest) |
|
364 { |
|
365 case ECreateLocalView: test.Printf(_L("Test failed at step CreateLocalView (%i) with error %i"), iCurrentTest, aError); break; |
|
366 case EExerciseLocalView: test.Printf(_L("Test failed at step ExerciseLocalView (%i) with error %i"), iCurrentTest, aError); break; |
|
367 case ECreateGroupOneView: test.Printf(_L("Test failed at step CreateGroupOneView (%i) with error %i"), iCurrentTest, aError); break; |
|
368 case ETestGroupOneView: test.Printf(_L("Test failed at step TestGroupOneView (%i) with error %i"), iCurrentTest, aError); break; |
|
369 case ECreateGroupOneViewByName: test.Printf(_L("Test failed at step CreateGroupOneViewByName (%i) with error %i"), iCurrentTest, aError); break; |
|
370 case ETestGroupOneViewByName: test.Printf(_L("Test failed at step TestGroupOneViewByName (%i) with error %i"), iCurrentTest, aError); break; |
|
371 case ECreateGroupOneViewNotInGroup: test.Printf(_L("Test failed at step CreateGroupOneViewNotInGroup (%i) with error %i"), iCurrentTest, aError); break; |
|
372 case ETestGroupOneViewNotInGroup: test.Printf(_L("Test failed at step TestGroupOneViewNotInGroup (%i) with error %i"), iCurrentTest, aError); break; |
|
373 case EAllViewsOutOfBoundsAccess: test.Printf(_L("Test failed at step AllViewsOutOfBoundsAccess (%i) with error %i"), iCurrentTest, aError); break; |
|
374 case ECreateUnfiledGroupView: test.Printf(_L("Test failed at step CreateUnfiledGroupView (%i) with error %i"), iCurrentTest, aError); break; |
|
375 case ETestUnfiledGroupView: test.Printf(_L("Test failed at step TestUnfiledGroupView (%i) with error %i"), iCurrentTest, aError); break; |
|
376 case ETestUnfiledGroupAddition: test.Printf(_L("Test failed at step TestUnfiledGroupAddition (%i) with error %i"), iCurrentTest, aError); break; |
|
377 |
|
378 case ENumTests: test.Printf(_L("Test failed at step NumTests (%i) with error %i"), iCurrentTest, aError); break; |
|
379 |
|
380 default: test.Printf(_L("Test failed at step %i with error %i"), iCurrentTest, aError); break; |
|
381 } |
|
382 |
|
383 CActiveScheduler::Stop(); |
|
384 return KErrNone; |
|
385 } |
|
386 |
|
387 void CGroupViewTester::HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent) |
|
388 { |
|
389 //LOGGING// |
|
390 if(&aView == iLocalView) |
|
391 test.Printf(_L("LocalView ")); |
|
392 else if(&aView == iGroupViewOne) |
|
393 test.Printf(_L("GroupViewOne ")); |
|
394 else if(&aView == iGroupViewOneByName) |
|
395 test.Printf(_L("GroupViewOneByName ")); |
|
396 else if(&aView == iGroupViewOneNotInGroup) |
|
397 test.Printf(_L("GroupViewOneNotInGroup ")); |
|
398 else if(&aView == iGroupViewUnfiled) |
|
399 test.Printf(_L("GroupViewUnfiled ")); |
|
400 else |
|
401 test.Printf(_L("Er, none of the known views... ")); |
|
402 |
|
403 switch (aEvent.iEventType) |
|
404 { |
|
405 case TContactViewEvent::EUnavailable: |
|
406 test.Printf(_L("EUnavailable\n")); |
|
407 break; |
|
408 case TContactViewEvent::EReady: |
|
409 test.Printf(_L("EReady\n")); |
|
410 break; |
|
411 case TContactViewEvent::ESortOrderChanged: |
|
412 test.Printf(_L("ESortOrderChanged\n")); |
|
413 break; |
|
414 case TContactViewEvent::ESortError: |
|
415 test.Printf(_L("ESortError\n")); |
|
416 break; |
|
417 case TContactViewEvent::EServerError: |
|
418 test.Printf(_L("EServerError\n")); |
|
419 break; |
|
420 case TContactViewEvent::EIndexingError: |
|
421 test.Printf(_L("EIndexingError\n")); |
|
422 break; |
|
423 case TContactViewEvent::EItemAdded: |
|
424 test.Printf(_L("EItemAdded\n")); |
|
425 break; |
|
426 case TContactViewEvent::EItemRemoved: |
|
427 test.Printf(_L("EItemRemoved\n")); |
|
428 break; |
|
429 case TContactViewEvent::EGroupChanged: |
|
430 test.Printf(_L("EGroupChanged\n")); |
|
431 break; |
|
432 default: |
|
433 test.Printf(_L("Er, none of the known event types... ")); |
|
434 break; |
|
435 } |
|
436 // |
|
437 |
|
438 switch (iCurrentTest) |
|
439 { |
|
440 case ECreateLocalView: |
|
441 test(iLocalView==&aView); |
|
442 test(aEvent.iEventType==TContactViewEvent::EReady); |
|
443 break; |
|
444 case EExerciseLocalView: |
|
445 test(ETrue); |
|
446 break; |
|
447 case ECreateGroupOneView: |
|
448 test(iGroupViewOne==&aView); |
|
449 test(aEvent.iEventType==TContactViewEvent::EReady); |
|
450 break; |
|
451 case ETestGroupOneView: |
|
452 test(EFalse); |
|
453 break; |
|
454 case ECreateGroupOneViewByName: |
|
455 test(iGroupViewOneByName==&aView); |
|
456 test(aEvent.iEventType==TContactViewEvent::EReady); |
|
457 break; |
|
458 case ETestGroupOneViewByName: |
|
459 test(EFalse); |
|
460 break; |
|
461 case ECreateGroupOneViewNotInGroup: |
|
462 test(iGroupViewOneNotInGroup==&aView); |
|
463 test(aEvent.iEventType==TContactViewEvent::EReady); |
|
464 break; |
|
465 case ETestGroupOneViewNotInGroup: |
|
466 test(EFalse); |
|
467 break; |
|
468 case EAllViewsOutOfBoundsAccess: |
|
469 test(EFalse); |
|
470 break; |
|
471 case ECreateUnfiledGroupView: |
|
472 test(iGroupViewUnfiled==&aView); |
|
473 test(aEvent.iEventType==TContactViewEvent::EReady); |
|
474 break; |
|
475 case ETestUnfiledGroupView: |
|
476 break; |
|
477 case ETestUnfiledGroupAddition: |
|
478 { |
|
479 // No point testing for each and every notification: the test will |
|
480 // pass for all notifications. |
|
481 if (iNumNotificationExpected > 1) |
|
482 { |
|
483 break; |
|
484 } |
|
485 // Test that adding contact which formed part of iGroupViewUnfiled |
|
486 // to iGroupOne caused update of iGroupViewUnfiled such that the |
|
487 // contact no longer forms part of iGroupViewUnfiled (i.e. by adding |
|
488 // the contact to the group it is no longer unfiled is not a member |
|
489 // of the unfiled view). |
|
490 TInt ret(KErrNone); |
|
491 TRAPD(err1, ret = iGroupViewUnfiled->FindL(KNumContacts) ); |
|
492 test(err1 == KErrNone && ret == KErrNotFound); |
|
493 // Double check - make sure the number of items in the unfiled |
|
494 // group view agrees with the number of unfiled items reported by |
|
495 // the database. |
|
496 TInt groupViewUnfiledCount(0); |
|
497 TRAPD(err2, groupViewUnfiledCount = iGroupViewUnfiled->CountL() ); |
|
498 CContactIdArray* dbUnfiled = NULL; |
|
499 TRAPD(err3, dbUnfiled = iDb.UnfiledContactsL() ); |
|
500 test(err2 == KErrNone && err3 == KErrNone && groupViewUnfiledCount==dbUnfiled->Count() ); |
|
501 delete dbUnfiled; |
|
502 } |
|
503 break; |
|
504 case ENumTests: |
|
505 default: |
|
506 test(EFalse); |
|
507 break; |
|
508 } |
|
509 if (--iNumNotificationExpected <= 0) |
|
510 { |
|
511 iNumNotificationExpected=0; |
|
512 NextTest(); |
|
513 } |
|
514 } |
|
515 |
|
516 void CGroupViewTester::NextTest() |
|
517 { |
|
518 ++iCurrentTest; |
|
519 TRequestStatus *pS=&iStatus; |
|
520 User::RequestComplete(pS,KErrNone); |
|
521 SetActive(); |
|
522 } |
|
523 |
|
524 void CGroupViewTester::ExceriseViewL(CContactViewBase& aView) |
|
525 { |
|
526 TContactItemId lastId=0; |
|
527 const TInt numItems=aView.CountL(); |
|
528 for (TInt loop = 0;loop < numItems;++loop) |
|
529 { |
|
530 if (loop == numItems-1) |
|
531 { |
|
532 lastId=aView.AtL(loop); |
|
533 } |
|
534 iDb.ReadContactTextDefL(aView.AtL(loop),iScratchBuf,iTextDef); |
|
535 iLog.LogLineNoEcho(iScratchBuf); |
|
536 iScratchBuf.SetLength(0); |
|
537 } |
|
538 |
|
539 test(aView.FindL(lastId)==numItems-1); |
|
540 } |
|
541 |
|
542 |
|
543 void CGroupViewTester::TestGroupViewSortOrderL(CContactGroupView& aView) |
|
544 { |
|
545 const TInt numItems=aView.CountL(); |
|
546 for (TInt ii=0;ii<numItems;++ii) |
|
547 { |
|
548 if(ii!=numItems-1)//not last item |
|
549 { |
|
550 TContactIdWithMapping first = (aView.iGroupContacts)[ii]; |
|
551 TContactIdWithMapping second = (aView.iGroupContacts)[ii+1]; |
|
552 test(first.iMapping < second.iMapping); |
|
553 } |
|
554 } |
|
555 } |
|
556 |
|
557 void CGroupViewTester::DoCancel() |
|
558 { |
|
559 } |
|
560 // Callback from event consumer class instance |
|
561 TInt CGroupViewTester::EventConsumerCallBack(TAny* aThis) |
|
562 { |
|
563 // Just go to the next test in the RunL() |
|
564 static_cast<CGroupViewTester*>(aThis)->NextTest(); |
|
565 return KErrNone; |
|
566 } |
|
567 |
|
568 // |
|
569 |
|
570 // |
|
571 // Main. |
|
572 // |
|
573 |
|
574 /** |
|
575 |
|
576 @SYMTestCaseID PIM-T-GROUPVIEW-0001 |
|
577 |
|
578 */ |
|
579 |
|
580 GLDEF_C TInt E32Main() |
|
581 { |
|
582 __UHEAP_MARK; |
|
583 RProcess().SetPriority(EPriorityBackground); |
|
584 CActiveScheduler* scheduler=new CActiveScheduler; |
|
585 if (scheduler) |
|
586 { |
|
587 CActiveScheduler::Install(scheduler); |
|
588 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
589 if (cleanup) |
|
590 { |
|
591 CTestConductor* testConductor=NULL; |
|
592 test.Start(KTestName); |
|
593 |
|
594 TRAPD(err,testConductor=CTestConductor::NewL()); |
|
595 test(err == KErrNone); |
|
596 test.End(); |
|
597 delete testConductor; |
|
598 test.Close(); |
|
599 delete cleanup; |
|
600 } |
|
601 delete scheduler; |
|
602 } |
|
603 __UHEAP_MARKEND; |
|
604 return KErrNone; |
|
605 } |