|
1 // Copyright (c) 1998-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 // Name of test harness: T_MIUT07 |
|
15 // Component: IMCM |
|
16 // Owner: EH |
|
17 // Brief description of test harness: |
|
18 // Tests CImOffLineOperation. |
|
19 // Detailed description of test harness: |
|
20 // As above. |
|
21 // Input files required to run test harness: |
|
22 // None |
|
23 // Intermediate files produced while running test harness: |
|
24 // <DRIVE>:\msgtest\T_MIUT07\T_IMCM.log |
|
25 // Output files produced by running test harness: |
|
26 // <DRIVE>:\msglogs\T_MIUT07.<PLATFORM>.<VARIANT>.LOG.txt |
|
27 // Description of how to build test harness: |
|
28 // cd \msg\imcm\ |
|
29 // bldmake bldfiles |
|
30 // abld test build |
|
31 // Description of how to run test harness: |
|
32 // The following instructions are the same for all platforms: |
|
33 // 1. Build T_DB test harness from COMMDB component: |
|
34 // cd \commdb\group |
|
35 // bldmake bldfiles |
|
36 // abld test build t_db |
|
37 // 2. Build the test utilities: |
|
38 // cd \msg\testutils\group\ |
|
39 // bldmake bldfiles |
|
40 // abld build |
|
41 // WINS running instructions: |
|
42 // 1. \epoc32\release\wins\<VARIANT>\T_MIUT07.exe can be used at the command prompt |
|
43 // or executable can be run from Windows Explorer. |
|
44 // All other platform running instructions: |
|
45 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_MIUT07.exe onto the other platform |
|
46 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into |
|
47 // <DRIVE>:\system\libs on the other platform |
|
48 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into |
|
49 // <DRIVE>:\system\libs on the other platform |
|
50 // 4. Run T_MIUT07.exe on the other platform |
|
51 // |
|
52 // |
|
53 |
|
54 #include "emailtestutils.h" |
|
55 |
|
56 #include <offop.h> |
|
57 #include "MIUTLOG.H" // used for Logs |
|
58 |
|
59 #include "CFakeStoreManager.h" |
|
60 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
61 #include "msvconsts.h" |
|
62 #endif |
|
63 |
|
64 // |
|
65 // TestScheduler implements an error handler that doesn't panic. |
|
66 class TestScheduler : public CActiveScheduler |
|
67 { |
|
68 public: |
|
69 void Error (TInt aError) const; |
|
70 }; |
|
71 |
|
72 // |
|
73 // Session observer, reports stuff it is notified about |
|
74 class CDummySessionObserver : public CBase , public MMsvSessionObserver |
|
75 { |
|
76 public: |
|
77 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
78 }; |
|
79 |
|
80 // |
|
81 class CDummyUndo : public MImUndoOffLineOperation |
|
82 { |
|
83 public: |
|
84 void UndoOffLineChangesL(const CImOffLineOperation& /*aDeleted*/, TMsvId /*aFolderId*/) {}; |
|
85 }; |
|
86 |
|
87 // |
|
88 class CDummyStoreObserver : public CBase, public MMsvStoreObserver |
|
89 { |
|
90 public: |
|
91 void HandleStoreEvent(TMsvStoreEvent /*aEvent*/, TMsvId /*aId*/) {}; |
|
92 }; |
|
93 |
|
94 // |
|
95 class CDerivedMsvStore : public CMsvStore |
|
96 { |
|
97 public: |
|
98 CDerivedMsvStore(MMsvStoreObserver& aObserver, RFs& aFs, TMsvId aId, MMsvStoreManager& aStoreManager) |
|
99 : CMsvStore(aObserver, aFs, aId, aStoreManager) {}; |
|
100 public: |
|
101 static CMsvStore* MyOpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId) |
|
102 { |
|
103 return CMsvStore::OpenForReadL(aObserver, aFs, aStoreManager, aId); |
|
104 } |
|
105 static CMsvStore* MyOpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId) |
|
106 { |
|
107 return CMsvStore::OpenForWriteL(aObserver, aFs, aStoreManager, aId); |
|
108 } |
|
109 }; |
|
110 |
|
111 // |
|
112 // Globals needed for the test code |
|
113 LOCAL_D RTest test(_L("T_OFFOP - Test CImOffLineOperation class")); |
|
114 LOCAL_D CTrapCleanup* theCleanup; |
|
115 |
|
116 LOCAL_D TMsvEntry entry; |
|
117 LOCAL_D CImLog* log; |
|
118 LOCAL_D CEmailTestUtils* testUtils; |
|
119 |
|
120 #define KtheFirstCommand _L8("FirstCommand") |
|
121 #define KtheSecondCommand _L8("SecondCommand") |
|
122 |
|
123 // |
|
124 // Client side classes |
|
125 CDummySessionObserver* theSessionObserver = NULL; |
|
126 CMsvSession* theSession = NULL; |
|
127 TMsvId theServiceId = KMsvLocalServiceIndexEntryId; |
|
128 CImOperationQueueList* theQueue = NULL; |
|
129 |
|
130 // Folders created, to test the lists of queued operations stored within folders. |
|
131 CMsvEntrySelection* theFolders = NULL; |
|
132 CMsvEntrySelection* theSubfolders = NULL; |
|
133 CDummyUndo theDummyUndoer; |
|
134 |
|
135 |
|
136 // |
|
137 |
|
138 LOCAL_D const TUid theTechnologyTypeUid = KUidMsgTypeIMAP4; |
|
139 |
|
140 // Nr folders to be created. |
|
141 const TInt KNrFolders = 2; |
|
142 const TInt KNrSubFolders = 2; |
|
143 const TInt KNrQueuedPerFolder = 5; |
|
144 const TInt KNrToDelete = 5; |
|
145 |
|
146 // |
|
147 // Data component file name for client |
|
148 // The data component file is a file belonging to the |
|
149 // MTM. a class CMtmGroupData is stored in it, specifying the |
|
150 // UID's of the components belonging to the MTM. |
|
151 // The CMsvSession class needs it to install the MTM.. |
|
152 // the function CreateDataComponentFileStoreL creates the file for this MTM. |
|
153 #define DataComponentFileName _L("c:\\system\\mtm\\impc.dat") |
|
154 // Service we're connected to. |
|
155 TFileName theRootDir = _L("C:\\Data\\impc\\"); |
|
156 |
|
157 // |
|
158 const TMsvId KDummyMessageId =0x01101; |
|
159 const TMsvId KDummyTargetFolderId =0x01102; |
|
160 const TInt KDummyCommandId =0x0123; |
|
161 unsigned char *theFirstCommand = (unsigned char *)"FirstCommand"; |
|
162 unsigned char *theSecondCommand = (unsigned char *)"SecondCommand"; |
|
163 |
|
164 |
|
165 // |
|
166 void TestScheduler::Error(TInt anError) const |
|
167 { |
|
168 test.Printf(TRefByValue<const TDesC>_L("Active object left with error code %d\n"), anError); |
|
169 CActiveScheduler::Stop(); |
|
170 } |
|
171 |
|
172 // |
|
173 void CDummySessionObserver::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
174 { |
|
175 }; |
|
176 |
|
177 // |
|
178 |
|
179 LOCAL_C TMsvId CreateFolderEntryL(CMsvEntry& aClientEntry) |
|
180 // |
|
181 // Create a folder entry below aClientEntry, and see if there was an error. |
|
182 // |
|
183 { |
|
184 log->AppendComment(_L8("\tCreating Folder Entry")); |
|
185 TBool result = ETrue; |
|
186 TMsvEntry folderEntry; |
|
187 |
|
188 folderEntry.iDescription.Set(_L("IMAP4 Folder")); |
|
189 folderEntry.iDetails.Set(_L("IMAP4")); |
|
190 folderEntry.iType = KUidMsvFolderEntry; |
|
191 folderEntry.iServiceId = theServiceId; |
|
192 folderEntry.iSize = 0; |
|
193 folderEntry.iMtm = KUidMsgTypeIMAP4; |
|
194 |
|
195 CMsvOperationWait* wait = CMsvOperationWait::NewLC(); |
|
196 wait->Start(); |
|
197 CMsvOperation* opert = aClientEntry.CreateL(folderEntry, wait->iStatus); |
|
198 CActiveScheduler::Start(); // operation complete |
|
199 TBool result1=(opert->iStatus.Int()==KErrNone); |
|
200 if (!result1) |
|
201 log->AppendError(_L8("\t\tiStatus does not equal 0"),-1); |
|
202 result&=result1; |
|
203 TBool result2=(opert->Mtm()==KUidMsvLocalServiceMtm); |
|
204 if (!result2) |
|
205 log->AppendError(_L8("\t\tiMtm does not equal KUidMsvLocalServiceMtm"),-1); |
|
206 result&=result2; |
|
207 TMsvLocalOperationProgress details; |
|
208 TPckgC<TMsvLocalOperationProgress> package(details); |
|
209 package.Set(opert->ProgressL()); |
|
210 TBool result3=(package().iType==TMsvLocalOperationProgress::ELocalNew); |
|
211 if (!result3) |
|
212 log->AppendError(_L8("\t\tiType does not equal ELocalNew"),-1); |
|
213 result&=result3; |
|
214 TBool result4=(package().iTotalNumberOfEntries==1); |
|
215 if (!result4) |
|
216 log->AppendError(_L8("\t\tiTotalNumberOfEntries does not equal 1"),-1); |
|
217 result&=result4; |
|
218 TBool result5=(package().iError==KErrNone); |
|
219 if (!result5) |
|
220 log->AppendError(_L8("\t\tiError not equal to KErrNone"),-1); |
|
221 result&=result5; |
|
222 TBool result6=(package().iNumberCompleted==1); |
|
223 if (!result6) |
|
224 log->AppendError(_L8("\t\tiNumberCompleted not equal to 1"),-1); |
|
225 result&=result6; |
|
226 TBool result7=(package().iNumberFailed==0); |
|
227 if (!result7) |
|
228 log->AppendError(_L8("\t\tiNumberFailed not equal to 0"),-1); |
|
229 result&=result7; |
|
230 TBool result8=(package().iNumberRemaining==0); |
|
231 if (!result8) |
|
232 log->AppendError(_L8("\t\tiNumberRemaining not equal to 0()"),-1); |
|
233 result&=result8; |
|
234 delete opert; opert=NULL; |
|
235 CleanupStack::PopAndDestroy();//wait |
|
236 |
|
237 log->AppendComment(_L8("\tCreated Folder Entry")); |
|
238 // The Id of the service entry |
|
239 return package().iId; |
|
240 } |
|
241 |
|
242 LOCAL_C TBool DeleteFolderEntryL(CMsvEntry& aClientEntry, TMsvId aIdToDelete) |
|
243 // |
|
244 // Delete a folder entry below aClientEntry, and see if there was an error. |
|
245 // |
|
246 { |
|
247 log->AppendComment(_L8("\tDeleting Folder Entry")); |
|
248 TBool result = ETrue; |
|
249 CMsvOperationWait* wait = CMsvOperationWait::NewLC(); |
|
250 wait->Start(); |
|
251 CMsvOperation* opert = aClientEntry.DeleteL(aIdToDelete, wait->iStatus); |
|
252 |
|
253 CActiveScheduler::Start(); // operation complete |
|
254 TBool result1=(opert->iStatus.Int()==KErrNone); |
|
255 if (!result1) |
|
256 log->AppendError(_L8("\t\tiStatus does not equal 0"),-1); |
|
257 result&=result1; |
|
258 TBool result2=(opert->Mtm()==KUidMsvLocalServiceMtm); |
|
259 if (!result2) |
|
260 log->AppendError(_L8("\t\tiMtm not equal to KUidMsvLocalServiceMtm"),-1); |
|
261 result&=result2; |
|
262 TMsvLocalOperationProgress details; |
|
263 TPckgC<TMsvLocalOperationProgress> package(details); |
|
264 package.Set(opert->ProgressL()); |
|
265 TBool result3=(package().iType==TMsvLocalOperationProgress::ELocalDelete); |
|
266 if (!result3) |
|
267 log->AppendError(_L8("\t\tiType not equal to ELocalDelete"),-1); |
|
268 result&=result3; |
|
269 TBool result4=(package().iTotalNumberOfEntries==package().iNumberCompleted); |
|
270 if (!result4) |
|
271 log->AppendError(_L8("\t\tiTotalNumberOfEntries not equal to iNumberCompleted"),-1); |
|
272 result&=result4; |
|
273 TBool result5=(package().iError==KErrNone); |
|
274 if (!result5) |
|
275 log->AppendError(_L8("\t\tiError does not equal KErrNone"),-1); |
|
276 result&=result5; |
|
277 TBool result6=(package().iNumberFailed==0); |
|
278 if (!result6) |
|
279 log->AppendError(_L8("\t\tiNumberFailed does not equal 0"),-1); |
|
280 result&=result6; |
|
281 TBool result7=(package().iNumberRemaining==0); |
|
282 if (!result7) |
|
283 log->AppendError(_L8("\t\tiNumberRemaining does not equal 0"),-1); |
|
284 result&=result7; |
|
285 delete opert; opert=NULL; |
|
286 CleanupStack::PopAndDestroy();//wait |
|
287 log->AppendComment(_L8("\tDeleted Folder Entry")); |
|
288 return result; |
|
289 } |
|
290 |
|
291 LOCAL_C CMsvEntrySelection* CreateFoldersL(TMsvId aRootId, TInt aNrFolders) |
|
292 { |
|
293 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, aRootId, TMsvSelectionOrdering()); |
|
294 CleanupStack::PushL(msventry); |
|
295 |
|
296 TInt i; |
|
297 for ( i = 0 ; i < aNrFolders ; i ++ ) |
|
298 { |
|
299 CreateFolderEntryL(*msventry); |
|
300 } |
|
301 |
|
302 CMsvEntrySelection* folders = msventry->ChildrenWithServiceL(theServiceId) ; |
|
303 CleanupStack::PopAndDestroy();//msventry |
|
304 log->AppendComment(_L8("\tCreated Folders")); |
|
305 return folders; |
|
306 } |
|
307 |
|
308 LOCAL_C TBool testCreateFoldersL() |
|
309 { |
|
310 log->AppendComment(_L8("\tTesting Created Folders")); |
|
311 TBool result = ETrue; |
|
312 theFolders = CreateFoldersL(KMsvGlobalInBoxIndexEntryId, KNrFolders); |
|
313 TBool result1=(theFolders->Count() == KNrFolders); |
|
314 if (!result1) |
|
315 log->AppendError(_L8("\t\tThe number of folders created is incorrect"),-1); |
|
316 result&=result1; |
|
317 theSubfolders = CreateFoldersL((*theFolders)[0], KNrSubFolders); |
|
318 TBool result2=(theSubfolders->Count() == KNrSubFolders); |
|
319 if (!result2) |
|
320 log->AppendError(_L8("\t\tThe number of subfolders created is incorrect"),-1); |
|
321 result&=result; |
|
322 return result; |
|
323 } |
|
324 |
|
325 LOCAL_C void StoreQueuedOperationsL(CMsvEntry& aEntry, MImOffLineOperationArray& aArray) |
|
326 { |
|
327 CMsvStore* store=aEntry.EditStoreL(); |
|
328 CleanupStack::PushL(store); |
|
329 |
|
330 CImOffLineArrayStore externaliser(aArray); |
|
331 externaliser.StoreL(*store); |
|
332 store->CommitL(); |
|
333 |
|
334 CleanupStack::PopAndDestroy();//store |
|
335 log->AppendComment(_L8("\tStored Queued Operations")); |
|
336 } |
|
337 |
|
338 LOCAL_C CImOffLineOperationArray* BuildOfflineOperationArrayLC() |
|
339 { |
|
340 TInt i; |
|
341 CImOffLineOperationArray* array = CImOffLineOperationArray::NewL(); |
|
342 CleanupStack::PushL(array); |
|
343 |
|
344 CImOffLineOperation operation; |
|
345 |
|
346 for (i=0;i<KNrQueuedPerFolder-2;i++) |
|
347 { |
|
348 array->AppendOperationL(operation); |
|
349 } |
|
350 |
|
351 TBuf8<100> scrap; |
|
352 scrap = _L8(theFirstCommand); |
|
353 operation.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
354 array->AppendOperationL(operation); |
|
355 |
|
356 scrap = _L8(theSecondCommand); |
|
357 operation.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
358 array->AppendOperationL(operation); |
|
359 |
|
360 log->AppendComment(_L8("\tBuilt OffLine Operation Array")); |
|
361 return array; |
|
362 } |
|
363 |
|
364 LOCAL_C TBool testOffLineArraysFirstFiveEqual(MImOffLineOperationArray& aArray1, MImOffLineOperationArray& aArray2) |
|
365 { |
|
366 log->AppendComment(_L8("\tTesting Offline Arrays are Equal")); |
|
367 TBool result = ETrue; |
|
368 TInt i; |
|
369 for (i=0;i<KNrQueuedPerFolder;i++) |
|
370 result &= (aArray1.Operation(i).Equals(aArray2.Operation(i))); |
|
371 if (!result) |
|
372 log->AppendError(_L8("\t\tOperations are not equal on the arrays"),-1); |
|
373 return result; |
|
374 } |
|
375 |
|
376 LOCAL_C TBool testPopulateFoldersWithQueuedOperationsL() |
|
377 { |
|
378 log->AppendComment(_L8("\tPopulating Folders With Queued Operations")); |
|
379 TBool result = ETrue; |
|
380 TInt i; |
|
381 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
382 CleanupStack::PushL(msventry); |
|
383 |
|
384 CImOffLineOperationArray* array = BuildOfflineOperationArrayLC(); |
|
385 |
|
386 // See to it that the operations came through ok... |
|
387 CImOffLineOperation operation; |
|
388 |
|
389 TBuf8<100> scrap; |
|
390 scrap = _L8(theFirstCommand); |
|
391 operation.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
392 TBool result1=(operation.Equals(array->Operation(KNrQueuedPerFolder-2))); |
|
393 if (!result1) |
|
394 log->AppendError(_L8("\t\tOperations are not equal"),-1); |
|
395 result&=result1; |
|
396 |
|
397 scrap = _L8(theSecondCommand); |
|
398 operation.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
399 TBool result2=(operation.Equals(array->Operation(KNrQueuedPerFolder-1))); |
|
400 if (!result2) |
|
401 log->AppendError(_L8("\t\tOperations are not equal"),-1); |
|
402 result&=result2; |
|
403 |
|
404 for (i=0;i<theFolders->Count();i++) |
|
405 { |
|
406 msventry->SetEntryL((*theFolders)[i]); |
|
407 StoreQueuedOperationsL(*msventry, *array); |
|
408 } |
|
409 |
|
410 for (i=0;i<theSubfolders->Count();i++) |
|
411 { |
|
412 msventry->SetEntryL((*theSubfolders)[i]); |
|
413 StoreQueuedOperationsL(*msventry, *array); |
|
414 } |
|
415 |
|
416 CleanupStack::PopAndDestroy();//array |
|
417 CleanupStack::PopAndDestroy();//msventry |
|
418 return result; |
|
419 } |
|
420 |
|
421 LOCAL_C TBool testReadBackOperationsL() |
|
422 { |
|
423 log->AppendComment(_L8("\tReading Back Operations")); |
|
424 TBool result = ETrue; |
|
425 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
426 CleanupStack::PushL(msventry); |
|
427 |
|
428 CImOffLineOperationArray* array = CImOffLineOperationArray::NewL(); |
|
429 CleanupStack::PushL(array); |
|
430 |
|
431 msventry->SetEntryL((*theFolders)[0]); |
|
432 CMsvStore* store=msventry->ReadStoreL(); |
|
433 CleanupStack::PushL(store); |
|
434 CImOffLineArrayStore internaliser(*array); |
|
435 internaliser.RestoreL(*store); |
|
436 CleanupStack::PopAndDestroy();//store |
|
437 |
|
438 CImOffLineOperationArray* built = BuildOfflineOperationArrayLC(); |
|
439 result &= testOffLineArraysFirstFiveEqual(*array, *built); |
|
440 CleanupStack::PopAndDestroy();//built |
|
441 |
|
442 CleanupStack::PopAndDestroy();//array |
|
443 CleanupStack::PopAndDestroy();//msventry |
|
444 return result; |
|
445 } |
|
446 |
|
447 |
|
448 LOCAL_C TBool testReadBackQueuedOperationsL() |
|
449 { |
|
450 log->AppendComment(_L8("\tReading Back Queued Operations")); |
|
451 TBool result = ETrue; |
|
452 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
453 CleanupStack::PushL(msventry); |
|
454 |
|
455 CImQueuedList* array = CImQueuedList::NewL(); |
|
456 CleanupStack::PushL(array); |
|
457 |
|
458 msventry->SetEntryL((*theFolders)[0]); |
|
459 CMsvStore* store=msventry->ReadStoreL(); |
|
460 |
|
461 CleanupStack::PushL(store); |
|
462 CImOffLineArrayStore internaliser(*array); |
|
463 internaliser.RestoreL(*store); |
|
464 CleanupStack::PopAndDestroy();//store |
|
465 |
|
466 CImOffLineOperationArray* built = BuildOfflineOperationArrayLC(); |
|
467 result &= testOffLineArraysFirstFiveEqual(*array, *built); |
|
468 CleanupStack::PopAndDestroy();//built |
|
469 |
|
470 CleanupStack::PopAndDestroy();//array |
|
471 CleanupStack::PopAndDestroy();//msventry |
|
472 return result; |
|
473 } |
|
474 |
|
475 LOCAL_C TBool testDeleteFoldersL() |
|
476 { |
|
477 log->AppendComment(_L8("\tDeleting Folders")); |
|
478 TBool result = ETrue; |
|
479 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
480 CleanupStack::PushL(msventry); |
|
481 TInt i; |
|
482 |
|
483 for ( i = 0 ; i < theFolders->Count() ; i ++ ) |
|
484 { |
|
485 result &= DeleteFolderEntryL(*msventry, (*theFolders)[i]); |
|
486 } |
|
487 if (!result) |
|
488 log->AppendError(_L8("\t\tError in Deleting Folder Entry"),-1); |
|
489 CleanupStack::PopAndDestroy();//msventry |
|
490 |
|
491 delete theFolders; |
|
492 theFolders = NULL; |
|
493 delete theSubfolders; |
|
494 theSubfolders = NULL; |
|
495 return result; |
|
496 } |
|
497 |
|
498 LOCAL_C TBool testClearInboxL() |
|
499 { |
|
500 TBool result = ETrue; |
|
501 log->AppendComment(_L8("\tClearing Inbox")); |
|
502 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
503 CleanupStack::PushL(msventry); |
|
504 theFolders = msventry->ChildrenWithServiceL(theServiceId) ; |
|
505 CleanupStack::PopAndDestroy();//msventry |
|
506 result &= testDeleteFoldersL(); |
|
507 return result; |
|
508 } |
|
509 |
|
510 LOCAL_C TBool CreateDataComponentFileStoreL() |
|
511 // |
|
512 // Test read file handling. |
|
513 // |
|
514 { |
|
515 // Open file |
|
516 |
|
517 CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray(); |
|
518 CleanupStack::PushL(mtmdllinfoarray); |
|
519 |
|
520 CMtmDllInfo* mtmdllinfo1=CMtmDllInfo::NewL(_L("IMAP4 SERVER component"),TUidType(KDynamicLibraryUid,KUidMtmServerComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),KImap4ServerMtmFileName,1,TVersion(2,0,0)); |
|
521 mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo1); |
|
522 |
|
523 CMtmDllInfo* mtmdllinfo2=CMtmDllInfo::NewL(_L("IMAP4 CLIENT component"),TUidType(KDynamicLibraryUid,KUidMtmClientComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),KImap4ClientMtmFileName,1,TVersion(2,0,0)); |
|
524 mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo2); |
|
525 |
|
526 CMtmDllInfo* mtmdllinfo3=CMtmDllInfo::NewL(_L("IMAP4 UI component"),TUidType(KDynamicLibraryUid,KUidMtmUiComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),KImap4DataLayerFileName,1,TVersion(2,0,0)); |
|
527 mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo3); |
|
528 |
|
529 CMtmDllInfo* mtmdllinfo4=CMtmDllInfo::NewL(_L("IMAP4 UI DATA component"),TUidType(KDynamicLibraryUid,KUidMtmUiDataComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),KImap4DataLayerFileName,1,TVersion(2,0,0)); |
|
530 mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo4); |
|
531 |
|
532 TCapabilitySet capSet; |
|
533 capSet.SetEmpty(); |
|
534 CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership |
|
535 CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(KUidMsgTypeIMAP4, theTechnologyTypeUid, mtmdllinfoarray, capSet); |
|
536 CleanupStack::PushL(mtmgroupdata); |
|
537 |
|
538 testUtils->FileSession().Delete(DataComponentFileName); |
|
539 CFileStore* filestore = CPermanentFileStore::ReplaceLC(testUtils->FileSession(),DataComponentFileName,EFileShareExclusive|EFileStream|EFileWrite); |
|
540 TUidType uidtype(KPermanentFileStoreLayoutUid,KUidMsvDataComponent,KUidMsgTypeIMAP4); |
|
541 filestore->SetTypeL(uidtype); |
|
542 RStoreWriteStream out; |
|
543 TStreamId streamid=out.CreateLC(*filestore); // Push to stack |
|
544 mtmgroupdata->ExternalizeL(out); |
|
545 out.CommitL(); |
|
546 CleanupStack::PopAndDestroy(); // out |
|
547 filestore->SetRootL(streamid); |
|
548 filestore->CommitL(); |
|
549 CleanupStack::PopAndDestroy(); // filestore |
|
550 |
|
551 CleanupStack::PopAndDestroy(); // mtmgroupdata |
|
552 log->AppendComment(_L8("\tCreated Data Component File Store")); |
|
553 return ETrue; |
|
554 } |
|
555 |
|
556 |
|
557 LOCAL_C TBool CreateClientRegistryL() |
|
558 // |
|
559 // Get access to the Client MTM object (CBaseMtm-derived). |
|
560 // |
|
561 { |
|
562 TBool result = ETrue; |
|
563 // Session observer. Needed to create a session |
|
564 theSessionObserver = new (ELeave) CDummySessionObserver; |
|
565 result &= (theSessionObserver != NULL); |
|
566 CleanupStack::PushL(theSessionObserver); |
|
567 // Session. Needed to create a client registry. |
|
568 theSession=CMsvSession::OpenSyncL(*theSessionObserver); |
|
569 result &= (theSession != NULL); |
|
570 CleanupStack::PushL(theSession); |
|
571 |
|
572 CleanupStack::Pop(2);// theSessionObserver, theSession |
|
573 log->AppendComment(_L8("\tCreated Client Registry")); |
|
574 return result; |
|
575 } |
|
576 |
|
577 LOCAL_C void DeleteClientRegistry() |
|
578 { |
|
579 // Clean up |
|
580 delete theSession; |
|
581 theSession = NULL; |
|
582 delete theSessionObserver; |
|
583 theSessionObserver = NULL; |
|
584 log->AppendComment(_L8("\tDeleted Client Registry")); |
|
585 } |
|
586 |
|
587 |
|
588 LOCAL_C TBool testGetQueListL() |
|
589 { |
|
590 log->AppendComment(_L8("\tGetting Queue List")); |
|
591 CMsvEntry* msventry=CMsvEntry::NewL(*theSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
592 // Queue takes over ownership of msventry |
|
593 theQueue = CImOperationQueueList::NewL(*msventry, &theDummyUndoer); |
|
594 CleanupStack::PushL(theQueue); |
|
595 |
|
596 CleanupStack::Pop();//theQueue |
|
597 log->AppendComment(_L8("\tGot Queue List")); |
|
598 return ETrue; |
|
599 } |
|
600 |
|
601 |
|
602 // |
|
603 // TQueuedOperationSwap and TQueuedOperationKey : Classes needed for |
|
604 // a QuickSort in ExpungeDeletedOperationsL. They sort folders from lower |
|
605 // to higher ids, and within each folder from high line numbers to low |
|
606 // line numbers. That way the highest numbers get deleted first, maintaining |
|
607 // the validity of the other removals. |
|
608 // |
|
609 class TQueuedOperationSwap : public TSwap |
|
610 { |
|
611 public: |
|
612 IMPORT_C TQueuedOperationSwap(CImQueuedList& aList); |
|
613 void Swap(TInt aLeft,TInt aRight) const; |
|
614 private: |
|
615 CImQueuedList& iList; |
|
616 }; |
|
617 |
|
618 class TQueuedOperationKey : public TKey |
|
619 { |
|
620 public: |
|
621 IMPORT_C TQueuedOperationKey(CImQueuedList& aList); |
|
622 TInt Compare(TInt aLeft,TInt aRight) const; |
|
623 TAny *At(TInt anIndex) const; |
|
624 private: |
|
625 CImQueuedList& iList; |
|
626 }; |
|
627 |
|
628 |
|
629 EXPORT_C TQueuedOperationKey::TQueuedOperationKey(CImQueuedList& aList) |
|
630 : iList(aList) |
|
631 { |
|
632 } |
|
633 |
|
634 TInt TQueuedOperationKey::Compare(TInt aLeft,TInt aRight) const |
|
635 { |
|
636 if (aLeft == aRight) |
|
637 return 0; |
|
638 if (iList[ aLeft ].FolderId() != iList[ aRight ].FolderId()) |
|
639 return iList[ aLeft ].FolderId() - iList[ aRight ].FolderId(); |
|
640 // Sort in descending order, so last lines will be deleted first |
|
641 TInt diff = iList[ aRight ].OperationIndex() - iList[ aLeft ].OperationIndex(); |
|
642 if (diff == 0) |
|
643 log->AppendError(_L8("\t\tTwo identical lines not allowed in queued operations list"), -1); |
|
644 return diff; |
|
645 } |
|
646 TAny *TQueuedOperationKey::At(TInt anIndex) const |
|
647 { |
|
648 return &iList[ anIndex ]; |
|
649 } |
|
650 |
|
651 |
|
652 LOCAL_C TBool testQueuedSortedCorrectlyL() |
|
653 { |
|
654 log->AppendComment(_L8("\tTesting Queue Sorted Correctly")); |
|
655 TBool result = ETrue; |
|
656 CImQueuedList *list=CImQueuedList::NewL(); |
|
657 CleanupStack::PushL(list); |
|
658 |
|
659 TQueuedOperation op; |
|
660 TInt i; |
|
661 for (i=0;i<theQueue->Count();i++) |
|
662 { |
|
663 op.CopyL((*theQueue)[i]); |
|
664 list->AppendL(op); |
|
665 } |
|
666 |
|
667 // Sort the queued list. |
|
668 TQueuedOperationKey key((*list)); |
|
669 TQueuedOperationSwap swap((*list)); |
|
670 User::QuickSort((*list).CountOperations(),key,swap); |
|
671 |
|
672 TInt nr = 1; |
|
673 |
|
674 TInt line=KNrQueuedPerFolder+1; |
|
675 |
|
676 // Now check if folders grouped together (not strictly necessary, but would slow down otherwise). |
|
677 for (i=1;i<list->CountOperations();i++) |
|
678 { |
|
679 if ((*list)[i].FolderId() != (*list)[i-1].FolderId()) |
|
680 { |
|
681 nr++; |
|
682 line=KNrQueuedPerFolder+1; |
|
683 } |
|
684 else |
|
685 { |
|
686 result &= (line>(*list)[i-1].OperationIndex()) ; |
|
687 line = (*list)[i-1].OperationIndex(); |
|
688 result &= (line>(*list)[i].OperationIndex()) ; |
|
689 } |
|
690 } |
|
691 result &= (nr == (KNrFolders + KNrSubFolders)); |
|
692 |
|
693 CleanupStack::PopAndDestroy(); //list |
|
694 if (result) |
|
695 log->AppendComment(_L8("\tQueue Sorted Correctly")); |
|
696 else |
|
697 log->AppendError(_L8("\t\tGetting Queue List"), -1); |
|
698 return result; |
|
699 } |
|
700 |
|
701 LOCAL_C TBool StoreFirstL(MMsvStoreManager& aStoreManager, TMsvId aId) |
|
702 { |
|
703 CImOffLineOperationArray *array = CImOffLineOperationArray::NewL(); |
|
704 CleanupStack::PushL(array); |
|
705 |
|
706 CImOffLineOperation op; |
|
707 |
|
708 // Store a operation |
|
709 CDummyStoreObserver dummy; |
|
710 CMsvStore* store = CDerivedMsvStore::MyOpenForWriteL(dummy, testUtils->FileSession(), aStoreManager, aId); |
|
711 CleanupStack::PushL(store); |
|
712 |
|
713 TBuf8<100> scrap; |
|
714 scrap = _L8(theFirstCommand); |
|
715 op.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
716 array->AppendOperationL(op); |
|
717 |
|
718 // Test insertion: insert this operation before the one already added. |
|
719 op.SetCopyWithinService(KDummyMessageId, KDummyTargetFolderId); |
|
720 array->InsertOperationL(op,0); |
|
721 |
|
722 CImOffLineArrayStore externaliser(*array); |
|
723 externaliser.StoreL(*store); |
|
724 |
|
725 store->CommitL(); |
|
726 |
|
727 CleanupStack::PopAndDestroy(); //store |
|
728 CleanupStack::PopAndDestroy(); //array |
|
729 |
|
730 log->AppendComment(_L8("\tStored First")); |
|
731 return ETrue; |
|
732 } |
|
733 |
|
734 LOCAL_C TBool RestoreAndTestL(MMsvStoreManager& aStoreManager, TMsvId aId) |
|
735 { |
|
736 TBool result = ETrue; |
|
737 CImOffLineOperationArray *array = CImOffLineOperationArray::NewL(); |
|
738 CleanupStack::PushL(array); |
|
739 |
|
740 CImOffLineOperation op; |
|
741 |
|
742 // Store a operation |
|
743 CDummyStoreObserver dummy; |
|
744 CMsvStore* store = CDerivedMsvStore::MyOpenForReadL(dummy, testUtils->FileSession(), aStoreManager, aId); |
|
745 CleanupStack::PushL(store); |
|
746 |
|
747 CImOffLineArrayStore internaliser(*array); |
|
748 internaliser.RestoreL(*store); |
|
749 result &= (array->CountOperations() == 2); |
|
750 |
|
751 op.SetCopyWithinService(KDummyMessageId, KDummyTargetFolderId); |
|
752 result &= (op.Equals(array->Operation(0))); |
|
753 |
|
754 TBuf8<100> scrap; |
|
755 scrap = _L8(theFirstCommand); |
|
756 op.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
757 |
|
758 CImOffLineOperation op2; |
|
759 op2.CopyL(array->Operation(1)); |
|
760 result &= (op.Equals(op2)); |
|
761 |
|
762 CleanupStack::PopAndDestroy(); //store |
|
763 CleanupStack::PopAndDestroy(); //array |
|
764 |
|
765 log->AppendComment(_L8("\tRestored and Tested")); |
|
766 return result; |
|
767 } |
|
768 |
|
769 LOCAL_C TBool testStoreRestoreWorkscorrectlyL() |
|
770 { |
|
771 TBool result = ETrue; |
|
772 log->AppendComment(_L8("\tTesting if Store/Restore Works Correctly")); |
|
773 |
|
774 CFakeStoreManager* storeManager = CFakeStoreManager::NewL(testUtils->FileSession()); |
|
775 CleanupStack::PushL(storeManager); |
|
776 TMsvId entryId = 100; |
|
777 storeManager->DeleteFileStoreL(entryId); |
|
778 result &= StoreFirstL(*storeManager, entryId); |
|
779 result &= RestoreAndTestL(*storeManager, entryId); |
|
780 |
|
781 return result; |
|
782 } |
|
783 |
|
784 LOCAL_C TBool testDeleteQueuedL(TInt aOffset, TInt aStep, TInt aNr) |
|
785 { |
|
786 log->AppendComment(_L8("\tTesting Deleting from the Queue")); |
|
787 TBool result = ETrue; |
|
788 result &= (theQueue != NULL); |
|
789 result &= (aNr <= theQueue->Count()); |
|
790 if (!result) |
|
791 log->AppendError(_L8("\t\tCannot delete more items than on the queue"), -1); |
|
792 TInt i; |
|
793 for (i=0;i<aNr;i++) |
|
794 { |
|
795 theQueue->DeleteL(aOffset); |
|
796 aOffset += aStep; |
|
797 aOffset %= theQueue->Count(); |
|
798 } |
|
799 log->AppendComment(_L8("\tTested Deleting from the Queue")); |
|
800 return result; |
|
801 } |
|
802 |
|
803 LOCAL_C TBool testExpungeQueListL() |
|
804 { |
|
805 TBool result = ETrue; |
|
806 result &= (theQueue != NULL); |
|
807 theQueue->ExpungeDeletedOperationsL(); |
|
808 log->AppendComment(_L8("\tTested Expunge Queue List")); |
|
809 return result; |
|
810 } |
|
811 |
|
812 LOCAL_C TBool testFreeQueListL() |
|
813 { |
|
814 TBool result = ETrue; |
|
815 result &= (theQueue != NULL); |
|
816 delete theQueue; |
|
817 theQueue = NULL; |
|
818 log->AppendComment(_L8("\tFreed Queue List")); |
|
819 return result; |
|
820 } |
|
821 |
|
822 LOCAL_C TBool TestOperationL(CImOffLineOperation& aOp,CImOffLineOperation::TOffLineOpType aOpType,TMsvId aMessageId,TMsvId aTargetMessageId,TInt aMtmFunctionId, const TDesC8* aMtmParameters) |
|
823 { |
|
824 TBool result = ETrue; |
|
825 TBool result1=(aOp.OpType() == aOpType); |
|
826 if (!result1) |
|
827 log->AppendError(_L8("\t\tOpType not identical"),-1); |
|
828 result&=result1; |
|
829 |
|
830 TBool result2=(aOp.MessageId() == aMessageId); |
|
831 if (!result2) |
|
832 log->AppendError(_L8("\t\tMessageId not identical"),-1); |
|
833 result&=result2; |
|
834 |
|
835 TBool result3=(aOp.TargetMessageId() == aTargetMessageId); |
|
836 if (!result3) |
|
837 log->AppendError(_L8("\t\tTargetMessageId not identical"),-1); |
|
838 result&=result3; |
|
839 |
|
840 TBool result4=(aOp.MtmFunctionId() == aMtmFunctionId); |
|
841 if (!result4) |
|
842 log->AppendError(_L8("\t\tMtmFunctionId not identical"),-1); |
|
843 result&=result4; |
|
844 |
|
845 if (aMtmParameters) |
|
846 { |
|
847 TBool result6=(aOp.MtmParameters() == *aMtmParameters); |
|
848 if (!result6) |
|
849 log->AppendError(_L8("\t\tMtmParameters not identical"),-1); |
|
850 result&=result6; |
|
851 } |
|
852 return result; |
|
853 } |
|
854 |
|
855 LOCAL_C TBool testOffLineOperationMethodsL() |
|
856 { |
|
857 log->AppendComment(_L8("\tTesting OffLine Operation Methods")); |
|
858 TBool result = ETrue;; |
|
859 // Create a no operation |
|
860 CImOffLineOperation op; |
|
861 CImOffLineOperation op2; |
|
862 CImOffLineOperation op3; |
|
863 |
|
864 // |
|
865 // Testing Offline operation creation |
|
866 log->AppendComment(_L8("\tTesting Offline operation creation")); |
|
867 TBool result1=TestOperationL(op,CImOffLineOperation::EOffLineOpNone,KMsvNullIndexEntryId, KMsvNullIndexEntryId,0,NULL); |
|
868 // Create a copy operation |
|
869 op.SetCopyToLocal(KDummyMessageId, KDummyTargetFolderId); |
|
870 log->AppendComment(_L8("\tCreate a copy operation")); |
|
871 result1&=TestOperationL(op,CImOffLineOperation::EOffLineOpCopyToLocal,KDummyMessageId, KDummyTargetFolderId,0,NULL); |
|
872 // Create a move operation |
|
873 op.SetMoveFromLocal(KDummyMessageId, KDummyTargetFolderId); |
|
874 log->AppendComment(_L8("\tCreate a move operation")); |
|
875 result1&=TestOperationL(op,CImOffLineOperation::EOffLineOpMoveFromLocal,KDummyMessageId, KDummyTargetFolderId,0,NULL); |
|
876 // Create a delete operation |
|
877 op.SetDelete(KDummyMessageId); |
|
878 log->AppendComment(_L8("\tCreate a delete operation")); |
|
879 result1&=TestOperationL(op,CImOffLineOperation::EOffLineOpDelete,KDummyMessageId, KMsvNullIndexEntryId,0,NULL); |
|
880 // Create a delete operation |
|
881 op.SetDelete(KDummyMessageId); |
|
882 log->AppendComment(_L8("\tCreate a delete operation")); |
|
883 result1&=TestOperationL(op,CImOffLineOperation::EOffLineOpDelete,KDummyMessageId, KMsvNullIndexEntryId,0,NULL); |
|
884 // Create a change operation |
|
885 op.SetChange(KDummyMessageId); |
|
886 log->AppendComment(_L8("\tCreate a change operation")); |
|
887 result1&=TestOperationL(op,CImOffLineOperation::EOffLineOpChange,KDummyMessageId, KMsvNullIndexEntryId,0,NULL); |
|
888 // Create a create operation |
|
889 op.SetCreate(KDummyMessageId); |
|
890 log->AppendComment(_L8("\tCreate a create operation")); |
|
891 result1&=TestOperationL(op,CImOffLineOperation::EOffLineOpCreate,KDummyMessageId, KMsvNullIndexEntryId,0,NULL); |
|
892 if (!result1) |
|
893 log->AppendError(_L8("\t\tError Creating Operations"),-1); |
|
894 // |
|
895 // Testing Equals, CopyL |
|
896 |
|
897 log->AppendComment(_L8("\tTesting Equals/CopyL")); |
|
898 // Create a mtm-specific operation |
|
899 // Op takes over ownership of command. |
|
900 TBuf8<100> scrap; |
|
901 scrap = _L8(theFirstCommand); |
|
902 op.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
903 TBool result2=TestOperationL(op,CImOffLineOperation::EOffLineOpMtmSpecific,KDummyMessageId, KDummyTargetFolderId,KDummyCommandId,&scrap); |
|
904 |
|
905 scrap = _L8(theFirstCommand); |
|
906 op2.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
907 result2&=TestOperationL(op2,CImOffLineOperation::EOffLineOpMtmSpecific,KDummyMessageId, KDummyTargetFolderId,KDummyCommandId,&scrap); |
|
908 |
|
909 result2&=(op.Equals(op2)); |
|
910 if (!result2) |
|
911 log->AppendError(_L8("\t\tError with Equals()"),-1); |
|
912 result&=result2; |
|
913 |
|
914 scrap = _L8(theSecondCommand); |
|
915 op2.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
916 TBool result3=TestOperationL(op2,CImOffLineOperation::EOffLineOpMtmSpecific,KDummyMessageId, KDummyTargetFolderId,KDummyCommandId,&scrap); |
|
917 |
|
918 result3&=(!op.Equals(op2)); |
|
919 if (!result3) |
|
920 log->AppendError(_L8("\t\tError with Equals()"),-1); |
|
921 result&=result3; |
|
922 |
|
923 op3.CopyL(op2); |
|
924 |
|
925 TBool result4=( op3.Equals(op2)); |
|
926 if (!result4) |
|
927 log->AppendError(_L8("\t\tError with Equals()"),-1); |
|
928 result&=result4; |
|
929 TBool result5=(!op3.Equals(op )); |
|
930 if (!result5) |
|
931 log->AppendError(_L8("\t\tError with Equals()"),-1); |
|
932 result&=result5; |
|
933 |
|
934 return result; |
|
935 } |
|
936 |
|
937 LOCAL_C TBool testListedOffLineOperationMethodsL() |
|
938 { |
|
939 log->AppendComment(_L8("\tTesting Listed Offline Operation Methods")); |
|
940 TBool result = ETrue; |
|
941 // Create a no operation |
|
942 CImOffLineOperation op1; |
|
943 CImOffLineOperation op2; |
|
944 CImOffLineOperation op3; |
|
945 |
|
946 // |
|
947 // Testing Offline operation creation |
|
948 |
|
949 // Create a copy operation |
|
950 op1.SetCopyWithinService(KDummyMessageId, KDummyTargetFolderId); |
|
951 TBuf8<100> scrap; |
|
952 scrap = _L8(theFirstCommand); |
|
953 op2.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
954 scrap = _L8(theSecondCommand); |
|
955 op3.SetMtmSpecificCommandL(KDummyMessageId, KDummyTargetFolderId, KDummyCommandId, scrap); |
|
956 |
|
957 // Creation |
|
958 TQueuedOperation *qop1=TQueuedOperation::NewL(KDummyTargetFolderId,0, op1); |
|
959 CleanupStack::PushL(qop1); |
|
960 TQueuedOperation *qop2=TQueuedOperation::NewL(KDummyTargetFolderId,0, op1); |
|
961 CleanupStack::PushL(qop2); |
|
962 TQueuedOperation *qop3=TQueuedOperation::NewL(KDummyTargetFolderId,1, op2); |
|
963 CleanupStack::PushL(qop3); |
|
964 TQueuedOperation *qop4=TQueuedOperation::NewL(KDummyTargetFolderId+1,0, op2); |
|
965 CleanupStack::PushL(qop4); |
|
966 TQueuedOperation *qop5=TQueuedOperation::NewL(KDummyTargetFolderId+1,0, op3); |
|
967 CleanupStack::PushL(qop5); |
|
968 |
|
969 // See if data arrived ok... |
|
970 TBool result1 = ETrue; |
|
971 result1 &= (qop3->FolderId() == KDummyTargetFolderId); |
|
972 result1 &= (qop3->OperationIndex() == 1); |
|
973 result1 &= (qop3->Operation().Equals(op2)); |
|
974 if (!result1) |
|
975 log->AppendError(_L8("\t\tData did not arrive OK"), -1); |
|
976 result&=result1; |
|
977 |
|
978 // CopyL |
|
979 TBool result2 = ETrue; |
|
980 result2 &= ( *qop1 != *qop3 ); |
|
981 result2 &= ( *qop1 != *qop4 ); |
|
982 result2 &= (!(*qop1 != *qop2)); |
|
983 result2 &= ( *qop4 != *qop5 ); |
|
984 |
|
985 qop2->CopyL(*qop4); |
|
986 result2 &= ( *qop1 != *qop2 ); |
|
987 result2 &= (!(*qop2 != *qop4)); |
|
988 if (!result2) |
|
989 log->AppendError(_L8("\t\tError Copying"), -1); |
|
990 result&=result2; |
|
991 CleanupStack::Pop(5);//qop1 to qop5, not CBase derived |
|
992 delete qop1; |
|
993 delete qop2; |
|
994 delete qop3; |
|
995 delete qop4; |
|
996 delete qop5; |
|
997 return result; |
|
998 } |
|
999 |
|
1000 // |
|
1001 |
|
1002 LOCAL_C void InitL() |
|
1003 { |
|
1004 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
1005 CActiveScheduler::Install(scheduler); |
|
1006 CleanupStack::PushL(scheduler); |
|
1007 |
|
1008 testUtils = CEmailTestUtils::NewLC(test); |
|
1009 testUtils->CleanMessageFolderL(); |
|
1010 testUtils->FileSession().Delete(_L("C:\\system\\mtm\\MTM Registry")); |
|
1011 } |
|
1012 |
|
1013 LOCAL_C void Closedown() |
|
1014 { |
|
1015 CleanupStack::PopAndDestroy(2); //testUtils, scheduler |
|
1016 } |
|
1017 |
|
1018 // |
|
1019 |
|
1020 LOCAL_C void doMainL() |
|
1021 { |
|
1022 TBool result = ETrue; |
|
1023 InitL(); |
|
1024 testUtils->GoClientSideL(); |
|
1025 testUtils->FileSession().SetSessionPath(_L("c:\\")); |
|
1026 testUtils->FileSession().MkDir(_L("c:\\logs\\")); |
|
1027 testUtils->FileSession().MkDir(_L("c:\\logs\\email\\")); |
|
1028 |
|
1029 log=CImLog::NewL(_L("c:\\logs\\email\\T_IMCM.log"),EAppend); |
|
1030 CleanupStack::PushL(log); |
|
1031 |
|
1032 log->AppendComment(_L8("********** T_MIUT07 Test CImOffLineOperation class **********")); |
|
1033 log->AppendComment(_L8("\tInit() Completed")); |
|
1034 |
|
1035 testUtils->TestStart(1); |
|
1036 test.Printf(_L("Create Data Component FileStore\n")); // Test 1 |
|
1037 result &= CreateDataComponentFileStoreL(); |
|
1038 if (result) |
|
1039 log->AppendComment(_L8("PASSED Test 1")); |
|
1040 else |
|
1041 log->AppendError(_L8("FAILED Test 1"),-1); |
|
1042 testUtils->TestFinish(1); |
|
1043 |
|
1044 testUtils->TestStart(2); |
|
1045 // Get the client mtm, by using the just created file |
|
1046 test.Printf(_L("Create Client Registry\n")); // Test 2 |
|
1047 result &= CreateClientRegistryL(); |
|
1048 if (result) |
|
1049 log->AppendComment(_L8("PASSED Test 2")); |
|
1050 else |
|
1051 log->AppendError(_L8("FAILED Test 2"),-1); |
|
1052 testUtils->TestFinish(2); |
|
1053 |
|
1054 User::After(5000000); //delay to allow MailInit to complete |
|
1055 |
|
1056 testUtils->TestStart(3); |
|
1057 test.Printf(_L("Clear inbox\n")); // Test 3 |
|
1058 result &= testClearInboxL(); |
|
1059 if (result) |
|
1060 log->AppendComment(_L8("PASSED Test 3")); |
|
1061 else |
|
1062 log->AppendError(_L8("FAILED Test 3"),-1); |
|
1063 testUtils->TestFinish(3); |
|
1064 |
|
1065 testUtils->TestStart(4); |
|
1066 test.Printf(_L("Creating folders\n")); // Test 4 |
|
1067 result &= testCreateFoldersL(); |
|
1068 if (result) |
|
1069 log->AppendComment(_L8("PASSED Test 4")); |
|
1070 else |
|
1071 log->AppendError(_L8("FAILED Test 4"),-1); |
|
1072 testUtils->TestFinish(4); |
|
1073 |
|
1074 testUtils->TestStart(5); |
|
1075 test.Printf(_L("Testing offline operation access\n")); // Test 5 |
|
1076 result &= testOffLineOperationMethodsL(); |
|
1077 if (result) |
|
1078 log->AppendComment(_L8("PASSED Test 5")); |
|
1079 else |
|
1080 log->AppendError(_L8("FAILED Test 5"),-1); |
|
1081 testUtils->TestFinish(5); |
|
1082 |
|
1083 testUtils->TestStart(6); |
|
1084 test.Printf(_L("Testing listed offline operation access\n")); // Test 6 |
|
1085 result &= testListedOffLineOperationMethodsL(); |
|
1086 if (result) |
|
1087 log->AppendComment(_L8("PASSED Test 6")); |
|
1088 else |
|
1089 log->AppendError(_L8("FAILED Test 6"),-1); |
|
1090 testUtils->TestFinish(6); |
|
1091 |
|
1092 testUtils->TestStart(7); |
|
1093 test.Printf(_L("Testing externalisation/internalisation of offline operations\n")); //Test 7 |
|
1094 result &= testStoreRestoreWorkscorrectlyL(); |
|
1095 if (result) |
|
1096 log->AppendComment(_L8("PASSED Test 7")); |
|
1097 else |
|
1098 log->AppendError(_L8("FAILED Test 7"),-1); |
|
1099 testUtils->TestFinish(7); |
|
1100 |
|
1101 testUtils->TestStart(8); |
|
1102 test.Printf(_L("Obtaining folders with no stores associated\n")); // Test 8 |
|
1103 result &= testGetQueListL(); |
|
1104 result &= testFreeQueListL(); |
|
1105 if (result) |
|
1106 log->AppendComment(_L8("PASSED Test 8")); |
|
1107 else |
|
1108 log->AppendError(_L8("FAILED Test 8"),-1); |
|
1109 testUtils->TestFinish(8); |
|
1110 |
|
1111 testUtils->TestStart(9); |
|
1112 test.Printf(_L("Testing queued operations access\n")); // Test 9 |
|
1113 result &= testPopulateFoldersWithQueuedOperationsL(); |
|
1114 if (result) |
|
1115 log->AppendComment(_L8("PASSED Test 9")); |
|
1116 else |
|
1117 log->AppendError(_L8("FAILED Test 9"),-1); |
|
1118 testUtils->TestFinish(9); |
|
1119 |
|
1120 testUtils->TestStart(10); |
|
1121 result &= testReadBackOperationsL(); // Test 10 |
|
1122 if (result) |
|
1123 log->AppendComment(_L8("PASSED Test 10")); |
|
1124 else |
|
1125 log->AppendError(_L8("FAILED Test 10"),-1); |
|
1126 testUtils->TestFinish(10); |
|
1127 |
|
1128 testUtils->TestStart(11); |
|
1129 result &= testReadBackQueuedOperationsL(); // Test 11 |
|
1130 if (result) |
|
1131 log->AppendComment(_L8("PASSED Test 11")); |
|
1132 else |
|
1133 log->AppendError(_L8("FAILED Test 11"),-1); |
|
1134 testUtils->TestFinish(11); |
|
1135 |
|
1136 testUtils->TestStart(12); |
|
1137 result &= testGetQueListL(); // Test 12 |
|
1138 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder); |
|
1139 if (result) |
|
1140 log->AppendComment(_L8("PASSED Test 12")); |
|
1141 else |
|
1142 log->AppendError(_L8("FAILED Test 12"),-1); |
|
1143 testUtils->TestFinish(12); |
|
1144 |
|
1145 testUtils->TestStart(13); |
|
1146 result &= testFreeQueListL(); // Test 13 |
|
1147 if (result) |
|
1148 log->AppendComment(_L8("PASSED Test 13")); |
|
1149 else |
|
1150 log->AppendError(_L8("FAILED Test 13"),-1); |
|
1151 testUtils->TestFinish(13); |
|
1152 |
|
1153 testUtils->TestStart(14); |
|
1154 test.Printf(_L("Testing if queued list sorted correctly\n")); // Test 14 |
|
1155 result &= testGetQueListL(); |
|
1156 result &= testQueuedSortedCorrectlyL(); |
|
1157 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder); |
|
1158 result &= testFreeQueListL(); |
|
1159 if (result) |
|
1160 log->AppendComment(_L8("PASSED Test 14")); |
|
1161 else |
|
1162 log->AppendError(_L8("FAILED Test 14"),-1); |
|
1163 testUtils->TestFinish(14); |
|
1164 |
|
1165 testUtils->TestStart(15); |
|
1166 result &= testGetQueListL(); // Test 15 |
|
1167 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder); |
|
1168 result &= testExpungeQueListL(); |
|
1169 result &= testFreeQueListL(); |
|
1170 if (result) |
|
1171 log->AppendComment(_L8("PASSED Test 15")); |
|
1172 else |
|
1173 log->AppendError(_L8("FAILED Test 15"),-1); |
|
1174 testUtils->TestFinish(15); |
|
1175 |
|
1176 testUtils->TestStart(16); |
|
1177 test.Printf(_L("Testing rewrite of queued operations\n")); // Test 16 |
|
1178 result &= testGetQueListL(); |
|
1179 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder); |
|
1180 testDeleteQueuedL(0,4,KNrToDelete); |
|
1181 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder-KNrToDelete); |
|
1182 result &= testFreeQueListL(); |
|
1183 if (result) |
|
1184 log->AppendComment(_L8("PASSED Test 16")); |
|
1185 else |
|
1186 log->AppendError(_L8("FAILED Test 16"),-1); |
|
1187 testUtils->TestFinish(16); |
|
1188 |
|
1189 testUtils->TestStart(17); |
|
1190 test.Printf(_L("Testing removal queued operations\n")); // Test 17 |
|
1191 result &= testGetQueListL(); |
|
1192 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder); |
|
1193 testDeleteQueuedL(0,4,KNrToDelete); |
|
1194 result &= testExpungeQueListL(); |
|
1195 result &= testFreeQueListL(); |
|
1196 if (result) |
|
1197 log->AppendComment(_L8("PASSED Test 17")); |
|
1198 else |
|
1199 log->AppendError(_L8("FAILED Test 17"),-1); |
|
1200 testUtils->TestFinish(17); |
|
1201 |
|
1202 testUtils->TestStart(18); |
|
1203 result &= testGetQueListL(); // Test 18 |
|
1204 result &= (theQueue->Count() == (KNrFolders + KNrSubFolders)*KNrQueuedPerFolder-KNrToDelete); |
|
1205 result &= testFreeQueListL(); |
|
1206 if (result) |
|
1207 log->AppendComment(_L8("PASSED Test 18")); |
|
1208 else |
|
1209 log->AppendError(_L8("FAILED Test 18"),-1); |
|
1210 testUtils->TestFinish(18); |
|
1211 |
|
1212 testUtils->TestStart(19); |
|
1213 test.Printf(_L("Deleting folders\n")); // Test 19 |
|
1214 result &= testDeleteFoldersL(); |
|
1215 if (result) |
|
1216 log->AppendComment(_L8("PASSED Test 19")); |
|
1217 else |
|
1218 log->AppendError(_L8("FAILED Test 19"),-1); |
|
1219 testUtils->TestFinish(19); |
|
1220 |
|
1221 // |
|
1222 // Finished. Clean up all objects |
|
1223 test.Printf(_L("Deleting used objects\n")); |
|
1224 DeleteClientRegistry(); |
|
1225 |
|
1226 if (result) |
|
1227 { |
|
1228 log->AppendComment(_L8("PASSED All tests Correctly")); |
|
1229 test.Printf(_L("PASSED all Tests")); |
|
1230 testUtils->TestHarnessCompleted(); |
|
1231 } |
|
1232 else |
|
1233 { |
|
1234 test.Printf(_L("FAILED Tests")); |
|
1235 log->AppendError(_L8("FAILED At Least one test"),-1); |
|
1236 testUtils->TestHarnessFailed(KErrGeneral); |
|
1237 } |
|
1238 |
|
1239 log->AppendComment(_L8("************* T_MIUT07 Tests Complete *************")); |
|
1240 log->AppendComment(_L8("")); |
|
1241 |
|
1242 CleanupStack::PopAndDestroy(); //log |
|
1243 |
|
1244 Closedown(); |
|
1245 } |
|
1246 |
|
1247 GLDEF_C TInt E32Main() |
|
1248 { |
|
1249 __UHEAP_MARK; |
|
1250 test.Start(_L("T_MIUT07 Test CImOffLineOperation class\n")); |
|
1251 theCleanup=CTrapCleanup::New(); |
|
1252 TRAPD(ret,doMainL()); |
|
1253 test(ret==KErrNone); |
|
1254 delete theCleanup; |
|
1255 test.End(); |
|
1256 test.Close(); |
|
1257 __UHEAP_MARKEND; |
|
1258 User::Heap().Check(); |
|
1259 return(KErrNone); |
|
1260 } |