|
1 // Copyright (c) 2003-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 // PreferencesBug Test module |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include <e32test.h> |
|
20 #include <cntdef.h> |
|
21 #include <cntdb.h> |
|
22 #include <cntitem.h> |
|
23 #include <cntfield.h> |
|
24 #include <cntfldst.h> |
|
25 #include <cntviewbase.h> |
|
26 |
|
27 #include "CContactViewEventQueue.h" |
|
28 #include "CContactDbEventQueue.h" |
|
29 |
|
30 _LIT(KTestName, "T_PreferencesBug"); |
|
31 |
|
32 _LIT(KTestDbName, "c:T_PreferencesBug.cdb"); |
|
33 |
|
34 const TInt KEventWaitTime = 2; |
|
35 |
|
36 LOCAL_D RTest test(KTestName); |
|
37 |
|
38 enum TPanicCode |
|
39 { |
|
40 EPanicNoReadyEventFromView = 1 |
|
41 }; |
|
42 |
|
43 static void Panic(TInt aReason) |
|
44 { |
|
45 User::Panic(KTestName, aReason); |
|
46 } |
|
47 |
|
48 class CTestResources : public CBase |
|
49 { |
|
50 public: // Interface |
|
51 static CTestResources* NewLC(); |
|
52 void ConstructL(); |
|
53 void CreateTestViewsL |
|
54 (TContactViewPreferences aAddViewPreferences=static_cast<TContactViewPreferences>(0)); |
|
55 ~CTestResources(); |
|
56 |
|
57 enum TTestViews |
|
58 { |
|
59 ETestViewContactsOnly, |
|
60 ETestViewGroupsOnly, |
|
61 ETestViewContactsAndGroups |
|
62 }; |
|
63 |
|
64 CContactDatabase& Db() const { return *iDb; } |
|
65 CContactDbEventQueue& DbEvents() const { return *iDbEvents; } |
|
66 |
|
67 CContactViewBase& TestView(TTestViews aViewIndex) const |
|
68 { |
|
69 return *iTestViews[aViewIndex].iView; |
|
70 } |
|
71 |
|
72 CContactViewEventQueue& TestViewEvents(TTestViews aViewIndex) const |
|
73 { |
|
74 return *iTestViews[aViewIndex].iViewEvents; |
|
75 } |
|
76 |
|
77 private: // Implementation |
|
78 struct TTestViewInit |
|
79 { |
|
80 enum { KMaxSortOrderLen = 5 }; |
|
81 TContactViewPreferences iViewPrefs; |
|
82 TInt iSortOrder[KMaxSortOrderLen]; |
|
83 }; |
|
84 |
|
85 class TTestView |
|
86 { |
|
87 public: |
|
88 TTestView(); |
|
89 void InitLC |
|
90 (CContactDatabase& aDb, |
|
91 TContactViewPreferences aAddViewPreferences, |
|
92 const TTestViewInit& aInit); |
|
93 void Destroy(); |
|
94 RContactViewSortOrder iSortOrder; |
|
95 CContactViewEventQueue* iViewEvents; |
|
96 CContactLocalView* iView; |
|
97 private: |
|
98 static void Cleanup(TAny* aPtr); |
|
99 }; |
|
100 |
|
101 private: // Data |
|
102 static const TTestViewInit iTestViewInit[]; |
|
103 CContactDatabase* iDb; |
|
104 CContactDbEventQueue* iDbEvents; |
|
105 RArray<TTestView> iTestViews; |
|
106 }; |
|
107 |
|
108 // Constant data for creating the test views |
|
109 const CTestResources::TTestViewInit CTestResources::iTestViewInit[] = |
|
110 { |
|
111 { EContactsOnly, |
|
112 { KUidContactFieldFamilyNameValue, KUidContactFieldGivenNameValue, KUidContactFieldCompanyNameValue, KNullUidValue } }, |
|
113 { EGroupsOnly, |
|
114 { KUidContactFieldTemplateLabelValue, KNullUidValue } }, |
|
115 { EContactAndGroups, |
|
116 { KUidContactFieldFamilyNameValue, KUidContactFieldGivenNameValue, KUidContactFieldCompanyNameValue, KUidContactFieldTemplateLabelValue, KNullUidValue } }, |
|
117 { static_cast<TContactViewPreferences>(0), { KNullUidValue } } |
|
118 }; |
|
119 |
|
120 CTestResources* CTestResources::NewLC() |
|
121 { |
|
122 CTestResources* self = new(ELeave) CTestResources; |
|
123 CleanupStack::PushL(self); |
|
124 self->ConstructL(); |
|
125 return self; |
|
126 } |
|
127 |
|
128 void CTestResources::ConstructL() |
|
129 { |
|
130 iDb = CContactDatabase::ReplaceL(KTestDbName); |
|
131 iDbEvents = CContactDbEventQueue::NewL(iDb); |
|
132 } |
|
133 |
|
134 void CTestResources::CreateTestViewsL(TContactViewPreferences aAddViewPreferences) |
|
135 { |
|
136 for (const TTestViewInit* initData = iTestViewInit; |
|
137 initData->iSortOrder[0]!=KNullUidValue; |
|
138 ++initData) |
|
139 { |
|
140 TTestView testView; |
|
141 testView.InitLC(*iDb,aAddViewPreferences,*initData); |
|
142 User::LeaveIfError(iTestViews.Append(testView)); |
|
143 CleanupStack::Pop(); // testView |
|
144 } |
|
145 |
|
146 // Wait for the views to get ready |
|
147 for (TInt i=0; i<iTestViews.Count(); ++i) |
|
148 { |
|
149 TContactViewEvent event; |
|
150 __ASSERT_ALWAYS(iTestViews[i].iViewEvents->ListenForEvent(10,event), |
|
151 Panic(EPanicNoReadyEventFromView)); |
|
152 __ASSERT_ALWAYS(event.iEventType==TContactViewEvent::EReady, |
|
153 Panic(EPanicNoReadyEventFromView)); |
|
154 } |
|
155 } |
|
156 |
|
157 CTestResources::~CTestResources() |
|
158 { |
|
159 for (TInt i=iTestViews.Count()-1; i>=0; --i) |
|
160 { |
|
161 iTestViews[i].Destroy(); |
|
162 } |
|
163 iTestViews.Close(); |
|
164 delete iDbEvents; |
|
165 delete iDb; |
|
166 TRAP_IGNORE(CContactDatabase::DeleteDatabaseL(KTestDbName)); |
|
167 } |
|
168 |
|
169 CTestResources::TTestView::TTestView() |
|
170 : iViewEvents(NULL), iView(NULL) |
|
171 { |
|
172 } |
|
173 |
|
174 void CTestResources::TTestView::InitLC |
|
175 (CContactDatabase& aDb, |
|
176 TContactViewPreferences aAddViewPreferences, |
|
177 const TTestViewInit& aInit) |
|
178 { |
|
179 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
180 for (const TInt* fieldType=aInit.iSortOrder; *fieldType!=KNullUidValue; ++fieldType) |
|
181 { |
|
182 iSortOrder.AppendL(TUid::Uid(*fieldType)); |
|
183 } |
|
184 iViewEvents = CContactViewEventQueue::NewL(); |
|
185 iView = CContactLocalView::NewL |
|
186 (*iViewEvents, |
|
187 aDb, |
|
188 iSortOrder, |
|
189 static_cast<TContactViewPreferences>(aInit.iViewPrefs|aAddViewPreferences)); |
|
190 } |
|
191 |
|
192 void CTestResources::TTestView::Destroy() |
|
193 { |
|
194 if (iView) iView->Close(*iViewEvents); |
|
195 delete iViewEvents; |
|
196 iSortOrder.Close(); |
|
197 } |
|
198 |
|
199 void CTestResources::TTestView::Cleanup(TAny* aPtr) |
|
200 { |
|
201 static_cast<TTestView*>(aPtr)->Destroy(); |
|
202 } |
|
203 |
|
204 |
|
205 LOCAL_C void AddFieldToContactL |
|
206 (CContactItem& aContact, TFieldType aFieldType, const TDesC& aText) |
|
207 { |
|
208 CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, aFieldType); |
|
209 field->TextStorage()->SetTextL(aText); |
|
210 aContact.AddFieldL(*field); |
|
211 CleanupStack::Pop(field); |
|
212 } |
|
213 |
|
214 LOCAL_C TContactItemId CreateTestContactL |
|
215 (CContactDatabase& aDb, |
|
216 const TDesC& aFamilyName, |
|
217 const TDesC& aGivenName, |
|
218 const TDesC& aCompanyName) |
|
219 { |
|
220 CContactCard* card = CContactCard::NewLC(); |
|
221 AddFieldToContactL(*card, KUidContactFieldFamilyName, aFamilyName); |
|
222 AddFieldToContactL(*card, KUidContactFieldGivenName, aGivenName); |
|
223 AddFieldToContactL(*card, KUidContactFieldCompanyName, aCompanyName); |
|
224 const TContactItemId id = aDb.AddNewContactL(*card); |
|
225 CleanupStack::PopAndDestroy(card); |
|
226 return id; |
|
227 } |
|
228 |
|
229 LOCAL_C TContactItemId CreateTestGroupL |
|
230 (CContactDatabase& aDb, |
|
231 const TDesC& aLabel) |
|
232 { |
|
233 CContactItem* group = aDb.CreateContactGroupLC(aLabel); |
|
234 const TContactItemId id = group->Id(); |
|
235 CleanupStack::PopAndDestroy(group); |
|
236 return id; |
|
237 } |
|
238 |
|
239 /** |
|
240 * Returns ETrue if aView contains all the contacts in aContacts. |
|
241 */ |
|
242 LOCAL_C TBool ContainsAllContactsL |
|
243 (const CContactViewBase& aView, const CContactIdArray& aContacts) |
|
244 { |
|
245 for (TInt i=0; i < aContacts.Count(); ++i) |
|
246 { |
|
247 if (aView.FindL(aContacts[i])==KErrNotFound) |
|
248 { |
|
249 return EFalse; |
|
250 } |
|
251 } |
|
252 return ETrue; |
|
253 } |
|
254 |
|
255 /** |
|
256 * Returns ETrue if aView doesn't contain _any_ contact of aContacts. |
|
257 */ |
|
258 LOCAL_C TBool DoesNotContainsContactsL |
|
259 (const CContactViewBase& aView, const CContactIdArray& aContacts) |
|
260 { |
|
261 for (TInt i=0; i < aContacts.Count(); ++i) |
|
262 { |
|
263 if (aView.FindL(aContacts[i])!=KErrNotFound) |
|
264 { |
|
265 return EFalse; |
|
266 } |
|
267 } |
|
268 return ETrue; |
|
269 } |
|
270 |
|
271 |
|
272 |
|
273 // TEST CODE |
|
274 |
|
275 LOCAL_C void TestOpenViewsWithExistingDataL |
|
276 (TContactViewPreferences aAddPrefs) |
|
277 { |
|
278 CTestResources* res = CTestResources::NewLC(); |
|
279 |
|
280 // Create test contacts and a group |
|
281 CContactIdArray* groups = CContactIdArray::NewLC(); |
|
282 TContactItemId groupId = CreateTestGroupL(res->Db(), _L("SYMBIANFOUNDATION")); |
|
283 groups->AddL(groupId); |
|
284 |
|
285 CContactIdArray* unsortedGroups = CContactIdArray::NewLC(); |
|
286 groupId = CreateTestGroupL(res->Db(), _L("")); |
|
287 unsortedGroups->AddL(groupId); |
|
288 |
|
289 CContactIdArray* contacts = CContactIdArray::NewLC(); |
|
290 TContactItemId id = CreateTestContactL(res->Db(), _L("Test"), _L("Name"), _L("SYMBIANFOUNDATION")); |
|
291 contacts->AddL(id); |
|
292 res->Db().AddContactToGroupL(id,(*groups)[0]); |
|
293 id = CreateTestContactL(res->Db(), _L("Example"), _L("Name"), _L("SYMBIANFOUNDATION")); |
|
294 contacts->AddL(id); |
|
295 res->Db().AddContactToGroupL(id,(*groups)[0]); |
|
296 id = CreateTestContactL(res->Db(), _L("Sample"), _L("Name"), _L("SYMBIANFOUNDATION1")); |
|
297 contacts->AddL(id); |
|
298 |
|
299 CContactIdArray* unsortedContacts = CContactIdArray::NewLC(); |
|
300 id = CreateTestContactL(res->Db(), _L(""), _L(""), _L("")); |
|
301 unsortedContacts->AddL(id); |
|
302 |
|
303 id = CreateTestContactL(res->Db(), _L(" "), _L(" "), _L(" ")); |
|
304 if (aAddPrefs & ESingleWhiteSpaceIsEmptyField) |
|
305 { |
|
306 unsortedContacts->AddL(id); |
|
307 } |
|
308 else |
|
309 { |
|
310 contacts->AddL(id); |
|
311 } |
|
312 |
|
313 // Eat all DB events |
|
314 TContactDbObserverEvent dbEvent; |
|
315 while (res->DbEvents().ListenForEvent(KEventWaitTime,dbEvent)) |
|
316 { |
|
317 } |
|
318 |
|
319 // Create the test contact views |
|
320 res->CreateTestViewsL(aAddPrefs); |
|
321 |
|
322 // Check the test view states |
|
323 test.Next(_L("Check EContactsOnly view contains all the contacts")); |
|
324 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewContactsOnly), *contacts)); |
|
325 if (res->TestView(CTestResources::ETestViewContactsOnly).ContactViewPreferences() & EIgnoreUnSorted) |
|
326 { |
|
327 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewContactsOnly), *unsortedContacts)); |
|
328 } |
|
329 else |
|
330 { |
|
331 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewContactsOnly), *unsortedContacts)); |
|
332 } |
|
333 |
|
334 test.Next(_L("Check EGroupsOnly view contains all the groups")); |
|
335 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewGroupsOnly), *groups)); |
|
336 if (res->TestView(CTestResources::ETestViewGroupsOnly).ContactViewPreferences() & EIgnoreUnSorted) |
|
337 { |
|
338 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewGroupsOnly), *unsortedGroups)); |
|
339 } |
|
340 else |
|
341 { |
|
342 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewGroupsOnly), *unsortedGroups)); |
|
343 } |
|
344 |
|
345 test.Next(_L("Check EContactAndGroups view contains all contacts and groups")); |
|
346 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewContactsAndGroups), *groups)); |
|
347 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewContactsAndGroups), *contacts)); |
|
348 if (res->TestView(CTestResources::ETestViewContactsAndGroups).ContactViewPreferences() & EIgnoreUnSorted) |
|
349 { |
|
350 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewContactsAndGroups), *unsortedContacts)); |
|
351 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewContactsAndGroups), *unsortedGroups)); |
|
352 } |
|
353 else |
|
354 { |
|
355 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewContactsAndGroups), *unsortedContacts)); |
|
356 test(ContainsAllContactsL(res->TestView(CTestResources::ETestViewContactsAndGroups), *unsortedGroups)); |
|
357 } |
|
358 |
|
359 test.Next(_L("Check EContactsOnly view does not contain any groups")); |
|
360 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewContactsOnly), *groups)); |
|
361 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewContactsOnly), *unsortedGroups)); |
|
362 |
|
363 test.Next(_L("Check EGroupsOnly view does not contain any contacts")); |
|
364 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewGroupsOnly), *contacts)); |
|
365 test(DoesNotContainsContactsL(res->TestView(CTestResources::ETestViewGroupsOnly), *unsortedContacts)); |
|
366 |
|
367 test.Next(_L("Check EContactsOnly view count")); |
|
368 if (res->TestView(CTestResources::ETestViewContactsOnly).ContactViewPreferences() & EIgnoreUnSorted) |
|
369 { |
|
370 test(res->TestView(CTestResources::ETestViewContactsOnly).CountL() == contacts->Count()); |
|
371 } |
|
372 else |
|
373 { |
|
374 test(res->TestView(CTestResources::ETestViewContactsOnly).CountL() == contacts->Count()+unsortedContacts->Count()); |
|
375 } |
|
376 |
|
377 test.Next(_L("Check EGroupsOnly view count")); |
|
378 if (res->TestView(CTestResources::ETestViewGroupsOnly).ContactViewPreferences() & EIgnoreUnSorted) |
|
379 { |
|
380 test(res->TestView(CTestResources::ETestViewGroupsOnly).CountL() == groups->Count()); |
|
381 } |
|
382 else |
|
383 { |
|
384 test(res->TestView(CTestResources::ETestViewGroupsOnly).CountL() == groups->Count()+unsortedGroups->Count()); |
|
385 } |
|
386 |
|
387 test.Next(_L("Check EContactAndGroups view count")); |
|
388 if (res->TestView(CTestResources::ETestViewContactsAndGroups).ContactViewPreferences() & EIgnoreUnSorted) |
|
389 { |
|
390 const TInt count = contacts->Count()+groups->Count(); |
|
391 test(res->TestView(CTestResources::ETestViewContactsAndGroups).CountL() == count); |
|
392 } |
|
393 else |
|
394 { |
|
395 const TInt count = contacts->Count()+unsortedContacts->Count()+groups->Count()+unsortedGroups->Count(); |
|
396 test(res->TestView(CTestResources::ETestViewContactsAndGroups).CountL() == count); |
|
397 } |
|
398 |
|
399 CleanupStack::PopAndDestroy(5,res); |
|
400 } |
|
401 |
|
402 LOCAL_C void TestOpenViewsWithExistingDataL() |
|
403 { |
|
404 test.Start(_L("Open views with exisiting data (no special preferences)")); |
|
405 TestOpenViewsWithExistingDataL(static_cast<TContactViewPreferences>(0)); |
|
406 |
|
407 // Calypso Phonebook uses these view preferences |
|
408 test.Next(_L("Open views with exisiting data (EUnSortedAtEnd | ESingleWhiteSpaceIsEmptyField)")); |
|
409 TestOpenViewsWithExistingDataL |
|
410 (static_cast<TContactViewPreferences>(EUnSortedAtEnd|ESingleWhiteSpaceIsEmptyField)); |
|
411 |
|
412 test.Next(_L("Open views with exisiting data (EIgnoreUnSorted)")); |
|
413 TestOpenViewsWithExistingDataL(EIgnoreUnSorted); |
|
414 |
|
415 test.Next(_L("Open views with exisiting data (EIgnoreUnSorted|ESingleWhiteSpaceIsEmptyField)")); |
|
416 TestOpenViewsWithExistingDataL |
|
417 (static_cast<TContactViewPreferences>(EIgnoreUnSorted|ESingleWhiteSpaceIsEmptyField)); |
|
418 |
|
419 test.Next(_L("Open views with exisiting data (EUnSortedAtBeginning)")); |
|
420 TestOpenViewsWithExistingDataL(EUnSortedAtBeginning); |
|
421 |
|
422 test.Next(_L("Open views with exisiting data (EUnSortedAtBeginning|ESingleWhiteSpaceIsEmptyField)")); |
|
423 TestOpenViewsWithExistingDataL |
|
424 (static_cast<TContactViewPreferences>(EUnSortedAtBeginning|ESingleWhiteSpaceIsEmptyField)); |
|
425 |
|
426 test.Next(_L("Open views with exisiting data (EUnSortedAtEnd)")); |
|
427 TestOpenViewsWithExistingDataL(EUnSortedAtEnd); |
|
428 |
|
429 test.Next(_L("Open views with exisiting data (EUnSortedAtEnd|ESingleWhiteSpaceIsEmptyField)")); |
|
430 TestOpenViewsWithExistingDataL |
|
431 (static_cast<TContactViewPreferences>(EUnSortedAtEnd|ESingleWhiteSpaceIsEmptyField)); |
|
432 |
|
433 test.Next(_L("Open views with exisiting data (ESingleWhiteSpaceIsEmptyField)")); |
|
434 TestOpenViewsWithExistingDataL(ESingleWhiteSpaceIsEmptyField); |
|
435 |
|
436 test.End(); |
|
437 } |
|
438 |
|
439 LOCAL_C void TestModifyContactL(CTestResources& aRes, TContactItemId aContactId) |
|
440 { |
|
441 CContactItem* contact = aRes.Db().OpenContactLX(aContactId); |
|
442 CleanupStack::PushL(contact); |
|
443 const TInt fieldIndex = contact->CardFields().Find(KUidContactFieldFamilyName); |
|
444 contact->CardFields()[fieldIndex].TextStorage()->SetTextL(_L("Modified")); |
|
445 aRes.Db().CommitContactL(*contact); |
|
446 CleanupStack::PopAndDestroy(2); |
|
447 |
|
448 TContactDbObserverEvent dbEvent; |
|
449 test(aRes.DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
450 test(dbEvent.iType==EContactDbObserverEventContactChanged && dbEvent.iContactId==aContactId); |
|
451 |
|
452 TContactViewEvent event; |
|
453 test(aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
454 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
455 test(aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
456 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==aContactId); |
|
457 test(aRes.TestView(CTestResources::ETestViewContactsOnly).FindL(aContactId)!=KErrNotFound); |
|
458 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
459 |
|
460 test(!aRes.TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
461 test(aRes.TestView(CTestResources::ETestViewGroupsOnly).FindL(aContactId)==KErrNotFound); |
|
462 |
|
463 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
464 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
465 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
466 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==aContactId); |
|
467 test(aRes.TestView(CTestResources::ETestViewContactsAndGroups).FindL(aContactId)!=KErrNotFound); |
|
468 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
469 } |
|
470 |
|
471 LOCAL_C void TestModifyUnsortedContactL(CTestResources& aRes, TContactItemId aContactId) |
|
472 { |
|
473 CContactItem* contact = aRes.Db().OpenContactLX(aContactId); |
|
474 CleanupStack::PushL(contact); |
|
475 AddFieldToContactL(*contact, KUidContactFieldEMail, _L("test@symbianfoundation.test")); |
|
476 aRes.Db().CommitContactL(*contact); |
|
477 CleanupStack::PopAndDestroy(2); |
|
478 |
|
479 TContactDbObserverEvent dbEvent; |
|
480 test(aRes.DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
481 test(dbEvent.iType==EContactDbObserverEventContactChanged && dbEvent.iContactId==aContactId); |
|
482 |
|
483 TContactViewEvent event; |
|
484 if (aRes.TestView(CTestResources::ETestViewContactsOnly).ContactViewPreferences() & EIgnoreUnSorted) |
|
485 { |
|
486 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
487 } |
|
488 else |
|
489 { |
|
490 test(aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
491 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
492 test(aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
493 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==aContactId); |
|
494 test(aRes.TestView(CTestResources::ETestViewContactsOnly).FindL(aContactId)!=KErrNotFound); |
|
495 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
496 } |
|
497 |
|
498 test(!aRes.TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
499 test(aRes.TestView(CTestResources::ETestViewGroupsOnly).FindL(aContactId)==KErrNotFound); |
|
500 |
|
501 if (aRes.TestView(CTestResources::ETestViewContactsAndGroups).ContactViewPreferences() & EIgnoreUnSorted) |
|
502 { |
|
503 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
504 } |
|
505 else |
|
506 { |
|
507 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
508 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
509 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
510 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==aContactId); |
|
511 test(aRes.TestView(CTestResources::ETestViewContactsAndGroups).FindL(aContactId)!=KErrNotFound); |
|
512 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
513 } |
|
514 } |
|
515 |
|
516 LOCAL_C void TestDeleteGroupL(CTestResources& aRes, TContactItemId aGroupId) |
|
517 { |
|
518 aRes.Db().DeleteContactL(aGroupId); |
|
519 TContactDbObserverEvent dbEvent; |
|
520 test(aRes.DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
521 test(dbEvent.iType==EContactDbObserverEventGroupDeleted && dbEvent.iContactId==aGroupId); |
|
522 |
|
523 TContactViewEvent event; |
|
524 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
525 test(aRes.TestView(CTestResources::ETestViewContactsOnly).FindL(aGroupId)==KErrNotFound); |
|
526 |
|
527 test(aRes.TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
528 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aGroupId); |
|
529 test(aRes.TestView(CTestResources::ETestViewGroupsOnly).FindL(aGroupId)==KErrNotFound); |
|
530 test(!aRes.TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
531 |
|
532 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
533 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aGroupId); |
|
534 test(aRes.TestView(CTestResources::ETestViewContactsAndGroups).FindL(aGroupId)==KErrNotFound); |
|
535 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
536 } |
|
537 |
|
538 LOCAL_C void TestDeleteContactL(CTestResources& aRes, TContactItemId aContactId) |
|
539 { |
|
540 aRes.Db().DeleteContactL(aContactId); |
|
541 TContactDbObserverEvent dbEvent; |
|
542 test(aRes.DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
543 test(dbEvent.iType==EContactDbObserverEventContactDeleted && dbEvent.iContactId==aContactId); |
|
544 |
|
545 TContactViewEvent event; |
|
546 test(aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
547 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
548 test(aRes.TestView(CTestResources::ETestViewContactsOnly).FindL(aContactId)==KErrNotFound); |
|
549 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
550 |
|
551 test(!aRes.TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
552 test(aRes.TestView(CTestResources::ETestViewGroupsOnly).FindL(aContactId)==KErrNotFound); |
|
553 |
|
554 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
555 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
556 test(aRes.TestView(CTestResources::ETestViewContactsAndGroups).FindL(aContactId)==KErrNotFound); |
|
557 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
558 } |
|
559 |
|
560 LOCAL_C void TestDeleteUnsortedContactL(CTestResources& aRes, TContactItemId aContactId) |
|
561 { |
|
562 aRes.Db().DeleteContactL(aContactId); |
|
563 TContactDbObserverEvent dbEvent; |
|
564 test(aRes.DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
565 test(dbEvent.iType==EContactDbObserverEventContactDeleted && dbEvent.iContactId==aContactId); |
|
566 |
|
567 TContactViewEvent event; |
|
568 if (aRes.TestView(CTestResources::ETestViewContactsOnly).ContactViewPreferences() & EIgnoreUnSorted) |
|
569 { |
|
570 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
571 test(aRes.TestView(CTestResources::ETestViewContactsOnly).FindL(aContactId)==KErrNotFound); |
|
572 } |
|
573 else |
|
574 { |
|
575 test(aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
576 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
577 test(aRes.TestView(CTestResources::ETestViewContactsOnly).FindL(aContactId)==KErrNotFound); |
|
578 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
579 } |
|
580 |
|
581 test(!aRes.TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
582 test(aRes.TestView(CTestResources::ETestViewGroupsOnly).FindL(aContactId)==KErrNotFound); |
|
583 |
|
584 if (aRes.TestView(CTestResources::ETestViewContactsAndGroups).ContactViewPreferences() & EIgnoreUnSorted) |
|
585 { |
|
586 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
587 test(aRes.TestView(CTestResources::ETestViewContactsAndGroups).FindL(aContactId)==KErrNotFound); |
|
588 } |
|
589 else |
|
590 { |
|
591 test(aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
592 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==aContactId); |
|
593 test(aRes.TestView(CTestResources::ETestViewContactsAndGroups).FindL(aContactId)==KErrNotFound); |
|
594 test(!aRes.TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
595 } |
|
596 } |
|
597 |
|
598 LOCAL_C void TestViewEventsL |
|
599 (TContactViewPreferences aAddPrefs) |
|
600 { |
|
601 CTestResources* res = CTestResources::NewLC(); |
|
602 // Create the test contact views |
|
603 res->CreateTestViewsL(aAddPrefs); |
|
604 |
|
605 // Add a contact |
|
606 test.Next(_L("Add a contact")); |
|
607 CContactIdArray* contacts = CContactIdArray::NewLC(); |
|
608 TContactItemId id = CreateTestContactL(res->Db(), _L("Name2"), _L("LName"), _L("SYMBIANFOUNDATION")); |
|
609 contacts->AddL(id); |
|
610 |
|
611 TContactDbObserverEvent dbEvent; |
|
612 test(res->DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
613 test(dbEvent.iType==EContactDbObserverEventContactAdded && dbEvent.iContactId==id); |
|
614 |
|
615 TContactViewEvent event; |
|
616 test(res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
617 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
618 test(res->TestView(CTestResources::ETestViewContactsOnly).FindL(id)!=KErrNotFound); |
|
619 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
620 |
|
621 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
622 |
|
623 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
624 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
625 test(res->TestView(CTestResources::ETestViewContactsAndGroups).FindL(id)!=KErrNotFound); |
|
626 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
627 |
|
628 // Add a group |
|
629 test.Next(_L("Add a group")); |
|
630 CContactIdArray* groups = CContactIdArray::NewLC(); |
|
631 id = CreateTestGroupL(res->Db(), _L("SYMBIANFOUNDATION")); |
|
632 groups->AddL(id); |
|
633 |
|
634 test(res->DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
635 test(dbEvent.iType==EContactDbObserverEventGroupAdded && dbEvent.iContactId==id); |
|
636 |
|
637 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
638 |
|
639 test(res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
640 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
641 test(res->TestView(CTestResources::ETestViewGroupsOnly).FindL(id)!=KErrNotFound); |
|
642 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
643 |
|
644 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
645 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
646 test(res->TestView(CTestResources::ETestViewContactsAndGroups).FindL(id)!=KErrNotFound); |
|
647 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
648 |
|
649 // Add an unsorted contact |
|
650 CContactIdArray* unsortedContacts = CContactIdArray::NewLC(); |
|
651 test.Next(_L("Add an unsorted contact")); |
|
652 id = CreateTestContactL(res->Db(), _L(""), _L(""), _L("")); |
|
653 unsortedContacts->AddL(id); |
|
654 |
|
655 test(res->DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
656 test(dbEvent.iType==EContactDbObserverEventContactAdded && dbEvent.iContactId==id); |
|
657 |
|
658 if (aAddPrefs & EIgnoreUnSorted) |
|
659 { |
|
660 TContactViewEvent event; |
|
661 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
662 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
663 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
664 } |
|
665 else |
|
666 { |
|
667 TContactViewEvent event; |
|
668 test(res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
669 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
670 test(res->TestView(CTestResources::ETestViewContactsOnly).FindL(id)!=KErrNotFound); |
|
671 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
672 |
|
673 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
674 |
|
675 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
676 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
677 test(res->TestView(CTestResources::ETestViewContactsAndGroups).FindL(id)!=KErrNotFound); |
|
678 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
679 } |
|
680 |
|
681 // Add an unsorted contact (fields contain spaces) |
|
682 test.Next(_L("Add an unsorted contact (fields contain spaces)")); |
|
683 id = CreateTestContactL(res->Db(), _L(" "), _L(" "), _L(" ")); |
|
684 if (aAddPrefs & ESingleWhiteSpaceIsEmptyField) |
|
685 { |
|
686 unsortedContacts->AddL(id); |
|
687 } |
|
688 |
|
689 test(res->DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
690 test(dbEvent.iType==EContactDbObserverEventContactAdded && dbEvent.iContactId==id); |
|
691 |
|
692 if ((aAddPrefs & ESingleWhiteSpaceIsEmptyField) && (aAddPrefs & EIgnoreUnSorted)) |
|
693 { |
|
694 TContactViewEvent event; |
|
695 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
696 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
697 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
698 } |
|
699 else |
|
700 { |
|
701 TContactViewEvent event; |
|
702 test(res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
703 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
704 test(res->TestView(CTestResources::ETestViewContactsOnly).FindL(id)!=KErrNotFound); |
|
705 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
706 |
|
707 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
708 |
|
709 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
710 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==id); |
|
711 test(res->TestView(CTestResources::ETestViewContactsAndGroups).FindL(id)!=KErrNotFound); |
|
712 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
713 } |
|
714 |
|
715 // Modify contacts |
|
716 TInt i; |
|
717 test.Next(_L("Modify contacts")); |
|
718 for (i=0; i<contacts->Count(); ++i) |
|
719 { |
|
720 TestModifyContactL(*res,(*contacts)[i]); |
|
721 } |
|
722 |
|
723 // Modify unsorted contacts |
|
724 test.Next(_L("Modify unsorted contacts")); |
|
725 for (i=0; i<unsortedContacts->Count(); ++i) |
|
726 { |
|
727 TestModifyUnsortedContactL(*res,(*unsortedContacts)[i]); |
|
728 } |
|
729 |
|
730 // Modify a group |
|
731 test.Next(_L("Modify a group")); |
|
732 res->Db().AddContactToGroupL((*contacts)[0], (*groups)[0]); |
|
733 test(res->DbEvents().ListenForEvent(KEventWaitTime,dbEvent)); |
|
734 test(dbEvent.iType==EContactDbObserverEventGroupChanged && dbEvent.iContactId==(*groups)[0]); |
|
735 |
|
736 // Here the design is really weird: why an EContactsOnly view sends an event when |
|
737 // a _group_ changes??? |
|
738 test(res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
739 test(event.iEventType==TContactViewEvent::EGroupChanged && event.iContactId==(*groups)[0]); |
|
740 test(!res->TestViewEvents(CTestResources::ETestViewContactsOnly).ListenForEvent(KEventWaitTime,event)); |
|
741 |
|
742 test(res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
743 test(event.iEventType==TContactViewEvent::EGroupChanged && event.iContactId==(*groups)[0]); |
|
744 test(res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
745 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==(*groups)[0]); |
|
746 test(res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
747 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==(*groups)[0]); |
|
748 test(!res->TestViewEvents(CTestResources::ETestViewGroupsOnly).ListenForEvent(KEventWaitTime,event)); |
|
749 |
|
750 // Same weirdness here |
|
751 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
752 // This seems to be the event ordering |
|
753 test(event.iEventType==TContactViewEvent::EGroupChanged && event.iContactId==(*groups)[0]); |
|
754 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
755 test(event.iEventType==TContactViewEvent::EItemRemoved && event.iContactId==(*groups)[0]); |
|
756 test(res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
757 test(event.iEventType==TContactViewEvent::EItemAdded && event.iContactId==(*groups)[0]); |
|
758 test(!res->TestViewEvents(CTestResources::ETestViewContactsAndGroups).ListenForEvent(KEventWaitTime,event)); |
|
759 |
|
760 // Delete groups |
|
761 test.Next(_L("Delete groups")); |
|
762 for (i=0; i<groups->Count(); ++i) |
|
763 { |
|
764 TestDeleteGroupL(*res, (*groups)[i]); |
|
765 } |
|
766 |
|
767 // Delete contacts |
|
768 test.Next(_L("Delete contacts")); |
|
769 for (i=0; i<contacts->Count(); ++i) |
|
770 { |
|
771 TestDeleteContactL(*res,(*contacts)[i]); |
|
772 } |
|
773 |
|
774 // Delete unsorted contacts |
|
775 test.Next(_L("Delete unsorted contacts")); |
|
776 for (i=0; i<unsortedContacts->Count(); ++i) |
|
777 { |
|
778 TestDeleteUnsortedContactL(*res,(*unsortedContacts)[i]); |
|
779 } |
|
780 |
|
781 CleanupStack::PopAndDestroy(4,res); |
|
782 } |
|
783 |
|
784 |
|
785 LOCAL_C void TestViewEventsL() |
|
786 { |
|
787 test.Start(_L("Test view events (no special preferences)")); |
|
788 TestViewEventsL(static_cast<TContactViewPreferences>(0)); |
|
789 |
|
790 // Calypso Phonebook uses these view preferences |
|
791 test.Next(_L("Test view events (EUnSortedAtEnd | ESingleWhiteSpaceIsEmptyField)")); |
|
792 TestViewEventsL |
|
793 (static_cast<TContactViewPreferences>(EUnSortedAtEnd|ESingleWhiteSpaceIsEmptyField)); |
|
794 |
|
795 test.Next(_L("Test view events (EIgnoreUnSorted)")); |
|
796 TestViewEventsL(static_cast<TContactViewPreferences>(EIgnoreUnSorted)); |
|
797 |
|
798 test.Next(_L("Test view events (EIgnoreUnSorted|ESingleWhiteSpaceIsEmptyField)")); |
|
799 TestViewEventsL(static_cast<TContactViewPreferences>(EIgnoreUnSorted|ESingleWhiteSpaceIsEmptyField)); |
|
800 |
|
801 test.Next(_L("Test view events (EUnSortedAtBeginning)")); |
|
802 TestViewEventsL(EUnSortedAtBeginning); |
|
803 |
|
804 test.Next(_L("Test view events (EUnSortedAtBeginning|ESingleWhiteSpaceIsEmptyField)")); |
|
805 TestViewEventsL |
|
806 (static_cast<TContactViewPreferences>(EUnSortedAtBeginning|ESingleWhiteSpaceIsEmptyField)); |
|
807 |
|
808 test.Next(_L("Test view events (EUnSortedAtEnd)")); |
|
809 TestViewEventsL(EUnSortedAtEnd); |
|
810 |
|
811 test.Next(_L("Test view events (EUnSortedAtEnd|ESingleWhiteSpaceIsEmptyField)")); |
|
812 TestViewEventsL |
|
813 (static_cast<TContactViewPreferences>(EUnSortedAtEnd|ESingleWhiteSpaceIsEmptyField)); |
|
814 |
|
815 test.Next(_L("Test view events (ESingleWhiteSpaceIsEmptyField)")); |
|
816 TestViewEventsL(ESingleWhiteSpaceIsEmptyField); |
|
817 |
|
818 test.End(); |
|
819 } |
|
820 /** |
|
821 |
|
822 @SYMTestCaseID PIM-T-PREFERENCESBUG-0001 |
|
823 |
|
824 */ |
|
825 LOCAL_C void DoTestsL() |
|
826 { |
|
827 CleanupClosePushL(test); |
|
828 test.Start(_L("@SYMTestCaseID:PIM-T-PREFERENCESBUG-0001 T_PreferencesBug")); |
|
829 |
|
830 TestOpenViewsWithExistingDataL(); |
|
831 |
|
832 test.Next(KNullDesC); |
|
833 TestViewEventsL(); |
|
834 |
|
835 test.End(); |
|
836 CleanupStack::PopAndDestroy(); // test.Close() |
|
837 } |
|
838 |
|
839 GLDEF_C TInt E32Main() |
|
840 { |
|
841 // Init |
|
842 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
843 if (!cleanupStack) |
|
844 { |
|
845 return KErrNoMemory; |
|
846 } |
|
847 |
|
848 CActiveScheduler* activeScheduler = new CActiveScheduler; |
|
849 if (!activeScheduler) |
|
850 { |
|
851 return KErrNoMemory; |
|
852 } |
|
853 CActiveScheduler::Install(activeScheduler); |
|
854 |
|
855 // Run the tests |
|
856 __UHEAP_MARK; |
|
857 TRAPD(err, DoTestsL()); |
|
858 __UHEAP_MARKEND; |
|
859 |
|
860 // Cleanup |
|
861 delete activeScheduler; |
|
862 delete cleanupStack; |
|
863 |
|
864 return err; |
|
865 } |