|
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_PopFullDsk |
|
15 // Component: POPS |
|
16 // Owner: NB |
|
17 // Brief description of test harness: |
|
18 // Tests copying messages in POPS when there is a Full Disk |
|
19 // Detailed description of test harness: |
|
20 // Implements the following Tests: |
|
21 // 1 - Test Copy To Local |
|
22 // 2 - Test Copy Within Service |
|
23 // 3 - Test Copying from a Local folder to another Local Folder |
|
24 // 4 - Test Offline Copy |
|
25 // Input files required to run test harness: |
|
26 // The following files should be copied to <drive>:\msgtest\pops\ |
|
27 // T_PopFullDsk_CopyAll.scr |
|
28 // T_PopFullDsk_Populate.scr |
|
29 // T_PopFullDsk_OfflineCopy.scr |
|
30 // T_PopFullDsk_Msg.eml |
|
31 // Output files produced by running test harness: |
|
32 // <DRIVE>:\msglogs\T_POPSFullDisk.<PLATFORM>.<VARIANT>.LOG.txt |
|
33 // Description of how to build test harness: |
|
34 // cd \msg\pops\ |
|
35 // bldmake bldfiles |
|
36 // abld test build |
|
37 // Description of how to run test harness: |
|
38 // (1) You need to create a small partitioned drive (ie less than 20GB) to |
|
39 // run the harness on (eg a Compact Flash Card). |
|
40 // (2) For running on the emulator, alter the epoc32\data\epoc.ini |
|
41 // file so that it uses this drive (eg _EPOC_DRIVE_C E:\ |
|
42 // if E:\ is your small partioned drive ). |
|
43 // The following instructions are the same for all platforms: |
|
44 // 1. Build T_DB test harness from COMMDB component: |
|
45 // cd \commdb\group |
|
46 // bldmake bldfiles |
|
47 // abld test build t_db |
|
48 // 2. Build the test utilities: |
|
49 // cd \msg\testutils\group\ |
|
50 // bldmake bldfiles |
|
51 // abld build |
|
52 // WINS running instructions: |
|
53 // 1. \epoc32\release\wins\<VARIANT>\T_PopFullDsk.exe can be used at the command prompt |
|
54 // or executable can be run from Windows Explorer. |
|
55 // All other platform running instructions: |
|
56 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_PopFullDsk.exe onto the other platform |
|
57 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into |
|
58 // <DRIVE>:\system\libs on the other platform |
|
59 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into |
|
60 // <DRIVE>:\system\libs on the other platform |
|
61 // 4. Copy \epoc32\wins\c\msgtest\pops\*.* to |
|
62 // <DRIVE>:\msgtest\pops\ |
|
63 // Note that this drive should be a CF card as the test files are large |
|
64 // 5. Run T_PopFullDsk.exe on the other platform with the CF card |
|
65 // Generic POPS Test Harness |
|
66 // |
|
67 // |
|
68 |
|
69 #include "emailtestutils.h" |
|
70 #include "scripttestutils.h" |
|
71 #include <miutlog.h> |
|
72 #include <miutmsg.h> |
|
73 #include <txtrich.h> |
|
74 #include <popsmtm.h> |
|
75 #include "T_mtmcmd.h" |
|
76 #include <cemailaccounts.h> |
|
77 |
|
78 |
|
79 // NOTE: This is the amout of available Disk Space that we are creating to test |
|
80 // the Low Disk Space condition. It definitely has to be less than KMinimumDiskSpaceForSync |
|
81 // and ideally very small, as more space is made available as the operations are performed. |
|
82 const TInt KTestDiskSpace = 500; |
|
83 |
|
84 const TInt KFillDiskTooBigFreeSize =0x00080000; // 1/2 Gb in kb |
|
85 const TInt KFillDiskOneKByte =0x400; |
|
86 const TInt KFillDiskMaxBlockSize =1024; |
|
87 |
|
88 _LIT(KSubFolder, "LocalFolder"); |
|
89 _LIT(KSessionPath, "c:\\"); |
|
90 _LIT(KTestMsgPath, "c:\\msgtest\\pops\\T_PopFullDsk_Msg.eml"); |
|
91 _LIT(KMsvTestFillDiskFile, "c:\\Dummy fill file"); |
|
92 |
|
93 _LIT(K_POPS_COMPONENT_NAME, "POPS"); |
|
94 |
|
95 _LIT(K_SCRIPT_COPY_ALL, "T_PopFullDsk_CopyAll.scr"); |
|
96 _LIT(K_SCRIPT_POPULATE_ALL, "T_PopFullDsk_Populate.scr"); |
|
97 _LIT(K_SCRIPT_OFFLINE_COPY, "T_PopFullDsk_OfflineCopy.scr"); |
|
98 |
|
99 _LIT(KTest1Pass, "Test 1 OK, Copy To Local Failed correctly with KErrDiskFull"); |
|
100 _LIT(KTest2Pass, "Test 2 OK, Copy Within Service Failed correctly with KErrDiskFull"); |
|
101 _LIT(KTest3Pass, "Test 3 OK, Local Copy Failed correctly with KErrDiskFull"); |
|
102 |
|
103 _LIT(KTest1Failed, "Test 1 Failed, Copy To Local should NOT have completed"); |
|
104 _LIT(KTest2Failed, "Test 2 Failed, CopyWithin Service should NOT have completed"); |
|
105 _LIT(KTest3Failed, "Test 3 Failed, Local Copy should NOT have completed"); |
|
106 |
|
107 const TInt KMsvTestBackgroundDeleteInitialWait =1000000; |
|
108 |
|
109 _LIT(KImcmTest, "T_POPSFullDisk - Test Copy when Disk Full"); |
|
110 RTest test(KImcmTest); |
|
111 |
|
112 |
|
113 class CDelayTimer : public CTimer |
|
114 { |
|
115 public: |
|
116 CDelayTimer() : CTimer(EPriorityHigh) |
|
117 {} |
|
118 void ConstructL() |
|
119 { CTimer::ConstructL(); CActiveScheduler::Add(this); } |
|
120 void RunL(void) |
|
121 { CActiveScheduler::Stop(); } |
|
122 void Delay(TTimeIntervalMicroSeconds32 anInterval) |
|
123 { CTimer::After(anInterval); CActiveScheduler::Start(); } |
|
124 }; |
|
125 |
|
126 |
|
127 |
|
128 //------------------------------------- |
|
129 // CPopsTestHarness |
|
130 //------------------------------------- |
|
131 class CPopsTestHarness : public CBase |
|
132 { |
|
133 public: |
|
134 static CPopsTestHarness* NewLC(); |
|
135 ~CPopsTestHarness(); |
|
136 |
|
137 void RunTestsL(); |
|
138 |
|
139 |
|
140 private: |
|
141 CPopsTestHarness(); |
|
142 void ConstructL(); |
|
143 |
|
144 void InitL(); |
|
145 void ResetL(); |
|
146 void StartTestL(CMtmTestHarness& aTestCommands); |
|
147 void CopyScriptFileL(const TDesC& aScriptFile); |
|
148 void EndTestL(); |
|
149 void EndTestHarnessL(); |
|
150 |
|
151 // Fns to fill the disk |
|
152 void FillDiskL(); |
|
153 TInt CheckDiskSpace(TInt64& aFreeSpace); |
|
154 void TestAvailableSpaceOnDriveL(); |
|
155 |
|
156 // The Testing Functions |
|
157 void TestCopyToLocalL(const TDesC& aPassText, const TDesC& aFailText); |
|
158 void TestCopyWithinServiceL(const TDesC& aPassText, const TDesC& aFailText); |
|
159 void TestLocalCopyL(const TDesC& aPassText, const TDesC& aFailText); |
|
160 void TestOfflineCopyL(const TDesC& aPassText, const TDesC& aFailText); |
|
161 void DoLocalCopyTestL(); |
|
162 void CheckIfTestFailedL(TInt aError, CMtmTestHarness& aTestHarness,const TDesC& aPassText, const TDesC& aFailText); |
|
163 |
|
164 void SetUpTestL(const TDesC& aScriptFile); |
|
165 void SetUpPopServiceL(); |
|
166 void CreateTestHarnessesL(); |
|
167 void ResetMtmL(); |
|
168 |
|
169 public: |
|
170 CMtmTestHarness* iConnectAndCopyAll; |
|
171 CMtmTestHarness* iConnectAndPopulateAll; |
|
172 CMtmTestHarness* iOfflineCopy; |
|
173 |
|
174 private: |
|
175 TBool iRemoveMailFolder; |
|
176 TInt iTestError; |
|
177 TInt iTestNumber; |
|
178 TInt iGlobalError; |
|
179 |
|
180 TMsvId iPop3Service; |
|
181 |
|
182 CEmailTestUtils* iTestUtils; |
|
183 CScriptTestUtils* iScriptUtils; |
|
184 }; |
|
185 |
|
186 |
|
187 // |
|
188 |
|
189 CPopsTestHarness::CPopsTestHarness() |
|
190 : iGlobalError(KErrNone) |
|
191 { |
|
192 } |
|
193 |
|
194 CPopsTestHarness::~CPopsTestHarness() |
|
195 { |
|
196 delete iTestUtils; |
|
197 |
|
198 delete iScriptUtils; |
|
199 delete iConnectAndCopyAll; |
|
200 delete iConnectAndPopulateAll; |
|
201 delete iOfflineCopy; |
|
202 } |
|
203 |
|
204 CPopsTestHarness* CPopsTestHarness::NewLC() |
|
205 { |
|
206 CPopsTestHarness* self = new (ELeave) CPopsTestHarness(); |
|
207 CleanupStack::PushL(self); |
|
208 self->ConstructL(); |
|
209 return self; |
|
210 } |
|
211 |
|
212 void CPopsTestHarness::ConstructL() |
|
213 { |
|
214 iTestUtils = CEmailTestUtils::NewL(test); |
|
215 |
|
216 InitL(); |
|
217 } |
|
218 |
|
219 |
|
220 void CPopsTestHarness::SetUpTestL(const TDesC& aScriptFile) |
|
221 { |
|
222 // Delete any old dummy fill files |
|
223 iTestUtils->FileSession().Delete(KMsvTestFillDiskFile); |
|
224 |
|
225 // Reset & Copy the script file before filling the Disk |
|
226 ResetL(); |
|
227 CopyScriptFileL(aScriptFile); |
|
228 } |
|
229 |
|
230 void CPopsTestHarness::RunTestsL() |
|
231 { |
|
232 iTestNumber = 0; |
|
233 iRemoveMailFolder = ETrue; |
|
234 SetUpPopServiceL(); |
|
235 |
|
236 // 1 - Test Copy To Local |
|
237 TestCopyToLocalL(KTest1Pass, KTest1Failed); |
|
238 |
|
239 // 2 - Test Copy Within Service |
|
240 TestCopyWithinServiceL(KTest2Pass, KTest2Failed); |
|
241 |
|
242 // 3 - Test Copying from a Local folder to another Local Folder |
|
243 TestLocalCopyL(KTest3Pass, KTest3Failed); |
|
244 |
|
245 // 4 - Test Offline Copy |
|
246 // TestOfflineCopyL(KTest4Pass, KTest4Failed); |
|
247 |
|
248 // Enf of the Tests |
|
249 EndTestHarnessL(); |
|
250 } |
|
251 |
|
252 |
|
253 void CPopsTestHarness::TestCopyToLocalL(const TDesC& aPassText, const TDesC& aFailText) |
|
254 // ------------------------------------ |
|
255 // Test Copying To Local |
|
256 // ------------------------------------ |
|
257 { |
|
258 iTestError = 0; |
|
259 iTestNumber++; |
|
260 SetUpTestL(K_SCRIPT_COPY_ALL); |
|
261 FillDiskL(); |
|
262 TRAPD(testError, StartTestL(*iConnectAndCopyAll)); |
|
263 |
|
264 // Check if the Test Failed |
|
265 CheckIfTestFailedL(testError, *iConnectAndCopyAll, aPassText, aFailText); |
|
266 EndTestL(); |
|
267 } |
|
268 |
|
269 |
|
270 |
|
271 void CPopsTestHarness::TestCopyWithinServiceL(const TDesC& aPassText, const TDesC& aFailText) |
|
272 // ------------------------------------ |
|
273 // Test Copy Within Service |
|
274 // ------------------------------------ |
|
275 { |
|
276 iTestError = 0; |
|
277 iTestNumber++; |
|
278 SetUpTestL(K_SCRIPT_POPULATE_ALL); |
|
279 FillDiskL(); |
|
280 |
|
281 TRAPD(testError, StartTestL(*iConnectAndPopulateAll)); |
|
282 |
|
283 // Check if the Test Failed |
|
284 CheckIfTestFailedL(testError, *iConnectAndPopulateAll, aPassText, aFailText); |
|
285 EndTestL(); |
|
286 } |
|
287 |
|
288 |
|
289 void CPopsTestHarness::TestLocalCopyL(const TDesC& aPassText, const TDesC& aFailText) |
|
290 // ------------------------------------------------------------------ |
|
291 // Test Copying from a Local folder to another Local Folder |
|
292 // ------------------------------------------------------------------ |
|
293 { |
|
294 iTestError = 0; |
|
295 iTestNumber++; |
|
296 |
|
297 // Reset the harness & run the Test |
|
298 iTestUtils->FileSession().Delete(KMsvTestFillDiskFile); |
|
299 ResetL(); |
|
300 iTestUtils->TestStart(iTestNumber); |
|
301 TRAPD(error, DoLocalCopyTestL()); |
|
302 |
|
303 // Delete the fill file, so we can write to the log |
|
304 iTestUtils->FileSession().Delete(KMsvTestFillDiskFile); |
|
305 |
|
306 if (error == KErrDiskFull) |
|
307 { |
|
308 // Test OK = We could not Copy, as the disk was too Full |
|
309 iTestUtils->WriteComment(aPassText); |
|
310 } |
|
311 else if (error == KErrNone) |
|
312 { |
|
313 // ERROR - The Copy completed, even though the Disk was Full |
|
314 iTestUtils->WriteComment(aFailText); |
|
315 iTestError = KErrGeneral; |
|
316 } |
|
317 |
|
318 EndTestL(); |
|
319 } |
|
320 |
|
321 |
|
322 void CPopsTestHarness::TestOfflineCopyL(const TDesC& aPassText, const TDesC& aFailText) |
|
323 // ------------------------------------------------------------------ |
|
324 // Test Offline Copy - Populate some Messages & then try to create |
|
325 // Offline Ops to copy them locally |
|
326 // ------------------------------------------------------------------ |
|
327 { |
|
328 iTestError = 0; |
|
329 iTestNumber++; |
|
330 |
|
331 // Connect & Populate all the messages first |
|
332 SetUpTestL(K_SCRIPT_POPULATE_ALL); |
|
333 TRAPD(test2Error, StartTestL(*iConnectAndPopulateAll)); |
|
334 |
|
335 // Now reset, but DONT delete the Mail directory. |
|
336 iRemoveMailFolder = EFalse; |
|
337 SetUpTestL(K_SCRIPT_OFFLINE_COPY); |
|
338 |
|
339 // Fill the Disk & attempt to do an Offline Copy |
|
340 FillDiskL(); |
|
341 TRAPD(error, StartTestL(*iOfflineCopy)); |
|
342 |
|
343 // Check if the Test Failed |
|
344 CheckIfTestFailedL(error, *iOfflineCopy, aPassText, aFailText); |
|
345 EndTestL(); |
|
346 } |
|
347 |
|
348 |
|
349 void CPopsTestHarness::DoLocalCopyTestL() |
|
350 // Test copying a message locally. ie create a message in the Drafts folder |
|
351 // and copy it to a local sub folder |
|
352 { |
|
353 // Create the Message in the Drafts Folder |
|
354 iTestUtils->CreateMessageL(KTestMsgPath, KMsvDraftEntryId, KMsvDraftEntryId); |
|
355 CMsvServerEntry* serverEntry = iTestUtils->iServerEntry; |
|
356 serverEntry->SetEntry(KMsvDraftEntryId); |
|
357 CMsvEntrySelection* newMessageList = new (ELeave)CMsvEntrySelection(); |
|
358 CleanupStack::PushL(newMessageList); |
|
359 serverEntry->GetChildren(*newMessageList); |
|
360 TMsvId newMessageId = (*newMessageList)[0]; |
|
361 |
|
362 // Create a local folder under the Drafts folder |
|
363 TMsvEntry parentEntry = serverEntry->Entry(); |
|
364 TMsvEntry newFolder; |
|
365 newFolder.SetStandardFolder(ETrue); |
|
366 newFolder.iDetails.Set(KSubFolder); |
|
367 newFolder.iType.iUid=KUidMsvFolderEntryValue; |
|
368 newFolder.iMtm=parentEntry.iMtm; |
|
369 newFolder.iServiceId = parentEntry.iServiceId; |
|
370 serverEntry->CreateEntry(newFolder); |
|
371 |
|
372 // Fill the Disk Space and attempt to do the Copy |
|
373 FillDiskL(); |
|
374 |
|
375 // Copy the message into the new LOCAL Sub-Folder |
|
376 CTestActive* active = new(ELeave) CTestActive; |
|
377 CleanupStack::PushL(active); |
|
378 serverEntry->CopyEntryL(newMessageId, newFolder.Id(), active->iStatus); |
|
379 active->StartL(); |
|
380 CActiveScheduler::Start(); |
|
381 |
|
382 CleanupStack::PopAndDestroy(2); // newMessageList, active |
|
383 } |
|
384 |
|
385 |
|
386 void CPopsTestHarness::CheckIfTestFailedL(TInt aError, CMtmTestHarness& aTestHarness, |
|
387 const TDesC& aPassText, const TDesC& aFailText) |
|
388 { |
|
389 // Delete the fill file, so we can write to the log |
|
390 iTestUtils->FileSession().Delete(KMsvTestFillDiskFile); |
|
391 |
|
392 if (aError == KErrDiskFull) |
|
393 { |
|
394 // Test OK = We could not Copy, as the disk was too Full |
|
395 iTestUtils->WriteComment(aPassText); |
|
396 } |
|
397 else if (aError == KErrNone) |
|
398 { |
|
399 // The test returned ok, so check if the Mtm Test Harness returned an error |
|
400 TInt commandError = aTestHarness.CommandError(); |
|
401 TInt commandStatus = aTestHarness.iStatus.Int(); |
|
402 if (commandError == KErrDiskFull || commandStatus == KErrDiskFull) |
|
403 { |
|
404 // Test OK = We could not Copy as the disk was too Full |
|
405 iTestUtils->WriteComment(aPassText); |
|
406 } |
|
407 else |
|
408 { |
|
409 // ERROR - The Copy completed, even though the Disk was Full |
|
410 iTestUtils->WriteComment(aFailText); |
|
411 iTestError = KErrGeneral; |
|
412 } |
|
413 } |
|
414 } |
|
415 |
|
416 |
|
417 |
|
418 void CPopsTestHarness::TestAvailableSpaceOnDriveL() |
|
419 // |
|
420 // Make sure there is enougth disk space to run the Tests |
|
421 // |
|
422 { |
|
423 const TInt64 KMaximumAllowedFreeSpaceOnDrive=10*1024*1024; // 10MB |
|
424 |
|
425 // Get drive information. |
|
426 TVolumeInfo volumeInfo; |
|
427 User::LeaveIfError(iTestUtils->FileSession().Volume(volumeInfo, EDriveC)); |
|
428 |
|
429 // Check that the media is present. |
|
430 test(volumeInfo.iDrive.iType!=EMediaNotPresent); |
|
431 |
|
432 // Check that there is not too much free space (ie 20Gb!) |
|
433 test(volumeInfo.iFree<=KMaximumAllowedFreeSpaceOnDrive); |
|
434 } |
|
435 |
|
436 |
|
437 |
|
438 TInt CPopsTestHarness::CheckDiskSpace(TInt64& aFreeSpace) |
|
439 // |
|
440 // Check available disk space. |
|
441 // |
|
442 { |
|
443 TVolumeInfo volumeInfo; |
|
444 TInt error = iTestUtils->FileSession().Volume(volumeInfo, EDriveC); |
|
445 aFreeSpace = error?0:volumeInfo.iFree; |
|
446 return(error); |
|
447 } |
|
448 |
|
449 |
|
450 void CPopsTestHarness::FillDiskL() |
|
451 // |
|
452 // Fill all available space on C: drive leaving aLeaveFreeByes free. |
|
453 // |
|
454 { |
|
455 TInt leaveFreeBytes = KTestDiskSpace; |
|
456 |
|
457 // Check that there is a C-drive and that it is less than 10MB in size. |
|
458 TestAvailableSpaceOnDriveL(); |
|
459 |
|
460 // NOTE: This test harness should be used with a dedicated small partition or |
|
461 // subst'ed floppy drive as the EPOC C: drive. As a safety precaution, it |
|
462 // tests the free space on the partition to ensure that it does not attempt |
|
463 // to eat 20 GB of free space and either crash Windows or at least cause a |
|
464 // headache of some sort... |
|
465 |
|
466 // Delete any old dummy fill files - if there is one to delete. |
|
467 iTestUtils->FileSession().Delete(KMsvTestFillDiskFile); |
|
468 |
|
469 // Create the delay timer |
|
470 CDelayTimer* delayTimer = new(ELeave)CDelayTimer; |
|
471 CleanupStack::PushL(delayTimer); |
|
472 delayTimer->ConstructL(); |
|
473 |
|
474 // Check that available disk space does not exceed the max free space to fill. |
|
475 // See above... |
|
476 TInt64 freeSpace; |
|
477 TInt64 freeSpaceLeft; |
|
478 TInt error = CheckDiskSpace(freeSpace); |
|
479 TInt reclaimActive = 0; |
|
480 do |
|
481 { |
|
482 delayTimer->Delay(KMsvTestBackgroundDeleteInitialWait); |
|
483 error = CheckDiskSpace(freeSpaceLeft); |
|
484 if (freeSpaceLeft == freeSpace) |
|
485 reclaimActive++; |
|
486 freeSpace = freeSpaceLeft; |
|
487 } |
|
488 while (!error && reclaimActive<3); |
|
489 User::LeaveIfError(error); |
|
490 |
|
491 CleanupStack::PopAndDestroy(); //delayTimer |
|
492 |
|
493 // Free space in kb. |
|
494 freeSpace/=KFillDiskOneKByte; |
|
495 |
|
496 // Check free space on C: drive is not too big. |
|
497 TInt freeSpaceInKb = I64INT(freeSpace); |
|
498 if (freeSpaceInKb>KFillDiskTooBigFreeSize) |
|
499 User::Leave(KErrTooBig); |
|
500 |
|
501 // Fill disk with large file. |
|
502 TBuf8<KFillDiskMaxBlockSize> dummy; |
|
503 dummy.SetMax(); |
|
504 dummy.Fill('?'); |
|
505 |
|
506 // Open dummy file. |
|
507 RFile fillDiskFile; |
|
508 User::LeaveIfError(fillDiskFile.Replace(iTestUtils->FileSession(), KMsvTestFillDiskFile, EFileWrite)); |
|
509 |
|
510 // Establish required dummy file size. |
|
511 freeSpaceLeft-=leaveFreeBytes; |
|
512 if (freeSpaceLeft<0) |
|
513 // Uh oh, we have less space available than what was asked for... |
|
514 User::Leave(KErrDiskFull); |
|
515 |
|
516 // Write dummy file. |
|
517 while (freeSpaceLeft>0 && error==KErrNone) |
|
518 { |
|
519 dummy.SetLength(Min(KFillDiskMaxBlockSize,I64INT(freeSpaceLeft))); |
|
520 error=fillDiskFile.Write(dummy); |
|
521 freeSpaceLeft-=KFillDiskMaxBlockSize; |
|
522 } |
|
523 fillDiskFile.Close(); |
|
524 if (error==KErrDiskFull) |
|
525 error=KErrNone; |
|
526 User::LeaveIfError(error); |
|
527 } |
|
528 |
|
529 void CPopsTestHarness::ResetMtmL() |
|
530 { |
|
531 // Get server MTM. |
|
532 iTestUtils->Reset(); |
|
533 |
|
534 if (iRemoveMailFolder) |
|
535 { |
|
536 iTestUtils->CleanMessageFolderL(); |
|
537 } |
|
538 else |
|
539 { |
|
540 iRemoveMailFolder = ETrue; |
|
541 } |
|
542 |
|
543 iTestUtils->GoServerSideL(); |
|
544 SetUpPopServiceL(); |
|
545 iTestUtils->InstantiatePopServerMtmL(); |
|
546 } |
|
547 |
|
548 void CPopsTestHarness::ResetL() |
|
549 { |
|
550 ResetMtmL(); |
|
551 CreateTestHarnessesL(); |
|
552 } |
|
553 |
|
554 void CPopsTestHarness::StartTestL(CMtmTestHarness& aTestCommands) |
|
555 { |
|
556 iTestError = KErrNone; |
|
557 iTestUtils->TestStart(iTestNumber); |
|
558 |
|
559 // Run the commands. |
|
560 aTestCommands.StartL(_L("T_PopFullDsk - POP Copy Disk Full Test Harness")); |
|
561 } |
|
562 |
|
563 void CPopsTestHarness::CopyScriptFileL(const TDesC& aScriptFile) |
|
564 { |
|
565 TParse parsedScriptFile; |
|
566 parsedScriptFile.Set(aScriptFile,0,0); |
|
567 if (!parsedScriptFile.DrivePresent()) |
|
568 // This isn't a full path name so we need to resolve it |
|
569 { |
|
570 iTestUtils->ResolveFile(K_POPS_COMPONENT_NAME, aScriptFile, parsedScriptFile); |
|
571 } |
|
572 iTestUtils->CopyScriptFileL(parsedScriptFile.FullName(), _L("110")); |
|
573 } |
|
574 |
|
575 void CPopsTestHarness::EndTestL() |
|
576 { |
|
577 if ((iTestError != KErrNone) && (iGlobalError == KErrNone)) |
|
578 { |
|
579 iGlobalError = iTestError; |
|
580 } |
|
581 |
|
582 iTestUtils->TestFinish(iTestNumber, iTestError); |
|
583 } |
|
584 |
|
585 void CPopsTestHarness::EndTestHarnessL() |
|
586 { |
|
587 if (iGlobalError == KErrNone) |
|
588 { |
|
589 iTestUtils->TestHarnessCompleted(); |
|
590 } |
|
591 else |
|
592 { |
|
593 iTestUtils->TestHarnessFailed(iGlobalError); |
|
594 } |
|
595 } |
|
596 |
|
597 void CPopsTestHarness::InitL() |
|
598 { |
|
599 iTestUtils->CreateAllTestDirectories(); |
|
600 iTestUtils->FileSession().SetSessionPath(KSessionPath); |
|
601 iTestUtils->CleanMessageFolderL(); |
|
602 iTestUtils->GoServerSideL(); |
|
603 |
|
604 iScriptUtils = CScriptTestUtils::NewLC(*iTestUtils); |
|
605 CleanupStack::Pop(); // iScriptUtils |
|
606 |
|
607 iTestUtils->FileSession().SetSessionPath(KSessionPath); |
|
608 } |
|
609 |
|
610 void CPopsTestHarness::SetUpPopServiceL() |
|
611 { |
|
612 // Create the POP3 service and set the settings for this test. |
|
613 iPop3Service = iTestUtils->CreatePopServiceL(); |
|
614 |
|
615 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
|
616 CleanupStack::PushL(settings); |
|
617 |
|
618 settings->Reset(); |
|
619 _LIT(KPopServer, "pop3.demon.co.uk"); |
|
620 settings->SetServerAddressL(KPopServer); |
|
621 settings->SetLoginNameL(iTestUtils->MachineName()); |
|
622 settings->SetPasswordL(iTestUtils->MachineName()); |
|
623 settings->SetPort(110); |
|
624 settings->SetDisconnectedUserMode(ETrue); // eh xxxx, must test this when set to EFalse |
|
625 |
|
626 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
627 TPopAccount popAccount; |
|
628 accounts->GetPopAccountL(iPop3Service, popAccount); |
|
629 accounts->SavePopSettingsL(popAccount, *settings); |
|
630 CleanupStack::PopAndDestroy(2, settings); // accounts/store, settings |
|
631 |
|
632 test.Printf(_L("\nPerforming Tests\n")); |
|
633 } |
|
634 |
|
635 |
|
636 void CPopsTestHarness::CreateTestHarnessesL() |
|
637 { |
|
638 CMsvEntrySelection* serviceSelection = new (ELeave) CMsvEntrySelection; |
|
639 CleanupStack::PushL(serviceSelection); |
|
640 serviceSelection->AppendL(iPop3Service); |
|
641 TBuf8<128> parameter; |
|
642 |
|
643 //-------------------------------------------- |
|
644 // Copy To Local |
|
645 //-------------------------------------------- |
|
646 delete iConnectAndCopyAll; |
|
647 iConnectAndCopyAll = NULL; |
|
648 iConnectAndCopyAll = CMtmTestHarness::NewL(*(iTestUtils->iPopServerMtm), *iTestUtils); |
|
649 // Connect |
|
650 iConnectAndCopyAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils->iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
651 // Copy all messages under the service to the local inbox. |
|
652 CMtmTestCommand* copyToLocal = CMtmTestCopyToLocal::NewL(*(iTestUtils->iPopServerMtm), 0, KMsvGlobalInBoxIndexEntryId); |
|
653 iConnectAndCopyAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils->iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils->iServerEntry))); |
|
654 // Quit |
|
655 iConnectAndCopyAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils->iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
656 |
|
657 //-------------------------------------------- |
|
658 // Copy Within Service |
|
659 //-------------------------------------------- |
|
660 delete iConnectAndPopulateAll; |
|
661 iConnectAndPopulateAll = NULL; |
|
662 iConnectAndPopulateAll = CMtmTestHarness::NewL(*(iTestUtils->iPopServerMtm), *iTestUtils); |
|
663 // Connect |
|
664 iConnectAndPopulateAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils->iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
665 // Copy all messages under the service to the local service. |
|
666 copyToLocal = CMtmTestCopyWithinService::NewL(*(iTestUtils->iPopServerMtm), 0, iPop3Service); |
|
667 iConnectAndPopulateAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils->iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils->iServerEntry))); |
|
668 // Quit |
|
669 iConnectAndPopulateAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils->iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
670 |
|
671 |
|
672 //-------------------------------------------- |
|
673 // Offline Copy |
|
674 //-------------------------------------------- |
|
675 CMsvServerEntry* serverEntry = iTestUtils->iServerEntry; |
|
676 serverEntry->SetEntry(iPop3Service); |
|
677 CMsvEntrySelection* newMessageList = new (ELeave)CMsvEntrySelection(); |
|
678 CleanupStack::PushL(newMessageList); |
|
679 serverEntry->GetChildren(*newMessageList); |
|
680 delete iOfflineCopy; |
|
681 iOfflineCopy = NULL; |
|
682 iOfflineCopy = CMtmTestHarness::NewL(*(iTestUtils->iPopServerMtm), *iTestUtils); |
|
683 // Copy all messages under the service to the local inbox. |
|
684 copyToLocal = CMtmTestCopyToLocal::NewL(*(iTestUtils->iPopServerMtm), newMessageList, KMsvGlobalInBoxIndexEntryId); |
|
685 iOfflineCopy->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils->iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils->iServerEntry))); |
|
686 // Connect |
|
687 iOfflineCopy->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils->iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
688 // Quit |
|
689 iOfflineCopy->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils->iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
690 |
|
691 |
|
692 CleanupStack::PopAndDestroy(2); // newMessageList, serviceSelection |
|
693 } |
|
694 |
|
695 |
|
696 // |
|
697 |
|
698 |
|
699 |
|
700 LOCAL_C void doMainL() |
|
701 { |
|
702 CActiveScheduler* scheduler; |
|
703 scheduler = new (ELeave) CActiveScheduler; |
|
704 CleanupStack::PushL(scheduler); |
|
705 CActiveScheduler::Install(scheduler); |
|
706 |
|
707 // Create the Test Harness & run the Tests |
|
708 CPopsTestHarness* popsTestHarness = CPopsTestHarness::NewLC(); |
|
709 popsTestHarness->RunTestsL(); |
|
710 |
|
711 CleanupStack::PopAndDestroy(2); // popsTestHarness, scheduler |
|
712 } |
|
713 |
|
714 GLDEF_C TInt E32Main() |
|
715 { |
|
716 __UHEAP_MARK; |
|
717 test.Start(_L("T_PopFullDsk, POP Copy Disk Full Tests")); |
|
718 CTrapCleanup* theCleanup = CTrapCleanup::New(); |
|
719 |
|
720 TRAPD(ret,doMainL()); |
|
721 test(ret==KErrNone); |
|
722 delete theCleanup; |
|
723 test.End(); |
|
724 test.Close(); |
|
725 __UHEAP_MARKEND; |
|
726 User::Heap().Check(); |
|
727 return(KErrNone); |
|
728 } |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |