email/pop3andsmtpmtm/clientmtms/test/src/T_POPC.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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_POPC
       
    15 // Component: IMCM
       
    16 // Owner: KP
       
    17 // Brief description of test harness:
       
    18 // Tests the client-side API of POP3 MTM; Query capability; standard POP3 
       
    19 // functionality; CImPop3GetMail API.
       
    20 // Detailed description of test harness:
       
    21 // As above.
       
    22 // Input files required to run test harness:
       
    23 // None
       
    24 // Intermediate files produced while running test harness:
       
    25 // <DRIVE>:\msglogs\T_POPC\T_IMCM.log
       
    26 // <DRIVE>:\msglogs\T_POPC\Entry_Structure.txt
       
    27 // Output files produced by running test harness:
       
    28 // <DRIVE>:\msglogs\T_POPC.<PLATFORM>.<VARIANT>.LOG.txt
       
    29 // Description of how to build test harness:
       
    30 // cd \msg\imcm\
       
    31 // bldmake bldfiles
       
    32 // abld test build
       
    33 // Description of how to run test harness:
       
    34 // The following instructions are the same for all platforms:
       
    35 // 1. Build T_DB test harness from COMMDB component:
       
    36 // cd \commdb\group
       
    37 // bldmake bldfiles
       
    38 // abld test build t_db
       
    39 // 2. Build the test utilities:
       
    40 // cd \msg\testutils\group\
       
    41 // bldmake bldfiles
       
    42 // abld build
       
    43 // WINS running instructions:
       
    44 // 1. \epoc32\release\wins\<VARIANT>\T_POPC.exe can be used at the command prompt
       
    45 // or executable can be run from Windows Explorer.
       
    46 // All other platform running instructions:
       
    47 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_POPC.exe onto the other platform
       
    48 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into 
       
    49 // <DRIVE>:\system\libs on the other platform
       
    50 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into 
       
    51 // <DRIVE>:\system\libs on the other platform
       
    52 // 4. Run T_POPC.exe on the other platform
       
    53 // 
       
    54 //
       
    55 
       
    56 #include "emailtestutils.h"
       
    57 #include <txtrich.h>
       
    58 #include <c32comm.h>
       
    59 #include <commdb.h>
       
    60 #include <mtmuids.h>
       
    61 #include "TESTENV.h"
       
    62 #include <bacline.h>
       
    63 #include <cemailaccounts.h>
       
    64 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    65 #include "cimmessagepart.h"
       
    66 #endif
       
    67 
       
    68 
       
    69 // For loading the serial comms device drivers 
       
    70 #if defined (__WINS__)
       
    71 	#define PDD_NAME		_L("ECDRV")
       
    72 	#define LDD_NAME		_L("ECOMM")
       
    73 #else
       
    74 	#define PDD_NAME		_L("EUART1")
       
    75 	#define LDD_NAME		_L("ECOMM")
       
    76 #endif
       
    77 
       
    78 // local variables etc //
       
    79 
       
    80 _LIT(KImcmTest, "T_POPC - Testing CImPop3GetMail");
       
    81 RTest test(KImcmTest);
       
    82 
       
    83 _LIT(KTestParams,"-testparams");
       
    84 enum TCmdLineArgs
       
    85 	{
       
    86 	EArgProgramName,
       
    87 	EArgTestParams,
       
    88 	EArgServerAddress,
       
    89 	EArgLogin,
       
    90 	EArgPassword,
       
    91 	EArgPopulationLimit,
       
    92 	EArgEnd
       
    93 	};
       
    94 
       
    95 
       
    96 LOCAL_D TMsvId Pop3Service;
       
    97 LOCAL_D TMsvId smtpService;
       
    98 
       
    99 LOCAL_D CTrapCleanup* theCleanup;
       
   100 LOCAL_D CEmailTestUtils* testUtils;
       
   101 
       
   102 LOCAL_D CMsvOperation* msvOperation;
       
   103 LOCAL_D CMsvEntrySelection* msvSelection;
       
   104 
       
   105 LOCAL_D CMsvEntrySelection* messageSelection;
       
   106 
       
   107 LOCAL_D CConsoleBase* console;
       
   108 
       
   109 class COperationActive;
       
   110 LOCAL_D COperationActive* opActive;
       
   111 LOCAL_D TInt testNo = 1;
       
   112 LOCAL_D TInt globalError = 0;
       
   113 LOCAL_D TBool iDoCancel = EFalse;
       
   114 
       
   115 _LIT(KTestSettingsServerAddress,"2.2.2.2");
       
   116 const TInt KTestSettingsPort = 111;
       
   117 _LIT8(KTestSettingsLoginName,"testuser");
       
   118 _LIT8(KTestSettingsPassword,"password");
       
   119 const TInt KTestPopulationLimit=30;
       
   120 
       
   121 _LIT(KServer, "lon-cn-exchng2k.msexchange2k.closedtest.intra");
       
   122 _LIT8(KLoginName, "t_popc");
       
   123 _LIT8(KPassword, "t_popc");
       
   124 
       
   125 
       
   126 //
       
   127 class TestUiTimer : public CTimer
       
   128 	{
       
   129 public:
       
   130 	static TestUiTimer* NewLC(CConsoleBase* aConsole);
       
   131 	~TestUiTimer();
       
   132 
       
   133 	void RunL();
       
   134 	void DoCancel();
       
   135 	void ConstructL();
       
   136 	void IssueRequest();
       
   137 	void SetOperation(CMsvOperation* aOperation);
       
   138 	TTimeIntervalMicroSeconds32 period;
       
   139 	TPtrC Progress(TInt progressNumber);
       
   140 	void SetCancelState(TInt aState);
       
   141 protected:
       
   142 	TestUiTimer(CConsoleBase* aConsole);
       
   143 	
       
   144 	CConsoleBase*		iConsole;
       
   145 public:
       
   146 	CMsvOperation*		iOperation;
       
   147 private:
       
   148 	TInt	iCancelState;
       
   149 	};
       
   150 
       
   151 //
       
   152 TestUiTimer* TestUiTimer::NewLC(CConsoleBase* aConsole)
       
   153 	{
       
   154 	TestUiTimer* self = new(ELeave) TestUiTimer(aConsole);
       
   155 	CleanupStack::PushL(self);
       
   156 	self->ConstructL();
       
   157 	return self;
       
   158 	}
       
   159 
       
   160 TestUiTimer::TestUiTimer(CConsoleBase* aConsole)
       
   161 	: CTimer(1), iCancelState(KMaxTInt)
       
   162 	{
       
   163 	iConsole = aConsole;
       
   164 	period = 10000;
       
   165 	}
       
   166 
       
   167 TestUiTimer::~TestUiTimer()
       
   168 	{
       
   169 	delete iOperation;
       
   170 	}
       
   171 
       
   172 void TestUiTimer::ConstructL()
       
   173 	{
       
   174 	CTimer::ConstructL();
       
   175 	CActiveScheduler::Add(this);
       
   176 	}
       
   177 
       
   178 void TestUiTimer::IssueRequest()
       
   179 	{
       
   180 	After(period);
       
   181 	}
       
   182 
       
   183 void TestUiTimer::SetOperation(CMsvOperation* aOperation)
       
   184 	{
       
   185 	if(iOperation)
       
   186 		{
       
   187 		delete iOperation;
       
   188 		iOperation=NULL;
       
   189 		}
       
   190 	iOperation = aOperation;
       
   191 	}
       
   192 
       
   193 void TestUiTimer::DoCancel()
       
   194 	{
       
   195 	CTimer::DoCancel();
       
   196 	}
       
   197 
       
   198 TPtrC TestUiTimer::Progress(TInt progressNumber)
       
   199 	{
       
   200 	switch (progressNumber)
       
   201 		{
       
   202 		case 0:
       
   203 			return _L("Refreshing              ");
       
   204 		case 1:
       
   205 			return _L("Copying                 ");
       
   206 		case 2:
       
   207 			return _L("Deleting                ");
       
   208 		case 3:
       
   209 			return _L("Connecting              ");
       
   210 		case 4:
       
   211 			return _L("Tidying                 ");
       
   212 		case 5:
       
   213 			return _L("Connected and Idle      ");
       
   214 		case 6:
       
   215 			return _L("Disconnecting           ");
       
   216 		case 7:
       
   217 			return _L("Disconnected            ");
       
   218 		case 8:
       
   219 			return _L("Moving                  ");
       
   220 		case 9:
       
   221 			return _L("Copying New Mail        ");
       
   222 		case 10:
       
   223 			return _L("Moving New Mail         ");
       
   224 		case 11:
       
   225 			return _L("Copying Mail Selection  ");
       
   226 		case 12:
       
   227 			return _L("Moving Mail Selection   ");
       
   228 		case 13:
       
   229 			return _L("Copying All Mail        ");
       
   230 		case 14:
       
   231 			return _L("Moving All Mail         ");
       
   232 		default:
       
   233 			return _L("Unknown Progress        ");
       
   234 		}
       
   235 	}
       
   236 
       
   237 void TestUiTimer::SetCancelState(TInt aState)
       
   238 	{
       
   239 	iCancelState = aState;
       
   240 	}
       
   241 
       
   242 void TestUiTimer::RunL()
       
   243 	{
       
   244 	// display the current progress
       
   245 	if(iOperation!=NULL)
       
   246 		{
       
   247 		if(iDoCancel == TBool(ETrue))
       
   248 			{
       
   249 			iOperation->Cancel();
       
   250 			}
       
   251 		TPop3Progress temp;	
       
   252 		TPckgC<TPop3Progress> paramPack(temp);
       
   253 		paramPack.Set(iOperation->ProgressL());
       
   254 		TPop3Progress progress=paramPack();	
       
   255 
       
   256 		if (iCancelState == progress.iPop3SubStateProgress)
       
   257 			{
       
   258 			iConsole->Printf(_L("	Calling Cancel\n"));
       
   259 			iOperation->Cancel();
       
   260 			}
       
   261 
       
   262 		iConsole->SetPos(0, 12);
       
   263 		TBuf<80> progressBuf = Progress(progress.iPop3Progress);
       
   264 		iConsole->Printf(TRefByValue<const TDesC>_L("   Super Operation Progress: %S           "), &progressBuf);
       
   265 		iConsole->SetPos(0, 13);
       
   266 		progressBuf = Progress(progress.iPop3SubStateProgress);
       
   267 		iConsole->Printf(TRefByValue<const TDesC>_L("   Sub Operation Progress  : %S           "), &progressBuf);
       
   268 		iConsole->SetPos(0, 14);
       
   269 		iConsole->Printf(TRefByValue<const TDesC>_L("   Progress:  %d/%d %d/%d Total:%d                \n"),
       
   270 					progress.iTotalMsgs-progress.iMsgsToProcess,
       
   271 					progress.iTotalMsgs,
       
   272 					progress.iBytesDone,
       
   273 					progress.iTotalBytes,
       
   274 					progress.iTotalSize);
       
   275 		iConsole->SetPos(0, 15);
       
   276 		iConsole->Printf(TRefByValue<const TDesC>_L("   Error: %d                             \n"), progress.iErrorCode);
       
   277 		if (progress.iErrorCode && !globalError)
       
   278 			{
       
   279 			if(!iDoCancel || progress.iErrorCode!=KErrCancel)
       
   280 				{// we should not report KErrCancel as an error when iDoCancel is true because that is expected behviour
       
   281 				globalError=progress.iErrorCode;
       
   282 				}
       
   283 			}
       
   284 		}
       
   285 	IssueRequest();
       
   286 	};
       
   287 
       
   288 //
       
   289 
       
   290 class COperationActive : public CActive
       
   291 	{
       
   292 public:
       
   293 	COperationActive();
       
   294 	~COperationActive();
       
   295 	static COperationActive* NewL();
       
   296 	void StartL(TBool aDisableProgress = EFalse);
       
   297 	void SetOperation(CMsvOperation*);
       
   298 	void SetCancelState(TInt aCancelState);
       
   299 	
       
   300 protected:
       
   301 	void DoCancel();
       
   302 	void RunL();
       
   303 public:	
       
   304 	TestUiTimer* iTimer;
       
   305 private:
       
   306 	TBool iSetActive;
       
   307 	};
       
   308 
       
   309 //
       
   310 COperationActive::COperationActive()
       
   311 : CActive(0)
       
   312 	{
       
   313 	}
       
   314 
       
   315 COperationActive::~COperationActive()
       
   316 	{
       
   317 	Cancel();
       
   318 	delete iTimer;
       
   319 	}
       
   320 
       
   321 COperationActive* COperationActive::NewL()
       
   322 	{
       
   323 	COperationActive* self = new (ELeave) COperationActive;
       
   324 	CActiveScheduler::Add(self);
       
   325 
       
   326 	self->iSetActive = ETrue;
       
   327 	self->iTimer = TestUiTimer::NewLC(test.Console());
       
   328 	CleanupStack::Pop();
       
   329 	return self;
       
   330 	}
       
   331 
       
   332 void COperationActive::DoCancel()
       
   333 	{
       
   334 	iTimer->DoCancel();
       
   335 	}
       
   336 
       
   337 void COperationActive::StartL(TBool aDisableProgress)
       
   338 	{
       
   339 	if(aDisableProgress)
       
   340 		{
       
   341 		iTimer->IssueRequest();	// Start the connect observation timer
       
   342 		SetActive();
       
   343 		test.Printf(TRefByValue<const TDesC>_L("POP3 progress disabled"));
       
   344 		}
       
   345 	else
       
   346 		{	
       
   347 		TPop3Progress temp;	
       
   348 		TPckgC<TPop3Progress> paramPack(temp);
       
   349 		paramPack.Set(iTimer->iOperation->ProgressL());
       
   350 		TPop3Progress progress=paramPack();	
       
   351 
       
   352 		switch(progress.iPop3Progress)
       
   353 			{
       
   354 			case TPop3Progress::EPopDisconnected:
       
   355 			case TPop3Progress::EPopDisconnecting:
       
   356 				// don't set active
       
   357 				iSetActive = EFalse;
       
   358 				break;
       
   359 			case TPop3Progress::EPopCopyNewMail:
       
   360 			case TPop3Progress::EPopMoveNewMail:
       
   361 			case TPop3Progress::EPopCopyMailSelection:
       
   362 			case TPop3Progress::EPopMoveMailSelection:
       
   363 			case TPop3Progress::EPopCopyAllMail:
       
   364 			case TPop3Progress::EPopMoveAllMail:
       
   365 			case TPop3Progress::EPopPopulating:
       
   366 			default:
       
   367 				switch(progress.iPop3SubStateProgress)
       
   368 					{
       
   369 					// don't set active if we are in the disconnecting state or if we have disconnected.
       
   370 					case TPop3Progress::EPopDisconnected:
       
   371 					case TPop3Progress::EPopDisconnecting:
       
   372 					default:
       
   373 						// don't set active
       
   374 						iSetActive = EFalse;	
       
   375 						break;
       
   376 					case TPop3Progress::EPopCopying:
       
   377 					case TPop3Progress::EPopDeleting:
       
   378 					case TPop3Progress::EPopConnectedAndIdle:
       
   379 					case TPop3Progress::EPopMoving:
       
   380 					case TPop3Progress::EPopRefreshing:
       
   381 					case TPop3Progress::EPopConnecting:
       
   382 					case TPop3Progress::EPopTidying:
       
   383 						{
       
   384 						if (iSetActive && iTimer->iOperation->IsActive())
       
   385 							{
       
   386 							
       
   387 							iTimer->IssueRequest();	// Start the connect observation timer
       
   388 							SetActive();
       
   389 							
       
   390 							}
       
   391 						}
       
   392 					}
       
   393 			}
       
   394 
       
   395 		test.Console()->SetPos(0, 17);
       
   396 		test.Printf(TRefByValue<const TDesC>_L("Operation TRequestStatus %d"), iStatus);
       
   397 		
       
   398 		}
       
   399 	}
       
   400 
       
   401 void COperationActive::SetOperation(CMsvOperation *aOperation)
       
   402 	{
       
   403 	iTimer->SetOperation(aOperation);
       
   404 	}
       
   405 
       
   406 void COperationActive::SetCancelState(TInt aCancelState)
       
   407 	{
       
   408 	iTimer->SetCancelState(aCancelState);
       
   409 	}
       
   410 
       
   411 void COperationActive::RunL() 
       
   412 	{
       
   413 	iTimer->Cancel();
       
   414 	test.Console()->SetPos(25, 17);
       
   415 	test.Printf(_L("                "));
       
   416 	test.Console()->SetPos(0, 17);
       
   417 	test.Printf(TRefByValue<const TDesC>_L("Operation TRequestStatus %d"), iStatus);
       
   418 	CActiveScheduler::Stop();
       
   419 	}
       
   420 
       
   421 //
       
   422 
       
   423 LOCAL_C void StoreClientSettingsL()
       
   424 //
       
   425 // Dummy settings for checking that StoreSettingsL work for the client mtm
       
   426 //	
       
   427 	{
       
   428 	testUtils->WriteComment(_L("Storing settings in client mtm"));
       
   429 	CImPop3Settings* pop3Settings = new(ELeave)CImPop3Settings;
       
   430 	CleanupStack::PushL(pop3Settings);
       
   431 	pop3Settings->CopyL(testUtils->iPopClientMtm->Settings());
       
   432     pop3Settings->SetServerAddressL(KTestSettingsServerAddress);
       
   433 	pop3Settings->SetPort(KTestSettingsPort);
       
   434 	pop3Settings->SetLoginNameL(KTestSettingsLoginName);
       
   435 	pop3Settings->SetPasswordL(KTestSettingsPassword);
       
   436 	pop3Settings->SetPopulationLimitL(KTestPopulationLimit);
       
   437 	testUtils->iPopClientMtm->SetSettingsL(*pop3Settings);
       
   438 	CleanupStack::PopAndDestroy(pop3Settings);
       
   439 	testUtils->iPopClientMtm->StoreSettingsL();
       
   440 	}
       
   441 
       
   442 LOCAL_C TInt VerifyStoredClientSettingsL()
       
   443 //
       
   444 // Comparison of the settings stored to see that the client commits after storing
       
   445 //
       
   446 	{
       
   447 	// Handle command line arguments
       
   448 	CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC();
       
   449 	TInt count = cmdLineArg->Count();
       
   450 	TBool isCmdLine=FALSE;
       
   451 	if (count>2)	// Command line arguments?
       
   452 		{
       
   453 		if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd)
       
   454 			isCmdLine=TRUE;
       
   455 		}	
       
   456 
       
   457 	testUtils->WriteComment(_L("Checking stored settings in client mtm"));
       
   458 	testUtils->iPopClientMtm->RestoreSettingsL();
       
   459 	CImPop3Settings* pop3Settings = new(ELeave)CImPop3Settings;
       
   460 	CleanupStack::PushL(pop3Settings);
       
   461 	pop3Settings->CopyL(testUtils->iPopClientMtm->Settings());
       
   462 
       
   463     TInt result=0;
       
   464 	result += pop3Settings->ServerAddress().Compare(KTestSettingsServerAddress);
       
   465 	result += pop3Settings->Port() - KTestSettingsPort;
       
   466 	result += pop3Settings->LoginName().Compare(KTestSettingsLoginName);
       
   467 	result += pop3Settings->Password().Compare(KTestSettingsPassword);
       
   468     result += (pop3Settings->PopulationLimit()!=KTestPopulationLimit);
       
   469 
       
   470 	pop3Settings->Reset();
       
   471 
       
   472 	if (isCmdLine)
       
   473 		{
       
   474 		TBuf<100> buf;
       
   475 		TLex lex(cmdLineArg->Arg(EArgServerAddress));
       
   476 		buf=lex.NextToken();
       
   477 		pop3Settings->SetServerAddressL(buf);
       
   478 		}
       
   479 	else
       
   480 		{
       
   481 		pop3Settings->SetServerAddressL(KServer);
       
   482 		}
       
   483 
       
   484 	if (isCmdLine)
       
   485 		{
       
   486 		TBuf<100> buf;
       
   487 		TBuf8<64> data;
       
   488 		TLex lex(cmdLineArg->Arg(EArgLogin));
       
   489 		buf=lex.NextToken();
       
   490 		data.Copy(buf);
       
   491 		pop3Settings->SetLoginNameL(data);
       
   492 		}
       
   493 	else
       
   494 		{
       
   495 		pop3Settings->SetLoginNameL(KLoginName);
       
   496 		}
       
   497 
       
   498 	if (isCmdLine)
       
   499 		{
       
   500 		TBuf<100> buf;
       
   501 		TBuf8<64> data;
       
   502 		TLex lex(cmdLineArg->Arg(EArgPassword));
       
   503 		buf=lex.NextToken();
       
   504 		data.Copy(buf);
       
   505 		pop3Settings->SetPasswordL(data);
       
   506 		}
       
   507 	else
       
   508 		{
       
   509 		pop3Settings->SetPasswordL(KPassword);
       
   510 		}
       
   511 
       
   512 	if (isCmdLine)
       
   513 		{
       
   514 		TBuf<100> buf;
       
   515 		TLex lex(cmdLineArg->Arg(EArgPopulationLimit));
       
   516 		buf=lex.NextToken();
       
   517 		TInt limit;
       
   518 		TLex lex2(buf);
       
   519 		lex2.Val(limit);
       
   520 		pop3Settings->SetPopulationLimitL(limit);
       
   521 		}
       
   522 	else
       
   523 		{
       
   524 		TInt populationLimit=40;
       
   525 		pop3Settings->SetPopulationLimitL(populationLimit);
       
   526 		}
       
   527 
       
   528 	
       
   529 	pop3Settings->SetPort(110);
       
   530 	testUtils->iPopClientMtm->SetSettingsL(*pop3Settings);
       
   531 	testUtils->iPopClientMtm->StoreSettingsL();
       
   532 	
       
   533    	TRequestStatus st;
       
   534    	TMsvId s=0;
       
   535    	TMsvPartList retPart=KMsvMessagePartBody;
       
   536    	TUint id=0;
       
   537    	TInt add=0;
       
   538    	
       
   539    	TBuf<1> des;
       
   540    	TBuf8<1> des8;
       
   541 
       
   542 	TRAP_IGNORE(testUtils->iPopClientMtm->SaveMessageL());
       
   543 	TRAP_IGNORE(testUtils->iPopClientMtm->ReplyL(s,retPart,st));
       
   544 	TRAP_IGNORE(testUtils->iPopClientMtm->ForwardL(s,retPart,st));
       
   545 	testUtils->iPopClientMtm->ValidateMessage(retPart);
       
   546 	TRAP_IGNORE(testUtils->iPopClientMtm->AddAddresseeL(des));
       
   547 	TRAP_IGNORE(testUtils->iPopClientMtm->AddAddresseeL(des,des));
       
   548 	testUtils->iPopClientMtm->RemoveAddressee(add);
       
   549 	TRAP_IGNORE(testUtils->iPopClientMtm->AddAttachmentL(des, des8,id,st));
       
   550 	TRAP_IGNORE(testUtils->iPopClientMtm->AddLinkedAttachmentL(des,des8,id,st));
       
   551 	TRAP_IGNORE(testUtils->iPopClientMtm->AddEntryAsAttachmentL(s,st));
       
   552 	TRAP_IGNORE(testUtils->iPopClientMtm->CreateMessageL(s));
       
   553 	TRAP_IGNORE(testUtils->iPopClientMtm->DefaultServiceL());
       
   554 	TRAP_IGNORE(testUtils->iPopClientMtm->RemoveDefaultServiceL());
       
   555 	TRAP_IGNORE(testUtils->iPopClientMtm->ChangeDefaultServiceL(s));
       
   556 	
       
   557 	CleanupStack::PopAndDestroy(pop3Settings);
       
   558 	CleanupStack::PopAndDestroy();	// cmdLineArg
       
   559 	return result;
       
   560 	}
       
   561 
       
   562 LOCAL_C void ConnectToServerL()
       
   563 	{
       
   564 	testUtils->WriteComment(_L("Connecting to the Pop3 server"));
       
   565 	TBuf8<1> aParameter;
       
   566 	msvSelection->ResizeL(0);
       
   567 	msvSelection->AppendL(Pop3Service);
       
   568 	
       
   569 	opActive->iStatus = KRequestPending;
       
   570 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnect, *msvSelection, aParameter, opActive->iStatus);
       
   571 	opActive->SetOperation(msvOperation);
       
   572 	opActive->StartL();	// Start the connect active object
       
   573 	}
       
   574 
       
   575 LOCAL_C void DisconnectFromServerL()
       
   576 	{
       
   577 	testUtils->WriteComment(_L("Disconnecting from the Pop3 server"));
       
   578 	TBuf8<1> aParameter;
       
   579 	msvSelection->ResizeL(0);
       
   580 	msvSelection->AppendL(Pop3Service);
       
   581 	
       
   582 	opActive->iStatus = KRequestPending;
       
   583 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMDisconnect, *msvSelection, aParameter, opActive->iStatus);
       
   584 	opActive->SetOperation(msvOperation);
       
   585 	opActive->StartL();	// Start the disconnect active object
       
   586 	}
       
   587 
       
   588 //
       
   589 // Get Mail when already Connected tests
       
   590 //
       
   591 
       
   592 LOCAL_C void CopyNewMailWhenAlreadyConnectedL()
       
   593 	{
       
   594 	testUtils->WriteComment(_L("Copying New Mail when already connected")); 
       
   595 
       
   596 	msvSelection->ResizeL(0);
       
   597 	msvSelection->AppendL(Pop3Service);
       
   598 	msvSelection->AppendL(0x00100002); // remote inbox
       
   599 	
       
   600 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   601 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   602 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   603 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   604 	
       
   605 	opActive->iStatus = KRequestPending;
       
   606 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCopyNewMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   607 	opActive->SetOperation(msvOperation);
       
   608 	opActive->StartL(ETrue);	// Start the copy new mail active object
       
   609 	}
       
   610 
       
   611 
       
   612 LOCAL_C void MoveNewMailWhenAlreadyConnectedL()
       
   613 	{
       
   614 	testUtils->WriteComment(_L("Moving New Mail when already connected"));
       
   615 	msvSelection->ResizeL(0);
       
   616 	msvSelection->AppendL(Pop3Service);
       
   617 	msvSelection->AppendL(0x00100002);
       
   618 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   619 	Pop3GetMailInfo.iMaxEmailSize=KMaxTInt;
       
   620 	Pop3GetMailInfo.iDestinationFolder= KMsvGlobalInBoxIndexEntryIdValue;
       
   621 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   622 	opActive->iStatus = KRequestPending;
       
   623 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMMoveNewMailWhenAlreadyConnected,*msvSelection,package,opActive->iStatus);
       
   624 	opActive->SetOperation(msvOperation);
       
   625 	opActive->StartL(ETrue);
       
   626 	}
       
   627 
       
   628 
       
   629 LOCAL_C void CopyAllMailWhenAlreadyConnectedL()
       
   630 	{
       
   631 	testUtils->WriteComment(_L("Copying All Mail when already connected")); 
       
   632 
       
   633 	msvSelection->ResizeL(0);
       
   634 	msvSelection->AppendL(Pop3Service);
       
   635 	msvSelection->AppendL(0x00100002); // remote inbox
       
   636 	
       
   637 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   638 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   639 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   640 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   641 	
       
   642 	opActive->iStatus = KRequestPending;
       
   643 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCopyAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   644 	opActive->SetOperation(msvOperation);
       
   645 	opActive->StartL(ETrue);	// Start the copy all mail active object
       
   646 	}
       
   647 
       
   648 
       
   649 LOCAL_C void MoveAllMailWhenAlreadyConnectedL()
       
   650 	{
       
   651 	testUtils->WriteComment(_L("Moving All Mails when already connected"));
       
   652 	msvSelection->ResizeL(0);
       
   653 	msvSelection->AppendL(Pop3Service);
       
   654 	msvSelection->AppendL(0x00100002); // remote inbox
       
   655 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   656 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   657 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   658 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   659 	opActive->iStatus = KRequestPending;
       
   660 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMMoveAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   661 	opActive->SetOperation(msvOperation);
       
   662 	opActive->StartL(ETrue);	
       
   663 	}
       
   664 
       
   665 
       
   666 LOCAL_C void CopyMailSelectionWhenAlreadyConnectedL()
       
   667 	{
       
   668 	testUtils->WriteComment(_L("Copying Mail Selection when already connected")); 
       
   669 
       
   670 	msvSelection->ResizeL(0);
       
   671 	msvSelection->AppendL(Pop3Service);
       
   672 
       
   673 	testUtils->SetEntryL(Pop3Service);
       
   674 	CMsvEntrySelection* sel = testUtils->iMsvEntry->ChildrenL();
       
   675 	CleanupStack::PushL(sel);
       
   676 	if (sel->Count()>1)
       
   677 		{
       
   678 		msvSelection->AppendL((*sel)[0]); 
       
   679 		msvSelection->AppendL((*sel)[1]); 
       
   680 		}
       
   681 	else if (sel->Count())
       
   682 		msvSelection->AppendL((*sel)[0]);
       
   683 	CleanupStack::PopAndDestroy(); //sel
       
   684 	
       
   685 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   686 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   687 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   688 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   689 	
       
   690 	opActive->iStatus = KRequestPending;
       
   691 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCopyMailSelectionWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   692 	opActive->SetOperation(msvOperation);
       
   693 	opActive->StartL(ETrue);	// Start the copy mail selection active object
       
   694 	}
       
   695 
       
   696 
       
   697 LOCAL_C void MoveMailSelectionWhenAlreadyConnectedL()
       
   698 	{
       
   699 	testUtils->WriteComment(_L("Moving Mail Selection when already connected")); 
       
   700 	msvSelection->ResizeL(0);
       
   701 	msvSelection->AppendL(Pop3Service);	//Pop3Service is already set while connecting to the server
       
   702 	testUtils->SetEntryL(Pop3Service);
       
   703 	CMsvEntrySelection* sel = testUtils->iMsvEntry->ChildrenL();
       
   704 	CleanupStack::PushL(sel);
       
   705 	if (sel->Count()>1)
       
   706 		{
       
   707 		msvSelection->AppendL((*sel)[0]); 
       
   708 		msvSelection->AppendL((*sel)[1]); 
       
   709 		}
       
   710 	else if (sel->Count())
       
   711 		msvSelection->AppendL((*sel)[0]);
       
   712 	CleanupStack::PopAndDestroy(); //sel
       
   713 		
       
   714 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   715 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   716 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   717 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   718 	opActive->iStatus = KRequestPending;
       
   719 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMMoveMailSelectionWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   720 	opActive->SetOperation(msvOperation);
       
   721 	opActive->StartL(ETrue);	// Start the move mail selection active object
       
   722 	}
       
   723 
       
   724 
       
   725 //
       
   726 // Connect, Get Mail and Disconnect tests
       
   727 //
       
   728 
       
   729 LOCAL_C void ConnectAndCopyNewMailAndDisconnectL()
       
   730 	{
       
   731 	testUtils->WriteComment(_L("Connect, Copying New Mail, Disconnect")); 
       
   732 
       
   733 	msvSelection->ResizeL(0);
       
   734 	msvSelection->AppendL(Pop3Service);
       
   735 	msvSelection->AppendL(0x00100002); // remote inbox
       
   736 	
       
   737 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   738 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   739 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   740 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   741 	
       
   742 	opActive->iStatus = KRequestPending;
       
   743 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyNewMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   744 	opActive->SetOperation(msvOperation);
       
   745 	opActive->StartL();	// Start the copy new mail active object
       
   746 	}
       
   747 
       
   748 LOCAL_C void ConnectAndMoveNewMailAndDisconnectL()
       
   749 	{
       
   750 	testUtils->WriteComment(_L("Connect, Move New Mail, Disconnect")); 
       
   751 
       
   752 	msvSelection->ResizeL(0);
       
   753 	msvSelection->AppendL(Pop3Service);
       
   754 	msvSelection->AppendL(0x00100002); // remote inbox
       
   755 	
       
   756 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   757 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   758 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   759 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   760 	
       
   761 	opActive->iStatus = KRequestPending;
       
   762 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndMoveNewMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   763 	opActive->SetOperation(msvOperation);
       
   764 	opActive->StartL();	
       
   765 	}
       
   766 
       
   767 LOCAL_C void ConnectAndCopyAllMailAndDisconnectL()
       
   768 	{
       
   769 	testUtils->WriteComment(_L("Connect, Copying All Mail, Disconnect")); 
       
   770 
       
   771 	msvSelection->ResizeL(0);
       
   772 	msvSelection->AppendL(Pop3Service);
       
   773 	msvSelection->AppendL(0x00100002); // remote inbox
       
   774 	
       
   775 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   776 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   777 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   778 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   779 	
       
   780 	opActive->iStatus = KRequestPending;
       
   781 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyAllMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   782 	opActive->SetOperation(msvOperation);
       
   783 	opActive->StartL();	// Start the copy all mail active object
       
   784 	}
       
   785 
       
   786 
       
   787 LOCAL_C void ConnectAndMoveAllMailAndDisconnectL()
       
   788 	{
       
   789 	testUtils->WriteComment(_L("Connect, Moving All Mail, Disconnect")); 
       
   790 
       
   791 	msvSelection->ResizeL(0);
       
   792 	msvSelection->AppendL(Pop3Service);
       
   793 	msvSelection->AppendL(0x00100002); // remote inbox
       
   794 	
       
   795 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   796 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   797 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   798 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   799 	
       
   800 	opActive->iStatus = KRequestPending;
       
   801 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndMoveAllMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   802 	opActive->SetOperation(msvOperation);
       
   803 	opActive->StartL();	
       
   804 	}
       
   805 
       
   806 
       
   807 
       
   808 
       
   809 
       
   810 LOCAL_C void ConnectAndCopyMailSelectionAndDisconnectL(TBool aEmptyMessageSelection = EFalse)
       
   811 	{
       
   812 	testUtils->WriteComment(_L("Connect, Copying Mail Selection, Disconnect")); 
       
   813 
       
   814 	msvSelection->ResizeL(0);
       
   815 	msvSelection->AppendL(Pop3Service);
       
   816 
       
   817 	if (!aEmptyMessageSelection)
       
   818 		{
       
   819 		testUtils->SetEntryL(Pop3Service);
       
   820 		CMsvEntrySelection* sel = testUtils->iMsvEntry->ChildrenL();
       
   821 		CleanupStack::PushL(sel);
       
   822 		if (sel->Count()>1)
       
   823 			{
       
   824 			msvSelection->AppendL((*sel)[0]); 
       
   825 			msvSelection->AppendL((*sel)[1]); 
       
   826 			}
       
   827 		else if (sel->Count())
       
   828 			msvSelection->AppendL((*sel)[0]);
       
   829 		CleanupStack::PopAndDestroy(); //sel
       
   830 		}
       
   831 	
       
   832 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   833 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   834 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   835 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   836 	
       
   837 	opActive->iStatus = KRequestPending;
       
   838 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyMailSelectionAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   839 	opActive->SetOperation(msvOperation);
       
   840 	opActive->StartL();	// Start the copy all mail active object
       
   841 	}
       
   842 
       
   843 
       
   844 LOCAL_C void ConnectAndMoveMailSelectionAndDisconnectL(TBool aEmptyMessageSelection = EFalse)
       
   845 	{
       
   846 	testUtils->WriteComment(_L("Connect, Move Mail Selection, Disconnect")); 
       
   847 
       
   848 	msvSelection->ResizeL(0);
       
   849 	msvSelection->AppendL(Pop3Service);
       
   850 
       
   851 	if (!aEmptyMessageSelection)
       
   852 		{
       
   853 		testUtils->SetEntryL(Pop3Service);
       
   854 		CMsvEntrySelection* sel = testUtils->iMsvEntry->ChildrenL();
       
   855 		CleanupStack::PushL(sel);
       
   856 		if (sel->Count()>1)
       
   857 			{
       
   858 			msvSelection->AppendL((*sel)[0]); 
       
   859 			msvSelection->AppendL((*sel)[1]); 
       
   860 			}
       
   861 		else if (sel->Count())
       
   862 			msvSelection->AppendL((*sel)[0]);
       
   863 		CleanupStack::PopAndDestroy(); //sel
       
   864 		}
       
   865 	
       
   866 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   867 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   868 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   869 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   870 	
       
   871 	opActive->iStatus = KRequestPending;
       
   872 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndMoveMailSelectionAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   873 	opActive->SetOperation(msvOperation);
       
   874 	opActive->StartL();
       
   875 	}
       
   876 
       
   877 //
       
   878 // Connect, Get Mail and Stay Online tests
       
   879 //
       
   880 
       
   881 LOCAL_C void ConnectAndCopyNewMailAndStayOnlineL()
       
   882 	{
       
   883 	testUtils->WriteComment(_L("Connect, Copying New Mail, Stay Online")); 
       
   884 
       
   885 	msvSelection->ResizeL(0);
       
   886 	msvSelection->AppendL(Pop3Service);
       
   887 	msvSelection->AppendL(0x00100002); // remote inbox
       
   888 	
       
   889 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   890 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   891 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   892 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   893 	
       
   894 	opActive->iStatus = KRequestPending;
       
   895 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyNewMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   896 	opActive->SetOperation(msvOperation);
       
   897 	opActive->StartL();	// Start the copy new mail active object
       
   898 	}
       
   899 
       
   900 
       
   901 LOCAL_C void ConnectAndMoveNewMailAndStayOnlineL()
       
   902 	{
       
   903 	testUtils->WriteComment(_L("Connect, Moving New Mail, Stay Online"));
       
   904 	msvSelection->ResizeL(0);
       
   905 	msvSelection->AppendL(Pop3Service);
       
   906 	msvSelection->AppendL(0x00100002); // remote inbox
       
   907 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   908 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   909 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   910 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   911 	opActive->iStatus = KRequestPending;
       
   912 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndMoveNewMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   913 	opActive->SetOperation(msvOperation);
       
   914 	opActive->StartL();
       
   915 	}
       
   916 
       
   917 LOCAL_C void ConnectAndCopyAllMailAndStayOnlineL()
       
   918 	{
       
   919 	testUtils->WriteComment(_L("Connect, Copying All Mail, Stay Online")); 
       
   920 
       
   921 	msvSelection->ResizeL(0);
       
   922 	msvSelection->AppendL(Pop3Service);
       
   923 	msvSelection->AppendL(0x00100002); // remote inbox
       
   924 	
       
   925 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   926 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   927 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   928 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   929 	
       
   930 	opActive->iStatus = KRequestPending;
       
   931 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyAllMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   932 	opActive->SetOperation(msvOperation);
       
   933 	opActive->StartL();	// Start the copy all mail active object
       
   934 	}
       
   935 
       
   936 
       
   937 LOCAL_C void ConnectAndMoveAllMailAndStayOnlineL()
       
   938 	{
       
   939 	testUtils->WriteComment(_L("Connect, Move All Mail, Stay Online")); 
       
   940 
       
   941 	msvSelection->ResizeL(0);
       
   942 	msvSelection->AppendL(Pop3Service);
       
   943 	msvSelection->AppendL(0x00100002); // remote inbox
       
   944 	
       
   945 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   946 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   947 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   948 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   949 	
       
   950 	opActive->iStatus = KRequestPending;
       
   951 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndMoveAllMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   952 	opActive->SetOperation(msvOperation);
       
   953 	opActive->StartL();	
       
   954 	}
       
   955 
       
   956 
       
   957 LOCAL_C void ConnectAndCopyMailSelectionAndStayOnlineL()
       
   958 	{
       
   959 	testUtils->WriteComment(_L("Connect, Copying Mail Selection, Stay Online")); 
       
   960 
       
   961 	msvSelection->ResizeL(0);
       
   962 	msvSelection->AppendL(Pop3Service);
       
   963 
       
   964 	testUtils->SetEntryL(Pop3Service);
       
   965 	CMsvEntrySelection* sel = testUtils->iMsvEntry->ChildrenL();
       
   966 	CleanupStack::PushL(sel);
       
   967 	if (sel->Count()>1)
       
   968 		{
       
   969 		msvSelection->AppendL((*sel)[0]); 
       
   970 		msvSelection->AppendL((*sel)[1]); 
       
   971 		}
       
   972 	else if (sel->Count())
       
   973 		msvSelection->AppendL((*sel)[0]);
       
   974 	CleanupStack::PopAndDestroy(); //sel
       
   975 	
       
   976 	TImPop3GetMailInfo Pop3GetMailInfo;
       
   977 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   978 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   979 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
   980 	
       
   981 	opActive->iStatus = KRequestPending;
       
   982 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyMailSelectionAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   983 	opActive->SetOperation(msvOperation);
       
   984 	opActive->StartL();	// Start the copy message selection active object
       
   985 	}
       
   986 
       
   987 LOCAL_C void ConnectAndMoveMailSelectionAndStayOnlineL()
       
   988 	{
       
   989 	testUtils->WriteComment(_L("Connect, Move Mail Selection, Stay Online")); 
       
   990 
       
   991 	msvSelection->ResizeL(0);
       
   992 	msvSelection->AppendL(Pop3Service);
       
   993 
       
   994 	testUtils->SetEntryL(Pop3Service);
       
   995 	CMsvEntrySelection* sel = testUtils->iMsvEntry->ChildrenL();
       
   996 	CleanupStack::PushL(sel);
       
   997 	if (sel->Count()>1)
       
   998 		{
       
   999 		msvSelection->AppendL((*sel)[0]); 
       
  1000 		msvSelection->AppendL((*sel)[1]); 
       
  1001 		}
       
  1002 	else if (sel->Count())
       
  1003 		msvSelection->AppendL((*sel)[0]);
       
  1004 	CleanupStack::PopAndDestroy(); //sel
       
  1005 	
       
  1006 	TImPop3GetMailInfo Pop3GetMailInfo;
       
  1007 	Pop3GetMailInfo.iMaxEmailSize = KMaxTInt;
       
  1008 	Pop3GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
  1009 	TPckgBuf<TImPop3GetMailInfo> package(Pop3GetMailInfo);
       
  1010 	
       
  1011 	opActive->iStatus = KRequestPending;
       
  1012 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndMoveMailSelectionAndStayOnline, *msvSelection, package, opActive->iStatus);
       
  1013 	opActive->SetOperation(msvOperation);
       
  1014 	opActive->StartL();	
       
  1015 	}
       
  1016 
       
  1017 
       
  1018 //
       
  1019 
       
  1020 LOCAL_C void ConnectAndDisconnectL()
       
  1021 	{
       
  1022 	console->SetPos(0, 6);
       
  1023 	test.Printf(_L("\nPerforming Tests\n"));
       
  1024 	console->SetPos(0, 7);
       
  1025 	test.Printf(_L("Connecting to Pop server                        \n"));
       
  1026 	ConnectToServerL();
       
  1027 	CActiveScheduler::Start();
       
  1028 
       
  1029 	CleanupStack::PopAndDestroy(); // opActive
       
  1030 	opActive = COperationActive::NewL();
       
  1031 	CleanupStack::PushL(opActive);
       
  1032 	console->SetPos(0, 7);
       
  1033 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1034 	DisconnectFromServerL();
       
  1035 	CActiveScheduler::Start();
       
  1036 	}
       
  1037 
       
  1038 //
       
  1039 
       
  1040 
       
  1041 LOCAL_C void CreateReplyEmailMessage()
       
  1042 	{
       
  1043 	testUtils->WriteComment(_L("Creating a Reply Email Message"));
       
  1044 	msvSelection->ResizeL(0);
       
  1045 	
       
  1046 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1047 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
  1048 	//CleanupStack::PushL(messageSelection);
       
  1049 	msvSelection->AppendL(KMsvGlobalOutBoxIndexEntryId); //destination id
       
  1050 	msvSelection->AppendL(messageSelection->At(5)); // message id to which the reply is to be assigned
       
  1051 	//CleanupStack::PopAndDestroy(); 	 //messageSelection
       
  1052 	
       
  1053 	//create an object of type TImCreateMessageOptions
       
  1054 	TImCreateMessageOptions Pop3CreateMessage;
       
  1055 	
       
  1056 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
  1057 	Pop3CreateMessage.iMsvPartList = KMsvMessagePartBody;
       
  1058 	Pop3CreateMessage.iMsvEmailTypeList = 0;
       
  1059 	Pop3CreateMessage.iMessageType = KUidMsgTypeSMTP;
       
  1060 	TPckgBuf<TImCreateMessageOptions> package(Pop3CreateMessage);
       
  1061 	
       
  1062 	//set the status
       
  1063 	opActive->iStatus = KRequestPending;
       
  1064 	
       
  1065 	//invoke the func InvokeAsyncFunctionL()
       
  1066 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCreateReplyEmailMessage, *msvSelection, package, opActive->iStatus);
       
  1067 	
       
  1068 	//start the operation
       
  1069 	opActive->SetOperation(msvOperation);
       
  1070 	opActive->StartL(ETrue);	
       
  1071 	delete messageSelection;
       
  1072 	}
       
  1073 
       
  1074 
       
  1075 LOCAL_C void CreateForwardEmailMessage()
       
  1076 	{
       
  1077 	testUtils->WriteComment(_L("Creating a Forward Email Message"));
       
  1078 	msvSelection->ResizeL(0);
       
  1079 	
       
  1080 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1081 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
  1082 	msvSelection->AppendL(KMsvGlobalOutBoxIndexEntryId); //destination id
       
  1083 	msvSelection->AppendL(messageSelection->At(5)); // message id to which the reply is to be assigned
       
  1084 		
       
  1085 	//create an object of type TImCreateMessageOptions
       
  1086 	TImCreateMessageOptions Pop3CreateMessage;
       
  1087 	
       
  1088 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
  1089 	Pop3CreateMessage.iMsvPartList = KMsvMessagePartBody;
       
  1090 	Pop3CreateMessage.iMsvEmailTypeList = 0;
       
  1091 	Pop3CreateMessage.iMessageType = KUidMsgTypeSMTP;
       
  1092 	TPckgBuf<TImCreateMessageOptions> package(Pop3CreateMessage);
       
  1093 	
       
  1094 	//set the status
       
  1095 	opActive->iStatus = KRequestPending;
       
  1096 	
       
  1097 	//invoke the func InvokeAsyncFunctionL()
       
  1098 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCreateForwardEmailMessage, *msvSelection, package, opActive->iStatus);
       
  1099 	
       
  1100 	//start the operation
       
  1101 	opActive->SetOperation(msvOperation);
       
  1102 	opActive->StartL(ETrue);	
       
  1103 	delete messageSelection;
       
  1104 	}
       
  1105 
       
  1106 
       
  1107 LOCAL_C void CreateForwardAsAttachmentEmailMessage()
       
  1108 	{
       
  1109 	testUtils->WriteComment(_L("Creating a Forward As Attachment Email Message"));
       
  1110 	msvSelection->ResizeL(0);
       
  1111 	
       
  1112 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1113 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
  1114 	
       
  1115 	msvSelection->AppendL(Pop3Service); //destination id
       
  1116 	msvSelection->AppendL(messageSelection->At(1)); // message id to which the reply is to be assigned
       
  1117 	
       
  1118 	
       
  1119 	//create an object of type TImCreateMessageOptions
       
  1120 	TImCreateMessageOptions Pop3CreateMessage;
       
  1121 	
       
  1122 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
  1123 	Pop3CreateMessage.iMsvPartList =KMsvMessagePartBody | KMsvMessagePartAttachments;
       
  1124 	Pop3CreateMessage.iMsvEmailTypeList = KMsvEmailTypeListMHTMLMessage;
       
  1125 	Pop3CreateMessage.iMessageType = KUidMsgTypeSMTP;
       
  1126 	TPckgBuf<TImCreateMessageOptions> package(Pop3CreateMessage);
       
  1127 	
       
  1128 	//set the status
       
  1129 	opActive->iStatus = KRequestPending;
       
  1130 	
       
  1131 	//invoke the func InvokeAsyncFunctionL()
       
  1132 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCreateForwardAsAttachmentEmailMessage, *msvSelection, package, opActive->iStatus);
       
  1133 	
       
  1134 	//start the operation
       
  1135 	opActive->SetOperation(msvOperation);
       
  1136 	opActive->StartL(ETrue);	
       
  1137 	delete messageSelection;
       
  1138 	}
       
  1139 
       
  1140 
       
  1141 LOCAL_C void CreateReceiptEmailMessage()
       
  1142 	{
       
  1143 	testUtils->WriteComment(_L("Creating a Receipt Email Message"));
       
  1144 	msvSelection->ResizeL(0);
       
  1145 	
       
  1146 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1147 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
  1148 	
       
  1149 	msvSelection->AppendL(KMsvGlobalOutBoxIndexEntryId); //destination id
       
  1150 	msvSelection->AppendL(messageSelection->At(5)); // message id 
       
  1151 	
       
  1152 	
       
  1153 	//create an object of type TImCreateMessageOptions
       
  1154 	TImCreateMessageOptions Pop3CreateMessage;
       
  1155 	
       
  1156 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
  1157 	Pop3CreateMessage.iMsvPartList = KMsvMessagePartBody;
       
  1158 	Pop3CreateMessage.iMsvEmailTypeList = 0;
       
  1159 	Pop3CreateMessage.iMessageType = KUidMsgTypeSMTP;
       
  1160 	TPckgBuf<TImCreateMessageOptions> package(Pop3CreateMessage);
       
  1161 	
       
  1162 	//set the status
       
  1163 	opActive->iStatus = KRequestPending;
       
  1164 	
       
  1165 	//invoke the func InvokeAsyncFunctionL()
       
  1166 	msvOperation = testUtils->iPopClientMtm->InvokeAsyncFunctionL(KPOP3MTMCreateReceiptEmailMessage, *msvSelection, package, opActive->iStatus);
       
  1167 	
       
  1168 	//start the operation
       
  1169 	opActive->SetOperation(msvOperation);
       
  1170 	opActive->StartL(ETrue);	
       
  1171 	delete messageSelection;
       
  1172 	}
       
  1173 
       
  1174 
       
  1175 LOCAL_C void TestCapabilityL()
       
  1176 	{
       
  1177 	TInt response = 0;
       
  1178 	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQuerySupportedBody, response) == KErrNone);
       
  1179 	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQuerySupportAttachments, response) == KErrNone);
       
  1180 //	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQuerySupportSubject, response) == KErrNone);
       
  1181 //	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQuerySupportsFolder, response) == KErrNotSupported);
       
  1182 //	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQueryOffLineAllowed, response) == KErrNotSupported);
       
  1183 	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQueryCanSendMsg, response) == KErrNotSupported);
       
  1184 	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQueryCanReceiveMsg, response) == KErrNone);
       
  1185 	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQuerySendAsRequiresRenderedImage, response) == KErrNotSupported);
       
  1186 	test(testUtils->iPopClientMtm->QueryCapability(KUidMtmQueryMaxRecipientCount, response) == KErrNotSupported);
       
  1187 	}
       
  1188 
       
  1189 LOCAL_C void DeleteAndCreateServicesL()
       
  1190 	{
       
  1191 	// Handle command line arguments
       
  1192 	CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC();
       
  1193 	TInt count = cmdLineArg->Count();
       
  1194 	TBool isCmdLine=FALSE;
       
  1195 	if (count>2)	// Command line arguments?
       
  1196 		{
       
  1197 		if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd)
       
  1198 			isCmdLine=TRUE;
       
  1199 		}	
       
  1200 
       
  1201 	// delete services
       
  1202 	testUtils->iMsvEntry->SetEntryL(KMsvRootIndexEntryId);
       
  1203 	testUtils->iMsvEntry->DeleteL(Pop3Service);
       
  1204 	testUtils->iMsvEntry->DeleteL(smtpService);
       
  1205 
       
  1206 	// Create Services
       
  1207 	smtpService = testUtils->CreateSmtpServiceL();
       
  1208 	Pop3Service = testUtils->CreatePopServiceL();
       
  1209 
       
  1210 	testUtils->iMsvEntry->SetEntryL(Pop3Service);
       
  1211 
       
  1212 //	TUint32 iap=0;
       
  1213 //	CCommsDatabase* db =CCommsDatabase::NewL();
       
  1214 //	CleanupStack::PushL(db);
       
  1215 //	db->GetGlobalSettingL(TPtrC(DIAL_OUT_IAP),iap);
       
  1216 //	CleanupStack::PopAndDestroy(); //db
       
  1217 
       
  1218 	//overwrite the settings with test code one.  Don't want the default settings.
       
  1219 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
  1220 
       
  1221 	CImPop3Settings* settings = new(ELeave) CImPop3Settings();
       
  1222 	CleanupStack::PushL(settings);
       
  1223 	settings->Reset();
       
  1224 
       
  1225 	if (isCmdLine)
       
  1226 		{
       
  1227 		TBuf<100> buf;
       
  1228 		TLex lex(cmdLineArg->Arg(EArgServerAddress));
       
  1229 		buf=lex.NextToken();
       
  1230 		settings->SetServerAddressL(buf);
       
  1231 		}
       
  1232 	else
       
  1233 		{
       
  1234 		settings->SetServerAddressL(KServer);
       
  1235 		}
       
  1236 
       
  1237 	if (isCmdLine)
       
  1238 		{
       
  1239 		TBuf<100> buf;
       
  1240 		TBuf8<64> data;
       
  1241 		TLex lex(cmdLineArg->Arg(EArgLogin));
       
  1242 		buf=lex.NextToken();
       
  1243 		data.Copy(buf);
       
  1244 		settings->SetLoginNameL(data);
       
  1245 		}
       
  1246 	else
       
  1247 		{
       
  1248 		settings->SetLoginNameL(KLoginName);
       
  1249 		}
       
  1250 
       
  1251 	if (isCmdLine)
       
  1252 		{
       
  1253 		TBuf<100> buf;
       
  1254 		TBuf8<64> data;
       
  1255 		TLex lex(cmdLineArg->Arg(EArgPassword));
       
  1256 		buf=lex.NextToken();
       
  1257 		data.Copy(buf);
       
  1258 		settings->SetPasswordL(data);
       
  1259 		}
       
  1260 	else
       
  1261 		{
       
  1262 		settings->SetPasswordL(KPassword);
       
  1263 		}
       
  1264 	
       
  1265 	settings->SetPort(110);
       
  1266 	TPopAccount pop3AccountId;
       
  1267 	accounts->GetPopAccountL(Pop3Service, pop3AccountId);
       
  1268 	accounts->SavePopSettingsL( pop3AccountId, *settings);
       
  1269 	
       
  1270 	CleanupStack::PopAndDestroy(2); //settings, store/accounts
       
  1271 	CleanupStack::PopAndDestroy();	// cmdLineArg
       
  1272 	}
       
  1273 
       
  1274 LOCAL_C void InitL()
       
  1275 	{
       
  1276 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
  1277 	CActiveScheduler::Install(scheduler);
       
  1278 	CleanupStack::PushL(scheduler);
       
  1279 
       
  1280 	testUtils = CEmailTestUtils::NewLC(test);
       
  1281 	console = test.Console();
       
  1282 	testUtils->FileSession().SetSessionPath(_L("C:\\"));
       
  1283 	testUtils->CleanMessageFolderL();
       
  1284 	testUtils->ClearEmailAccountsL();
       
  1285 	// Create Services
       
  1286 	testUtils->GoClientSideL();
       
  1287 	testUtils->ClearEmailAccountsL();
       
  1288 	smtpService = testUtils->CreateSmtpServiceL();
       
  1289 	Pop3Service = testUtils->CreatePopServiceL();
       
  1290 	testUtils->GoServerSideL();
       
  1291 	
       
  1292 	console->SetPos(0, 3);
       
  1293 	test.Printf(_L("Create Data Component FileStores"));
       
  1294 	testUtils->CreateSmtpServerMtmRegL();
       
  1295 	testUtils->CreatePopServerMtmRegL();
       
  1296 
       
  1297 	// Load the DLLs
       
  1298 	testUtils->CreateRegistryObjectAndControlL();
       
  1299 	testUtils->InstallSmtpMtmGroupL();
       
  1300 	testUtils->InstallPopMtmGroupL();
       
  1301 
       
  1302 	// Create Services
       
  1303 
       
  1304 	testUtils->WriteComment(_L("********** T_POPC Test CImPop3GetMail class **********"));
       
  1305 
       
  1306 	}
       
  1307 	
       
  1308 LOCAL_C void Closedown()
       
  1309 	{
       
  1310 	// mkn testUtils->WriteComment(_L("**********      T_POPC Tests Complete      **********"));
       
  1311 
       
  1312 	CleanupStack::PopAndDestroy(2);  //testUtils, scheduler
       
  1313 	}
       
  1314 
       
  1315 //
       
  1316 
       
  1317 LOCAL_C TPtrC Progress(TInt progressNumber)
       
  1318 	{
       
  1319 	switch (progressNumber)
       
  1320 		{
       
  1321 		case 0:
       
  1322 			return _L("Refreshing              ");
       
  1323 		case 1:
       
  1324 			return _L("Copying                 ");
       
  1325 		case 2:
       
  1326 			return _L("Deleting                ");
       
  1327 		case 3:
       
  1328 			return _L("Connecting              ");
       
  1329 		case 4:
       
  1330 			return _L("Tidying                 ");
       
  1331 		case 5:
       
  1332 			return _L("Connected and Idle      ");
       
  1333 		case 6:
       
  1334 			return _L("Disconnecting           ");
       
  1335 		case 7:
       
  1336 			return _L("Disconnected            ");
       
  1337 		case 8:
       
  1338 			return _L("Moving                  ");
       
  1339 		case 9:
       
  1340 			return _L("Copying New Mail        ");
       
  1341 		case 10:
       
  1342 			return _L("Moving New Mail         ");
       
  1343 		case 11:
       
  1344 			return _L("Copying Mail Selection  ");
       
  1345 		case 12:
       
  1346 			return _L("Moving Mail Selection   ");
       
  1347 		case 13:
       
  1348 			return _L("Copying All Mail        ");
       
  1349 		case 14:
       
  1350 			return _L("Moving All Mail         ");
       
  1351 		default:
       
  1352 			return _L("Unknown Progress        ");
       
  1353 		}
       
  1354 	}
       
  1355 
       
  1356 LOCAL_C void doMainL()
       
  1357 	{
       
  1358 	InitL();
       
  1359 	testUtils->FileSession().SetSessionPath(_L("c:\\"));
       
  1360 
       
  1361 	testUtils->CreateMessageFilesL(Pop3Service, KMsvGlobalInBoxIndexEntryId, _L("c:\\mailtest\\IMCM\\"));
       
  1362 	// Load the serial comms device drivers.  If this is not done,
       
  1363 	// connecting via NT-RAS returns KErrNotFound (-1).
       
  1364 	TInt driverErr;
       
  1365 	driverErr=User::LoadPhysicalDevice(PDD_NAME);
       
  1366 	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
       
  1367 		User::Leave(driverErr);
       
  1368 	driverErr=User::LoadLogicalDevice(LDD_NAME);
       
  1369 	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
       
  1370 		User::Leave(driverErr);
       
  1371 
       
  1372 	// Delete any *.scr files in c:\logs\email directory.
       
  1373 	testUtils->DeleteScriptFilesFromLogsDirL();
       
  1374 
       
  1375 	// Instantiate the Pop3 Client MTM
       
  1376 	testUtils->GoClientSideL();
       
  1377 
       
  1378 	testUtils->iMsvEntry->SetEntryL(Pop3Service);
       
  1379 
       
  1380 	TMsvEntry entry=testUtils->iMsvEntry->Entry();
       
  1381 	testUtils->iMsvEntry->ChangeL(entry);
       
  1382 
       
  1383 	// Handle command line arguments
       
  1384 	CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC();
       
  1385 	TInt count = cmdLineArg->Count();
       
  1386 	TBool isCmdLine=FALSE;
       
  1387 	if (count>2)	// Command line arguments?
       
  1388 		{
       
  1389 		if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd)
       
  1390 			isCmdLine=TRUE;
       
  1391 		}	
       
  1392 
       
  1393 	//overwrite the settings with test code one.  Don't want the default settings.
       
  1394 	CImPop3Settings* settings = new(ELeave) CImPop3Settings();
       
  1395 	CleanupStack::PushL(settings);
       
  1396 
       
  1397 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
  1398 	
       
  1399 	TPopAccount pop3AccountId;
       
  1400 	accounts->GetPopAccountL(Pop3Service, pop3AccountId);
       
  1401 	accounts->LoadPopSettingsL(pop3AccountId, *settings);
       
  1402 
       
  1403 	if (isCmdLine)
       
  1404 		{
       
  1405 		TBuf<100> buf;
       
  1406 		TLex lex(cmdLineArg->Arg(EArgServerAddress));
       
  1407 		buf=lex.NextToken();
       
  1408 		test.Printf(_L("Server address: %S\n"),&buf);
       
  1409 		settings->SetServerAddressL(buf);
       
  1410 		}
       
  1411 	else
       
  1412 		{
       
  1413 		settings->SetServerAddressL(KServer);
       
  1414 		}
       
  1415 
       
  1416 	if (isCmdLine)
       
  1417 		{
       
  1418 		TBuf<100> buf;
       
  1419 		TBuf8<64> data;
       
  1420 		TLex lex(cmdLineArg->Arg(EArgLogin));
       
  1421 		buf=lex.NextToken();
       
  1422 		test.Printf(_L("Login: %S\n"),&buf);
       
  1423 		data.Copy(buf);
       
  1424 		settings->SetLoginNameL(data);
       
  1425 		}
       
  1426 	else
       
  1427 		{
       
  1428 		settings->SetLoginNameL(KLoginName);
       
  1429 		}
       
  1430 
       
  1431 	if (isCmdLine)
       
  1432 		{
       
  1433 		TBuf<100> buf;
       
  1434 		TBuf8<64> data;
       
  1435 		TLex lex(cmdLineArg->Arg(EArgPassword));
       
  1436 		buf=lex.NextToken();
       
  1437 		test.Printf(_L("Password: %S\n"),&buf);
       
  1438 		data.Copy(buf);
       
  1439 		settings->SetPasswordL(data);
       
  1440 		}
       
  1441 	else
       
  1442 		{
       
  1443 		settings->SetPasswordL(KPassword);
       
  1444 		}
       
  1445 
       
  1446 	if (isCmdLine)
       
  1447 		{
       
  1448 		TBuf<100> buf;
       
  1449 		TLex lex(cmdLineArg->Arg(EArgPopulationLimit));
       
  1450 		buf=lex.NextToken();
       
  1451 		TInt limit;
       
  1452 		TLex lex2(buf);
       
  1453 		lex2.Val(limit);
       
  1454 		settings->SetPopulationLimitL(limit);
       
  1455 		}
       
  1456 	else
       
  1457 		{
       
  1458 		TInt populationLimit=40;
       
  1459 		settings->SetPopulationLimitL(populationLimit);
       
  1460 		}
       
  1461 	
       
  1462 	settings->SetPort(110);
       
  1463 	accounts->SavePopSettingsL(pop3AccountId, *settings);
       
  1464 	CleanupStack::PopAndDestroy(2); // store/accounts, settings
       
  1465 	CleanupStack::PopAndDestroy();	// cmdLineArg
       
  1466 
       
  1467 	console->SetPos(0, 3);
       
  1468 	test.Printf(_L("Instantiating POP3 Client MTM"));
       
  1469 	testUtils->InstantiatePopClientMtmL();
       
  1470 	testUtils->WriteComment(_L("Instantiated POP3 Client MTM"));
       
  1471 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1472 	CleanupStack::PushL(msvSelection);
       
  1473 
       
  1474 	// Check that CPop3ClientMtm::StoreSettingsL() really works.
       
  1475 	testUtils->TestStart(testNo++);
       
  1476 	console->SetPos(0, 7);
       
  1477 	test.Printf(_L("Storing settings								 \n"));
       
  1478 	StoreClientSettingsL();
       
  1479 	TInt result = VerifyStoredClientSettingsL();
       
  1480 	test(result == KErrNone);
       
  1481 	testUtils->TestFinish(testNo-1);
       
  1482 
       
  1483 	// Copy New Mail when already connected to server
       
  1484 	testUtils->TestStart(testNo++);
       
  1485 	opActive = COperationActive::NewL();
       
  1486 	CleanupStack::PushL(opActive);
       
  1487 	console->SetPos(0, 7);
       
  1488 	test.Printf(_L("Connecting to Pop server                         \n"));
       
  1489 	ConnectToServerL();
       
  1490 	CActiveScheduler::Start();
       
  1491 
       
  1492 	
       
  1493 	
       
  1494 	CleanupStack::PopAndDestroy(); // opActive
       
  1495 	opActive = COperationActive::NewL();
       
  1496 	CleanupStack::PushL(opActive);
       
  1497 	console->SetPos(0, 7);
       
  1498 	test.Printf(_L("Copy New Mail when already connected to server   \n"));
       
  1499 	CopyNewMailWhenAlreadyConnectedL();
       
  1500 	CActiveScheduler::Start();
       
  1501 
       
  1502 	CleanupStack::PopAndDestroy(); // opActive
       
  1503 	opActive = COperationActive::NewL();
       
  1504 	CleanupStack::PushL(opActive);
       
  1505 	console->SetPos(0, 7);
       
  1506 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1507 	DisconnectFromServerL();
       
  1508 	iDoCancel = ETrue;
       
  1509 	CActiveScheduler::Start();
       
  1510 	iDoCancel = EFalse;
       
  1511 
       
  1512 		{
       
  1513 	// wait 5 seconds so that user can see the final progess!
       
  1514 	CTestTimer* timer = CTestTimer::NewL();
       
  1515 	timer->After(10000000);
       
  1516 	CActiveScheduler::Start();  
       
  1517 	delete timer;
       
  1518 		}
       
  1519 		
       
  1520 		
       
  1521 	testUtils->TestFinish(testNo-1);
       
  1522 	
       
  1523 	// cleanup for next test
       
  1524 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1525 	DeleteAndCreateServicesL();
       
  1526 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1527 
       
  1528 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1529 	CleanupStack::PushL(msvSelection);
       
  1530 
       
  1531 	
       
  1532 	testUtils->TestStart(testNo++);
       
  1533 	/*Step1: Connect to the POP3 server*/
       
  1534 	opActive = COperationActive::NewL();
       
  1535 	CleanupStack::PushL(opActive);
       
  1536 	console->SetPos(0,7);
       
  1537 	test.Printf(_L("Connecting to Pop server\n"));
       
  1538 	ConnectToServerL();
       
  1539 	CActiveScheduler::Start();
       
  1540 	
       
  1541 	CleanupStack::PopAndDestroy();	//opActive
       
  1542 	
       
  1543 	/*Step2: Move new mails*/
       
  1544 	opActive =  COperationActive::NewL();
       
  1545 	CleanupStack::PushL(opActive);
       
  1546 	console->SetPos(0,7);
       
  1547 	test.Printf(_L("Move new mail when already connected to server  \n"));
       
  1548 	MoveNewMailWhenAlreadyConnectedL();	
       
  1549 	CActiveScheduler::Start();
       
  1550 	
       
  1551 	CleanupStack::PopAndDestroy();	//opActive
       
  1552 	
       
  1553 	/*Step 3: Disconnect from the server */
       
  1554 	opActive = COperationActive::NewL();
       
  1555 	CleanupStack::PushL(opActive);
       
  1556 	console->SetPos(0,7);
       
  1557 	test.Printf(_L("Disconnecting from server\n"));
       
  1558 	DisconnectFromServerL();
       
  1559 	CActiveScheduler::Start();
       
  1560 	
       
  1561 	testUtils->TestFinish(testNo-1);
       
  1562 	//cleanup for next test
       
  1563 	CleanupStack::PopAndDestroy(2);  //opActive, msvSelection
       
  1564 	DeleteAndCreateServicesL();
       
  1565 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1566 
       
  1567 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1568 	CleanupStack::PushL(msvSelection);
       
  1569 
       
  1570 	
       
  1571 	testUtils->TestStart(testNo++);
       
  1572 	// Copy All Mail when already connected to server
       
  1573 	opActive = COperationActive::NewL();
       
  1574 	CleanupStack::PushL(opActive);
       
  1575 	console->SetPos(0, 7);
       
  1576 	test.Printf(_L("Connecting to Pop server                        \n"));
       
  1577 	ConnectToServerL();
       
  1578 	CActiveScheduler::Start();
       
  1579 
       
  1580 	CleanupStack::PopAndDestroy(); // opActive
       
  1581 	opActive = COperationActive::NewL();
       
  1582 	CleanupStack::PushL(opActive);
       
  1583 	console->SetPos(0, 7);  
       
  1584 	test.Printf(_L("Copy All Mail when already connected to server   \n"));
       
  1585 	CopyAllMailWhenAlreadyConnectedL();
       
  1586 	CActiveScheduler::Start();
       
  1587 	
       
  1588 	CleanupStack::PopAndDestroy(); // opActive
       
  1589 	opActive = COperationActive::NewL();
       
  1590 	CleanupStack::PushL(opActive);
       
  1591 	console->SetPos(0, 7);
       
  1592 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1593 	DisconnectFromServerL();
       
  1594 	CActiveScheduler::Start();
       
  1595 
       
  1596 	testUtils->TestFinish(testNo-1);
       
  1597 
       
  1598   	// cleanup for next test
       
  1599 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1600 	DeleteAndCreateServicesL();
       
  1601 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1602 
       
  1603 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1604 	CleanupStack::PushL(msvSelection);
       
  1605 
       
  1606 
       
  1607 	testUtils->TestStart(testNo++);
       
  1608 	// Step 1: connect to server
       
  1609 	opActive = COperationActive::NewL();
       
  1610 	CleanupStack::PushL(opActive);
       
  1611 	console->SetPos(0, 7);
       
  1612 	test.Printf(_L("Connecting to Pop server                        \n"));
       
  1613 	ConnectToServerL();
       
  1614 	CActiveScheduler::Start();
       
  1615 
       
  1616 	//Step 2: Move All Mails 
       
  1617 	CleanupStack::PopAndDestroy(); // opActive
       
  1618 	opActive = COperationActive::NewL();
       
  1619 	CleanupStack::PushL(opActive);
       
  1620 	console->SetPos(0, 7);  
       
  1621 	test.Printf(_L("Move All Mail when already connected to server   \n"));
       
  1622 	MoveAllMailWhenAlreadyConnectedL();
       
  1623 	CActiveScheduler::Start();
       
  1624 		
       
  1625 	//Step 3: Disconnect the server	
       
  1626 	CleanupStack::PopAndDestroy(); // opActive
       
  1627 	opActive = COperationActive::NewL();
       
  1628 	CleanupStack::PushL(opActive);
       
  1629 	console->SetPos(0, 7);
       
  1630 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1631 	DisconnectFromServerL();
       
  1632 	CActiveScheduler::Start();
       
  1633 
       
  1634 	testUtils->TestFinish(testNo-1);
       
  1635 
       
  1636 	// cleanup for next test
       
  1637 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1638 	DeleteAndCreateServicesL();
       
  1639 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1640 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1641 	CleanupStack::PushL(msvSelection);
       
  1642 		
       
  1643 	testUtils->TestStart(testNo++);
       
  1644 	// Copy Mail Selection when already connected to server
       
  1645 	opActive = COperationActive::NewL();
       
  1646 	CleanupStack::PushL(opActive);
       
  1647 	console->SetPos(0, 7);
       
  1648 	test.Printf(_L("Connecting to Pop server                        \n"));
       
  1649 	ConnectToServerL();
       
  1650 	CActiveScheduler::Start();
       
  1651 
       
  1652 	CleanupStack::PopAndDestroy(); // opActive
       
  1653 	opActive = COperationActive::NewL();
       
  1654 	CleanupStack::PushL(opActive);
       
  1655 	console->SetPos(0, 7);			
       
  1656 	test.Printf(_L("Copy Msg selection when already connected        \n"));
       
  1657 	CopyMailSelectionWhenAlreadyConnectedL();
       
  1658 	CActiveScheduler::Start();
       
  1659 
       
  1660 	CleanupStack::PopAndDestroy(); // opActive
       
  1661 	opActive = COperationActive::NewL();
       
  1662 	CleanupStack::PushL(opActive);
       
  1663 	console->SetPos(0, 7);
       
  1664 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1665 	DisconnectFromServerL();
       
  1666 	CActiveScheduler::Start();
       
  1667 
       
  1668 	testUtils->TestFinish(testNo-1);
       
  1669 
       
  1670 	// cleanup for next test
       
  1671 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1672 	DeleteAndCreateServicesL();
       
  1673 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1674 
       
  1675 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1676 	CleanupStack::PushL(msvSelection);
       
  1677 
       
  1678 
       
  1679 	testUtils->TestStart(testNo++);
       
  1680 	//Step 1: connect to server
       
  1681 	opActive = COperationActive::NewL();
       
  1682 	CleanupStack::PushL(opActive);
       
  1683 	console->SetPos(0, 7);
       
  1684 	test.Printf(_L("Connecting to Pop server                        \n"));
       
  1685 	ConnectToServerL();
       
  1686 	CActiveScheduler::Start();
       
  1687 
       
  1688 	//Step 2: Move Selected mails when already connected
       
  1689 	CleanupStack::PopAndDestroy(); // opActive
       
  1690 	opActive = COperationActive::NewL();
       
  1691 	CleanupStack::PushL(opActive);
       
  1692 	console->SetPos(0, 7);			
       
  1693 	test.Printf(_L("Move Mail selection when already connected        \n"));
       
  1694 	MoveMailSelectionWhenAlreadyConnectedL();
       
  1695 	CActiveScheduler::Start();
       
  1696 	
       
  1697 	//Step 3:Disconnect the server
       
  1698 	CleanupStack::PopAndDestroy(); // opActive
       
  1699 	opActive = COperationActive::NewL();
       
  1700 	CleanupStack::PushL(opActive);
       
  1701 	console->SetPos(0, 7);
       
  1702 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1703 	DisconnectFromServerL();
       
  1704 	CActiveScheduler::Start();
       
  1705 
       
  1706 	testUtils->TestFinish(testNo-1);
       
  1707 	
       
  1708 	//clean up for next test
       
  1709 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1710 	DeleteAndCreateServicesL();
       
  1711 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1712 
       
  1713 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1714 	CleanupStack::PushL(msvSelection);
       
  1715 
       
  1716 	
       
  1717 	//
       
  1718 	// 			Tests for Creating Replies and Forwards     				//
       
  1719 	//
       
  1720 	//Creating a Reply Email Message
       
  1721 
       
  1722 	testUtils->TestStart(testNo++);
       
  1723 	// Connecting to server
       
  1724 	opActive = COperationActive::NewL();
       
  1725 	CleanupStack::PushL(opActive);
       
  1726 	console->SetPos(0, 7);
       
  1727 	test.Printf(_L("Connecting to server             \n"));
       
  1728 	ConnectToServerL();
       
  1729 	CActiveScheduler::Start();
       
  1730 			
       
  1731 	CleanupStack::PopAndDestroy(); // opActive
       
  1732 	opActive = COperationActive::NewL();
       
  1733 	CleanupStack::PushL(opActive);
       
  1734 	console->SetPos(0, 7);			
       
  1735 	test.Printf(_L("Create Reply Email Message               \n"));
       
  1736 	CreateReplyEmailMessage();
       
  1737 	CActiveScheduler::Start();
       
  1738 			
       
  1739 	CleanupStack::PopAndDestroy(); // opActive
       
  1740 	opActive = COperationActive::NewL();
       
  1741 	CleanupStack::PushL(opActive);
       
  1742 	console->SetPos(0, 7);
       
  1743 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1744 	DisconnectFromServerL();
       
  1745 	CActiveScheduler::Start();
       
  1746 			
       
  1747 	testUtils->TestFinish(testNo-1);
       
  1748 
       
  1749 	// cleanup for next test
       
  1750 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1751 	DeleteAndCreateServicesL();
       
  1752 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1753 
       
  1754 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1755 	CleanupStack::PushL(msvSelection);
       
  1756 
       
  1757 	
       
  1758 	//Creating a Forward Email Message
       
  1759 
       
  1760 	testUtils->TestStart(testNo++);
       
  1761 	// Connecting to server
       
  1762 	opActive = COperationActive::NewL();
       
  1763 	CleanupStack::PushL(opActive);
       
  1764 	console->SetPos(0, 7);
       
  1765 	test.Printf(_L("Connecting to server             \n"));
       
  1766 	ConnectToServerL();
       
  1767 	CActiveScheduler::Start();
       
  1768 			
       
  1769 	CleanupStack::PopAndDestroy(); // opActive
       
  1770 	opActive = COperationActive::NewL();
       
  1771 	CleanupStack::PushL(opActive);
       
  1772 	console->SetPos(0, 7);			
       
  1773 	test.Printf(_L("Create Reply Email Message               \n"));
       
  1774 	CreateForwardEmailMessage();
       
  1775 	CActiveScheduler::Start();
       
  1776 			
       
  1777 	CleanupStack::PopAndDestroy(); // opActive
       
  1778 	opActive = COperationActive::NewL();
       
  1779 	CleanupStack::PushL(opActive);
       
  1780 	console->SetPos(0, 7);
       
  1781 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1782 	DisconnectFromServerL();
       
  1783 	CActiveScheduler::Start();
       
  1784 			
       
  1785 	testUtils->TestFinish(testNo-1);
       
  1786 
       
  1787 	// cleanup for next test
       
  1788 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1789 	DeleteAndCreateServicesL();
       
  1790 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1791 
       
  1792 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1793 	CleanupStack::PushL(msvSelection);
       
  1794 
       
  1795 
       
  1796 	//Creating a Forward As Attachment Email Message
       
  1797 
       
  1798 	testUtils->TestStart(testNo++);
       
  1799 	// Connecting to server
       
  1800 	opActive = COperationActive::NewL();
       
  1801 	CleanupStack::PushL(opActive);
       
  1802 	console->SetPos(0, 7);
       
  1803 	test.Printf(_L("Connecting to server             \n"));
       
  1804 	ConnectToServerL();
       
  1805 	CActiveScheduler::Start();
       
  1806 				
       
  1807 	CleanupStack::PopAndDestroy(); // opActive
       
  1808 	opActive = COperationActive::NewL();
       
  1809 	CleanupStack::PushL(opActive);
       
  1810 	console->SetPos(0, 7);			
       
  1811 	test.Printf(_L("Create a Forward As Attachment Email Message               \n"));
       
  1812 	CreateForwardAsAttachmentEmailMessage();
       
  1813 	CActiveScheduler::Start();
       
  1814 				
       
  1815 	CleanupStack::PopAndDestroy(); // opActive
       
  1816 	opActive = COperationActive::NewL();
       
  1817 	CleanupStack::PushL(opActive);
       
  1818 	console->SetPos(0, 7);
       
  1819 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1820 	DisconnectFromServerL();
       
  1821 	CActiveScheduler::Start();
       
  1822 				
       
  1823 	testUtils->TestFinish(testNo-1);
       
  1824 
       
  1825 	// cleanup for next test
       
  1826 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1827 	DeleteAndCreateServicesL();
       
  1828 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1829 
       
  1830 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1831 	CleanupStack::PushL(msvSelection);
       
  1832 
       
  1833 	
       
  1834 	//Create Receipt Email Message
       
  1835 
       
  1836 	testUtils->TestStart(testNo++);
       
  1837 	// Connecting to server
       
  1838 	opActive = COperationActive::NewL();
       
  1839 	CleanupStack::PushL(opActive);
       
  1840 	console->SetPos(0, 7);
       
  1841 	test.Printf(_L("Connecting to server             \n"));
       
  1842 	ConnectToServerL();
       
  1843 	CActiveScheduler::Start();
       
  1844 					
       
  1845 	CleanupStack::PopAndDestroy(); // opActive
       
  1846 	opActive = COperationActive::NewL();
       
  1847 	CleanupStack::PushL(opActive);
       
  1848 	console->SetPos(0, 7);			
       
  1849 	test.Printf(_L("Create a Receipt Email Message               \n"));
       
  1850 	CreateReceiptEmailMessage();
       
  1851 	CActiveScheduler::Start();
       
  1852 					
       
  1853 	CleanupStack::PopAndDestroy(); // opActive
       
  1854 	opActive = COperationActive::NewL();
       
  1855 	CleanupStack::PushL(opActive);
       
  1856 	console->SetPos(0, 7);
       
  1857 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1858 	DisconnectFromServerL();
       
  1859 	CActiveScheduler::Start();
       
  1860 					
       
  1861 	testUtils->TestFinish(testNo-1);
       
  1862 
       
  1863 	// cleanup for next test
       
  1864 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1865 	DeleteAndCreateServicesL();
       
  1866 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1867 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1868 	CleanupStack::PushL(msvSelection);
       
  1869 
       
  1870 	
       
  1871 	testUtils->TestStart(testNo++);
       
  1872 	// Connect, Copy New Mail and then disconnect
       
  1873 	opActive = COperationActive::NewL();
       
  1874 	CleanupStack::PushL(opActive);
       
  1875 	console->SetPos(0, 7);
       
  1876 	
       
  1877 	test.Printf(_L("Connect, Copy New Mail, Disconnect               \n"));
       
  1878 	ConnectAndCopyNewMailAndDisconnectL();
       
  1879 	CActiveScheduler::Start();
       
  1880 
       
  1881 	// cleanup for next test
       
  1882 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1883 	DeleteAndCreateServicesL();
       
  1884 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1885 	
       
  1886 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1887 	CleanupStack::PushL(msvSelection);
       
  1888 
       
  1889 
       
  1890 	testUtils->TestStart(testNo++);
       
  1891 	// Connect, Move New Mail and then disconnect
       
  1892 	opActive = COperationActive::NewL();
       
  1893 	CleanupStack::PushL(opActive);
       
  1894 	console->SetPos(0, 7);
       
  1895 		
       
  1896 	test.Printf(_L("Connect, Move New Mail, Disconnect               \n"));
       
  1897 	ConnectAndMoveNewMailAndDisconnectL();
       
  1898 	CActiveScheduler::Start();
       
  1899 
       
  1900 	// cleanup for next test
       
  1901 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1902 	DeleteAndCreateServicesL();
       
  1903 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1904 	
       
  1905 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1906 	CleanupStack::PushL(msvSelection);
       
  1907 
       
  1908 	
       
  1909 	testUtils->TestStart(testNo++);
       
  1910 	// Connect, Copy All Mail and then disconnect
       
  1911 	opActive = COperationActive::NewL();
       
  1912 	CleanupStack::PushL(opActive);
       
  1913 	console->SetPos(0, 7);
       
  1914 	test.Printf(_L("Connect, Copy All Mail, Disconnect               \n"));
       
  1915 	ConnectAndCopyAllMailAndDisconnectL();
       
  1916 	CActiveScheduler::Start();
       
  1917 
       
  1918 	testUtils->TestFinish(testNo-1);
       
  1919 
       
  1920 	// cleanup for next test
       
  1921 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1922 	DeleteAndCreateServicesL();
       
  1923 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1924 
       
  1925 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1926 	CleanupStack::PushL(msvSelection);
       
  1927 
       
  1928 	testUtils->TestStart(testNo++);
       
  1929 
       
  1930 	// Connect, Move All Mail and then disconnect
       
  1931 		opActive = COperationActive::NewL();
       
  1932 		CleanupStack::PushL(opActive);
       
  1933 		console->SetPos(0, 7);
       
  1934 		test.Printf(_L("Connect,Move All Mail, Disconnect               \n"));
       
  1935 		ConnectAndMoveAllMailAndDisconnectL();
       
  1936 		CActiveScheduler::Start();
       
  1937 
       
  1938 		testUtils->TestFinish(testNo-1);
       
  1939 
       
  1940 		// cleanup for next test
       
  1941 		CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1942 		DeleteAndCreateServicesL();
       
  1943 		testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1944 
       
  1945 		msvSelection = new (ELeave) CMsvEntrySelection;
       
  1946 		CleanupStack::PushL(msvSelection);
       
  1947 		testUtils->TestStart(testNo++);
       
  1948 
       
  1949 	
       
  1950 	// connect and then disconnect to update mailbox
       
  1951 	opActive = COperationActive::NewL();
       
  1952 	CleanupStack::PushL(opActive);
       
  1953 	console->SetPos(0, 7);
       
  1954 	test.Printf(_L("Connect, Disconnect                              \n"));
       
  1955 	ConnectAndDisconnectL();
       
  1956 	CleanupStack::PopAndDestroy(); // opActive
       
  1957 
       
  1958 	// Connect, Copy Mail Selection and then disconnect
       
  1959 	opActive = COperationActive::NewL();
       
  1960 	CleanupStack::PushL(opActive);
       
  1961 	console->SetPos(0, 7);
       
  1962 	test.Printf(_L("Connect, Copy Mail Selection, Disconnect         \n"));
       
  1963 	ConnectAndCopyMailSelectionAndDisconnectL();
       
  1964 	CActiveScheduler::Start();
       
  1965 
       
  1966 	testUtils->TestFinish(testNo-1);
       
  1967 
       
  1968 	// cleanup for next test
       
  1969 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1970 	DeleteAndCreateServicesL();
       
  1971 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1972 
       
  1973 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1974 	CleanupStack::PushL(msvSelection);
       
  1975 
       
  1976 	testUtils->TestStart(testNo++);
       
  1977 	
       
  1978 
       
  1979 	opActive = COperationActive::NewL();
       
  1980 	CleanupStack::PushL(opActive);
       
  1981 	console->SetPos(0, 7);
       
  1982 	test.Printf(_L("Connect, Move Mail Selection, Disconnect         \n"));
       
  1983 	ConnectAndMoveMailSelectionAndDisconnectL();
       
  1984 	CActiveScheduler::Start();
       
  1985 
       
  1986 	testUtils->TestFinish(testNo-1);
       
  1987 
       
  1988 	// cleanup for next test
       
  1989 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  1990 	DeleteAndCreateServicesL();
       
  1991 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  1992 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1993 	CleanupStack::PushL(msvSelection);
       
  1994 
       
  1995 
       
  1996 	testUtils->TestStart(testNo++);
       
  1997 	// Connect, Copy New Mail and Stay Online
       
  1998 	opActive = COperationActive::NewL();
       
  1999 	CleanupStack::PushL(opActive);
       
  2000 	console->SetPos(0, 7);
       
  2001 	test.Printf(_L("Connect, Copy New Mail, Stay Online              \n"));
       
  2002 	ConnectAndCopyNewMailAndStayOnlineL();
       
  2003 	CActiveScheduler::Start();
       
  2004 
       
  2005 	CleanupStack::PopAndDestroy(); // opActive
       
  2006 	opActive = COperationActive::NewL();
       
  2007 	CleanupStack::PushL(opActive);
       
  2008 	console->SetPos(0, 7);
       
  2009 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2010 	DisconnectFromServerL();
       
  2011 	CActiveScheduler::Start();
       
  2012 
       
  2013 	testUtils->TestFinish(testNo-1);
       
  2014 
       
  2015 	// cleanup for next test
       
  2016 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2017 	DeleteAndCreateServicesL();
       
  2018 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2019 	
       
  2020 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2021 	CleanupStack::PushL(msvSelection);
       
  2022 
       
  2023 
       
  2024 	testUtils->TestStart(testNo++);
       
  2025 	// Connect, Move New Mail and Stay Online
       
  2026 	opActive = COperationActive::NewL();
       
  2027 	CleanupStack::PushL(opActive);
       
  2028 	console->SetPos(0, 7);
       
  2029 	test.Printf(_L("Connect, Move New Mail, Stay Online              \n"));
       
  2030 	ConnectAndMoveNewMailAndStayOnlineL();
       
  2031 	CActiveScheduler::Start();
       
  2032 
       
  2033 	CleanupStack::PopAndDestroy(); // opActive
       
  2034 	opActive = COperationActive::NewL();
       
  2035 	CleanupStack::PushL(opActive);
       
  2036 	console->SetPos(0, 7);
       
  2037 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2038 	DisconnectFromServerL();
       
  2039 	CActiveScheduler::Start();
       
  2040 
       
  2041 	testUtils->TestFinish(testNo-1);
       
  2042 
       
  2043 	// cleanup for next test
       
  2044 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2045 	DeleteAndCreateServicesL();
       
  2046 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2047 	
       
  2048 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2049 	CleanupStack::PushL(msvSelection);
       
  2050 	
       
  2051 
       
  2052 	
       
  2053 	
       
  2054 	testUtils->TestStart(testNo++);
       
  2055 	// Connect, Copy All Mail and Stay Online
       
  2056 	opActive = COperationActive::NewL();
       
  2057 	CleanupStack::PushL(opActive);
       
  2058 	console->SetPos(0, 7);
       
  2059 	test.Printf(_L("Connect, Copy All Mail, Stay Online              \n"));
       
  2060 	ConnectAndCopyAllMailAndStayOnlineL();
       
  2061 	CActiveScheduler::Start();
       
  2062 
       
  2063 	CleanupStack::PopAndDestroy(); // opActive
       
  2064 	opActive = COperationActive::NewL();
       
  2065 	CleanupStack::PushL(opActive);
       
  2066 	console->SetPos(0, 7);
       
  2067 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2068 	DisconnectFromServerL();
       
  2069 	CActiveScheduler::Start();
       
  2070 	testUtils->TestFinish(testNo-1);
       
  2071 
       
  2072 	// cleanup for next test
       
  2073 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2074 	DeleteAndCreateServicesL();
       
  2075 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2076 	
       
  2077 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2078 	CleanupStack::PushL(msvSelection);
       
  2079 
       
  2080 	testUtils->TestStart(testNo++);
       
  2081 	
       
  2082 	opActive = COperationActive::NewL();
       
  2083 	CleanupStack::PushL(opActive);
       
  2084 	console->SetPos(0, 7);
       
  2085 	test.Printf(_L("Connect, Move All Mail, Stay Online              \n"));
       
  2086 	ConnectAndMoveAllMailAndStayOnlineL();
       
  2087 	CActiveScheduler::Start();
       
  2088 
       
  2089 	CleanupStack::PopAndDestroy(); // opActive
       
  2090 	opActive = COperationActive::NewL();
       
  2091 	CleanupStack::PushL(opActive);
       
  2092 	console->SetPos(0, 7);
       
  2093 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2094 	DisconnectFromServerL();
       
  2095 	CActiveScheduler::Start();
       
  2096 	testUtils->TestFinish(testNo-1);
       
  2097 
       
  2098 	// cleanup for next test
       
  2099 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2100 	DeleteAndCreateServicesL();
       
  2101 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2102 	
       
  2103 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2104 	CleanupStack::PushL(msvSelection);
       
  2105 	
       
  2106 	
       
  2107 	testUtils->TestStart(testNo++);
       
  2108 	// connect and then disconnect to update mailbox
       
  2109 	opActive = COperationActive::NewL();
       
  2110 	CleanupStack::PushL(opActive);
       
  2111 	console->SetPos(0, 7);
       
  2112 	test.Printf(_L("Connect, Disconnect                              \n"));
       
  2113 	ConnectAndDisconnectL();
       
  2114 	CleanupStack::PopAndDestroy(); // opActive
       
  2115 
       
  2116 	// Connect, Copy Mail Selection and Stay Online
       
  2117 	opActive = COperationActive::NewL();
       
  2118 	CleanupStack::PushL(opActive);
       
  2119 	console->SetPos(0, 7);
       
  2120 	test.Printf(_L("Connect, Copy Msg Selection, Stay Online         \n"));
       
  2121 	ConnectAndCopyMailSelectionAndStayOnlineL();
       
  2122 	CActiveScheduler::Start();
       
  2123 
       
  2124 	CleanupStack::PopAndDestroy(); // opActive
       
  2125 	opActive = COperationActive::NewL();
       
  2126 	CleanupStack::PushL(opActive);
       
  2127 	console->SetPos(0, 7);
       
  2128 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2129 	DisconnectFromServerL();
       
  2130 	CActiveScheduler::Start();
       
  2131 	testUtils->TestFinish(testNo-1);
       
  2132 
       
  2133 	// cleanup for next test
       
  2134 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2135 	DeleteAndCreateServicesL();
       
  2136 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2137 	
       
  2138 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2139 	CleanupStack::PushL(msvSelection);
       
  2140 
       
  2141 	
       
  2142 	opActive = COperationActive::NewL();
       
  2143 	CleanupStack::PushL(opActive);
       
  2144 	console->SetPos(0, 7);
       
  2145 	test.Printf(_L("Connect, Move Msg Selection, Stay Online         \n"));
       
  2146 	ConnectAndMoveMailSelectionAndStayOnlineL();
       
  2147 	CActiveScheduler::Start();
       
  2148 
       
  2149 	CleanupStack::PopAndDestroy(); // opActive
       
  2150 	opActive = COperationActive::NewL();
       
  2151 	CleanupStack::PushL(opActive);
       
  2152 	console->SetPos(0, 7);
       
  2153 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2154 	DisconnectFromServerL();
       
  2155 	CActiveScheduler::Start();
       
  2156 	testUtils->TestFinish(testNo-1);
       
  2157 
       
  2158 	// cleanup for next test
       
  2159 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2160 	DeleteAndCreateServicesL();
       
  2161 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2162 		
       
  2163 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2164 	CleanupStack::PushL(msvSelection);
       
  2165 	
       
  2166 	
       
  2167 //
       
  2168 //	Test an empty message selection (does not cause a panic!)
       
  2169 //
       
  2170 
       
  2171 	testUtils->TestStart(testNo++);
       
  2172 	// Connect, Copy All Mail and then disconnect
       
  2173 	opActive = COperationActive::NewL();
       
  2174 	CleanupStack::PushL(opActive);
       
  2175 	console->SetPos(0, 7);
       
  2176 	test.Printf(_L("Connect, Copy Empty Message Selection, Disconnect\n"));
       
  2177 	ConnectAndCopyMailSelectionAndDisconnectL(ETrue);
       
  2178 	CActiveScheduler::Start();
       
  2179 
       
  2180 	// check that final progress showing the correct information
       
  2181 	TPckgBuf<TPop3Progress> progress;
       
  2182 	progress.Copy(opActive->iTimer->iOperation->FinalProgress());
       
  2183 
       
  2184 	console->SetPos(0, 11);
       
  2185 	console->Printf(_L("Final Progress:                    "));
       
  2186 	console->SetPos(0, 12);
       
  2187 	TBuf<80> progressBuf = Progress(progress().iPop3Progress);
       
  2188 	console->Printf(TRefByValue<const TDesC>_L("   Super Operation Progress: %S           "), &progressBuf);
       
  2189 	console->SetPos(0, 13);
       
  2190 	progressBuf = Progress(progress().iPop3SubStateProgress);
       
  2191 	console->Printf(TRefByValue<const TDesC>_L("   Sub Operation Progress  : %S           "), &progressBuf);
       
  2192 	console->SetPos(0, 14);
       
  2193 	console->Printf(TRefByValue<const TDesC>_L("   Progress:  %d/%d %d/%d Total:%d               \n"),
       
  2194 				progress().iTotalMsgs-progress().iMsgsToProcess,
       
  2195 				progress().iTotalMsgs,
       
  2196 				progress().iBytesDone,
       
  2197 				progress().iTotalBytes,
       
  2198 				progress().iTotalSize);
       
  2199 	console->SetPos(0, 15);
       
  2200 	console->Printf(TRefByValue<const TDesC>_L("   Error: %d                             \n"), progress().iErrorCode);
       
  2201 
       
  2202 	// wait 5 seconds so that user can see the final progess!
       
  2203 	CTestTimer* timer = CTestTimer::NewL();
       
  2204 	timer->After(5000000);
       
  2205 	CActiveScheduler::Start();
       
  2206 	delete timer;
       
  2207 
       
  2208 	testUtils->TestFinish(testNo-1);
       
  2209 
       
  2210 //
       
  2211 //	Do Cancel Operation Tests
       
  2212 //
       
  2213 
       
  2214 	testUtils->WriteComment(_L("Doing Cancel Tests"));
       
  2215 	// cleanup for next test
       
  2216 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2217 	DeleteAndCreateServicesL();
       
  2218 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2219 
       
  2220 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2221 	CleanupStack::PushL(msvSelection);
       
  2222 
       
  2223 	testUtils->TestStart(testNo++);
       
  2224 	// Connect, Copy New Mail and then disconnect
       
  2225 	opActive = COperationActive::NewL();
       
  2226 	CleanupStack::PushL(opActive);
       
  2227 	console->SetPos(0, 11);
       
  2228 	console->Printf(_L("                                       "));
       
  2229 	console->SetPos(0, 7);
       
  2230 	opActive->SetCancelState(TPop3Progress::EPopConnecting);
       
  2231 	test.Printf(_L("Connect, Copy New Mail, Disconnect               \n"));
       
  2232 	ConnectAndCopyNewMailAndDisconnectL();
       
  2233 	CActiveScheduler::Start();
       
  2234 
       
  2235 	testUtils->TestFinish(testNo-1);
       
  2236 
       
  2237 	// cleanup for next test
       
  2238 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2239 	DeleteAndCreateServicesL();
       
  2240 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2241 
       
  2242 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2243 	CleanupStack::PushL(msvSelection);
       
  2244 
       
  2245 	testUtils->TestStart(testNo++);
       
  2246 	// Connect, Copy New Mail and then disconnect
       
  2247 	opActive = COperationActive::NewL();
       
  2248 	CleanupStack::PushL(opActive);
       
  2249 	console->SetPos(0, 7);
       
  2250 	opActive->SetCancelState(TPop3Progress::EPopRefreshing);
       
  2251 	test.Printf(_L("Connect, Copy New Mail, Disconnect               \n"));
       
  2252 	ConnectAndCopyNewMailAndDisconnectL();
       
  2253 	CActiveScheduler::Start();
       
  2254 
       
  2255 	testUtils->TestFinish(testNo-1);
       
  2256 
       
  2257 	// cleanup for next test
       
  2258 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2259 	DeleteAndCreateServicesL();
       
  2260 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2261 
       
  2262 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2263 	CleanupStack::PushL(msvSelection);
       
  2264 
       
  2265 	testUtils->TestStart(testNo++);
       
  2266 	// Connect, Copy New Mail and then disconnect
       
  2267 	opActive = COperationActive::NewL();
       
  2268 	CleanupStack::PushL(opActive);
       
  2269 	console->SetPos(0, 7);
       
  2270 	opActive->SetCancelState(TPop3Progress::EPopCopying);
       
  2271 	test.Printf(_L("Connect, Copy New Mail, Disconnect               \n"));
       
  2272 	ConnectAndCopyNewMailAndDisconnectL();
       
  2273 	CActiveScheduler::Start();
       
  2274 
       
  2275 	testUtils->TestFinish(testNo-1);
       
  2276 
       
  2277 	// cleanup for next test
       
  2278 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2279 	DeleteAndCreateServicesL();
       
  2280 	testUtils->iPopClientMtm->SwitchCurrentEntryL(Pop3Service);
       
  2281 
       
  2282 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2283 	CleanupStack::PushL(msvSelection);
       
  2284 	
       
  2285 	
       
  2286 
       
  2287 	testUtils->TestStart(testNo++);
       
  2288 	// Connect, Copy New Mail and then disconnect
       
  2289 	opActive = COperationActive::NewL();
       
  2290 	CleanupStack::PushL(opActive);
       
  2291 	console->SetPos(0, 7);
       
  2292 	opActive->SetCancelState(TPop3Progress::EPopDisconnecting);
       
  2293 	test.Printf(_L("Connect, Copy New Mail, Disconnect               \n"));
       
  2294 	ConnectAndCopyNewMailAndDisconnectL();
       
  2295 	CActiveScheduler::Start();
       
  2296 
       
  2297 	testUtils->TestFinish(testNo-1);
       
  2298 
       
  2299 	testUtils->TestStart(testNo++);
       
  2300 	TestCapabilityL();
       
  2301 	testUtils->TestFinish(testNo-1);
       
  2302 	if (globalError)
       
  2303 		testUtils->TestHarnessFailed(globalError);
       
  2304 	else
       
  2305 		testUtils->TestHarnessCompleted();
       
  2306 	// cleanup for next test
       
  2307 	CleanupStack::PopAndDestroy(2); //msvSelection, opActive, 
       
  2308 	testUtils->Reset();
       
  2309 	Closedown();
       
  2310 	}
       
  2311 
       
  2312 GLDEF_C TInt E32Main()
       
  2313 	{	
       
  2314 	__UHEAP_MARK;
       
  2315 	test.Start(_L("T_POPC Test CImPop3GetMail class"));
       
  2316 	theCleanup=CTrapCleanup::New();
       
  2317 	TRAPD(ret,doMainL());		
       
  2318 	test(ret==KErrNone);
       
  2319 	delete theCleanup;	
       
  2320 	test.End();
       
  2321 	test.Close();
       
  2322 	__UHEAP_MARKEND;
       
  2323 	User::Heap().Check();
       
  2324 	return(KErrNone);
       
  2325 	}