|
1 // Copyright (c) 2004-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_PARTIALFETCH |
|
15 // Component: IMCM |
|
16 // Owner: KP |
|
17 // Brief description of test harness: |
|
18 // Tests CImImap4GetMail - tests combination of Partial populate |
|
19 // new/all/selection when the user is already connected; connects, does |
|
20 // operation, disconnects; connects, does operation and stays online. |
|
21 // Detailed description of test harness: |
|
22 // As above. |
|
23 // Input files required to run test harness: |
|
24 // None |
|
25 // Output files produced by running test harness: |
|
26 // <DRIVE>:\msglogs\T_PARTIALFETCH.<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_PARTIALFETCH.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_PARTIALFETCH.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_PARTIALFETCH.exe on the other platform |
|
51 // |
|
52 // |
|
53 |
|
54 #include "emailtestutils.h" |
|
55 #include <txtrich.h> |
|
56 #include <commdb.h> |
|
57 #include "TESTENV.h" |
|
58 #include <imapconnectionobserver.h> |
|
59 #include <bacline.h> |
|
60 #include <cemailaccounts.h> |
|
61 |
|
62 // For loading the serial comms device drivers |
|
63 #if defined (__WINS__) |
|
64 #define PDD_NAME _L("ECDRV") |
|
65 #define LDD_NAME _L("ECOMM") |
|
66 #else |
|
67 #define PDD_NAME _L("EUART1") |
|
68 #define LDD_NAME _L("ECOMM") |
|
69 #endif |
|
70 |
|
71 // local variables etc // |
|
72 |
|
73 class CDummyConnectionObserver : public MMsvImapConnectionObserver |
|
74 { |
|
75 void HandleImapConnectionEvent(TImapConnectionEvent aConnectionEvent); |
|
76 }; |
|
77 |
|
78 void CDummyConnectionObserver::HandleImapConnectionEvent(TImapConnectionEvent) |
|
79 { |
|
80 } |
|
81 |
|
82 |
|
83 _LIT(KImcmTest, "T_PARTIALFETCH - Testing CImImap4GetMail"); |
|
84 RTest test(KImcmTest); |
|
85 |
|
86 _LIT(KTestParams,"-testparams"); |
|
87 enum TCmdLineArgs |
|
88 { |
|
89 EArgProgramName, |
|
90 EArgTestParams, |
|
91 EArgServerAddress, |
|
92 EArgLogin, |
|
93 EArgPassword, |
|
94 EArgFolderPath, |
|
95 EArgEnd |
|
96 }; |
|
97 |
|
98 LOCAL_D TMsvId imap4Service; |
|
99 LOCAL_D TMsvId smtpService; |
|
100 LOCAL_D TInt globalError; |
|
101 |
|
102 LOCAL_D CTrapCleanup* theCleanup; |
|
103 LOCAL_D CEmailTestUtils* testUtils; |
|
104 |
|
105 LOCAL_D CMsvOperation* msvOperation; |
|
106 LOCAL_D CMsvEntrySelection* msvSelection; |
|
107 LOCAL_D CConsoleBase* console; |
|
108 |
|
109 class COperationActive; |
|
110 LOCAL_D COperationActive* opActive; |
|
111 |
|
112 #if 1 |
|
113 _LIT(KImapServer, "lon-msgtest06.intra"); |
|
114 _LIT8(KFolderPath, ""); |
|
115 |
|
116 #else |
|
117 _LIT(KImapServer, "utter.chaos.org.uk"); |
|
118 _LIT8(KLoginName, "test"); |
|
119 _LIT8(KPassword, "testtest"); |
|
120 _LIT8(KFolderPath, "~/mail"); |
|
121 #endif |
|
122 |
|
123 // |
|
124 class TestUiTimer : public CTimer |
|
125 { |
|
126 public: |
|
127 static TestUiTimer* NewLC(CConsoleBase* aConsole); |
|
128 ~TestUiTimer(); |
|
129 |
|
130 void RunL(); |
|
131 void DoCancel(); |
|
132 void ConstructL(); |
|
133 void IssueRequest(); |
|
134 void SetOperation(CMsvOperation* aOperation); |
|
135 TTimeIntervalMicroSeconds32 period; |
|
136 TPtrC Progress(TInt progressNumber); |
|
137 void SetCancelState(TInt aState); |
|
138 protected: |
|
139 TestUiTimer(CConsoleBase* aConsole); |
|
140 |
|
141 CConsoleBase* iConsole; |
|
142 public: |
|
143 CMsvOperation* iOperation; |
|
144 private: |
|
145 TInt iCancelState; |
|
146 }; |
|
147 |
|
148 // |
|
149 TestUiTimer* TestUiTimer::NewLC(CConsoleBase* aConsole) |
|
150 { |
|
151 TestUiTimer* self = new(ELeave) TestUiTimer(aConsole); |
|
152 CleanupStack::PushL(self); |
|
153 self->ConstructL(); |
|
154 return self; |
|
155 } |
|
156 |
|
157 TestUiTimer::TestUiTimer(CConsoleBase* aConsole) |
|
158 : CTimer(1), iCancelState(200) |
|
159 { |
|
160 iConsole = aConsole; |
|
161 period = 10000; |
|
162 } |
|
163 |
|
164 TestUiTimer::~TestUiTimer() |
|
165 { |
|
166 delete iOperation; |
|
167 } |
|
168 |
|
169 void TestUiTimer::ConstructL() |
|
170 { |
|
171 CTimer::ConstructL(); |
|
172 CActiveScheduler::Add(this); |
|
173 } |
|
174 |
|
175 void TestUiTimer::IssueRequest() |
|
176 { |
|
177 After(period); |
|
178 } |
|
179 |
|
180 void TestUiTimer::SetOperation(CMsvOperation* aOperation) |
|
181 { |
|
182 if(iOperation) |
|
183 { |
|
184 delete iOperation; |
|
185 iOperation=NULL; |
|
186 } |
|
187 iOperation = aOperation; |
|
188 } |
|
189 |
|
190 void TestUiTimer::DoCancel() |
|
191 { |
|
192 CTimer::DoCancel(); |
|
193 } |
|
194 |
|
195 TPtrC TestUiTimer::Progress(TInt progressNumber) |
|
196 { |
|
197 switch (progressNumber) |
|
198 { |
|
199 case 0: |
|
200 return _L("Disconnected "); |
|
201 case 1: |
|
202 return _L("Connecting "); |
|
203 case 2: |
|
204 return _L("Idle "); |
|
205 case 3: |
|
206 return _L("Selecting "); |
|
207 case 4: |
|
208 return _L("Fetching "); |
|
209 case 5: |
|
210 return _L("Appending "); |
|
211 case 6: |
|
212 return _L("Copying "); |
|
213 case 7: |
|
214 return _L("Deleting "); |
|
215 case 8: |
|
216 return _L("Syncing "); |
|
217 case 9: |
|
218 return _L("Disconnecting "); |
|
219 case 10: |
|
220 return _L("Busy "); |
|
221 case 11: |
|
222 return _L("Moving "); |
|
223 case 12: |
|
224 return _L("Copying New Mail "); |
|
225 case 13: |
|
226 return _L("Moving New Mail "); |
|
227 case 14: |
|
228 return _L("Copying Mail Selection "); |
|
229 case 15: |
|
230 return _L("Moving Mail Selection "); |
|
231 case 16: |
|
232 return _L("Copying All Mail "); |
|
233 case 17: |
|
234 return _L("Moving All Mail "); |
|
235 case 18: |
|
236 return _L("Populating New Mail "); |
|
237 case 19: |
|
238 return _L("Populating All Mail "); |
|
239 case 20: |
|
240 return _L("Populating Mail Selection "); |
|
241 default: |
|
242 return _L("Unknown Progress "); |
|
243 } |
|
244 } |
|
245 |
|
246 void TestUiTimer::SetCancelState(TInt aState) |
|
247 { |
|
248 iCancelState = aState; |
|
249 } |
|
250 |
|
251 void TestUiTimer::RunL() |
|
252 { |
|
253 // display the current progress |
|
254 if(iOperation!=NULL) |
|
255 { |
|
256 TImap4GenericProgress temp; |
|
257 TPckgC<TImap4GenericProgress> paramPack(temp); |
|
258 paramPack.Set(iOperation->ProgressL()); |
|
259 TImap4GenericProgress progress=paramPack(); |
|
260 |
|
261 if (iCancelState == progress.iImap4SubStateProgress) |
|
262 { |
|
263 iConsole->Printf(_L(" Calling Cancel\n")); |
|
264 iOperation->Cancel(); |
|
265 } |
|
266 |
|
267 iConsole->SetPos(0, 12); |
|
268 TBuf<80> progressBuf = Progress(progress.iState); |
|
269 iConsole->Printf(TRefByValue<const TDesC>_L(" Super Operation Progress: %S "), &progressBuf); |
|
270 iConsole->SetPos(0, 13); |
|
271 progressBuf = Progress(progress.iImap4SubStateProgress); |
|
272 iConsole->Printf(TRefByValue<const TDesC>_L(" Sub Operation Progress : %S "), &progressBuf); |
|
273 iConsole->SetPos(0, 14); |
|
274 iConsole->Printf(TRefByValue<const TDesC>_L(" Progress: %d/%d %d/%d Total:%d \n"), |
|
275 progress.iMsgsDone, |
|
276 progress.iMsgsToDo, |
|
277 progress.iBytesDone, |
|
278 progress.iBytesToDo, |
|
279 progress.iTotalSize); |
|
280 |
|
281 iConsole->SetPos(0, 15); |
|
282 iConsole->Printf(TRefByValue<const TDesC>_L(" Error: %d \n"), progress.iErrorCode); |
|
283 if (!globalError && progress.iErrorCode) |
|
284 globalError=progress.iErrorCode; |
|
285 } |
|
286 IssueRequest(); |
|
287 }; |
|
288 |
|
289 // |
|
290 |
|
291 class COperationActive : public CActive |
|
292 { |
|
293 public: |
|
294 COperationActive(); |
|
295 ~COperationActive(); |
|
296 static COperationActive* NewL(); |
|
297 void StartL(); |
|
298 void SetOperation(CMsvOperation*); |
|
299 void SetCancelState(TInt aCancelState); |
|
300 |
|
301 protected: |
|
302 void DoCancel(); |
|
303 void RunL(); |
|
304 public: |
|
305 TestUiTimer* iTimer; |
|
306 private: |
|
307 TBool iSetActive; |
|
308 }; |
|
309 |
|
310 // |
|
311 COperationActive::COperationActive() |
|
312 : CActive(0) |
|
313 { |
|
314 } |
|
315 |
|
316 COperationActive::~COperationActive() |
|
317 { |
|
318 Cancel(); |
|
319 delete iTimer; |
|
320 } |
|
321 |
|
322 COperationActive* COperationActive::NewL() |
|
323 { |
|
324 COperationActive* self = new (ELeave) COperationActive; |
|
325 CActiveScheduler::Add(self); |
|
326 |
|
327 self->iSetActive = ETrue; |
|
328 self->iTimer = TestUiTimer::NewLC(test.Console()); |
|
329 CleanupStack::Pop(); |
|
330 return self; |
|
331 } |
|
332 |
|
333 void COperationActive::DoCancel() |
|
334 { |
|
335 iTimer->DoCancel(); |
|
336 } |
|
337 |
|
338 void COperationActive::StartL() |
|
339 { |
|
340 globalError=0; |
|
341 iTimer->IssueRequest(); // Start the connect observation timer |
|
342 SetActive(); |
|
343 test.Console()->SetPos(0, 17); |
|
344 test.Printf(TRefByValue<const TDesC>_L("Operation TRequestStatus %d"), iStatus); |
|
345 } |
|
346 |
|
347 void COperationActive::SetOperation(CMsvOperation *aOperation) |
|
348 { |
|
349 iTimer->SetOperation(aOperation); |
|
350 } |
|
351 |
|
352 void COperationActive::SetCancelState(TInt aCancelState) |
|
353 { |
|
354 iTimer->SetCancelState(aCancelState); |
|
355 } |
|
356 |
|
357 void COperationActive::RunL() |
|
358 { |
|
359 iTimer->Cancel(); |
|
360 test.Console()->SetPos(25, 17); |
|
361 test.Printf(_L(" ")); |
|
362 test.Console()->SetPos(0, 17); |
|
363 test.Printf(TRefByValue<const TDesC>_L("Operation TRequestStatus %d"), iStatus); |
|
364 CActiveScheduler::Stop(); |
|
365 } |
|
366 |
|
367 // |
|
368 LOCAL_C void CreateMailSelection(CMsvEntrySelection& aSelection) |
|
369 { |
|
370 // Create a selection of all IMAP4 messages in the parent folder. |
|
371 testUtils->iMsvEntry->SetEntryL(imap4Service+1); |
|
372 // testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service+1); |
|
373 CMsvEntrySelection* selection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry); |
|
374 |
|
375 for(TInt i=0 ; i<selection->Count(); i++) |
|
376 aSelection.AppendL(selection->At(i)); |
|
377 testUtils->iMsvEntry->SetEntryL(imap4Service); |
|
378 } |
|
379 |
|
380 LOCAL_C void ConnectAndSyncCompleteL() |
|
381 { |
|
382 testUtils->WriteComment(_L("Inside ConnectAndSyncCompleteL ")); |
|
383 |
|
384 testUtils->WriteComment(_L("Connecting to the IMAP4 server")); |
|
385 |
|
386 CDummyConnectionObserver *dummyObserver = new(ELeave)CDummyConnectionObserver; |
|
387 //CleanupStack::PushL(dummyObserver); |
|
388 |
|
389 TPckg<MMsvImapConnectionObserver*> aParameter(dummyObserver); |
|
390 |
|
391 msvSelection->ResizeL(0); |
|
392 msvSelection->AppendL(imap4Service); |
|
393 |
|
394 opActive->iStatus = KRequestPending; |
|
395 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndSyncCompleteAfterDisconnect, *msvSelection, aParameter, opActive->iStatus); |
|
396 opActive->SetOperation(msvOperation); |
|
397 opActive->StartL(); // Start the connect active object |
|
398 testUtils->WriteComment(_L("End of ConnectAndSyncCompleteL ")); |
|
399 } |
|
400 |
|
401 |
|
402 LOCAL_C void ConnectToServerL() |
|
403 { |
|
404 testUtils->WriteComment(_L("Connecting to the IMAP4 server")); |
|
405 TBuf8<1> aParameter; |
|
406 msvSelection->ResizeL(0); |
|
407 msvSelection->AppendL(imap4Service); |
|
408 |
|
409 opActive->iStatus = KRequestPending; |
|
410 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnect, *msvSelection, aParameter, opActive->iStatus); |
|
411 opActive->SetOperation(msvOperation); |
|
412 opActive->StartL(); // Start the connect active object |
|
413 } |
|
414 |
|
415 LOCAL_C void SynchronizeRemoteInbox() |
|
416 { |
|
417 testUtils->WriteComment(_L("Synchronizing Remote Inbox")); |
|
418 msvSelection->ResizeL(0); |
|
419 msvSelection->AppendL(imap4Service); |
|
420 |
|
421 TImImap4GetMailInfo imap4GetMailInfo; |
|
422 imap4GetMailInfo.iMaxEmailSize = KMaxTInt; |
|
423 imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue; |
|
424 imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyText;//EGetImap4EmailBodyTextAndAttachments; |
|
425 TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo); |
|
426 |
|
427 opActive->iStatus = KRequestPending; |
|
428 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMFullSync, *msvSelection, package, opActive->iStatus); |
|
429 opActive->SetOperation(msvOperation); |
|
430 opActive->StartL(); // Start the active object |
|
431 } |
|
432 |
|
433 LOCAL_C void DisconnectFromServerL() |
|
434 { |
|
435 testUtils->WriteComment(_L("Disconnecting from the IMAP4 server")); |
|
436 TBuf8<1> aParameter; |
|
437 msvSelection->ResizeL(0); |
|
438 msvSelection->AppendL(imap4Service); |
|
439 |
|
440 opActive->iStatus = KRequestPending; |
|
441 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMDisconnect, *msvSelection, aParameter, opActive->iStatus); |
|
442 opActive->SetOperation(msvOperation); |
|
443 opActive->StartL(); // Start the disconnect active object |
|
444 } |
|
445 |
|
446 // |
|
447 // Get Mail when already Connected tests |
|
448 // |
|
449 LOCAL_C void PopulateNewMessagesPartiallyWhenAlreadyConnectedL() |
|
450 { |
|
451 testUtils->WriteComment(_L("Populating new messages when already connected")); |
|
452 |
|
453 msvSelection->ResizeL(0); |
|
454 msvSelection->AppendL(imap4Service); |
|
455 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
456 |
|
457 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
458 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
459 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
460 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
461 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
462 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
463 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
464 |
|
465 opActive->iStatus = KRequestPending; |
|
466 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateNewMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus); |
|
467 opActive->SetOperation(msvOperation); |
|
468 opActive->StartL(); // Start the populate new mail active object |
|
469 } |
|
470 |
|
471 LOCAL_C void PopulateAllMessagesPartiallyWhenAlreadyConnectedL() |
|
472 { |
|
473 testUtils->WriteComment(_L("Populating all messages partially when already connected")); |
|
474 |
|
475 msvSelection->ResizeL(0); |
|
476 msvSelection->AppendL(imap4Service); |
|
477 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
478 |
|
479 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
480 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
481 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
482 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
483 imapGetPartialMailInfo.iAttachmentSizeLimit = 5000; |
|
484 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
485 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
486 |
|
487 opActive->iStatus = KRequestPending; |
|
488 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus); |
|
489 opActive->SetOperation(msvOperation); |
|
490 opActive->StartL(); // Start the populate all mail active object |
|
491 } |
|
492 |
|
493 LOCAL_C void PopulateAllMessagesWithCumulativeOption() |
|
494 { |
|
495 testUtils->WriteComment(_L("Populating all messages partially when already connected with TImImap4PartialMailOptions = ECumulative")); |
|
496 |
|
497 msvSelection->ResizeL(0); |
|
498 msvSelection->AppendL(imap4Service); |
|
499 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
500 |
|
501 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
502 imapGetPartialMailInfo.iPartialMailOptions=ECumulative; |
|
503 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
504 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
505 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
506 |
|
507 opActive->iStatus = KRequestPending; |
|
508 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus); |
|
509 opActive->SetOperation(msvOperation); |
|
510 opActive->StartL(); // Start the populate all mail active object |
|
511 } |
|
512 |
|
513 LOCAL_C void PopulateAllMessagesWithNoSizeLimitOption() |
|
514 { |
|
515 testUtils->WriteComment(_L("Populating all messages with no size limits")); |
|
516 |
|
517 msvSelection->ResizeL(0); |
|
518 msvSelection->AppendL(imap4Service); |
|
519 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
520 |
|
521 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
522 imapGetPartialMailInfo.iPartialMailOptions=ENoSizeLimits; |
|
523 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
524 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
525 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
526 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
527 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
528 |
|
529 opActive->iStatus = KRequestPending; |
|
530 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus); |
|
531 opActive->SetOperation(msvOperation); |
|
532 opActive->StartL(); // Start the populate all mail active object |
|
533 } |
|
534 |
|
535 |
|
536 LOCAL_C void PopulateMessageSelectionPartiallyWhenAlreadyConnectedL() |
|
537 { |
|
538 testUtils->WriteComment(_L("Populate mail selection partially when already connected")); |
|
539 |
|
540 msvSelection->ResizeL(0); |
|
541 msvSelection->AppendL(imap4Service); |
|
542 CreateMailSelection(*msvSelection); // message in the remote inbox (to populate) |
|
543 |
|
544 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
545 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
546 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
547 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
548 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
549 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
550 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
551 |
|
552 opActive->iStatus = KRequestPending; |
|
553 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected, *msvSelection, package, opActive->iStatus); |
|
554 opActive->SetOperation(msvOperation); |
|
555 opActive->StartL(); // Start the populate message selection active object |
|
556 } |
|
557 |
|
558 |
|
559 // |
|
560 // Connect, Get Mail and Disconnect tests |
|
561 // |
|
562 LOCAL_C void ConnectAndPopulateNewMailPartiallyAndDisconnectL() |
|
563 { |
|
564 testUtils->WriteComment(_L("Connect, Populate New Mail, Disconnect")); |
|
565 |
|
566 msvSelection->ResizeL(0); |
|
567 msvSelection->AppendL(imap4Service); |
|
568 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
569 |
|
570 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
571 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
572 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
573 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
574 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
575 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
576 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
577 |
|
578 opActive->iStatus = KRequestPending; |
|
579 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateNewMailAndDisconnect, *msvSelection, package, opActive->iStatus); |
|
580 opActive->SetOperation(msvOperation); |
|
581 opActive->StartL(); // Start the Populate new mail active object |
|
582 } |
|
583 |
|
584 LOCAL_C void ConnectAndPopulateAllMailPartiallyAndDisconnectL() |
|
585 { |
|
586 testUtils->WriteComment(_L("Connect, Populate All Mail Partially, Disconnect")); |
|
587 |
|
588 msvSelection->ResizeL(0); |
|
589 msvSelection->AppendL(imap4Service); |
|
590 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
591 |
|
592 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
593 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
594 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
595 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
596 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
597 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
598 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
599 |
|
600 opActive->iStatus = KRequestPending; |
|
601 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateAllMailAndDisconnect, *msvSelection, package, opActive->iStatus); |
|
602 opActive->SetOperation(msvOperation); |
|
603 opActive->StartL(); // Start the Populate all mail active object |
|
604 } |
|
605 |
|
606 |
|
607 LOCAL_C void ConnectAndPopulateAllMailAndDisconnectL() |
|
608 { |
|
609 testUtils->WriteComment(_L("Full download after partial download \n")); |
|
610 |
|
611 msvSelection->ResizeL(0); |
|
612 msvSelection->AppendL(imap4Service); |
|
613 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
614 |
|
615 TImImap4GetMailInfo imap4GetMailInfo; |
|
616 imap4GetMailInfo.iMaxEmailSize = KMaxTInt; |
|
617 imap4GetMailInfo.iDestinationFolder = imap4Service+2; // service |
|
618 imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments; |
|
619 TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo); |
|
620 |
|
621 |
|
622 opActive->iStatus = KRequestPending; |
|
623 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateAllMailAndDisconnect, *msvSelection, package, opActive->iStatus); |
|
624 opActive->SetOperation(msvOperation); |
|
625 opActive->StartL(); // Start the Populate all mail active object |
|
626 } |
|
627 |
|
628 LOCAL_C void ConnectAndPopulateMailSelectionPartiallyAndDisconnectL() |
|
629 { |
|
630 testUtils->WriteComment(_L("Connect, Populating remote msg, Disconnect")); |
|
631 |
|
632 msvSelection->ResizeL(0); |
|
633 msvSelection->AppendL(imap4Service); |
|
634 CreateMailSelection(*msvSelection); // message in the remote inbox (to populate) |
|
635 |
|
636 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
637 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
638 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
639 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
640 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
641 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
642 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
643 |
|
644 opActive->iStatus = KRequestPending; |
|
645 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateMailSelectionAndDisconnect, *msvSelection, package, opActive->iStatus); |
|
646 opActive->SetOperation(msvOperation); |
|
647 opActive->StartL(); // Start the populate message selection active object |
|
648 } |
|
649 |
|
650 // |
|
651 // Connect, Get Mail and Stay Online tests |
|
652 // |
|
653 LOCAL_C void ConnectAndPopulateNewMailPartiallyAndStayOnlineL() |
|
654 { |
|
655 testUtils->WriteComment(_L("Connect, Populate New Mail, Stay Online")); |
|
656 |
|
657 msvSelection->ResizeL(0); |
|
658 msvSelection->AppendL(imap4Service); |
|
659 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
660 |
|
661 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
662 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
663 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
664 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
665 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
666 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
667 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
668 |
|
669 opActive->iStatus = KRequestPending; |
|
670 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateNewMailAndStayOnline, *msvSelection, package, opActive->iStatus); |
|
671 opActive->SetOperation(msvOperation); |
|
672 opActive->StartL(); // Start the Populate new mail active object |
|
673 } |
|
674 |
|
675 LOCAL_C void ConnectAndPopulateAllMailPartiallyAndStayOnlineL() |
|
676 { |
|
677 testUtils->WriteComment(_L("Connect, Populate All Mail, Stay Online")); |
|
678 |
|
679 msvSelection->ResizeL(0); |
|
680 msvSelection->AppendL(imap4Service); |
|
681 msvSelection->AppendL(imap4Service+1); // remote inbox |
|
682 |
|
683 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
684 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
685 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
686 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
687 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
688 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
689 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
690 |
|
691 opActive->iStatus = KRequestPending; |
|
692 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateAllMailAndStayOnline, *msvSelection, package, opActive->iStatus); |
|
693 opActive->SetOperation(msvOperation); |
|
694 opActive->StartL(); // Start the Populate all mail active object |
|
695 } |
|
696 |
|
697 LOCAL_C void ConnectAndPopulateMailSelectionAndStayOnlineL() |
|
698 { |
|
699 testUtils->WriteComment(_L("Connect, Populating remote msg, Stay Online")); |
|
700 |
|
701 msvSelection->ResizeL(0); |
|
702 msvSelection->AppendL(imap4Service); |
|
703 CreateMailSelection(*msvSelection); // message in the remote inbox (to populate) |
|
704 |
|
705 TImImap4GetPartialMailInfo imapGetPartialMailInfo; |
|
706 imapGetPartialMailInfo.iPartialMailOptions=EBodyTextAndAttachments; |
|
707 imapGetPartialMailInfo.iDestinationFolder = imap4Service+1;//KMsvGlobalInBoxIndexEntryIdValue; |
|
708 imapGetPartialMailInfo.iBodyTextSizeLimit = 7000; |
|
709 imapGetPartialMailInfo.iAttachmentSizeLimit = 7000; |
|
710 imapGetPartialMailInfo.iTotalSizeLimit = 9000; |
|
711 TPckgBuf<TImImap4GetPartialMailInfo> package(imapGetPartialMailInfo); |
|
712 |
|
713 opActive->iStatus = KRequestPending; |
|
714 msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateMailSelectionAndStayOnline, *msvSelection, package, opActive->iStatus); |
|
715 opActive->SetOperation(msvOperation); |
|
716 opActive->StartL(); // Start the populate message selection active object |
|
717 } |
|
718 |
|
719 // |
|
720 |
|
721 LOCAL_C void ConnectAndSyncRemoteInboxAndDisconnectL() |
|
722 { |
|
723 console->SetPos(0, 6); |
|
724 test.Printf(_L("\nPerforming Tests\n")); |
|
725 console->SetPos(0, 7); |
|
726 test.Printf(_L("Connecting to IMAP server \n")); |
|
727 ConnectToServerL(); |
|
728 CActiveScheduler::Start(); |
|
729 |
|
730 CleanupStack::PopAndDestroy(); // opActive |
|
731 if (globalError) |
|
732 return; |
|
733 opActive = COperationActive::NewL(); |
|
734 CleanupStack::PushL(opActive); |
|
735 console->SetPos(0, 7); |
|
736 test.Printf(_L("Synchronize Remote Inbox \n")); |
|
737 SynchronizeRemoteInbox(); |
|
738 |
|
739 CActiveScheduler::Start(); |
|
740 |
|
741 CleanupStack::PopAndDestroy(); // opActive |
|
742 if (globalError) |
|
743 return; |
|
744 opActive = COperationActive::NewL(); |
|
745 CleanupStack::PushL(opActive); |
|
746 console->SetPos(0, 7); |
|
747 test.Printf(_L("Disconnecting from the server \n")); |
|
748 DisconnectFromServerL(); |
|
749 |
|
750 CActiveScheduler::Start(); |
|
751 CleanupStack::PopAndDestroy(); // opActive |
|
752 if (globalError) |
|
753 return; |
|
754 opActive = COperationActive::NewL(); |
|
755 CleanupStack::PushL(opActive); |
|
756 console->SetPos(0, 7); |
|
757 test.Printf(_L("ConnectAndSyncCompletedAfterDisconnect \n")); |
|
758 |
|
759 ConnectAndSyncCompleteL(); |
|
760 |
|
761 CActiveScheduler::Start(); |
|
762 |
|
763 CleanupStack::PopAndDestroy(); // opActive |
|
764 if (globalError) |
|
765 return; |
|
766 opActive = COperationActive::NewL(); |
|
767 CleanupStack::PushL(opActive); |
|
768 console->SetPos(0, 7); |
|
769 test.Printf(_L("Disconnecting from the server \n")); |
|
770 DisconnectFromServerL(); |
|
771 |
|
772 CActiveScheduler::Start(); |
|
773 if (globalError) |
|
774 return; |
|
775 } |
|
776 |
|
777 // |
|
778 |
|
779 LOCAL_C void DeleteAndCreateServicesL() |
|
780 { |
|
781 // Handle command line arguments |
|
782 CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); |
|
783 TInt count = cmdLineArg->Count(); |
|
784 TBool isCmdLine=FALSE; |
|
785 if (count>2) // Command line arguments? |
|
786 { |
|
787 if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd) |
|
788 isCmdLine=TRUE; |
|
789 } |
|
790 // delete services |
|
791 testUtils->iMsvEntry->SetEntryL(KMsvRootIndexEntryId); |
|
792 testUtils->iMsvEntry->DeleteL(imap4Service); |
|
793 testUtils->iMsvEntry->DeleteL(smtpService); |
|
794 |
|
795 // delete all messages in the Inbox |
|
796 testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
797 CMsvEntrySelection* children = testUtils->iMsvEntry->ChildrenL(); |
|
798 CleanupStack::PushL(children); |
|
799 TInt total = children->Count(); |
|
800 for (TInt i=0; i<total; i++) |
|
801 testUtils->iMsvEntry->DeleteL((*children)[i]); |
|
802 CleanupStack::PopAndDestroy(children); |
|
803 |
|
804 // Create Services |
|
805 smtpService = testUtils->CreateSmtpServiceL(); |
|
806 imap4Service = testUtils->CreateImapServiceL(); |
|
807 |
|
808 testUtils->iMsvEntry->SetEntryL(imap4Service); |
|
809 |
|
810 //overwrite the settings with test code one. Don't want the default settings. |
|
811 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
812 |
|
813 CImImap4Settings* settings = new(ELeave) CImImap4Settings(); |
|
814 CleanupStack::PushL(settings); |
|
815 settings->Reset(); |
|
816 |
|
817 if (isCmdLine) |
|
818 { |
|
819 TBuf<100> buf; |
|
820 TLex lex(cmdLineArg->Arg(EArgServerAddress)); |
|
821 buf=lex.NextToken(); |
|
822 settings->SetServerAddressL(buf); |
|
823 } |
|
824 else |
|
825 settings->SetServerAddressL(KImapServer); |
|
826 |
|
827 settings->SetDeleteEmailsWhenDisconnecting(ETrue); |
|
828 settings->SetAcknowledgeReceipts(ETrue); |
|
829 settings->SetAutoSendOnConnect(ETrue); |
|
830 |
|
831 if (isCmdLine) |
|
832 { |
|
833 TBuf<100> buf; |
|
834 TBuf8<64> data; |
|
835 TLex lex(cmdLineArg->Arg(EArgLogin)); |
|
836 buf=lex.NextToken(); |
|
837 data.Copy(buf); |
|
838 settings->SetLoginNameL(data); |
|
839 } |
|
840 else |
|
841 settings->SetLoginNameL(testUtils->MachineName()); |
|
842 |
|
843 if (isCmdLine) |
|
844 { |
|
845 TBuf<100> buf; |
|
846 TBuf8<64> data; |
|
847 TLex lex(cmdLineArg->Arg(EArgPassword)); |
|
848 buf=lex.NextToken(); |
|
849 data.Copy(buf); |
|
850 settings->SetPasswordL(data); |
|
851 } |
|
852 else |
|
853 settings->SetPasswordL(testUtils->MachineName()); |
|
854 |
|
855 settings->SetPort(143); |
|
856 |
|
857 if (isCmdLine) |
|
858 { |
|
859 TBuf<100> buf; |
|
860 TBuf8<64> data; |
|
861 TLex lex(cmdLineArg->Arg(EArgFolderPath)); |
|
862 buf=lex.NextToken(); |
|
863 data.Copy(buf); |
|
864 settings->SetFolderPathL(data); |
|
865 } |
|
866 else |
|
867 settings->SetFolderPathL(KFolderPath); |
|
868 |
|
869 TImapAccount imapAccount; |
|
870 accounts->GetImapAccountL(imap4Service, imapAccount); |
|
871 accounts->SaveImapSettingsL(imapAccount, *settings); |
|
872 |
|
873 CleanupStack::PopAndDestroy(2); //settings, store/accounts |
|
874 CleanupStack::PopAndDestroy(); // cmdLineArg |
|
875 } |
|
876 |
|
877 LOCAL_C void CreateServicesL() |
|
878 { |
|
879 // Handle command line arguments |
|
880 CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); |
|
881 TInt count = cmdLineArg->Count(); |
|
882 TBool isCmdLine=FALSE; |
|
883 if (count>2) // Command line arguments? |
|
884 { |
|
885 if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd) |
|
886 isCmdLine=TRUE; |
|
887 } |
|
888 |
|
889 //overwrite the settings with test code one. Don't want the default settings. |
|
890 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
891 |
|
892 CImImap4Settings* settings = new(ELeave) CImImap4Settings(); |
|
893 CleanupStack::PushL(settings); |
|
894 settings->Reset(); |
|
895 |
|
896 if (isCmdLine) |
|
897 { |
|
898 TBuf<100> buf; |
|
899 TLex lex(cmdLineArg->Arg(EArgServerAddress)); |
|
900 buf=lex.NextToken(); |
|
901 settings->SetServerAddressL(buf); |
|
902 } |
|
903 else |
|
904 settings->SetServerAddressL(KImapServer); |
|
905 |
|
906 settings->SetDeleteEmailsWhenDisconnecting(EFalse); |
|
907 settings->SetAcknowledgeReceipts(ETrue); |
|
908 settings->SetAutoSendOnConnect(ETrue); |
|
909 |
|
910 if (isCmdLine) |
|
911 { |
|
912 TBuf<100> buf; |
|
913 TBuf8<64> data; |
|
914 TLex lex(cmdLineArg->Arg(EArgLogin)); |
|
915 buf=lex.NextToken(); |
|
916 data.Copy(buf); |
|
917 settings->SetLoginNameL(data); |
|
918 } |
|
919 else |
|
920 settings->SetLoginNameL(testUtils->MachineName()); |
|
921 |
|
922 if (isCmdLine) |
|
923 { |
|
924 TBuf<100> buf; |
|
925 TBuf8<64> data; |
|
926 TLex lex(cmdLineArg->Arg(EArgPassword)); |
|
927 buf=lex.NextToken(); |
|
928 data.Copy(buf); |
|
929 settings->SetPasswordL(data); |
|
930 } |
|
931 else |
|
932 settings->SetPasswordL(testUtils->MachineName()); |
|
933 |
|
934 settings->SetPort(143); |
|
935 |
|
936 if (isCmdLine) |
|
937 { |
|
938 TBuf<100> buf; |
|
939 TBuf8<64> data; |
|
940 TLex lex(cmdLineArg->Arg(EArgFolderPath)); |
|
941 buf=lex.NextToken(); |
|
942 data.Copy(buf); |
|
943 settings->SetFolderPathL(data); |
|
944 } |
|
945 else |
|
946 settings->SetFolderPathL(KFolderPath); |
|
947 |
|
948 TImapAccount imapAccount; |
|
949 accounts->GetImapAccountL(testUtils->iMsvEntry->EntryId(), imapAccount); |
|
950 accounts->SaveImapSettingsL(imapAccount, *settings); |
|
951 |
|
952 CleanupStack::PopAndDestroy(2); //settings, store/accounts |
|
953 CleanupStack::PopAndDestroy(); // cmdLineArg |
|
954 } |
|
955 |
|
956 |
|
957 LOCAL_C void InitL() |
|
958 { |
|
959 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
960 CActiveScheduler::Install(scheduler); |
|
961 CleanupStack::PushL(scheduler); |
|
962 |
|
963 testUtils = CEmailTestUtils::NewLC(test); |
|
964 console = test.Console(); |
|
965 testUtils->FileSession().SetSessionPath(_L("C:\\")); |
|
966 testUtils->CleanMessageFolderL(); |
|
967 testUtils->GoClientSideL(); |
|
968 |
|
969 console->SetPos(0, 3); |
|
970 test.Printf(_L("Create Services ")); |
|
971 testUtils->WriteComment(_L("Create Services ")); |
|
972 // Create Services |
|
973 smtpService = testUtils->CreateSmtpServiceL(); |
|
974 imap4Service = testUtils->CreateImapServiceL(); |
|
975 |
|
976 testUtils->WriteComment(_L("********** T_PARTIALFETCH Test **********")); |
|
977 } |
|
978 |
|
979 LOCAL_C void Closedown() |
|
980 { |
|
981 CleanupStack::PopAndDestroy(2); //testUtils, scheduler |
|
982 } |
|
983 |
|
984 // |
|
985 |
|
986 LOCAL_C TPtrC Progress(TInt progressNumber) |
|
987 { |
|
988 switch (progressNumber) |
|
989 { |
|
990 case 0: |
|
991 return _L("Disconnected "); |
|
992 case 1: |
|
993 return _L("Connecting "); |
|
994 case 2: |
|
995 return _L("Idle "); |
|
996 case 3: |
|
997 return _L("Selecting "); |
|
998 case 4: |
|
999 return _L("Fetching "); |
|
1000 case 5: |
|
1001 return _L("Appending "); |
|
1002 case 6: |
|
1003 return _L("Copying "); |
|
1004 case 7: |
|
1005 return _L("Deleting "); |
|
1006 case 8: |
|
1007 return _L("Syncing "); |
|
1008 case 9: |
|
1009 return _L("Disconnecting "); |
|
1010 case 10: |
|
1011 return _L("Busy "); |
|
1012 case 11: |
|
1013 return _L("Moving "); |
|
1014 case 12: |
|
1015 return _L("Copying New Mail "); |
|
1016 case 13: |
|
1017 return _L("Moving New Mail "); |
|
1018 case 14: |
|
1019 return _L("Copying Mail Selection "); |
|
1020 case 15: |
|
1021 return _L("Moving Mail Selection "); |
|
1022 case 16: |
|
1023 return _L("Copying All Mail "); |
|
1024 case 17: |
|
1025 return _L("Moving All Mail "); |
|
1026 case 18: |
|
1027 return _L("Populating New Mail "); |
|
1028 case 19: |
|
1029 return _L("Populating All Mail "); |
|
1030 case 20: |
|
1031 return _L("Populating Mail Selection "); |
|
1032 default: |
|
1033 return _L("Unknown Progress "); |
|
1034 } |
|
1035 } |
|
1036 |
|
1037 |
|
1038 LOCAL_C void doMainL() |
|
1039 { |
|
1040 InitL(); |
|
1041 |
|
1042 // Load the serial comms device drivers. If this is not done, |
|
1043 // connecting via NT-RAS returns KErrNotFound (-1). |
|
1044 TInt driverErr; |
|
1045 driverErr=User::LoadPhysicalDevice(PDD_NAME); |
|
1046 if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) |
|
1047 User::Leave(driverErr); |
|
1048 driverErr=User::LoadLogicalDevice(LDD_NAME); |
|
1049 if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) |
|
1050 User::Leave(driverErr); |
|
1051 |
|
1052 testUtils->FileSession().SetSessionPath(_L("c:\\")); |
|
1053 // Delete any *.scr files in c:\logs\email directory. |
|
1054 testUtils->DeleteScriptFilesFromLogsDirL(); |
|
1055 |
|
1056 testUtils->iMsvEntry->SetEntryL(imap4Service); |
|
1057 |
|
1058 // Handle command line arguments |
|
1059 CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); |
|
1060 TInt count = cmdLineArg->Count(); |
|
1061 TBool isCmdLine=FALSE; |
|
1062 if (count>2) // Command line arguments? |
|
1063 { |
|
1064 if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd) |
|
1065 isCmdLine=TRUE; |
|
1066 } |
|
1067 |
|
1068 //overwrite the settings with test code one. Don't want the default settings. |
|
1069 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
1070 |
|
1071 CImImap4Settings* settings = new(ELeave) CImImap4Settings(); |
|
1072 CleanupStack::PushL(settings); |
|
1073 settings->Reset(); |
|
1074 |
|
1075 if (isCmdLine) |
|
1076 { |
|
1077 TBuf<100> buf; |
|
1078 TLex lex(cmdLineArg->Arg(EArgServerAddress)); |
|
1079 buf=lex.NextToken(); |
|
1080 test.Printf(_L("Server address: %S\n"),&buf); |
|
1081 settings->SetServerAddressL(buf); |
|
1082 } |
|
1083 else |
|
1084 settings->SetServerAddressL(KImapServer); |
|
1085 |
|
1086 settings->SetDeleteEmailsWhenDisconnecting(EFalse); |
|
1087 settings->SetAcknowledgeReceipts(ETrue); |
|
1088 // settings->SetAutoSendOnConnect(ETrue); |
|
1089 |
|
1090 if (isCmdLine) |
|
1091 { |
|
1092 TBuf<100> buf; |
|
1093 TBuf8<64> data; |
|
1094 TLex lex(cmdLineArg->Arg(EArgLogin)); |
|
1095 buf=lex.NextToken(); |
|
1096 test.Printf(_L("Login: %S\n"),&buf); |
|
1097 data.Copy(buf); |
|
1098 settings->SetLoginNameL(data); |
|
1099 } |
|
1100 else |
|
1101 settings->SetLoginNameL(testUtils->MachineName()); |
|
1102 |
|
1103 if (isCmdLine) |
|
1104 { |
|
1105 TBuf<100> buf; |
|
1106 TBuf8<64> data; |
|
1107 TLex lex(cmdLineArg->Arg(EArgPassword)); |
|
1108 buf=lex.NextToken(); |
|
1109 test.Printf(_L("Password: %S\n"),&buf); |
|
1110 data.Copy(buf); |
|
1111 settings->SetPasswordL(data); |
|
1112 } |
|
1113 else |
|
1114 settings->SetPasswordL(testUtils->MachineName()); |
|
1115 |
|
1116 settings->SetPort(143); |
|
1117 |
|
1118 if (isCmdLine) |
|
1119 { |
|
1120 TBuf<100> buf; |
|
1121 TBuf8<64> data; |
|
1122 TLex lex(cmdLineArg->Arg(EArgFolderPath)); |
|
1123 buf=lex.NextToken(); |
|
1124 test.Printf(_L("Folder Path: %S\n"),&buf); |
|
1125 data.Copy(buf); |
|
1126 settings->SetFolderPathL(data); |
|
1127 } |
|
1128 else |
|
1129 settings->SetFolderPathL(KFolderPath); |
|
1130 |
|
1131 TImapAccount imapAccount; |
|
1132 accounts->GetImapAccountL(imap4Service, imapAccount); |
|
1133 accounts->SaveImapSettingsL(imapAccount, *settings); |
|
1134 |
|
1135 CleanupStack::PopAndDestroy(2); //settings, store/accounts |
|
1136 CleanupStack::PopAndDestroy(); // cmdLineArg |
|
1137 |
|
1138 console->SetPos(0, 3); |
|
1139 test.Printf(_L("Instantiating IMAP4 Client MTM")); |
|
1140 testUtils->WriteComment(_L("Instantiating IMAP4 Client MTM")); |
|
1141 testUtils->InstantiateImapClientMtmL(); |
|
1142 // Tests start here |
|
1143 |
|
1144 // |
|
1145 // |
|
1146 // Test 1 |
|
1147 // Populating all mail partially when already connected |
|
1148 // |
|
1149 // |
|
1150 |
|
1151 DeleteAndCreateServicesL(); |
|
1152 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1153 |
|
1154 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1155 CleanupStack::PushL(msvSelection); |
|
1156 |
|
1157 opActive = COperationActive::NewL(); |
|
1158 CleanupStack::PushL(opActive); |
|
1159 |
|
1160 testUtils->TestStart(1); |
|
1161 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1162 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1163 |
|
1164 CleanupStack::PopAndDestroy(); // opActive |
|
1165 if (globalError) |
|
1166 { |
|
1167 Closedown(); |
|
1168 return; |
|
1169 } |
|
1170 opActive = COperationActive::NewL(); |
|
1171 CleanupStack::PushL(opActive); |
|
1172 console->SetPos(0, 7); |
|
1173 test.Printf(_L("Connecting to IMAP server \n")); |
|
1174 ConnectToServerL(); |
|
1175 CActiveScheduler::Start(); |
|
1176 |
|
1177 CleanupStack::PopAndDestroy(); // opActive |
|
1178 if (globalError) |
|
1179 { |
|
1180 Closedown(); |
|
1181 return; |
|
1182 } |
|
1183 opActive = COperationActive::NewL(); |
|
1184 CleanupStack::PushL(opActive); |
|
1185 console->SetPos(0, 7); |
|
1186 test.Printf(_L("Populating all mails partially when already connected \n")); |
|
1187 PopulateAllMessagesPartiallyWhenAlreadyConnectedL(); |
|
1188 CActiveScheduler::Start(); |
|
1189 |
|
1190 CleanupStack::PopAndDestroy(); // opActive |
|
1191 if (globalError) |
|
1192 { |
|
1193 Closedown(); |
|
1194 return; |
|
1195 } |
|
1196 |
|
1197 opActive = COperationActive::NewL(); |
|
1198 CleanupStack::PushL(opActive); |
|
1199 console->SetPos(0, 7); |
|
1200 test.Printf(_L("Disconnecting from the server \n")); |
|
1201 DisconnectFromServerL(); |
|
1202 CActiveScheduler::Start(); |
|
1203 |
|
1204 testUtils->TestFinish(1,globalError); |
|
1205 CleanupStack::PopAndDestroy(2); // opActive, msvSelection |
|
1206 if (globalError) |
|
1207 { |
|
1208 Closedown(); |
|
1209 return; |
|
1210 } |
|
1211 |
|
1212 // |
|
1213 // |
|
1214 // Test 2 |
|
1215 // Populate new mails partially when already connected to server |
|
1216 // |
|
1217 // |
|
1218 |
|
1219 DeleteAndCreateServicesL(); |
|
1220 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1221 |
|
1222 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1223 CleanupStack::PushL(msvSelection); |
|
1224 |
|
1225 opActive = COperationActive::NewL(); |
|
1226 CleanupStack::PushL(opActive); |
|
1227 |
|
1228 testUtils->TestStart(2); |
|
1229 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1230 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1231 |
|
1232 if (globalError) |
|
1233 { |
|
1234 Closedown(); |
|
1235 return; |
|
1236 } |
|
1237 |
|
1238 CleanupStack::PopAndDestroy(); // opActive |
|
1239 opActive = COperationActive::NewL(); |
|
1240 CleanupStack::PushL(opActive); |
|
1241 console->SetPos(0, 7); |
|
1242 test.Printf(_L("Connecting to IMAP server \n")); |
|
1243 ConnectToServerL(); |
|
1244 CActiveScheduler::Start(); |
|
1245 |
|
1246 CleanupStack::PopAndDestroy(); // opActive |
|
1247 if (globalError) |
|
1248 { |
|
1249 Closedown(); |
|
1250 return; |
|
1251 } |
|
1252 |
|
1253 opActive = COperationActive::NewL(); |
|
1254 CleanupStack::PushL(opActive); |
|
1255 console->SetPos(0, 7); |
|
1256 test.Printf(_L("Populate new mails partially when already connected to server \n")); |
|
1257 PopulateNewMessagesPartiallyWhenAlreadyConnectedL(); |
|
1258 CActiveScheduler::Start(); |
|
1259 |
|
1260 CleanupStack::PopAndDestroy(); // opActive |
|
1261 if (globalError) |
|
1262 { |
|
1263 Closedown(); |
|
1264 return; |
|
1265 } |
|
1266 opActive = COperationActive::NewL(); |
|
1267 CleanupStack::PushL(opActive); |
|
1268 console->SetPos(0, 7); |
|
1269 test.Printf(_L("Disconnecting from the server \n")); |
|
1270 DisconnectFromServerL(); |
|
1271 CActiveScheduler::Start(); |
|
1272 |
|
1273 testUtils->TestFinish(2,globalError); |
|
1274 // cleanup for next test |
|
1275 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1276 if (globalError) |
|
1277 { |
|
1278 Closedown(); |
|
1279 return; |
|
1280 } |
|
1281 |
|
1282 // |
|
1283 // |
|
1284 // Test 3 |
|
1285 // Populate mail selection partially when already connected to server |
|
1286 // |
|
1287 // |
|
1288 |
|
1289 DeleteAndCreateServicesL(); |
|
1290 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1291 |
|
1292 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1293 CleanupStack::PushL(msvSelection); |
|
1294 |
|
1295 opActive = COperationActive::NewL(); |
|
1296 CleanupStack::PushL(opActive); |
|
1297 |
|
1298 testUtils->TestStart(3); |
|
1299 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1300 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1301 |
|
1302 // Populate mail selection when already connected to server |
|
1303 CleanupStack::PopAndDestroy(); // opActive |
|
1304 if (globalError) |
|
1305 { |
|
1306 Closedown(); |
|
1307 return; |
|
1308 } |
|
1309 opActive = COperationActive::NewL(); |
|
1310 CleanupStack::PushL(opActive); |
|
1311 console->SetPos(0, 7); |
|
1312 test.Printf(_L("Connecting to IMAP server \n")); |
|
1313 ConnectToServerL(); |
|
1314 CActiveScheduler::Start(); |
|
1315 |
|
1316 CleanupStack::PopAndDestroy(); // opActive |
|
1317 if (globalError) |
|
1318 { |
|
1319 Closedown(); |
|
1320 return; |
|
1321 } |
|
1322 |
|
1323 opActive = COperationActive::NewL(); |
|
1324 CleanupStack::PushL(opActive); |
|
1325 console->SetPos(0, 7); |
|
1326 test.Printf(_L("Populate mail selection partially when already connected to server\n")); |
|
1327 PopulateMessageSelectionPartiallyWhenAlreadyConnectedL(); |
|
1328 CActiveScheduler::Start(); |
|
1329 |
|
1330 CleanupStack::PopAndDestroy(); // opActive |
|
1331 if (globalError) |
|
1332 { |
|
1333 Closedown(); |
|
1334 return; |
|
1335 } |
|
1336 opActive = COperationActive::NewL(); |
|
1337 CleanupStack::PushL(opActive); |
|
1338 console->SetPos(0, 7); |
|
1339 test.Printf(_L("Disconnecting from the server \n")); |
|
1340 DisconnectFromServerL(); |
|
1341 CActiveScheduler::Start(); |
|
1342 |
|
1343 testUtils->TestFinish(3,globalError); |
|
1344 // cleanup for next test |
|
1345 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1346 if (globalError) |
|
1347 { |
|
1348 Closedown(); |
|
1349 return; |
|
1350 } |
|
1351 |
|
1352 // |
|
1353 // |
|
1354 // Test 4 |
|
1355 // Connect and populate new mails partially and disconnect |
|
1356 // |
|
1357 // |
|
1358 |
|
1359 DeleteAndCreateServicesL(); |
|
1360 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1361 |
|
1362 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1363 CleanupStack::PushL(msvSelection); |
|
1364 |
|
1365 opActive = COperationActive::NewL(); |
|
1366 CleanupStack::PushL(opActive); |
|
1367 |
|
1368 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1369 |
|
1370 testUtils->TestStart(4); |
|
1371 CleanupStack::PopAndDestroy(); // opActive |
|
1372 if (globalError) |
|
1373 { |
|
1374 Closedown(); |
|
1375 return; |
|
1376 } |
|
1377 opActive = COperationActive::NewL(); |
|
1378 CleanupStack::PushL(opActive); |
|
1379 console->SetPos(0, 7); |
|
1380 test.Printf(_L("Connect, Populate New Mails Partially, Disconnect \n")); |
|
1381 ConnectAndPopulateNewMailPartiallyAndDisconnectL(); |
|
1382 CActiveScheduler::Start(); |
|
1383 |
|
1384 testUtils->TestFinish(4,globalError); |
|
1385 // cleanup for next test |
|
1386 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1387 if (globalError) |
|
1388 { |
|
1389 Closedown(); |
|
1390 return; |
|
1391 } |
|
1392 |
|
1393 // |
|
1394 // |
|
1395 // Test 5 |
|
1396 // Connect and populate all mails partially and disconnect |
|
1397 // |
|
1398 // |
|
1399 DeleteAndCreateServicesL(); |
|
1400 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1401 |
|
1402 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1403 CleanupStack::PushL(msvSelection); |
|
1404 |
|
1405 opActive = COperationActive::NewL(); |
|
1406 CleanupStack::PushL(opActive); |
|
1407 |
|
1408 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1409 |
|
1410 testUtils->TestStart(5); |
|
1411 // Connect, Populate All Mail and then disconnect |
|
1412 CleanupStack::PopAndDestroy(); // opActive |
|
1413 if (globalError) |
|
1414 { |
|
1415 Closedown(); |
|
1416 return; |
|
1417 } |
|
1418 opActive = COperationActive::NewL(); |
|
1419 CleanupStack::PushL(opActive); |
|
1420 console->SetPos(0, 7); |
|
1421 test.Printf(_L("Connect, Populate All Mails Partially, Disconnect \n")); |
|
1422 ConnectAndPopulateAllMailPartiallyAndDisconnectL(); |
|
1423 CActiveScheduler::Start(); |
|
1424 |
|
1425 testUtils->TestFinish(5,globalError); |
|
1426 |
|
1427 // cleanup for next test |
|
1428 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1429 if (globalError) |
|
1430 { |
|
1431 Closedown(); |
|
1432 return; |
|
1433 } |
|
1434 |
|
1435 // |
|
1436 // |
|
1437 // Test 6 |
|
1438 // Connect, Populate Mail Selection Partially, Stay Online |
|
1439 // |
|
1440 // |
|
1441 DeleteAndCreateServicesL(); |
|
1442 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1443 |
|
1444 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1445 CleanupStack::PushL(msvSelection); |
|
1446 |
|
1447 opActive = COperationActive::NewL(); |
|
1448 CleanupStack::PushL(opActive); |
|
1449 |
|
1450 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1451 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1452 |
|
1453 testUtils->TestStart(6); |
|
1454 // Connect, Populate Mail Selection and Stay Online |
|
1455 CleanupStack::PopAndDestroy(); // opActive |
|
1456 opActive = COperationActive::NewL(); |
|
1457 CleanupStack::PushL(opActive); |
|
1458 console->SetPos(0, 7); |
|
1459 test.Printf(_L("Connect, Populate Mail Selection Partially, Stay Online \n")); |
|
1460 ConnectAndPopulateMailSelectionAndStayOnlineL(); |
|
1461 CActiveScheduler::Start(); |
|
1462 |
|
1463 CleanupStack::PopAndDestroy(); // opActive |
|
1464 |
|
1465 opActive = COperationActive::NewL(); |
|
1466 CleanupStack::PushL(opActive); |
|
1467 console->SetPos(0, 7); |
|
1468 test.Printf(_L("Disconnecting from the server \n")); |
|
1469 DisconnectFromServerL(); |
|
1470 CActiveScheduler::Start(); |
|
1471 testUtils->TestFinish(6,globalError); |
|
1472 |
|
1473 // cleanup for next test |
|
1474 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1475 if (globalError) |
|
1476 { |
|
1477 Closedown(); |
|
1478 return; |
|
1479 } |
|
1480 |
|
1481 // |
|
1482 // |
|
1483 // Test 7 |
|
1484 // Connect, Populate New Mails Partially, Stay Online |
|
1485 // |
|
1486 // |
|
1487 DeleteAndCreateServicesL(); |
|
1488 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1489 |
|
1490 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1491 CleanupStack::PushL(msvSelection); |
|
1492 |
|
1493 opActive = COperationActive::NewL(); |
|
1494 CleanupStack::PushL(opActive); |
|
1495 |
|
1496 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1497 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1498 |
|
1499 testUtils->TestStart(7); |
|
1500 // Connect, Populate New Mail and Stay Online |
|
1501 CleanupStack::PopAndDestroy(); // opActive |
|
1502 if (globalError) |
|
1503 { |
|
1504 Closedown(); |
|
1505 return; |
|
1506 } |
|
1507 opActive = COperationActive::NewL(); |
|
1508 CleanupStack::PushL(opActive); |
|
1509 console->SetPos(0, 7); |
|
1510 test.Printf(_L("Connect, Populate New Mails Partially, Stay Online \n")); |
|
1511 ConnectAndPopulateNewMailPartiallyAndStayOnlineL(); |
|
1512 CActiveScheduler::Start(); |
|
1513 |
|
1514 CleanupStack::PopAndDestroy(); // opActive |
|
1515 if (globalError) |
|
1516 { |
|
1517 Closedown(); |
|
1518 return; |
|
1519 } |
|
1520 opActive = COperationActive::NewL(); |
|
1521 CleanupStack::PushL(opActive); |
|
1522 console->SetPos(0, 7); |
|
1523 test.Printf(_L("Disconnecting from the server \n")); |
|
1524 DisconnectFromServerL(); |
|
1525 CActiveScheduler::Start(); |
|
1526 testUtils->TestFinish(7,globalError); |
|
1527 |
|
1528 // cleanup for next test |
|
1529 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1530 if (globalError) |
|
1531 { |
|
1532 Closedown(); |
|
1533 return; |
|
1534 } |
|
1535 // |
|
1536 // |
|
1537 // Test 8 |
|
1538 // Connect, Populate All Mails partially, Stay Online |
|
1539 // |
|
1540 // |
|
1541 |
|
1542 DeleteAndCreateServicesL(); |
|
1543 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1544 |
|
1545 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1546 CleanupStack::PushL(msvSelection); |
|
1547 |
|
1548 opActive = COperationActive::NewL(); |
|
1549 CleanupStack::PushL(opActive); |
|
1550 |
|
1551 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1552 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1553 |
|
1554 testUtils->TestStart(8); |
|
1555 // Connect, Populate All Mail and Stay Online |
|
1556 CleanupStack::PopAndDestroy(); // opActive |
|
1557 if (globalError) |
|
1558 { |
|
1559 Closedown(); |
|
1560 return; |
|
1561 } |
|
1562 opActive = COperationActive::NewL(); |
|
1563 CleanupStack::PushL(opActive); |
|
1564 console->SetPos(0, 7); |
|
1565 test.Printf(_L("Connect, Populate All Mails Partially, Stay Online \n")); |
|
1566 ConnectAndPopulateAllMailPartiallyAndStayOnlineL(); |
|
1567 CActiveScheduler::Start(); |
|
1568 |
|
1569 CleanupStack::PopAndDestroy(); // opActive |
|
1570 if (globalError) |
|
1571 { |
|
1572 Closedown(); |
|
1573 return; |
|
1574 } |
|
1575 opActive = COperationActive::NewL(); |
|
1576 CleanupStack::PushL(opActive); |
|
1577 console->SetPos(0, 7); |
|
1578 test.Printf(_L("Disconnecting from the server \n")); |
|
1579 DisconnectFromServerL(); |
|
1580 CActiveScheduler::Start(); |
|
1581 testUtils->TestFinish(8,globalError); |
|
1582 |
|
1583 // cleanup for next test |
|
1584 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1585 if (globalError) |
|
1586 { |
|
1587 Closedown(); |
|
1588 return; |
|
1589 } |
|
1590 |
|
1591 // |
|
1592 // |
|
1593 // Test 9 |
|
1594 // Populating all mails partially when already connected with TImImap4PartialMailOptions = ENoSizeLimits |
|
1595 // |
|
1596 // |
|
1597 |
|
1598 DeleteAndCreateServicesL(); |
|
1599 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1600 |
|
1601 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1602 CleanupStack::PushL(msvSelection); |
|
1603 |
|
1604 opActive = COperationActive::NewL(); |
|
1605 CleanupStack::PushL(opActive); |
|
1606 |
|
1607 testUtils->TestStart(9); |
|
1608 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1609 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1610 |
|
1611 CleanupStack::PopAndDestroy(); // opActive |
|
1612 if (globalError) |
|
1613 { |
|
1614 Closedown(); |
|
1615 return; |
|
1616 } |
|
1617 opActive = COperationActive::NewL(); |
|
1618 CleanupStack::PushL(opActive); |
|
1619 console->SetPos(0, 7); |
|
1620 test.Printf(_L("Connecting to IMAP server \n")); |
|
1621 ConnectToServerL(); |
|
1622 CActiveScheduler::Start(); |
|
1623 |
|
1624 CleanupStack::PopAndDestroy(); // opActive |
|
1625 if (globalError) |
|
1626 { |
|
1627 Closedown(); |
|
1628 return; |
|
1629 } |
|
1630 opActive = COperationActive::NewL(); |
|
1631 CleanupStack::PushL(opActive); |
|
1632 console->SetPos(0, 7); |
|
1633 test.Printf(_L("Populating all mails with No Size Limits \n")); |
|
1634 PopulateAllMessagesWithNoSizeLimitOption(); |
|
1635 CActiveScheduler::Start(); |
|
1636 |
|
1637 CleanupStack::PopAndDestroy(); // opActive |
|
1638 if (globalError) |
|
1639 { |
|
1640 Closedown(); |
|
1641 return; |
|
1642 } |
|
1643 |
|
1644 opActive = COperationActive::NewL(); |
|
1645 CleanupStack::PushL(opActive); |
|
1646 console->SetPos(0, 7); |
|
1647 test.Printf(_L("Disconnecting from the server \n")); |
|
1648 DisconnectFromServerL(); |
|
1649 CActiveScheduler::Start(); |
|
1650 |
|
1651 testUtils->TestFinish(9,globalError); |
|
1652 CleanupStack::PopAndDestroy(2); // opActive,msvSelection |
|
1653 if (globalError) |
|
1654 { |
|
1655 Closedown(); |
|
1656 return; |
|
1657 } |
|
1658 |
|
1659 // |
|
1660 // |
|
1661 // Test 10 |
|
1662 // Populating all mails partially when already connected with TImImap4PartialMailOptions = ECumulative |
|
1663 // |
|
1664 // |
|
1665 |
|
1666 DeleteAndCreateServicesL(); |
|
1667 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1668 |
|
1669 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1670 CleanupStack::PushL(msvSelection); |
|
1671 |
|
1672 opActive = COperationActive::NewL(); |
|
1673 CleanupStack::PushL(opActive); |
|
1674 |
|
1675 testUtils->TestStart(10); |
|
1676 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1677 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1678 |
|
1679 CleanupStack::PopAndDestroy(); // opActive |
|
1680 if (globalError) |
|
1681 { |
|
1682 Closedown(); |
|
1683 return; |
|
1684 } |
|
1685 opActive = COperationActive::NewL(); |
|
1686 CleanupStack::PushL(opActive); |
|
1687 console->SetPos(0, 7); |
|
1688 test.Printf(_L("Connecting to IMAP server \n")); |
|
1689 ConnectToServerL(); |
|
1690 CActiveScheduler::Start(); |
|
1691 |
|
1692 CleanupStack::PopAndDestroy(); // opActive |
|
1693 if (globalError) |
|
1694 { |
|
1695 Closedown(); |
|
1696 return; |
|
1697 } |
|
1698 opActive = COperationActive::NewL(); |
|
1699 CleanupStack::PushL(opActive); |
|
1700 console->SetPos(0, 7); |
|
1701 test.Printf(_L("Populating all mails partially when already connected with TImImap4PartialMailOptions = ECumulative \n")); |
|
1702 PopulateAllMessagesWithCumulativeOption(); |
|
1703 CActiveScheduler::Start(); |
|
1704 |
|
1705 CleanupStack::PopAndDestroy(); // opActive |
|
1706 if (globalError) |
|
1707 { |
|
1708 Closedown(); |
|
1709 return; |
|
1710 } |
|
1711 |
|
1712 opActive = COperationActive::NewL(); |
|
1713 CleanupStack::PushL(opActive); |
|
1714 console->SetPos(0, 7); |
|
1715 test.Printf(_L("Disconnecting from the server \n")); |
|
1716 DisconnectFromServerL(); |
|
1717 CActiveScheduler::Start(); |
|
1718 |
|
1719 testUtils->TestFinish(10,globalError); |
|
1720 CleanupStack::PopAndDestroy(2); // opActive,msvSelection |
|
1721 if (globalError) |
|
1722 { |
|
1723 Closedown(); |
|
1724 return; |
|
1725 } |
|
1726 |
|
1727 // |
|
1728 // |
|
1729 // Test 11 |
|
1730 // Test for full download of emails after partial download |
|
1731 // |
|
1732 // |
|
1733 |
|
1734 DeleteAndCreateServicesL(); |
|
1735 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1736 |
|
1737 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1738 CleanupStack::PushL(msvSelection); |
|
1739 |
|
1740 opActive = COperationActive::NewL(); |
|
1741 CleanupStack::PushL(opActive); |
|
1742 |
|
1743 // Populating all mails partially when already connected |
|
1744 testUtils->TestStart(11); |
|
1745 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1746 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1747 CleanupStack::PopAndDestroy(); // opActive |
|
1748 if (globalError) |
|
1749 { |
|
1750 Closedown(); |
|
1751 return; |
|
1752 } |
|
1753 |
|
1754 opActive = COperationActive::NewL(); |
|
1755 CleanupStack::PushL(opActive); |
|
1756 console->SetPos(0, 7); |
|
1757 test.Printf(_L("Populating all mails partially when already connected \n")); |
|
1758 |
|
1759 ConnectAndPopulateAllMailPartiallyAndDisconnectL(); |
|
1760 |
|
1761 CActiveScheduler::Start(); |
|
1762 |
|
1763 CleanupStack::PopAndDestroy(); // opActive |
|
1764 if (globalError) |
|
1765 { |
|
1766 Closedown(); |
|
1767 return; |
|
1768 } |
|
1769 |
|
1770 testUtils->WriteComment(_L("Doing full download of emails after partial download")); |
|
1771 // Now do a full download of emails after partial download |
|
1772 CreateServicesL(); |
|
1773 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1774 opActive = COperationActive::NewL(); |
|
1775 CleanupStack::PushL(opActive); |
|
1776 console->SetPos(0, 7); |
|
1777 test.Printf(_L("Full download all mail when already connected \n")); |
|
1778 |
|
1779 ConnectAndPopulateAllMailAndDisconnectL(); |
|
1780 |
|
1781 CActiveScheduler::Start(); |
|
1782 |
|
1783 testUtils->TestFinish(11,globalError); |
|
1784 CleanupStack::PopAndDestroy(2); // opActive,msvSelection |
|
1785 if (globalError) |
|
1786 { |
|
1787 Closedown(); |
|
1788 return; |
|
1789 } |
|
1790 |
|
1791 // |
|
1792 // |
|
1793 // Test 12 |
|
1794 // Connect and populate mail selection Partially and disconnect |
|
1795 // |
|
1796 // |
|
1797 |
|
1798 DeleteAndCreateServicesL(); |
|
1799 testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service); |
|
1800 |
|
1801 msvSelection = new (ELeave) CMsvEntrySelection; |
|
1802 CleanupStack::PushL(msvSelection); |
|
1803 |
|
1804 opActive = COperationActive::NewL(); |
|
1805 CleanupStack::PushL(opActive); |
|
1806 |
|
1807 // connect, do full sync and then disconnect so that the inbox can be synced |
|
1808 ConnectAndSyncRemoteInboxAndDisconnectL(); |
|
1809 |
|
1810 testUtils->TestStart(12); |
|
1811 // Connect, Populate Mail Selection and then disconnect |
|
1812 CleanupStack::PopAndDestroy(); // opActive |
|
1813 if (globalError) |
|
1814 { |
|
1815 Closedown(); |
|
1816 return; |
|
1817 } |
|
1818 opActive = COperationActive::NewL(); |
|
1819 CleanupStack::PushL(opActive); |
|
1820 console->SetPos(0, 7); |
|
1821 test.Printf(_L("Connect, Populate Mail Selection Partially, Disconnect \n")); |
|
1822 ConnectAndPopulateMailSelectionPartiallyAndDisconnectL(); |
|
1823 CActiveScheduler::Start(); |
|
1824 |
|
1825 // check that final progress showing the correct information |
|
1826 TPckgBuf<TImap4GenericProgress> progress; |
|
1827 progress.Copy(opActive->iTimer->iOperation->FinalProgress()); |
|
1828 |
|
1829 console->SetPos(0, 11); |
|
1830 console->Printf(_L("Final Progress: ")); |
|
1831 console->SetPos(0, 12); |
|
1832 TBuf<80> progressBuf = Progress(progress().iState); |
|
1833 console->Printf(TRefByValue<const TDesC>_L(" Super Operation Progress: %S "), &progressBuf); |
|
1834 console->SetPos(0, 13); |
|
1835 progressBuf = Progress(progress().iImap4SubStateProgress); |
|
1836 console->Printf(TRefByValue<const TDesC>_L(" Sub Operation Progress : %S "), &progressBuf); |
|
1837 console->SetPos(0, 14); |
|
1838 console->Printf(TRefByValue<const TDesC>_L(" Progress: %d/%d %d/%d Total:%d \n"), |
|
1839 progress().iMsgsDone, |
|
1840 progress().iMsgsToDo, |
|
1841 progress().iBytesDone, |
|
1842 progress().iBytesToDo, |
|
1843 progress().iTotalSize); |
|
1844 console->SetPos(0, 15); |
|
1845 console->Printf(TRefByValue<const TDesC>_L(" Error: %d \n"), progress().iErrorCode); |
|
1846 |
|
1847 // wait 5 seconds so that user can see the final progess! |
|
1848 CTestTimer* timer = CTestTimer::NewL(); |
|
1849 timer->After(5000000); |
|
1850 CActiveScheduler::Start(); |
|
1851 delete timer; |
|
1852 |
|
1853 // testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse); |
|
1854 testUtils->TestFinish(12,globalError); |
|
1855 if (globalError) |
|
1856 testUtils->TestHarnessFailed(globalError); |
|
1857 else |
|
1858 testUtils->TestHarnessCompleted(); |
|
1859 |
|
1860 CleanupStack::PopAndDestroy(2); //msvSelection, opActive, |
|
1861 |
|
1862 testUtils->Reset(); |
|
1863 Closedown(); |
|
1864 } |
|
1865 |
|
1866 GLDEF_C TInt E32Main() |
|
1867 { |
|
1868 __UHEAP_MARK; |
|
1869 test.Start(_L("T_PARTIALFETCH Test for partial fetch of emails")); |
|
1870 theCleanup=CTrapCleanup::New(); |
|
1871 TRAPD(ret,doMainL()); |
|
1872 test(ret==KErrNone); |
|
1873 delete theCleanup; |
|
1874 test.End(); |
|
1875 test.Close(); |
|
1876 __UHEAP_MARKEND; |
|
1877 User::Heap().Check(); |
|
1878 return(KErrNone); |
|
1879 } |