|
1 // Copyright (c) 2000-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 // Generic POPS Test Harness |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "emailtestutils.h" |
|
20 #include "scripttestutils.h" |
|
21 #include <miutlog.h> |
|
22 #include <miutmsg.h> |
|
23 #include <txtrich.h> |
|
24 #include <popsmtm.h> |
|
25 #include "T_mtmcmd.h" |
|
26 #include <iapprefs.h> |
|
27 #include <securesocket.h> |
|
28 #include <commsdattypesv1_1.h> |
|
29 #include <commsdat.h> |
|
30 using namespace CommsDat; |
|
31 #include <cdbpreftable.h> |
|
32 #include <bacline.h> |
|
33 #include <cemailaccounts.h> |
|
34 #include <securesocket_internal.h> |
|
35 |
|
36 // For loading the serial comms device drivers |
|
37 #if defined (__WINS__) |
|
38 #define PDD_NAME _L("ECDRV") |
|
39 #define LDD_NAME _L("ECOMM") |
|
40 #else |
|
41 #define PDD_NAME _L("EUART1") |
|
42 #define LDD_NAME _L("ECOMM") |
|
43 #endif |
|
44 |
|
45 LOCAL_D CTrapCleanup* theCleanup; |
|
46 |
|
47 _LIT(POPS_SCRIPT_FILE_NAME, "c:\\logs\\email\\imsk110.scr"); |
|
48 |
|
49 |
|
50 // local variables etc // |
|
51 |
|
52 _LIT(KImcmTest, "T_POPS6 - Generic POPS Functionality Testing"); |
|
53 RTest test(KImcmTest); |
|
54 |
|
55 _LIT(KTestParams,"-testparams"); |
|
56 enum TCmdLineArgs |
|
57 { |
|
58 EArgProgramName, |
|
59 EArgTestParams, |
|
60 EArgServerAddress, |
|
61 EArgLogin, |
|
62 EArgPassword, |
|
63 EArgUseApop, |
|
64 EArgUseSecureSockets, |
|
65 EArgEnd |
|
66 }; |
|
67 |
|
68 |
|
69 class CPopsTestHarness : public CBase |
|
70 { |
|
71 public: |
|
72 static CPopsTestHarness* NewLC(CEmailTestUtils& aTestUtils); |
|
73 void InitL(); |
|
74 void ResetL(); |
|
75 void SetUpPopServiceL(); |
|
76 ~CPopsTestHarness(); |
|
77 |
|
78 void StartTestL(TInt aTestNumber, CMtmTestHarness& aTestCommands); |
|
79 void EndTestL(); |
|
80 void EndTestHarnessL(); |
|
81 |
|
82 private: |
|
83 CPopsTestHarness(CEmailTestUtils& aTestUtils); |
|
84 void ConstructL(); |
|
85 |
|
86 void CreateTestHarnessesL(); |
|
87 void ResetMtmL(); |
|
88 |
|
89 public: |
|
90 // These should be generated on request in future releases |
|
91 // of this test harness. |
|
92 CMtmTestHarness* iConnect; |
|
93 CMtmTestHarness* iConnectAndQuit; |
|
94 CMtmTestHarness* iConnectAndCopyAll; |
|
95 CMtmTestHarness* iConnectAndPopulateAll; |
|
96 CMtmTestHarness* iCopyAllWithoutConnect; |
|
97 CMtmTestHarness* iCopyAllOffline; |
|
98 CMtmTestHarness* iOfflineDelete; |
|
99 CMtmTestHarness* iCancelOfflineDeleteOnline; |
|
100 CMtmTestHarness* iCancelOfflineDelete; |
|
101 CMtmTestHarness* iConnectAndMoveAll; |
|
102 CMtmTestHarness* iMoveAll; |
|
103 CMtmTestHarness* iConnectAndTopPopulateAll; |
|
104 |
|
105 |
|
106 private: |
|
107 TInt iTestError; |
|
108 TInt iTestNumber; |
|
109 TInt iGlobalError; |
|
110 |
|
111 TMsvId iPop3Service; |
|
112 TMsvId iSmtpService; |
|
113 TMsvId iNewMessageId; |
|
114 |
|
115 CEmailTestUtils& iTestUtils; |
|
116 }; |
|
117 |
|
118 // |
|
119 LOCAL_C TBool GetTrueOrFalse() |
|
120 { |
|
121 TKeyCode k = test.Getch(); |
|
122 TChar key = k; |
|
123 test.Printf(_L("%c"), key); |
|
124 switch (key) |
|
125 { |
|
126 case 'Y': |
|
127 case 'y': |
|
128 return ETrue; |
|
129 default: |
|
130 return EFalse; |
|
131 }; |
|
132 } |
|
133 |
|
134 |
|
135 LOCAL_C TInt readConsoleLineBuf(const TDesC& aPrompt, TDes& aBuf) |
|
136 { |
|
137 test.Printf(_L("\n ")); |
|
138 TBool quit = EFalse; |
|
139 _LIT(KDeleteChar, "\b \b"); |
|
140 |
|
141 test.Printf(aPrompt); |
|
142 while (!quit) |
|
143 { |
|
144 TKeyCode k = test.Getch(); |
|
145 TChar key = k; |
|
146 switch (key) |
|
147 { |
|
148 case EKeyBackspace: |
|
149 if (aBuf.Length() > 0) |
|
150 { |
|
151 test.Printf(KDeleteChar); |
|
152 aBuf = aBuf.Left(aBuf.Length() - 1); |
|
153 } |
|
154 break; |
|
155 case EKeyEnter: |
|
156 if (aBuf.Length()) |
|
157 quit = ETrue; |
|
158 else |
|
159 test.Printf(_L("\nLogin, password and server address cannot be zero length ")); |
|
160 break; |
|
161 default: |
|
162 test.Printf(_L("%c"), key); |
|
163 aBuf.Append(key); |
|
164 break; |
|
165 } |
|
166 } |
|
167 return(KErrNone); |
|
168 } |
|
169 // |
|
170 |
|
171 CPopsTestHarness* CPopsTestHarness::NewLC(CEmailTestUtils& aTestUtils) |
|
172 { |
|
173 CPopsTestHarness* self = new (ELeave) CPopsTestHarness(aTestUtils); |
|
174 CleanupStack::PushL(self); |
|
175 self->ConstructL(); |
|
176 return self; |
|
177 } |
|
178 |
|
179 // |
|
180 |
|
181 void CPopsTestHarness::ResetMtmL() |
|
182 { |
|
183 // Get server MTM. |
|
184 iTestUtils.Reset(); |
|
185 iTestUtils.CleanMessageFolderL(); |
|
186 iTestUtils.GoServerSideL(); |
|
187 SetUpPopServiceL(); |
|
188 iTestUtils.InstantiatePopServerMtmL(); |
|
189 } |
|
190 |
|
191 // |
|
192 |
|
193 void CPopsTestHarness::ResetL() |
|
194 { |
|
195 ResetMtmL(); |
|
196 CreateTestHarnessesL(); |
|
197 } |
|
198 |
|
199 // |
|
200 |
|
201 void CPopsTestHarness::StartTestL(TInt aTestNumber, CMtmTestHarness& aTestCommands) |
|
202 { |
|
203 iTestNumber = aTestNumber; |
|
204 iTestError = KErrNone; |
|
205 iTestUtils.TestStart(aTestNumber); |
|
206 // Run the commands. |
|
207 iTestError=aTestCommands.StartL(_L("T_POPS6 - POPS Test Harness")); |
|
208 // TInt err = error(iTestUtils->iPopServerMtm->Progress()); |
|
209 } |
|
210 |
|
211 // |
|
212 |
|
213 void CPopsTestHarness::EndTestL() |
|
214 { |
|
215 if ((iTestError != KErrNone) && (iGlobalError == KErrNone)) |
|
216 { |
|
217 iGlobalError = iTestError; |
|
218 } |
|
219 |
|
220 iTestUtils.TestFinish(iTestNumber, iTestError); |
|
221 } |
|
222 |
|
223 // |
|
224 |
|
225 void CPopsTestHarness::EndTestHarnessL() |
|
226 { |
|
227 if (iGlobalError == KErrNone) |
|
228 { |
|
229 iTestUtils.TestHarnessCompleted(); |
|
230 } |
|
231 else |
|
232 { |
|
233 iTestUtils.TestHarnessFailed(iGlobalError); |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 void CPopsTestHarness::InitL() |
|
239 { |
|
240 iTestUtils.CreateAllTestDirectories(); |
|
241 iTestUtils.FileSession().SetSessionPath(_L("C:\\")); |
|
242 iTestUtils.CleanMessageFolderL(); |
|
243 iTestUtils.GoServerSideL(); |
|
244 |
|
245 test.Next(_L("Create Data Component FileStores")); |
|
246 |
|
247 iTestUtils.FileSession().SetSessionPath(_L("c:\\")); |
|
248 } |
|
249 |
|
250 // |
|
251 |
|
252 void CPopsTestHarness::ConstructL() |
|
253 { |
|
254 InitL(); |
|
255 } |
|
256 |
|
257 // |
|
258 |
|
259 CPopsTestHarness::~CPopsTestHarness() |
|
260 { |
|
261 delete iConnect; |
|
262 delete iConnectAndCopyAll; |
|
263 delete iConnectAndPopulateAll; |
|
264 delete iConnectAndMoveAll; |
|
265 delete iMoveAll; |
|
266 delete iCopyAllWithoutConnect; |
|
267 delete iCopyAllOffline; |
|
268 delete iConnectAndQuit; |
|
269 delete iOfflineDelete; |
|
270 delete iCancelOfflineDeleteOnline; |
|
271 delete iCancelOfflineDelete; |
|
272 delete iConnectAndTopPopulateAll; |
|
273 } |
|
274 |
|
275 // |
|
276 |
|
277 CPopsTestHarness::CPopsTestHarness(CEmailTestUtils& aTestUtils) : iGlobalError(KErrNone), iTestUtils(aTestUtils) |
|
278 {} |
|
279 |
|
280 // |
|
281 |
|
282 void CPopsTestHarness::SetUpPopServiceL() |
|
283 { |
|
284 // Handle command line arguments |
|
285 CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); |
|
286 TInt count = cmdLineArg->Count(); |
|
287 TBool isCmdLine=FALSE; |
|
288 if (count>2) // Command line arguments? |
|
289 { |
|
290 if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd) |
|
291 isCmdLine=TRUE; |
|
292 } |
|
293 |
|
294 // Create the POP3 service and set the settings for this test. |
|
295 iPop3Service = iTestUtils.CreatePopServiceL(); |
|
296 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
|
297 CleanupStack::PushL(settings); |
|
298 settings->Reset(); |
|
299 |
|
300 TBuf<100> buf; |
|
301 if (isCmdLine) |
|
302 { |
|
303 TLex lex(cmdLineArg->Arg(EArgServerAddress)); |
|
304 buf=lex.NextToken(); |
|
305 test.Printf(_L("Server address: %S\n"),&buf); |
|
306 } |
|
307 else |
|
308 { |
|
309 readConsoleLineBuf(_L("Server address: "),buf); |
|
310 } |
|
311 settings->SetServerAddressL(buf); |
|
312 buf.Zero(); |
|
313 if (isCmdLine) |
|
314 { |
|
315 TLex lex(cmdLineArg->Arg(EArgLogin)); |
|
316 buf=lex.NextToken(); |
|
317 test.Printf(_L("Login: %S\n"),&buf); |
|
318 } |
|
319 else |
|
320 { |
|
321 readConsoleLineBuf(_L("login: "),buf); |
|
322 } |
|
323 TBuf8<64> data; |
|
324 data.Copy(buf); |
|
325 settings->SetLoginNameL(iTestUtils.MachineName()); |
|
326 data.Zero(); |
|
327 buf.Zero(); |
|
328 if (isCmdLine) |
|
329 { |
|
330 TLex lex(cmdLineArg->Arg(EArgPassword)); |
|
331 buf=lex.NextToken(); |
|
332 test.Printf(_L("Password: %S\n"),&buf); |
|
333 } |
|
334 else |
|
335 { |
|
336 readConsoleLineBuf(_L("password: "),buf); |
|
337 } |
|
338 data.Copy(buf); |
|
339 settings->SetPasswordL(iTestUtils.MachineName()); |
|
340 settings->SetPort(110); |
|
341 settings->SetDisconnectedUserMode(ETrue); // eh xxxx, must test this when set to EFalse |
|
342 TChar choice; |
|
343 if (isCmdLine) |
|
344 { |
|
345 TLex lex(cmdLineArg->Arg(EArgUseApop)); |
|
346 choice=lex.Get(); |
|
347 test.Printf(_L("Use APOP: %c\n"),choice); |
|
348 if (choice=='y' || choice=='Y') |
|
349 settings->SetApop(ETrue); |
|
350 else |
|
351 settings->SetApop(EFalse); |
|
352 } |
|
353 else |
|
354 { |
|
355 test.Printf(_L("\n Use APOP? Enter (Y/N): ")); |
|
356 settings->SetApop(GetTrueOrFalse()); |
|
357 } |
|
358 if (isCmdLine) |
|
359 { |
|
360 TLex lex(cmdLineArg->Arg(EArgUseSecureSockets)); |
|
361 choice=lex.Get(); |
|
362 test.Printf(_L("Use secure sockets: %c\n"),choice); |
|
363 if (choice=='y' || choice=='Y') |
|
364 settings->SetSecureSockets(ETrue); |
|
365 else |
|
366 settings->SetSecureSockets(EFalse); |
|
367 } |
|
368 else |
|
369 { |
|
370 test.Printf(_L("\n Use secure sockets? Enter (Y/N): ")); |
|
371 settings->SetSecureSockets(GetTrueOrFalse()); |
|
372 } |
|
373 |
|
374 // Add IAP's to iIAPPreferences |
|
375 TImIAPChoice iap; |
|
376 CImIAPPreferences* prefs = CImIAPPreferences::NewLC(); |
|
377 TInt iapId = 0; |
|
378 CMDBSession* iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
379 CCDConnectionPrefsRecord *connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
380 CleanupStack::PushL(connPrefRecord); |
|
381 connPrefRecord->iDirection = ECommDbConnectionDirectionOutgoing; |
|
382 if(!connPrefRecord->FindL(*iDBSession)) |
|
383 { |
|
384 User::Leave(KErrNotFound); |
|
385 } |
|
386 iapId = iap.iIAP = connPrefRecord->iDefaultIAP; |
|
387 |
|
388 CleanupStack::PopAndDestroy(connPrefRecord); |
|
389 delete iDBSession; |
|
390 iDBSession= NULL; |
|
391 |
|
392 iap.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
393 prefs->AddIAPL(iap); |
|
394 iap.iIAP = iapId; |
|
395 iap.iDialogPref = ECommDbDialogPrefPrompt; |
|
396 prefs->AddIAPL(iap, 1); |
|
397 |
|
398 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
399 TPopAccount popAccount; |
|
400 accounts->GetPopAccountL(iPop3Service, popAccount); |
|
401 accounts->SavePopSettingsL(popAccount, *settings); |
|
402 accounts->SavePopIapSettingsL(popAccount, *prefs); |
|
403 CleanupStack::PopAndDestroy(4, cmdLineArg); // (accounts,) prefs, settings, (store,) cmdLineArg |
|
404 test.Printf(_L("\nPerforming Tests\n")); |
|
405 } |
|
406 |
|
407 // |
|
408 |
|
409 void CPopsTestHarness::CreateTestHarnessesL() |
|
410 { |
|
411 CMsvEntrySelection* serviceSelection = new (ELeave) CMsvEntrySelection; |
|
412 CleanupStack::PushL(serviceSelection); |
|
413 serviceSelection->AppendL(iPop3Service); |
|
414 TBuf8<128> parameter; |
|
415 |
|
416 delete iConnectAndCopyAll; |
|
417 iConnectAndCopyAll = NULL; |
|
418 iConnectAndCopyAll = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
419 // Connect |
|
420 iConnectAndCopyAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
421 // Copy all messages under the service to the local inbox. |
|
422 CMtmTestCommand* copyToLocal = CMtmTestCopyToLocal::NewL(*(iTestUtils.iPopServerMtm), 0, KMsvGlobalInBoxIndexEntryId); |
|
423 iConnectAndCopyAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
424 // Quit |
|
425 iConnectAndCopyAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
426 |
|
427 delete iConnectAndPopulateAll; |
|
428 iConnectAndPopulateAll = NULL; |
|
429 iConnectAndPopulateAll = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
430 // Connect |
|
431 iConnectAndPopulateAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
432 // Copy all messages under the service to the local inbox. |
|
433 copyToLocal = CMtmTestCopyWithinService::NewL(*(iTestUtils.iPopServerMtm), 0, iPop3Service); |
|
434 iConnectAndPopulateAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
435 // Quit |
|
436 iConnectAndPopulateAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
437 |
|
438 delete iConnectAndMoveAll; |
|
439 iConnectAndMoveAll = NULL; |
|
440 iConnectAndMoveAll = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
441 // Connect |
|
442 iConnectAndMoveAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
443 // Move all messages under the service to the local inbox. |
|
444 CMtmTestCommand* moveToLocal = CMtmTestMoveToLocal::NewL(*(iTestUtils.iPopServerMtm), 0, KMsvGlobalInBoxIndexEntryId); |
|
445 iConnectAndMoveAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), moveToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
446 // Quit |
|
447 iConnectAndMoveAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
448 |
|
449 delete iMoveAll; |
|
450 iMoveAll = NULL; |
|
451 iMoveAll = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
452 // Move all messages under the service to the local inbox. |
|
453 moveToLocal = CMtmTestMoveToLocal::NewL(*(iTestUtils.iPopServerMtm), 0, KMsvGlobalInBoxIndexEntryId); |
|
454 iMoveAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), moveToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
455 |
|
456 delete iConnect; |
|
457 iConnect = NULL; |
|
458 iConnect = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
459 // Connect |
|
460 iConnect->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
461 |
|
462 delete iConnectAndQuit; |
|
463 iConnectAndQuit = NULL; |
|
464 iConnectAndQuit = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
465 // Connect |
|
466 iConnectAndQuit->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
467 // Quit |
|
468 iConnectAndQuit->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
469 |
|
470 delete iCopyAllWithoutConnect; |
|
471 iCopyAllWithoutConnect = NULL; |
|
472 iCopyAllWithoutConnect = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
473 // Copy all messages under the service to the local inbox. |
|
474 copyToLocal = CMtmTestCopyToLocal::NewL(*(iTestUtils.iPopServerMtm), 0, KMsvGlobalInBoxIndexEntryId); |
|
475 iCopyAllWithoutConnect->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
476 // Quit |
|
477 iCopyAllWithoutConnect->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
478 |
|
479 delete iCopyAllOffline; |
|
480 iCopyAllOffline = NULL; |
|
481 iCopyAllOffline = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
482 // Copy all messages under the service to the local inbox. |
|
483 copyToLocal = CMtmTestCopyToLocal::NewL(*(iTestUtils.iPopServerMtm), 0, KMsvGlobalInBoxIndexEntryId); |
|
484 iCopyAllOffline->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
485 // Connect |
|
486 iCopyAllOffline->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
487 // Quit |
|
488 iCopyAllOffline->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
489 |
|
490 delete iOfflineDelete; |
|
491 iOfflineDelete = NULL; |
|
492 iOfflineDelete = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
493 // Connect |
|
494 iOfflineDelete->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
495 // Quit |
|
496 iOfflineDelete->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
497 // Delete all the entries |
|
498 CMtmTestDeleteAll* deleteAll = CMtmTestDeleteAll::NewL(*(iTestUtils.iPopServerMtm), 0); |
|
499 iOfflineDelete->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), deleteAll, iPop3Service, *(iTestUtils.iServerEntry))); |
|
500 |
|
501 delete iCancelOfflineDeleteOnline; |
|
502 iCancelOfflineDeleteOnline = NULL; |
|
503 iCancelOfflineDeleteOnline = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
504 // Connect |
|
505 iCancelOfflineDeleteOnline->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
506 // Cancel offline delete |
|
507 CMtmTestStartCommand* cancelAllDeletes = CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), 0, KPOP3MTMCancelOfflineOperations, parameter); |
|
508 iCancelOfflineDeleteOnline->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), cancelAllDeletes, iPop3Service, *(iTestUtils.iServerEntry))); |
|
509 // Quit |
|
510 iCancelOfflineDeleteOnline->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
511 |
|
512 delete iCancelOfflineDelete; |
|
513 iCancelOfflineDelete = NULL; |
|
514 iCancelOfflineDelete = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
515 // Cancel offline delete |
|
516 cancelAllDeletes = CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), 0, KPOP3MTMCancelOfflineOperations, parameter); |
|
517 iCancelOfflineDelete->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), cancelAllDeletes, iPop3Service, *(iTestUtils.iServerEntry))); |
|
518 |
|
519 // Top Test addition |
|
520 delete iConnectAndTopPopulateAll; |
|
521 iConnectAndTopPopulateAll = NULL; |
|
522 iConnectAndTopPopulateAll = CMtmTestHarness::NewL(*(iTestUtils.iPopServerMtm), iTestUtils); |
|
523 // Connect |
|
524 iConnectAndTopPopulateAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMConnect, parameter)); |
|
525 // Copy all messages under the service to the local inbox. |
|
526 copyToLocal = CMtmTestTopPopulate::NewL(*(iTestUtils.iPopServerMtm), 0, iPop3Service); |
|
527 iConnectAndTopPopulateAll->AddCommandL(CMtmTestCommandOnAllMessages::NewL(*(iTestUtils.iPopServerMtm), copyToLocal, iPop3Service, *(iTestUtils.iServerEntry))); |
|
528 // Quit |
|
529 iConnectAndTopPopulateAll->AddCommandL(CMtmTestStartCommand::NewL(*(iTestUtils.iPopServerMtm), serviceSelection, KPOP3MTMDisconnect, parameter)); |
|
530 |
|
531 CleanupStack::PopAndDestroy(); // serviceSelection |
|
532 } |
|
533 |
|
534 |
|
535 // |
|
536 |
|
537 LOCAL_C void doMainL() |
|
538 { |
|
539 CActiveScheduler* scheduler; |
|
540 scheduler = new (ELeave) CActiveScheduler; |
|
541 CleanupStack::PushL(scheduler); |
|
542 CActiveScheduler::Install(scheduler); |
|
543 |
|
544 // Load the serial comms device drivers. If this is not done, |
|
545 // connecting via NT-RAS returns KErrNotFound (-1). |
|
546 TInt driverErr; |
|
547 driverErr=User::LoadPhysicalDevice(PDD_NAME); |
|
548 if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) |
|
549 User::Leave(driverErr); |
|
550 driverErr=User::LoadLogicalDevice(LDD_NAME); |
|
551 if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) |
|
552 User::Leave(driverErr); |
|
553 |
|
554 |
|
555 CEmailTestUtils* testUtils = CEmailTestUtils::NewLC(test); |
|
556 |
|
557 testUtils->FileSession().Delete(POPS_SCRIPT_FILE_NAME); |
|
558 |
|
559 CPopsTestHarness* popsTestHarness = CPopsTestHarness::NewLC(*testUtils); |
|
560 |
|
561 // popsTestHarness->SetUpPopServiceL(); |
|
562 |
|
563 testUtils->FileSession().Delete(_L("c:\\logs\\email\\imsk110.scr")); |
|
564 |
|
565 // RUN THE TESTS |
|
566 |
|
567 popsTestHarness->ResetL(); |
|
568 popsTestHarness->StartTestL(1, *(popsTestHarness->iConnectAndPopulateAll)); |
|
569 popsTestHarness->EndTestL(); |
|
570 |
|
571 // Wait a bit |
|
572 CTestTimer* timer = CTestTimer::NewL(); |
|
573 timer->After(10000000); |
|
574 CActiveScheduler::Start(); |
|
575 delete timer; |
|
576 |
|
577 |
|
578 popsTestHarness->EndTestHarnessL(); |
|
579 CSecureSocketLibraryLoader::Unload(); |
|
580 |
|
581 CleanupStack::PopAndDestroy(3); // popsTestHarness, testUtils, scheduler |
|
582 } |
|
583 |
|
584 |
|
585 // |
|
586 |
|
587 GLDEF_C TInt E32Main() |
|
588 { |
|
589 __UHEAP_MARK; |
|
590 test.Start(_L("T_POPS6 Test, General POPS Tests")); |
|
591 theCleanup=CTrapCleanup::New(); |
|
592 |
|
593 TRAPD(ret,doMainL()); |
|
594 |
|
595 test(ret==KErrNone); |
|
596 delete theCleanup; |
|
597 test.End(); |
|
598 test.Close(); |
|
599 __UHEAP_MARKEND; |
|
600 User::Heap().Check(); |
|
601 return(KErrNone); |
|
602 } |
|
603 |