|
1 // Copyright (c) 2002-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 <e32test.h> |
|
17 #include <cntdef.h> |
|
18 #include <cntdb.h> |
|
19 #include <cntitem.h> |
|
20 #include <cntfield.h> |
|
21 #include <cntfldst.h> |
|
22 #include <cntviewbase.h> |
|
23 |
|
24 #include "CContactViewEventQueue.h" |
|
25 #include "CContactDbEventQueue.h" |
|
26 |
|
27 _LIT(KTestName, "T_GroupViewEvents"); |
|
28 |
|
29 _LIT(KTestDbName, "c:T_GroupViewEvents.cdb"); |
|
30 |
|
31 _LIT(KTestGrpName, "T_Group"); |
|
32 |
|
33 _LIT(KRemoteView, "Test_UnderlyingRemoteView"); |
|
34 |
|
35 LOCAL_D RTest test(KTestName); |
|
36 |
|
37 class CTestResources : public CBase |
|
38 { |
|
39 public: |
|
40 static CTestResources* NewLC(TBool aShowContactInGrp); |
|
41 static CTestResources* NewLC(TBool aShowContactInGrp, TBool aUnderlyingRemoteView); |
|
42 void ConstructL(TBool aUnderlinedRemoteView = EFalse); |
|
43 TContactItemId CreateTestContactL(const TDesC& aFamilyName); |
|
44 ~CTestResources(); |
|
45 |
|
46 CContactDatabase* iDb; |
|
47 CContactDbEventQueue* iDbEventQueue; |
|
48 CContactViewEventQueue* iLocalViewEventQueue; |
|
49 CContactViewEventQueue* iRemoteViewEventQueue; |
|
50 RContactViewSortOrder iViewSortOrder; |
|
51 CContactLocalView* iLocalView; |
|
52 CContactNamedRemoteView* iRemoteView; |
|
53 |
|
54 CContactViewEventQueue* iOldAPIGroupViewEventQueue; |
|
55 CContactViewEventQueue* iOldAPIFindViewEventQueue; |
|
56 CContactViewEventQueue* iOldAPISubViewEventQueue; |
|
57 |
|
58 CContactViewEventQueue* iNewAPIGroupViewEventQueue; |
|
59 CContactViewEventQueue* iNewAPIFindViewEventQueue; |
|
60 CContactViewEventQueue* iNewAPISubViewEventQueue; |
|
61 |
|
62 CContactGroupView* iGroupViewOldAPI; |
|
63 CContactFindView* iFindViewOldAPI; |
|
64 CContactSubView* iSubViewOldAPI; |
|
65 |
|
66 CContactGroupView* iGroupViewNewAPI; |
|
67 CContactFindView* iFindViewNewAPI; |
|
68 CContactSubView* iSubViewNewAPI; |
|
69 |
|
70 CContactIdArray* iContactIdArray; |
|
71 TContactItemId iTestContactId; |
|
72 TContactItemId iGrpId; |
|
73 |
|
74 TBool iShowContactInGrp; |
|
75 private: |
|
76 CTestResources(TBool aShowContactInGrp); |
|
77 |
|
78 }; |
|
79 |
|
80 CTestResources::CTestResources(TBool aShowContactInGrp) |
|
81 : iShowContactInGrp(aShowContactInGrp) |
|
82 { |
|
83 } |
|
84 |
|
85 CTestResources* CTestResources::NewLC(TBool aShowContactInGrp) |
|
86 { |
|
87 CTestResources* self = new(ELeave) CTestResources(aShowContactInGrp); |
|
88 |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(); |
|
91 return self; |
|
92 } |
|
93 |
|
94 CTestResources* CTestResources::NewLC(TBool aShowContactInGrp, TBool aUnderlyingRemoteView) |
|
95 { |
|
96 if(aUnderlyingRemoteView == EFalse) |
|
97 { |
|
98 return NewLC(aShowContactInGrp); |
|
99 } |
|
100 |
|
101 CTestResources* self = new(ELeave) CTestResources(aShowContactInGrp); |
|
102 CleanupStack::PushL(self); |
|
103 self->ConstructL(ETrue); |
|
104 return self; |
|
105 } |
|
106 |
|
107 void CTestResources::ConstructL(TBool aUnderlinedRemoteView) |
|
108 { |
|
109 iDb = CContactDatabase::ReplaceL(KTestDbName); |
|
110 iDbEventQueue = CContactDbEventQueue::NewL(iDb); |
|
111 |
|
112 iViewSortOrder.AppendL(KUidContactFieldFamilyName); |
|
113 iViewSortOrder.AppendL(KUidContactFieldGivenName); |
|
114 iViewSortOrder.AppendL(KUidContactFieldCompanyName); |
|
115 |
|
116 iContactIdArray = CContactIdArray::NewL(); |
|
117 |
|
118 CContactItem* grpItem = iDb->CreateContactGroupL(KTestGrpName); |
|
119 iGrpId = grpItem->Id(); |
|
120 delete grpItem; |
|
121 |
|
122 if(aUnderlinedRemoteView == EFalse) |
|
123 { |
|
124 iLocalViewEventQueue = CContactViewEventQueue::NewL(); |
|
125 iLocalView = CContactLocalView::NewL |
|
126 (*iLocalViewEventQueue, *iDb, iViewSortOrder, EContactsOnly); |
|
127 } |
|
128 else |
|
129 { |
|
130 iRemoteViewEventQueue = CContactViewEventQueue::NewL(); |
|
131 iRemoteView = CContactNamedRemoteView::NewL |
|
132 (*iRemoteViewEventQueue, KRemoteView, *iDb, iViewSortOrder, EContactsOnly); |
|
133 } |
|
134 |
|
135 iOldAPIGroupViewEventQueue = CContactViewEventQueue::NewL(); |
|
136 |
|
137 CContactGroupView::TGroupType grpType = iShowContactInGrp ? |
|
138 CContactGroupView::EShowContactsInGroup : |
|
139 CContactGroupView::EShowContactsNotInAnyGroup; |
|
140 |
|
141 CContactViewBase* underlyingView = aUnderlinedRemoteView?(static_cast<CContactViewBase*>(iRemoteView)):(static_cast<CContactViewBase*>(iLocalView)); //do not take the ownership |
|
142 // Create a group view to test old functionality/API |
|
143 iGroupViewOldAPI = CContactGroupView::NewL(*iDb, *underlyingView, *iOldAPIGroupViewEventQueue, KTestGrpName, grpType); |
|
144 |
|
145 iOldAPIFindViewEventQueue = CContactViewEventQueue::NewL(); |
|
146 CPtrCArray* findWordArray = new (ELeave) CPtrCArray(1); |
|
147 findWordArray->AppendL(_L("")); |
|
148 // Create a find view to test old functionality/API |
|
149 iFindViewOldAPI = CContactFindView::NewL(*iDb, *underlyingView, *iOldAPIFindViewEventQueue, findWordArray); |
|
150 |
|
151 iOldAPISubViewEventQueue = CContactViewEventQueue::NewL(); |
|
152 // Create a sub view to test old functionality/API |
|
153 iSubViewOldAPI = CContactSubView::NewL(*iOldAPISubViewEventQueue,*iDb, *underlyingView,_L(">a"), _L("<z")); |
|
154 |
|
155 iNewAPIGroupViewEventQueue = CContactViewEventQueue::NewL(); |
|
156 // Create a group view to test new functionality/API |
|
157 iGroupViewNewAPI = CContactGroupView::NewL(*underlyingView, *iDb, *iNewAPIGroupViewEventQueue, KTestGrpName, grpType); |
|
158 |
|
159 iNewAPIFindViewEventQueue = CContactViewEventQueue::NewL(); |
|
160 // Create a find view to test the new functionality/API |
|
161 iFindViewNewAPI = CContactFindView::NewL(*underlyingView, *iDb, *iNewAPIFindViewEventQueue, findWordArray); |
|
162 |
|
163 iNewAPISubViewEventQueue = CContactViewEventQueue::NewL(); |
|
164 // Create a sub view to test old functionality/API |
|
165 iSubViewNewAPI = CContactSubView::NewL(*underlyingView, *iDb, *iNewAPISubViewEventQueue, _L(">a"), _L("<z")); |
|
166 |
|
167 |
|
168 findWordArray->Reset(); |
|
169 delete findWordArray; |
|
170 |
|
171 // Wait for contact views derived classes to get ready |
|
172 TContactViewEvent event; |
|
173 if(aUnderlinedRemoteView == EFalse) |
|
174 { |
|
175 __ASSERT_ALWAYS(iOldAPIGroupViewEventQueue->ListenForEvent(10,event), User::Invariant()); |
|
176 __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); |
|
177 __ASSERT_ALWAYS(iOldAPIFindViewEventQueue->ListenForEvent(10,event), User::Invariant()); |
|
178 __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); |
|
179 __ASSERT_ALWAYS(iOldAPISubViewEventQueue->ListenForEvent(10,event), User::Invariant()); |
|
180 __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); |
|
181 |
|
182 __ASSERT_ALWAYS(iNewAPIGroupViewEventQueue->ListenForEvent(10,event), User::Invariant()); |
|
183 __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); |
|
184 __ASSERT_ALWAYS(iNewAPIFindViewEventQueue->ListenForEvent(10,event), User::Invariant()); |
|
185 __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); |
|
186 __ASSERT_ALWAYS(iNewAPISubViewEventQueue->ListenForEvent(10,event), User::Invariant()); |
|
187 __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); |
|
188 } |
|
189 |
|
190 // Flush all other events |
|
191 iDbEventQueue->Flush(); |
|
192 if(aUnderlinedRemoteView == EFalse) |
|
193 { |
|
194 iLocalViewEventQueue->Flush(); |
|
195 } |
|
196 else |
|
197 { |
|
198 iRemoteViewEventQueue->Flush(); |
|
199 } |
|
200 |
|
201 iOldAPIGroupViewEventQueue->Flush(); |
|
202 iOldAPIFindViewEventQueue->Flush(); |
|
203 iOldAPISubViewEventQueue->Flush(); |
|
204 |
|
205 iNewAPIGroupViewEventQueue->Flush(); |
|
206 iNewAPIFindViewEventQueue->Flush(); |
|
207 iNewAPISubViewEventQueue->Flush(); |
|
208 } |
|
209 |
|
210 TContactItemId CTestResources::CreateTestContactL(const TDesC& aFamilyName) |
|
211 { |
|
212 // Create a contact card |
|
213 CContactCard* card = CContactCard::NewLC(); |
|
214 // Create a name field |
|
215 CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName); |
|
216 field->TextStorage()->SetTextL(aFamilyName); |
|
217 card->AddFieldL(*field); |
|
218 CleanupStack::Pop(field); |
|
219 // Create a phone number field |
|
220 CContactItemField* phoneField = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber); |
|
221 phoneField->TextStorage()->SetTextL(_L("555")); |
|
222 card->AddFieldL(*phoneField); |
|
223 CleanupStack::Pop(phoneField); |
|
224 |
|
225 // Add the contact to the DB |
|
226 const TContactItemId contactId = iDb->AddNewContactL(*card); |
|
227 CleanupStack::PopAndDestroy(card); |
|
228 |
|
229 // Eat away contact db events |
|
230 TContactDbObserverEvent event; |
|
231 while |
|
232 (iDbEventQueue->ListenForEvent(10,event) && |
|
233 (event.iType != EContactDbObserverEventContactAdded || |
|
234 event.iContactId != contactId)) |
|
235 { |
|
236 } |
|
237 iTestContactId = contactId; |
|
238 |
|
239 if(iShowContactInGrp) |
|
240 { |
|
241 iDb->AddContactToGroupL(contactId, iGrpId); |
|
242 } |
|
243 |
|
244 return contactId; |
|
245 } |
|
246 |
|
247 CTestResources::~CTestResources() |
|
248 { |
|
249 if (iGroupViewOldAPI) |
|
250 iGroupViewOldAPI->Close(*iOldAPIGroupViewEventQueue); |
|
251 delete iOldAPIGroupViewEventQueue; |
|
252 |
|
253 if (iFindViewOldAPI) |
|
254 iFindViewOldAPI->Close(*iOldAPIFindViewEventQueue); |
|
255 delete iOldAPIFindViewEventQueue; |
|
256 |
|
257 if (iSubViewOldAPI) |
|
258 iSubViewOldAPI->Close(*iOldAPISubViewEventQueue); |
|
259 delete iOldAPISubViewEventQueue; |
|
260 |
|
261 if (iGroupViewNewAPI) |
|
262 iGroupViewNewAPI->Close(*iNewAPIGroupViewEventQueue); |
|
263 delete iNewAPIGroupViewEventQueue; |
|
264 |
|
265 if (iFindViewNewAPI) |
|
266 iFindViewNewAPI->Close(*iNewAPIFindViewEventQueue); |
|
267 delete iNewAPIFindViewEventQueue; |
|
268 |
|
269 if (iSubViewNewAPI) |
|
270 iSubViewNewAPI->Close(*iNewAPISubViewEventQueue); |
|
271 delete iNewAPISubViewEventQueue; |
|
272 |
|
273 if (iLocalView) |
|
274 iLocalView->Close(*iLocalViewEventQueue); |
|
275 delete iLocalViewEventQueue; |
|
276 |
|
277 if (iRemoteView) |
|
278 iRemoteView->Close(*iRemoteViewEventQueue); |
|
279 delete iRemoteViewEventQueue; |
|
280 |
|
281 iContactIdArray->Reset(); |
|
282 delete iContactIdArray; |
|
283 |
|
284 iViewSortOrder.Close(); |
|
285 delete iDbEventQueue; |
|
286 delete iDb; |
|
287 TRAP_IGNORE(CContactDatabase::DeleteDatabaseL(KTestDbName)); |
|
288 } |
|
289 |
|
290 LOCAL_C CTestResources* DoTestAddContactAPILC(TBool aShowContactInGrp) |
|
291 { |
|
292 //add 2 contacts and check if localview send events |
|
293 CTestResources* res = CTestResources::NewLC(aShowContactInGrp); |
|
294 |
|
295 const TContactItemId contactId = res->CreateTestContactL(_L("Example1")); |
|
296 res->iContactIdArray->AddL(contactId); |
|
297 |
|
298 // Check that iLocalView sends an event |
|
299 TContactViewEvent event; |
|
300 test(res->iLocalViewEventQueue->ListenForEvent(10,event)); |
|
301 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
302 test(event.iContactId == contactId); |
|
303 test(event.iInt == 0 && event.iInt < res->iLocalView->CountL()); |
|
304 test(res->iLocalView->AtL(event.iInt) == res->iTestContactId); |
|
305 |
|
306 if(aShowContactInGrp) |
|
307 { |
|
308 test(res->iLocalViewEventQueue->ListenForEvent(10,event)); |
|
309 test(event.iEventType == TContactViewEvent::EGroupChanged); |
|
310 test(event.iContactId == res->iGrpId); |
|
311 } |
|
312 |
|
313 const TContactItemId contactId1 = res->CreateTestContactL(_L("Example2")); |
|
314 res->iContactIdArray->AddL(contactId1); |
|
315 |
|
316 //get the EItemAdd event |
|
317 test(res->iLocalViewEventQueue->ListenForEvent(10,event)); |
|
318 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
319 test(event.iContactId == contactId1); |
|
320 test(event.iInt == 1); |
|
321 test(res->iLocalView->AtL(event.iInt) == res->iTestContactId); |
|
322 |
|
323 if(aShowContactInGrp) |
|
324 { |
|
325 test(res->iLocalViewEventQueue->ListenForEvent(10,event)); |
|
326 test(event.iEventType == TContactViewEvent::EGroupChanged); |
|
327 test(event.iContactId == res->iGrpId); |
|
328 } |
|
329 |
|
330 return res; |
|
331 } |
|
332 |
|
333 |
|
334 LOCAL_C void TestAddContactOldAPIL(TBool aShowContactInGrp) |
|
335 { |
|
336 test.Next(_L("Add a contact with phone number - old api")); |
|
337 |
|
338 CTestResources* res = DoTestAddContactAPILC(aShowContactInGrp); |
|
339 |
|
340 TContactViewEvent event; |
|
341 |
|
342 for(int i = 0; i < 2; i++) |
|
343 { |
|
344 // There should come EItemAdded event from group view - check if iInt is the right one |
|
345 test(res->iOldAPIGroupViewEventQueue->ListenForEvent(10,event)); |
|
346 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
347 test(event.iInt == 0); |
|
348 |
|
349 if(aShowContactInGrp) |
|
350 { |
|
351 //Consume add to group event |
|
352 test(res->iOldAPIGroupViewEventQueue->ListenForEvent(10,event)); |
|
353 } |
|
354 |
|
355 // There should come EItemAdded event from find view - check if iInt is the right one |
|
356 test(res->iOldAPIFindViewEventQueue->ListenForEvent(10,event)); |
|
357 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
358 test(event.iInt == 0); |
|
359 |
|
360 if(aShowContactInGrp) |
|
361 { |
|
362 //Consume add to group event |
|
363 test(res->iOldAPIFindViewEventQueue->ListenForEvent(10,event)); |
|
364 } |
|
365 |
|
366 // There should come EItemAdded event from sub view - check if iInt is the right one |
|
367 test(res->iOldAPISubViewEventQueue->ListenForEvent(10,event)); |
|
368 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
369 test(event.iInt == 0); |
|
370 |
|
371 if(aShowContactInGrp) |
|
372 { |
|
373 //Consume add to group event |
|
374 test(res->iOldAPISubViewEventQueue->ListenForEvent(10,event)); |
|
375 } |
|
376 } |
|
377 CleanupStack::PopAndDestroy(res); |
|
378 } |
|
379 |
|
380 |
|
381 LOCAL_C void TestRemoveContactOldAPIL(TBool aShowContactInGrp) |
|
382 { |
|
383 test.Next(_L("Remove a contact with phone number - old api")); |
|
384 |
|
385 CTestResources* res = DoTestAddContactAPILC(aShowContactInGrp); |
|
386 |
|
387 TContactViewEvent viewEvent; |
|
388 |
|
389 int factor = aShowContactInGrp? 2 : 1; |
|
390 |
|
391 // first comsume the add events from group view, find view and sub view |
|
392 for(int i = 0; i < 2 * factor; i++) |
|
393 { |
|
394 test(res->iOldAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
395 test(res->iOldAPIFindViewEventQueue->ListenForEvent(10,viewEvent)); |
|
396 test(res->iOldAPISubViewEventQueue->ListenForEvent(10,viewEvent)); |
|
397 } |
|
398 |
|
399 // Delete the last added contact |
|
400 res->iDb->DeleteContactL(res->iTestContactId); |
|
401 |
|
402 // Wait for a DB event |
|
403 TContactDbObserverEvent dbEvent; |
|
404 if(aShowContactInGrp) |
|
405 { |
|
406 test(res->iDbEventQueue->ListenForEvent(10,dbEvent)); |
|
407 test(dbEvent.iType == EContactDbObserverEventGroupChanged); |
|
408 } |
|
409 |
|
410 test(res->iDbEventQueue->ListenForEvent(10,dbEvent)); |
|
411 test(dbEvent.iType == EContactDbObserverEventContactDeleted); |
|
412 test(dbEvent.iContactId == res->iTestContactId); |
|
413 |
|
414 // Check that iLocalView sends an event |
|
415 test(res->iLocalViewEventQueue->ListenForEvent(10,viewEvent)); |
|
416 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
417 test(viewEvent.iContactId == res->iTestContactId); |
|
418 test(viewEvent.iInt == 1); |
|
419 test(res->iLocalView->FindL(viewEvent.iContactId) == KErrNotFound); |
|
420 |
|
421 // There should come events from group view - check if iInt is the right one |
|
422 test(res->iOldAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
423 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
424 test(viewEvent.iContactId == res->iTestContactId); |
|
425 test(viewEvent.iInt == 1); |
|
426 test(res->iGroupViewOldAPI->FindL(viewEvent.iContactId) == KErrNotFound); |
|
427 |
|
428 // There should come events from find view - check if iInt is the right one |
|
429 test(res->iOldAPIFindViewEventQueue->ListenForEvent(10,viewEvent)); |
|
430 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
431 test(viewEvent.iContactId == res->iTestContactId); |
|
432 test(viewEvent.iInt == 0); |
|
433 test(res->iGroupViewOldAPI->FindL(viewEvent.iContactId) == KErrNotFound); |
|
434 |
|
435 // There should come events from sub view - check if iInt is the right one |
|
436 test(res->iOldAPISubViewEventQueue->ListenForEvent(10,viewEvent)); |
|
437 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
438 test(viewEvent.iContactId == res->iTestContactId); |
|
439 test(viewEvent.iInt == 0); |
|
440 test(res->iGroupViewOldAPI->FindL(viewEvent.iContactId) == KErrNotFound); |
|
441 |
|
442 CleanupStack::PopAndDestroy(res); |
|
443 } |
|
444 |
|
445 LOCAL_C void TestAddContactNewAPIL(TBool aShowContactInGrp) |
|
446 { |
|
447 test.Next(_L("Add a contact with phone number - new api")); |
|
448 |
|
449 CTestResources* res = DoTestAddContactAPILC(aShowContactInGrp); |
|
450 |
|
451 TContactViewEvent event; |
|
452 |
|
453 for(int i = 0; i < 2; i++) |
|
454 { |
|
455 // There should come EItemAdded event from group view - check if iInt is the right one |
|
456 if(aShowContactInGrp) |
|
457 { |
|
458 //Consume add to group event |
|
459 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,event)); |
|
460 test(event.iEventType == TContactViewEvent::ESortOrderChanged); |
|
461 } |
|
462 else //TO_FIX |
|
463 { |
|
464 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,event)); |
|
465 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
466 test(event.iInt == i); |
|
467 } |
|
468 |
|
469 |
|
470 // There should come EItemAdded event from find view - check if iInt is the right one |
|
471 test(res->iNewAPIFindViewEventQueue->ListenForEvent(10,event)); |
|
472 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
473 test(event.iInt == i); |
|
474 |
|
475 if(aShowContactInGrp) |
|
476 { |
|
477 //Consume add to group event |
|
478 test(res->iNewAPIFindViewEventQueue->ListenForEvent(10,event)); |
|
479 test(event.iEventType == TContactViewEvent::EGroupChanged); |
|
480 } |
|
481 |
|
482 |
|
483 // There should come EItemAdded event from sub view - check if iInt is the right one |
|
484 test(res->iNewAPISubViewEventQueue->ListenForEvent(10,event)); |
|
485 test(event.iEventType == TContactViewEvent::EItemAdded); |
|
486 test(event.iInt == i); |
|
487 if(aShowContactInGrp) |
|
488 { |
|
489 //Consume add to group event |
|
490 test(res->iNewAPISubViewEventQueue->ListenForEvent(10,event)); |
|
491 test(event.iEventType == TContactViewEvent::EGroupChanged); |
|
492 } |
|
493 |
|
494 } |
|
495 CleanupStack::PopAndDestroy(res); |
|
496 } |
|
497 |
|
498 |
|
499 LOCAL_C void TestRemoveContactNewAPIL(TBool aShowContactInGrp) |
|
500 { |
|
501 test.Next(_L("Remove a contact with phone number - new api")); |
|
502 |
|
503 CTestResources* res = DoTestAddContactAPILC(aShowContactInGrp); |
|
504 |
|
505 TContactViewEvent viewEvent; |
|
506 |
|
507 // first comsume the add events from group view, find view and sub view |
|
508 res->iNewAPIGroupViewEventQueue->Flush(); |
|
509 res->iNewAPIFindViewEventQueue->Flush(); |
|
510 res->iNewAPISubViewEventQueue->Flush(); |
|
511 |
|
512 // Delete the last added contact |
|
513 res->iDb->DeleteContactL(res->iTestContactId); |
|
514 |
|
515 // Wait for a DB event |
|
516 TContactDbObserverEvent dbEvent; |
|
517 if(aShowContactInGrp) |
|
518 { |
|
519 test(res->iDbEventQueue->ListenForEvent(10,dbEvent)); |
|
520 test(dbEvent.iType == EContactDbObserverEventGroupChanged); |
|
521 } |
|
522 |
|
523 test(res->iDbEventQueue->ListenForEvent(10,dbEvent)); |
|
524 test(dbEvent.iType == EContactDbObserverEventContactDeleted); |
|
525 test(dbEvent.iContactId == res->iTestContactId); |
|
526 |
|
527 // Check that iLocalView sends an event |
|
528 test(res->iLocalViewEventQueue->ListenForEvent(10,viewEvent)); |
|
529 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
530 test(viewEvent.iContactId == res->iTestContactId); |
|
531 test(viewEvent.iInt == 1); |
|
532 test(res->iLocalView->FindL(viewEvent.iContactId) == KErrNotFound); |
|
533 |
|
534 // There should come events from group view - check if iInt is the right one |
|
535 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
536 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
537 test(viewEvent.iContactId == res->iTestContactId); |
|
538 test(viewEvent.iInt == 1); |
|
539 test(res->iGroupViewOldAPI->FindL(viewEvent.iContactId) == KErrNotFound); |
|
540 |
|
541 // There should come events from find view - check if iInt is the right one |
|
542 test(res->iNewAPIFindViewEventQueue->ListenForEvent(10,viewEvent)); |
|
543 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
544 test(viewEvent.iContactId == res->iTestContactId); |
|
545 test(viewEvent.iInt == 1); |
|
546 test(res->iGroupViewOldAPI->FindL(viewEvent.iContactId) == KErrNotFound); |
|
547 |
|
548 // There should come events from sub view - check if iInt is the right one |
|
549 test(res->iNewAPISubViewEventQueue->ListenForEvent(10,viewEvent)); |
|
550 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
551 test(viewEvent.iContactId == res->iTestContactId); |
|
552 test(viewEvent.iInt == 1); |
|
553 test(res->iGroupViewOldAPI->FindL(viewEvent.iContactId) == KErrNotFound); |
|
554 |
|
555 CleanupStack::PopAndDestroy(res); |
|
556 } |
|
557 |
|
558 /* |
|
559 This function checks that for multiple deletes using the DeleteContactsL api, this generates |
|
560 an EUnavailable event before sending EItemRemoved events to signify that the views are |
|
561 not synchronised yet. When the views are synchronised then a final EReady event is sent |
|
562 and all the views should then be consistent. All the subviews also receive the EUnavailable |
|
563 and EReady events. |
|
564 */ |
|
565 |
|
566 |
|
567 LOCAL_C void TestRemoveContactsNewAPIL(TBool aShowContactInGrp) |
|
568 { |
|
569 test.Next(_L("Remove multiple contacts with phone number - new api")); |
|
570 |
|
571 CTestResources* res = DoTestAddContactAPILC(aShowContactInGrp); |
|
572 |
|
573 TContactViewEvent viewEvent; |
|
574 |
|
575 // first consume the add events from group view, find view and sub view |
|
576 res->iNewAPIGroupViewEventQueue->Flush(); |
|
577 res->iNewAPIFindViewEventQueue->Flush(); |
|
578 res->iNewAPISubViewEventQueue->Flush(); |
|
579 |
|
580 // Delete multiple contacts, there are two in the array |
|
581 res->iDb->DeleteContactsL(*(res->iContactIdArray)); |
|
582 |
|
583 |
|
584 //Check that the view has not been updated yet after the delete |
|
585 TInt groupViewCount = res->iGroupViewNewAPI->CountL(); |
|
586 test(groupViewCount == 2); |
|
587 TInt contactViewBaseContactId = res->iGroupViewNewAPI->AtL(0); |
|
588 const CViewContact &vcontact = res->iGroupViewNewAPI->ContactAtL(0); |
|
589 |
|
590 |
|
591 // Wait for a DB event |
|
592 TContactDbObserverEvent dbEvent; |
|
593 |
|
594 test(res->iDbEventQueue->ListenForEvent(10,dbEvent)); |
|
595 test(res->iDbEventQueue->ListenForEvent(10,dbEvent)); |
|
596 test(dbEvent.iType == EContactDbObserverEventUnknownChanges); |
|
597 |
|
598 // Check that iLocalView sends an event |
|
599 test(res->iLocalViewEventQueue->ListenForEvent(10,viewEvent)); |
|
600 test(viewEvent.iEventType == TContactViewEvent::EUnavailable); |
|
601 test(res->iLocalViewEventQueue->ListenForEvent(10,viewEvent)); |
|
602 test(viewEvent.iEventType == TContactViewEvent::EReady); |
|
603 |
|
604 |
|
605 // There should be events from the group view - check if iInt is the right one |
|
606 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
607 test(viewEvent.iEventType == TContactViewEvent::EUnavailable); |
|
608 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
609 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
610 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
611 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
612 test(viewEvent.iContactId == res->iTestContactId); |
|
613 test(viewEvent.iInt == 0); |
|
614 |
|
615 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
616 test(viewEvent.iEventType == TContactViewEvent::EReady); |
|
617 |
|
618 |
|
619 // The group view should be consistent, there should be no contacts in this view |
|
620 groupViewCount = res->iGroupViewNewAPI->CountL(); |
|
621 test(groupViewCount == 0); |
|
622 // should not be able to find anything |
|
623 TRAPD(err, contactViewBaseContactId = res->iGroupViewNewAPI->AtL(0)); |
|
624 test(err == KErrNotFound); |
|
625 |
|
626 |
|
627 |
|
628 // Check that the find view receives its events |
|
629 if(aShowContactInGrp) |
|
630 { |
|
631 test(res->iNewAPIFindViewEventQueue->ListenForEvent(10,viewEvent)); |
|
632 test(viewEvent.iEventType == TContactViewEvent::EUnavailable); |
|
633 test(res->iNewAPIFindViewEventQueue->ListenForEvent(10,viewEvent)); |
|
634 test(viewEvent.iEventType == TContactViewEvent::EReady); |
|
635 } |
|
636 |
|
637 |
|
638 // Check that the subview event queue receives events correctly |
|
639 if(aShowContactInGrp) |
|
640 { |
|
641 test(res->iNewAPISubViewEventQueue->ListenForEvent(10,viewEvent)); |
|
642 test(viewEvent.iEventType == TContactViewEvent::EUnavailable); |
|
643 test(res->iNewAPISubViewEventQueue->ListenForEvent(10,viewEvent)); |
|
644 test(viewEvent.iEventType == TContactViewEvent::EReady); |
|
645 } |
|
646 test.Next(_L("Remove multiple contacts with phone number - new api Successfull")); |
|
647 CleanupStack::PopAndDestroy(res); |
|
648 } |
|
649 |
|
650 /* |
|
651 This function checks that for multiple deletes using the DeleteContactL api, EItemRemoved |
|
652 events are sent in the right order and with the right info. A remote view is used |
|
653 */ |
|
654 |
|
655 |
|
656 LOCAL_C void TestRemoveContactRemoteViewNewAPIL(TBool aShowContactInGrp) |
|
657 { |
|
658 test.Next(_L("Remote view - delete multiple contacts - new api")); |
|
659 |
|
660 CTestResources* res = CTestResources::NewLC(aShowContactInGrp, ETrue); |
|
661 TContactViewEvent viewEvent; |
|
662 |
|
663 CContactIdArray* idArray = CContactIdArray::NewLC(); |
|
664 // Create 4 contacts |
|
665 for(TInt loop = 0; loop < 4; ++loop) |
|
666 { |
|
667 idArray->AddL(res->CreateTestContactL(_L("a"))); |
|
668 } |
|
669 |
|
670 //just consume events |
|
671 while(res->iRemoteViewEventQueue->ListenForEvent(1, viewEvent)) |
|
672 { |
|
673 } |
|
674 |
|
675 // how many contacts do we have in remote view? |
|
676 TInt remoteViewCount = res->iRemoteView->CountL(); |
|
677 test(remoteViewCount == 4); |
|
678 |
|
679 //delete all contacts now |
|
680 for(TInt loop = 0; loop < idArray->Count(); ++loop) |
|
681 { |
|
682 res->iDb->DeleteContactL((*idArray)[loop]); |
|
683 } |
|
684 |
|
685 int currentEvent = 0; |
|
686 // check incoming events |
|
687 while(res->iRemoteViewEventQueue->ListenForEvent(1, viewEvent)) |
|
688 { |
|
689 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); |
|
690 test(viewEvent.iInt == 0); |
|
691 test(viewEvent.iContactId == (*idArray)[currentEvent++]); |
|
692 } |
|
693 |
|
694 while(idArray->Count() > 0) |
|
695 { |
|
696 idArray->Remove(0); |
|
697 } |
|
698 |
|
699 CleanupStack::PopAndDestroy(2, res); |
|
700 } |
|
701 |
|
702 LOCAL_C void SetTextFieldL(CContactItem& aItem, TUid aType, const TDesC& aValue) |
|
703 { |
|
704 CContactItemFieldSet& fieldSet = aItem.CardFields(); |
|
705 const TInt pos = fieldSet.Find(aType); |
|
706 if(pos == KErrNotFound) |
|
707 { |
|
708 // if does not exist add this field |
|
709 CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, aType); |
|
710 field->TextStorage()->SetTextL(aValue); |
|
711 aItem.AddFieldL(*field); |
|
712 CleanupStack::Pop(field); |
|
713 } |
|
714 else |
|
715 { |
|
716 fieldSet[pos].TextStorage()->SetTextL(aValue); |
|
717 } |
|
718 } |
|
719 |
|
720 |
|
721 LOCAL_C void TestSimulateSyncSessionL() |
|
722 { |
|
723 test.Next(_L("Simulate a sync session - 2 contacts changed - new api")); |
|
724 |
|
725 CTestResources* res = CTestResources::NewLC(ETrue, ETrue); |
|
726 TContactViewEvent viewEvent; |
|
727 |
|
728 // Create 2 contacts |
|
729 TContactItemId firstContactId = res->CreateTestContactL(_L("ExampleA")); |
|
730 TContactItemId secondContactId = res->CreateTestContactL(_L("ExampleB")); |
|
731 |
|
732 //we should have 5 events here |
|
733 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
734 test(viewEvent.iEventType == TContactViewEvent::EReady); |
|
735 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
736 test(viewEvent.iEventType == TContactViewEvent::EItemAdded); |
|
737 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
738 test(viewEvent.iEventType == TContactViewEvent::ESortOrderChanged); |
|
739 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
740 test(viewEvent.iEventType == TContactViewEvent::EItemAdded); |
|
741 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10,viewEvent)); |
|
742 test(viewEvent.iEventType == TContactViewEvent::ESortOrderChanged); |
|
743 |
|
744 TInt groupViewCount = res->iGroupViewNewAPI->CountL(); |
|
745 test(groupViewCount == 2); |
|
746 |
|
747 // change existing contact items |
|
748 CContactItem* firstContact = res->iDb->OpenContactL(firstContactId); |
|
749 CleanupStack::PushL(firstContact); |
|
750 CContactItem* secondContact = res->iDb->OpenContactL(secondContactId); |
|
751 CleanupStack::PushL(secondContact); |
|
752 |
|
753 // change name |
|
754 SetTextFieldL(*firstContact, KUidContactFieldFamilyName, _L("ExampleA1")); |
|
755 SetTextFieldL(*secondContact, KUidContactFieldFamilyName, _L("1ExampleB")); |
|
756 |
|
757 res->iNewAPIGroupViewEventQueue->Flush(); |
|
758 res->iNewAPIFindViewEventQueue->Flush(); |
|
759 res->iNewAPISubViewEventQueue->Flush(); |
|
760 |
|
761 res->iDb->CommitContactL(*firstContact); |
|
762 res->iDb->CommitContactL(*secondContact); |
|
763 |
|
764 // check events and count in group view after these changes |
|
765 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
766 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); //first we should have a removed |
|
767 test(res->iGroupViewNewAPI->CountL() == 1); |
|
768 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
769 test(viewEvent.iEventType == TContactViewEvent::EItemAdded); //then we should have an add |
|
770 test(res->iGroupViewNewAPI->CountL() == 2); |
|
771 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
772 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); //then we should have a removed |
|
773 test(res->iGroupViewNewAPI->CountL() == 1); |
|
774 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
775 test(viewEvent.iEventType == TContactViewEvent::EItemAdded); //then we should have an add |
|
776 test(res->iGroupViewNewAPI->CountL() == 2); |
|
777 |
|
778 // check now the status of the group view - we should have 1Baname ; Apan1 in the group view |
|
779 test(res->iGroupViewNewAPI->ContactAtL(0).Id() == secondContactId); |
|
780 test(res->iGroupViewNewAPI->ContactAtL(1).Id() == firstContactId); |
|
781 CleanupStack::PopAndDestroy(2, firstContact); |
|
782 |
|
783 // change back |
|
784 firstContact = res->iDb->OpenContactL(firstContactId); |
|
785 CleanupStack::PushL(firstContact); |
|
786 secondContact = res->iDb->OpenContactL(secondContactId); |
|
787 CleanupStack::PushL(secondContact); |
|
788 // change back contacts |
|
789 SetTextFieldL(*firstContact, KUidContactFieldFamilyName, _L("ExampleA")); |
|
790 SetTextFieldL(*secondContact, KUidContactFieldFamilyName, _L("ExampleB")); |
|
791 res->iDb->CommitContactL(*firstContact); |
|
792 res->iDb->CommitContactL(*secondContact); |
|
793 //just consume events |
|
794 while(res->iNewAPIGroupViewEventQueue->ListenForEvent(1, viewEvent)) |
|
795 { |
|
796 } |
|
797 // check now the status of the group view - we should have Apan ; Baname in the group view |
|
798 test(res->iGroupViewNewAPI->ContactAtL(0).Id() == firstContactId); |
|
799 test(res->iGroupViewNewAPI->ContactAtL(1).Id() == secondContactId); |
|
800 CleanupStack::PopAndDestroy(2, firstContact); |
|
801 |
|
802 // change again contacts but commit changes in different order |
|
803 firstContact = res->iDb->OpenContactL(firstContactId); |
|
804 CleanupStack::PushL(firstContact); |
|
805 secondContact = res->iDb->OpenContactL(secondContactId); |
|
806 CleanupStack::PushL(secondContact); |
|
807 // change back contacts |
|
808 SetTextFieldL(*firstContact, KUidContactFieldFamilyName, _L("ExampleA1")); |
|
809 SetTextFieldL(*secondContact, KUidContactFieldFamilyName, _L("1ExampleB")); |
|
810 res->iDb->CommitContactL(*firstContact); |
|
811 res->iDb->CommitContactL(*secondContact); |
|
812 |
|
813 // check events and count in group view after these changes |
|
814 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
815 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); //first we should have a removed |
|
816 test(res->iGroupViewNewAPI->CountL() == 1); |
|
817 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
818 test(viewEvent.iEventType == TContactViewEvent::EItemAdded); //then we should have an add |
|
819 test(res->iGroupViewNewAPI->CountL() == 2); |
|
820 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
821 test(viewEvent.iEventType == TContactViewEvent::EItemRemoved); //then we should have a removed |
|
822 test(res->iGroupViewNewAPI->CountL() == 1); |
|
823 test(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)); |
|
824 test(viewEvent.iEventType == TContactViewEvent::EItemAdded); //then we should have an add |
|
825 test(res->iGroupViewNewAPI->CountL() == 2); |
|
826 // check now the status of the group view - we should have 1Baname ; Apan1 in the group view |
|
827 test(res->iGroupViewNewAPI->ContactAtL(0).Id() == secondContactId); |
|
828 test(res->iGroupViewNewAPI->ContactAtL(1).Id() == firstContactId); |
|
829 |
|
830 CleanupStack::PopAndDestroy(3, res); |
|
831 } |
|
832 |
|
833 |
|
834 LOCAL_C void TestSimulateSyncSession1L() |
|
835 { |
|
836 test.Next(_L("Simulate a sync session - 3 contacts changed - new api - new api")); |
|
837 |
|
838 CTestResources* res = CTestResources::NewLC(ETrue, ETrue); |
|
839 TContactViewEvent viewEvent; |
|
840 |
|
841 // Create 3 contacts |
|
842 TContactItemId firstContactId = res->CreateTestContactL(_L("a")); |
|
843 TContactItemId secondContactId = res->CreateTestContactL(_L("b")); |
|
844 TContactItemId thirdContactId = res->CreateTestContactL(_L("c")); |
|
845 |
|
846 //just consume events |
|
847 while(res->iNewAPIGroupViewEventQueue->ListenForEvent(10, viewEvent)) |
|
848 { |
|
849 } |
|
850 |
|
851 TInt groupViewCount = res->iGroupViewNewAPI->CountL(); |
|
852 test(groupViewCount == 3); |
|
853 |
|
854 // change existing contact items |
|
855 CContactItem* firstContact = res->iDb->OpenContactL(firstContactId); |
|
856 CleanupStack::PushL(firstContact); |
|
857 CContactItem* secondContact = res->iDb->OpenContactL(secondContactId); |
|
858 CleanupStack::PushL(secondContact); |
|
859 CContactItem* thirdContact = res->iDb->OpenContactL(thirdContactId); |
|
860 CleanupStack::PushL(thirdContact); |
|
861 |
|
862 // change name |
|
863 SetTextFieldL(*firstContact, KUidContactFieldFamilyName, _L("3a")); |
|
864 SetTextFieldL(*secondContact, KUidContactFieldFamilyName, _L("2b")); |
|
865 SetTextFieldL(*thirdContact, KUidContactFieldFamilyName, _L("1c")); |
|
866 |
|
867 res->iNewAPIGroupViewEventQueue->Flush(); |
|
868 res->iNewAPIFindViewEventQueue->Flush(); |
|
869 res->iNewAPISubViewEventQueue->Flush(); |
|
870 |
|
871 res->iDb->CommitContactL(*firstContact); |
|
872 res->iDb->CommitContactL(*secondContact); |
|
873 res->iDb->CommitContactL(*thirdContact); |
|
874 |
|
875 //just consume events |
|
876 while(res->iNewAPIGroupViewEventQueue->ListenForEvent(1, viewEvent)) |
|
877 { |
|
878 } |
|
879 |
|
880 // check now the status of the group view - we should have 1c ; 2b ; 3a in the group view |
|
881 test(res->iGroupViewNewAPI->ContactAtL(0).Id() == thirdContactId); |
|
882 test(res->iGroupViewNewAPI->ContactAtL(1).Id() == secondContactId); |
|
883 test(res->iGroupViewNewAPI->ContactAtL(2).Id() == firstContactId); |
|
884 CleanupStack::PopAndDestroy(3, firstContact); |
|
885 |
|
886 //change back |
|
887 firstContact = res->iDb->OpenContactL(firstContactId); |
|
888 CleanupStack::PushL(firstContact); |
|
889 secondContact = res->iDb->OpenContactL(secondContactId); |
|
890 CleanupStack::PushL(secondContact); |
|
891 thirdContact = res->iDb->OpenContactL(thirdContactId); |
|
892 CleanupStack::PushL(thirdContact); |
|
893 |
|
894 // change name |
|
895 SetTextFieldL(*firstContact, KUidContactFieldFamilyName, _L("a")); |
|
896 SetTextFieldL(*secondContact, KUidContactFieldFamilyName, _L("b")); |
|
897 SetTextFieldL(*thirdContact, KUidContactFieldFamilyName, _L("c")); |
|
898 |
|
899 res->iDb->CommitContactL(*firstContact); |
|
900 res->iDb->CommitContactL(*secondContact); |
|
901 res->iDb->CommitContactL(*thirdContact); |
|
902 |
|
903 //just consume events |
|
904 while(res->iNewAPIGroupViewEventQueue->ListenForEvent(1, viewEvent)) |
|
905 { |
|
906 } |
|
907 |
|
908 // check now the status of the group view - we should have a ; b ; c in the group view |
|
909 test(res->iGroupViewNewAPI->ContactAtL(0).Id() == firstContactId); |
|
910 test(res->iGroupViewNewAPI->ContactAtL(1).Id() == secondContactId); |
|
911 test(res->iGroupViewNewAPI->ContactAtL(2).Id() == thirdContactId); |
|
912 |
|
913 CleanupStack::PopAndDestroy(4, res); |
|
914 } |
|
915 |
|
916 /** |
|
917 |
|
918 @SYMTestCaseID PIM-T-CONTACTVIEWEVENTS-0001 |
|
919 |
|
920 */ |
|
921 |
|
922 void DoTestsL() |
|
923 { |
|
924 test.Start(_L("@SYMTESTCaseID:PIM-T-CONTACTVIEWEVENTS-0001 T_FilteredViewEvents")); |
|
925 |
|
926 |
|
927 //Test with contacts not in group |
|
928 TestAddContactOldAPIL(EFalse); |
|
929 TestRemoveContactOldAPIL(EFalse); |
|
930 TestAddContactNewAPIL(EFalse); |
|
931 TestRemoveContactNewAPIL(EFalse); |
|
932 TestRemoveContactRemoteViewNewAPIL(EFalse); |
|
933 |
|
934 //Test with contacts in group |
|
935 TestAddContactOldAPIL(ETrue); |
|
936 TestRemoveContactOldAPIL(ETrue); |
|
937 TestAddContactNewAPIL(ETrue); |
|
938 TestRemoveContactNewAPIL(ETrue); |
|
939 TestRemoveContactRemoteViewNewAPIL(ETrue); |
|
940 |
|
941 // remove multiple contacts |
|
942 TestRemoveContactsNewAPIL(ETrue); |
|
943 TestSimulateSyncSessionL(); |
|
944 TestSimulateSyncSession1L(); |
|
945 |
|
946 test.End(); |
|
947 test.Close(); |
|
948 |
|
949 } |
|
950 |
|
951 GLDEF_C TInt E32Main() |
|
952 { |
|
953 // Init |
|
954 __UHEAP_MARK; |
|
955 |
|
956 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
957 if (!cleanupStack) |
|
958 { |
|
959 return KErrNoMemory; |
|
960 } |
|
961 |
|
962 CActiveScheduler* activeScheduler = new CActiveScheduler; |
|
963 if (!activeScheduler) |
|
964 { |
|
965 return KErrNoMemory; |
|
966 } |
|
967 CActiveScheduler::Install(activeScheduler); |
|
968 |
|
969 // Run the tests |
|
970 TRAPD(err, DoTestsL()); |
|
971 |
|
972 // Cleanup |
|
973 delete activeScheduler; |
|
974 delete cleanupStack; |
|
975 |
|
976 __UHEAP_MARKEND; |
|
977 |
|
978 return err; |
|
979 } |