email/pop3andsmtpmtm/smtpservermtm/test/src/t_smts01.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 1999-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 //
       
    15 
       
    16 #include "emailtestutils.h"
       
    17 #include "scripttestutils.h"
       
    18 #include <iapprefs.h>
       
    19 #include <commsdattypesv1_1.h>
       
    20 #include <commsdat.h>
       
    21 using namespace CommsDat;
       
    22 #include <cdbpreftable.h>
       
    23 #include <securesocket.h>
       
    24 #include <securesocket_internal.h>
       
    25 #include <bacline.h>
       
    26 
       
    27 #include <cemailaccounts.h>
       
    28 
       
    29 // For loading the serial comms device drivers 
       
    30 #if defined (__WINS__)
       
    31 	#define PDD_NAME		_L("ECDRV")
       
    32 	#define LDD_NAME		_L("ECOMM")
       
    33 #else
       
    34 	#define PDD_NAME		_L("EUART1")
       
    35 	#define LDD_NAME		_L("ECOMM")
       
    36 #endif
       
    37 
       
    38 
       
    39 _LIT(KSmtsTest, "T_SMTS01 - Testing SMTS Server MTM using dial out");
       
    40 RTest test(KSmtsTest);
       
    41 
       
    42 _LIT(KTestParams,"-testparams");
       
    43 enum TCmdLineArgs
       
    44 	{
       
    45 	EArgProgramName,
       
    46 	EArgTestParams,
       
    47 	EArgServerAddress,
       
    48 	EArgEmail,
       
    49 	EArgUseSecureSockets,
       
    50 	EArgEnd
       
    51 	};
       
    52 
       
    53 _LIT(KImskOutFile, "c:\\logs\\email\\imsk25.out");
       
    54 _LIT(KImskScrFile, "c:\\logs\\email\\imsk25.scr");
       
    55 _LIT(KSmtsComponent,"SMTS");
       
    56 _LIT(KSmtsRFCEmails,"RFC822\\");
       
    57 
       
    58 // UpdateProgressTimer is the time between calls to Progress()
       
    59 //  A small value ensures that progress is checked often and that small files
       
    60 //  do not slip through the checking process, especially when testing on NT-RAS
       
    61 const TInt UpdateProgressTimer = 50000;		// 50 milliseconds
       
    62 
       
    63 // DisplayProgressTimer is the time between calls to DisplayProgress()
       
    64 //  This value should be larger than the UpdateProgressValue to avoid the logs being
       
    65 //  swamped with progress messages
       
    66 const TInt DisplayProgressTimer = 400000;	// 400 milliseconds
       
    67 
       
    68 
       
    69 // Class to test a mesage Send Progress
       
    70 class TTestProgress 
       
    71 	{
       
    72 public:
       
    73 	TInt iCurrentMsg;
       
    74 	TInt iBytesToSend;
       
    75 	TInt iBytesSent;
       
    76 	};
       
    77 
       
    78 
       
    79 LOCAL_D CTrapCleanup* theCleanup;
       
    80 LOCAL_D CEmailTestUtils* testUtils;
       
    81 LOCAL_D TMsvId smtpService;
       
    82 LOCAL_D CBaseServerMtm* serverMtm;
       
    83 LOCAL_D CActiveScheduler* scheduler;
       
    84 LOCAL_D TInt globalError;
       
    85 LOCAL_D TTestProgress globalProgress;
       
    86 LOCAL_D TInt progressCount;
       
    87 
       
    88 
       
    89 LOCAL_C TBool TimeToDisplayProgress()
       
    90 	{
       
    91 	// Should we display progress?
       
    92 	// Yes if (progressCount mod (update_to_display_ratio)) == 0
       
    93 	TInt display = (progressCount%(DisplayProgressTimer / UpdateProgressTimer))  == 0;
       
    94 	return display;
       
    95 	}
       
    96 
       
    97 
       
    98 LOCAL_C TInt readConsoleLineBuf(const TDesC& aPrompt, TDes& aBuf)
       
    99 	{
       
   100 	test.Printf(_L("\n "));
       
   101 	TBool quit = EFalse;
       
   102 	_LIT(KDeleteChar, "\b \b");
       
   103 
       
   104 	test.Printf(aPrompt);
       
   105 	while (!quit)
       
   106 		{
       
   107 		TKeyCode k = test.Getch();
       
   108 		TChar key = k;
       
   109 		switch (key)
       
   110 			{
       
   111 		case EKeyBackspace:
       
   112 			if (aBuf.Length() > 0)
       
   113 				{
       
   114 				test.Printf(KDeleteChar);
       
   115 				aBuf = aBuf.Left(aBuf.Length() - 1);
       
   116 				}
       
   117 			break;
       
   118 		case EKeyEnter:
       
   119 			if (aBuf.Length())
       
   120 				quit = ETrue;
       
   121 			else
       
   122 				test.Printf(_L("\nLogin, password and server address cannot be zero length "));
       
   123 			break;
       
   124 		default:
       
   125 			test.Printf(_L("%c"), key);
       
   126 			aBuf.Append(key);
       
   127 			break;
       
   128 			}
       
   129 		}
       
   130 	return(KErrNone);
       
   131 	}
       
   132 
       
   133 
       
   134 LOCAL_C void ClosedownL()
       
   135 	{
       
   136 	CSecureSocketLibraryLoader::Unload();
       
   137 	if (globalError)
       
   138 		testUtils->TestHarnessFailed(globalError);
       
   139 	else
       
   140 		testUtils->TestHarnessCompleted();
       
   141 		
       
   142 	CleanupStack::PopAndDestroy(2);  //testUtils, ischeduler
       
   143 	}
       
   144 
       
   145 
       
   146 LOCAL_C void TestProgress(TImSmtpProgress& aProgress)
       
   147 // Check the Progress is Valid
       
   148 	{
       
   149 	// Make sure that we haven't finished sending
       
   150 	if (aProgress.Sent() == aProgress.SendTotal())
       
   151 		return;
       
   152 
       
   153 	// Check if we are about to send a New Message
       
   154 	if (globalProgress.iCurrentMsg != aProgress.MsgNo()+1)
       
   155 		{
       
   156 		// Check if the previous sent message sent all of its bytes ok
       
   157 		// (ie check if it had a complete Progress bar).
       
   158 		if (globalProgress.iCurrentMsg > 0)
       
   159 			{
       
   160 			TBuf<128> logString;
       
   161 			if (globalProgress.iBytesToSend != globalProgress.iBytesSent)
       
   162 				// Message has completed but progress info is not correct
       
   163 				{
       
   164 				globalError = KErrGeneral;
       
   165 				logString.Format(_L("Test failed - Incorrect Progress - Message No.%d didn't have a full progress bar"), globalProgress.iCurrentMsg);
       
   166 				testUtils->WriteComment(logString);
       
   167 				return;
       
   168 				}
       
   169 			else
       
   170 				// Message has completed OK
       
   171 				{
       
   172 				logString.Format(_L("Completed message No.%d/%d.\n"), 
       
   173 					globalProgress.iCurrentMsg, aProgress.SendTotal());
       
   174 				testUtils->WriteComment(logString);			
       
   175 				}
       
   176 			}
       
   177 
       
   178 		// Set up the Progress for a New Message
       
   179 		globalProgress.iCurrentMsg = aProgress.MsgNo()+1;
       
   180 		}
       
   181 	else
       
   182 		{
       
   183 		// Make sure the Bytes to Send hasn't altered
       
   184 		if (globalProgress.iBytesToSend >0 &&
       
   185 			aProgress.iSendFileProgress.iBytesToSend != globalProgress.iBytesToSend)
       
   186 			{
       
   187 			globalError = KErrGeneral;
       
   188 			testUtils->WriteComment(_L("Test failed - Incorrect Progress - num Bytes To Send has changed"));
       
   189 			return;
       
   190 			}
       
   191 
       
   192 		// Make sure the Bytes Sent doesn't go down
       
   193 		if (aProgress.iSendFileProgress.iBytesSent < globalProgress.iBytesSent)
       
   194 			{
       
   195 			globalError = KErrGeneral;
       
   196 			testUtils->WriteComment(_L("Test failed - Incorrect Progress - num Bytes Sent has gone down"));
       
   197 			return;
       
   198 			}
       
   199 		}
       
   200 
       
   201 	// Progress is ok, so set the new Bytes Sent Count
       
   202 	globalProgress.iBytesSent = aProgress.iSendFileProgress.iBytesSent;
       
   203 	globalProgress.iBytesToSend = aProgress.iSendFileProgress.iBytesToSend;
       
   204 	}
       
   205 
       
   206 
       
   207 LOCAL_C void DisplayProgress(TImSmtpProgress aProgress)
       
   208 	{
       
   209 	//  State of Smtp session?
       
   210 	TInt state = aProgress.Status();
       
   211 	TBuf<128> logString;
       
   212 
       
   213 	switch(state)
       
   214 		{
       
   215 		case EMsgOutboxProgressWaiting:
       
   216 			testUtils->WriteComment(_L("Waiting to start\n"));
       
   217 			break;
       
   218 		case EMsgOutboxProgressDone:
       
   219 			testUtils->WriteComment(_L("Connection Closed.\n"));
       
   220 			logString.Format(_L("%d messages: Sent %d, failed to send %d, didn't attempt to send %d.\n"), 
       
   221 				aProgress.SendTotal(),
       
   222 				aProgress.Sent(),
       
   223 				aProgress.FailedToSend(),
       
   224 				aProgress.NotSent());
       
   225 			testUtils->WriteComment(logString);
       
   226 			break;
       
   227 		case EMsgOutboxProgressConnecting:
       
   228 			logString.Format(_L("Connecting to SMTP server. Sending %d messages.\n"),
       
   229 				aProgress.SendTotal());
       
   230 			testUtils->WriteComment(logString);
       
   231 			break;
       
   232 		case EMsgOutboxProgressSending:
       
   233 			logString.Format(_L("Sending message No.%d/%d. Transmitted %d bytes of %d            \n"),     
       
   234 				aProgress.MsgNo()+1,
       
   235 				aProgress.SendTotal(),
       
   236 				aProgress.iSendFileProgress.iBytesSent,
       
   237 				aProgress.iSendFileProgress.iBytesToSend);
       
   238 			testUtils->WriteComment(logString);
       
   239 			break;
       
   240 		}
       
   241 	}
       
   242 
       
   243 LOCAL_C void UpdateProgress()
       
   244 	{
       
   245  	TImSmtpProgress temp;	
       
   246 	TPckgC<TImSmtpProgress> paramPack(temp);
       
   247 
       
   248 	const TDesC8& progBuf =serverMtm->Progress();
       
   249 	paramPack.Set(progBuf);
       
   250 	TImSmtpProgress progress=paramPack();	
       
   251 
       
   252 	//  State of Smtp session?
       
   253 	TInt state = progress.Status();
       
   254 
       
   255 	if (state == EMsgOutboxProgressSending)
       
   256 		{
       
   257 		// Test the sending progress
       
   258 		TestProgress(progress);
       
   259 		}
       
   260 
       
   261 	if (TimeToDisplayProgress())
       
   262 		{
       
   263 		DisplayProgress(progress);
       
   264 		}
       
   265 
       
   266 	progressCount++;
       
   267 	}
       
   268 
       
   269 
       
   270 class CSmtpTimer : public CTimer
       
   271 	{
       
   272 public:
       
   273 	static CSmtpTimer* NewL(CTestActive& aActive);
       
   274 	void StartL();
       
   275 private:
       
   276 	CSmtpTimer(CTestActive& aActive);
       
   277 	void RunL();	
       
   278 	CTestActive& iSmtpActive;
       
   279 	};
       
   280 
       
   281 CSmtpTimer::CSmtpTimer(CTestActive& aActive)
       
   282 : CTimer(EPriorityLow),	iSmtpActive(aActive)
       
   283 
       
   284 	{}
       
   285 
       
   286 
       
   287 CSmtpTimer* CSmtpTimer::NewL(CTestActive& aActive)
       
   288 	{
       
   289 	CSmtpTimer* self = new(ELeave) CSmtpTimer(aActive);
       
   290 	CleanupStack::PushL(self);
       
   291 	CActiveScheduler::Add(self);
       
   292 	CleanupStack::Pop();
       
   293 	return self;
       
   294 	}
       
   295 
       
   296 void CSmtpTimer::StartL()
       
   297 	{
       
   298 	CTimer::ConstructL();
       
   299 	TRequestStatus* status=&iStatus;
       
   300 	User::RequestComplete(status,KErrNone);
       
   301 	SetActive();
       
   302 	}
       
   303 
       
   304 void CSmtpTimer::RunL()
       
   305 	{
       
   306 	test.Console()->SetPos(0, 10);
       
   307 	UpdateProgress();
       
   308 
       
   309 	//this is how you check if the MTM is finished or not!
       
   310 	if (globalError || !iSmtpActive.IsActive())   
       
   311 		{
       
   312 		iSmtpActive.Cancel();
       
   313 		CActiveScheduler::Stop();
       
   314 		return;
       
   315 		}
       
   316 	else
       
   317 		{
       
   318 		After(UpdateProgressTimer);
       
   319 		}
       
   320 	}
       
   321 
       
   322 
       
   323 LOCAL_C void TestSendingMessagesL()
       
   324 	{
       
   325 	// About to start sending messages
       
   326 	globalProgress.iCurrentMsg = 0;
       
   327 	globalProgress.iBytesSent = 0;
       
   328 	globalProgress.iBytesToSend = 0;
       
   329 
       
   330 	CTestActive* testActive = new (ELeave) CTestActive();
       
   331 	CleanupStack::PushL(testActive);
       
   332 
       
   333 	CMsvEntrySelection* sendSel = new(ELeave) CMsvEntrySelection();
       
   334 	CleanupStack::PushL(sendSel);
       
   335 	testUtils->iServerEntry->SetEntry(KMsvGlobalOutBoxIndexEntryId);
       
   336 	User::LeaveIfError(testUtils->iServerEntry->GetChildren(*sendSel));
       
   337 	TInt count = sendSel->Count();
       
   338 	if (!count)
       
   339 		{
       
   340 		testUtils->WriteComment(_L("\t No messages to send in the outbox"));
       
   341 		CleanupStack::PopAndDestroy(2); //testActive, sendsel
       
   342 		return;
       
   343 		}
       
   344 	TBuf<100> logString;
       
   345 
       
   346 	testUtils->WriteComment(_L("Issuing CopyFromLocal request...\n"));
       
   347 	logString.Format(_L("\t messages to send in the outbox - %d"), count);
       
   348 	testUtils->WriteComment(logString);
       
   349 	
       
   350 	serverMtm->CopyFromLocalL(*sendSel,smtpService, testActive->iStatus);
       
   351 	CSmtpTimer* timer=CSmtpTimer::NewL(*testActive);
       
   352 	CleanupStack::PushL(timer);
       
   353 
       
   354 	testActive->StartL();
       
   355 	timer->StartL();
       
   356 	CActiveScheduler::Start();
       
   357 
       
   358 	// If there are no errors so far, then check the progress
       
   359 	if (!globalError)
       
   360 		{
       
   361 		UpdateProgress();
       
   362 		logString.Zero();
       
   363 		logString.Format(_L("\t CopyFromLocalL completed with %d"), testActive->iStatus.Int());
       
   364 		testUtils->WriteComment(logString);
       
   365  		TImSmtpProgress temp;	
       
   366 		TPckgC<TImSmtpProgress> paramPack(temp);
       
   367 	
       
   368 		const TDesC8& progBuf =serverMtm->Progress();
       
   369 		paramPack.Set(progBuf);
       
   370 		TImSmtpProgress progress=paramPack();
       
   371 		globalError=progress.Error();
       
   372 		}
       
   373 	
       
   374 	//For Coverage
       
   375 	CMsvEntrySelection* selection1 = new(ELeave)CMsvEntrySelection();
       
   376 	CleanupStack::PushL(selection1);
       
   377 	TRequestStatus st;
       
   378 	TMsvId s =0;
       
   379 	TRAP_IGNORE(serverMtm->MoveFromLocalL(*selection1, s,st));
       
   380 	TRAP_IGNORE(serverMtm->CopyToLocalL(*selection1, s,st));
       
   381 	TRAP_IGNORE(serverMtm->MoveToLocalL(*selection1, s,st));
       
   382 	TRAP_IGNORE(serverMtm->CopyWithinServiceL(*selection1, s,st));
       
   383 	TRAP_IGNORE(serverMtm->MoveWithinServiceL(*selection1, s,st));
       
   384 	
       
   385 	TRAP_IGNORE(serverMtm->DeleteAllL(*selection1, st));
       
   386 	TMsvEntry aEntry;
       
   387 	TRAP_IGNORE(serverMtm->CreateL(aEntry,st));
       
   388 	TRAP_IGNORE(serverMtm->ChangeL(aEntry,st));
       
   389 	
       
   390 		
       
   391 	CleanupStack::PopAndDestroy(selection1); //Selection
       
   392 	
       
   393 	CleanupStack::PopAndDestroy(3); //testActive, sendsel, /*timer*/
       
   394 	}
       
   395 
       
   396 
       
   397 LOCAL_C void InitL()
       
   398 	{
       
   399 	scheduler = new (ELeave) CActiveScheduler;
       
   400 	CleanupStack::PushL(scheduler);
       
   401 	CActiveScheduler::Install( scheduler );
       
   402 
       
   403 	testUtils = CEmailTestUtils::NewLC(test);
       
   404 	testUtils->WriteComment(KSmtsTest);
       
   405 	
       
   406 	testUtils->FileSession().Delete(KImskOutFile);
       
   407 	testUtils->FileSession().Delete(KImskScrFile);
       
   408 
       
   409 	testUtils->CleanMessageFolderL();
       
   410 	testUtils->ClearEmailAccountsL();
       
   411 	
       
   412 	if (!testUtils->FileSession().MkDir(KEmailDataDir))
       
   413 		{
       
   414 		testUtils->Printf(_L("Created c:\\logs\\email directory\n"));
       
   415 		}
       
   416 
       
   417 	testUtils->GoClientSideL();
       
   418 	smtpService = testUtils->CreateSmtpServiceL();
       
   419 	
       
   420 	// Handle command line arguments
       
   421 	CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC();
       
   422 	TInt count = cmdLineArg->Count();
       
   423 	TBool isCmdLine=FALSE;
       
   424 
       
   425 	if (count>2)	// Command line arguments?
       
   426 		{
       
   427 		if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd)
       
   428 			isCmdLine=TRUE;
       
   429 		}			
       
   430 		TInt iapID = 0;
       
   431 		CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion());
       
   432 		CleanupStack::PushL(dbSession);
       
   433 		CCDConnectionPrefsRecord *connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord));
       
   434 		CleanupStack::PushL(connPrefRecord);
       
   435 		connPrefRecord->iDirection = ECommDbConnectionDirectionOutgoing;
       
   436 		if(!connPrefRecord->FindL(*dbSession))
       
   437 			{
       
   438 			User::Leave(KErrNotFound);		
       
   439 			}		
       
   440 		iapID = connPrefRecord->iDefaultIAP;
       
   441 		
       
   442 		CleanupStack::PopAndDestroy(2); //dbSession,connPrefRecord
       
   443 	
       
   444 	
       
   445 	CImIAPPreferences* prefs = CImIAPPreferences::NewLC();
       
   446 
       
   447 	// Add IAP's to iIAPPreferences
       
   448 	TImIAPChoice iap;
       
   449 	iap.iIAP = iapID;
       
   450 	iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
       
   451 	prefs->AddIAPL(iap);
       
   452 
       
   453 
       
   454 	//overwrite the setings with test code one.  Don't want the default settings.
       
   455 
       
   456 	CImSmtpSettings* settings = new(ELeave) CImSmtpSettings();
       
   457 	CleanupStack::PushL(settings);
       
   458 	settings->Reset();
       
   459 
       
   460 	TBuf<100> buf;
       
   461 	if (isCmdLine)
       
   462 		{
       
   463 		TLex lex(cmdLineArg->Arg(EArgServerAddress));
       
   464 		buf=lex.NextToken();
       
   465 		test.Printf(_L("Server address: %S\n"),&buf);
       
   466 		}
       
   467 	else
       
   468 		{
       
   469 		readConsoleLineBuf(_L("Server address: "),buf);
       
   470 		}
       
   471 	settings->SetServerAddressL(buf);
       
   472 	buf.Zero();
       
   473 	if (isCmdLine)
       
   474 		{
       
   475 		TLex lex(cmdLineArg->Arg(EArgEmail));
       
   476 		buf=lex.NextToken();
       
   477 		test.Printf(_L("Mail: %S\n"),&buf);
       
   478 		}
       
   479 	else
       
   480 		{
       
   481 		readConsoleLineBuf(_L("From email address: "),buf);
       
   482 		}
       
   483 	settings->SetEmailAddressL(buf);
       
   484 	settings->SetEmailAliasL(_L("SMTP Test01"));
       
   485 	settings->SetReplyToAddressL(buf);
       
   486 	settings->SetBodyEncoding(EMsgOutboxMIME);
       
   487 	settings->SetReceiptAddressL(buf);
       
   488 	settings->SetSendCopyToSelf(ESendNoCopy);
       
   489 	settings->SetPort(25);
       
   490 
       
   491 	if (isCmdLine)
       
   492 		{
       
   493 		TLex lex(cmdLineArg->Arg(EArgUseSecureSockets));
       
   494 		TChar choice=lex.Get();
       
   495 		test.Printf(_L("Use secure sockets: %c\n"),choice);
       
   496 		if (choice=='y' || choice=='Y')
       
   497 			settings->SetSecureSockets(ETrue);
       
   498 		else
       
   499 			settings->SetSecureSockets(EFalse);
       
   500 		}
       
   501 	else
       
   502 		{
       
   503 		test.Printf(_L("\n Use secure sockets? Enter (Y/N)\n"));
       
   504 		TKeyCode k = test.Getch();
       
   505 		TChar key = k;
       
   506 		test.Printf(_L("%c"), key);
       
   507 		switch (key)
       
   508 			{
       
   509 			case 'Y':
       
   510 			case 'y':
       
   511 				settings->SetSecureSockets(ETrue);
       
   512 				break;
       
   513 			default:
       
   514 				settings->SetSecureSockets(EFalse);
       
   515 				break;
       
   516 			}
       
   517 		}
       
   518 
       
   519 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   520 
       
   521 	TSmtpAccount smtpAccountId ;
       
   522 	accounts->GetSmtpAccountL(smtpService,smtpAccountId); 
       
   523 	accounts->SaveSmtpSettingsL(smtpAccountId, *settings);
       
   524 	accounts->SaveSmtpIapSettingsL(smtpAccountId, *prefs);
       
   525 	
       
   526 	CleanupStack::PopAndDestroy(4, cmdLineArg); // accounts, settings, prefs, cmdLineArg
       
   527 	testUtils->WriteComment(_L(" smtp server created"));
       
   528 	
       
   529 	testUtils->GoServerSideL();
       
   530 
       
   531 	testUtils->InstantiateSmtpServerMtmL();
       
   532 	serverMtm=testUtils->iSmtpServerMtm;
       
   533 	}
       
   534 
       
   535 LOCAL_C void doMainL() 
       
   536 	{
       
   537 	InitL();
       
   538 
       
   539 	// Load the serial comms device drivers.  If this is not done,
       
   540 	// connecting via NT-RAS returns KErrNotFound (-1).
       
   541 	TInt driverErr;
       
   542 	driverErr=User::LoadPhysicalDevice(PDD_NAME);
       
   543 	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
       
   544 		User::Leave(driverErr);
       
   545 	driverErr=User::LoadLogicalDevice(LDD_NAME);
       
   546 	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
       
   547 		User::Leave(driverErr);
       
   548 
       
   549 
       
   550 	TParse dir;
       
   551 	testUtils->ResolveFile(KSmtsComponent,KSmtsRFCEmails,dir);
       
   552 
       
   553 	testUtils->CreateMessageFilesL(smtpService,KMsvGlobalOutBoxIndexEntryId,dir.FullName());
       
   554 	
       
   555 	testUtils->WriteComment(_L(" Messages created in the outbox"));
       
   556 	testUtils->WriteComment(_L("Instantiated smtp server mtm"));
       
   557 
       
   558 	testUtils->TestStart(1);
       
   559 	TestSendingMessagesL();
       
   560 	testUtils->TestFinish(1,globalError);
       
   561 	ClosedownL();
       
   562 	}
       
   563 
       
   564 
       
   565 GLDEF_C TInt E32Main()
       
   566 	{	
       
   567 	__UHEAP_MARK;
       
   568 	test.Start(_L("T_SMTS01 Test SMTP server MTM class"));
       
   569 	theCleanup=CTrapCleanup::New();
       
   570 	TRAPD(ret,doMainL());		
       
   571 	test(ret==KErrNone);
       
   572 	delete theCleanup;	
       
   573 	test.End();
       
   574 	test.Close();
       
   575 	__UHEAP_MARKEND;
       
   576 	User::Heap().Check();
       
   577 	return(KErrNone);
       
   578 	}