email/pop3andsmtpmtm/clientmtms/test/src/T_imcm02e.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_IMCM02E
       
    15 // Component: IMCM
       
    16 // Owner: KP
       
    17 // Brief description of test harness:
       
    18 // Tests CImEmailOperation - creates plaintext/HTML Receipt message 
       
    19 // with/without attachments; Also tests adding VCard and signature from the 
       
    20 // SMTP settings.
       
    21 // Detailed description of test harness:
       
    22 // As above
       
    23 // Input files required to run test harness:
       
    24 // \MSG\IMCMTSRC\contacts.cdb					<DRIVE>:\system\data\contacts.cdb
       
    25 // \MSG\IMCMTSRC\T_IMCM02E_Entry_Structure.txt	<DRIVE>:\msgtest\IMCM\T_IMCM02E_Entry_Structure.txt
       
    26 // \MSG\IMCMTSRC\rfc82201.txt					<DRIVE>:\msgtest\IMCM\rfc82201.txt
       
    27 // \MSG\IMCMTSRC\rfc82202.txt					<DRIVE>:\msgtest\IMCM\rfc82202.txt
       
    28 // \MSG\IMCMTSRC\rfc82203.txt					<DRIVE>:\msgtest\IMCM\rfc82203.txt
       
    29 // \MSG\IMCMTSRC\rfc82204.txt					<DRIVE>:\msgtest\IMCM\rfc82204.txt
       
    30 // \MSG\IMCMTSRC\rfc82205.txt					<DRIVE>:\msgtest\IMCM\rfc82205.txt
       
    31 // \MSG\IMCMTSRC\rfc82206.txt					<DRIVE>:\msgtest\IMCM\rfc82206.txt
       
    32 // Intermediate files produced while running test harness:
       
    33 // <DRIVE>:\msglogs\T_IMCM02E\Entry_Structure.txt
       
    34 // Output files produced by running test harness:
       
    35 // <DRIVE>:\msglogs\T_IMCM02E.<PLATFORM>.<VARIANT>.LOG.txt
       
    36 // Description of how to build test harness:
       
    37 // cd \msg\imcm\
       
    38 // bldmake bldfiles
       
    39 // abld test build
       
    40 // Description of how to run test harness:
       
    41 // The following instructions are the same for all platforms:
       
    42 // 1. Build T_DB test harness from COMMDB component:
       
    43 // cd \commdb\group
       
    44 // bldmake bldfiles
       
    45 // abld test build t_db
       
    46 // 2. Build the test utilities:
       
    47 // cd \msg\testutils\group\
       
    48 // bldmake bldfiles
       
    49 // abld build
       
    50 // WINS running instructions:
       
    51 // 1. \epoc32\release\wins\<VARIANT>\T_IMCM02E.exe can be used at the command prompt
       
    52 // or executable can be run from Windows Explorer.
       
    53 // All other platform running instructions:
       
    54 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_IMCM02E.exe onto the other platform
       
    55 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into 
       
    56 // <DRIVE>:\system\libs on the other platform
       
    57 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into 
       
    58 // <DRIVE>:\system\libs on the other platform
       
    59 // 4. Run T_IMCM02E.exe on the other platform
       
    60 // 
       
    61 //
       
    62 
       
    63 #include "emailtestutils.h"
       
    64 
       
    65 #include <miutmsg.h>
       
    66 
       
    67 
       
    68 #include <apfrec.h>
       
    69 #include <apgicnfl.h>
       
    70 #include <cemailaccounts.h>
       
    71 
       
    72 #include <cntdb.h>
       
    73 
       
    74 // local variables etc //
       
    75 
       
    76 #define KPeriod					10000	// period of timer
       
    77 
       
    78 _LIT(KImcm02Test, "T_IMCM02e - CImEmailOperation Tests");
       
    79 RTest test(KImcm02Test);
       
    80 
       
    81 LOCAL_D CTrapCleanup* theCleanup;
       
    82 
       
    83 LOCAL_D TMsvId pop3Service;
       
    84 LOCAL_D TMsvId smtpService;
       
    85 LOCAL_D CEmailTestUtils* testUtils;
       
    86 LOCAL_D CMsvEntrySelection* messageSelection;
       
    87 LOCAL_D TInt testNo = 1;
       
    88 LOCAL_D TBool testFailed=EFalse;
       
    89 
       
    90 #define KComponent				_L("IMCM")
       
    91 #define KTestMessageDir			_L("")
       
    92 #define KOkFileNameEntryStructure _L("T_IMCM02e_Entry_Structure.txt")
       
    93 
       
    94 
       
    95 LOCAL_C void InitL()
       
    96 	{
       
    97 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
    98 	CActiveScheduler::Install(scheduler);
       
    99 	CleanupStack::PushL(scheduler);
       
   100 
       
   101 	testUtils = CEmailTestUtils::NewLC(test);
       
   102 	testUtils->CreateAllTestDirectories();
       
   103 	CContactDatabase* contacts(NULL);
       
   104 	TRAPD(err, contacts = CContactDatabase::OpenL());
       
   105 	delete contacts;
       
   106 	if (err==KErrNotFound)
       
   107 		{
       
   108 		testUtils->WriteComment(_L("contacts file is missing from system data"));		
       
   109 		testFailed=ETrue;
       
   110 		return;
       
   111 		}
       
   112 	testUtils->FileSession().SetSessionPath(_L("C:\\"));
       
   113 	testUtils->ClearEmailAccountsL();
       
   114 	testUtils->CleanMessageFolderL();
       
   115 	testUtils->GoServerSideL();
       
   116 	
       
   117 	testUtils->WriteComment(_L("CImEmailOperation Tests"));
       
   118 	}
       
   119 	
       
   120 LOCAL_C void Closedown()
       
   121 	{
       
   122 	CleanupStack::PopAndDestroy(2);  //testUtils, scheduler
       
   123 	User::After(5000000);
       
   124 	}
       
   125 
       
   126 
       
   127 LOCAL_C void CreateReceiptL(TMsvId aMessageId, TMsvPartList aPartList, TMsvEmailTypeList aMsvEmailTypeList, TInt aTestNo)
       
   128 	{
       
   129 	testUtils->TestStart(aTestNo);
       
   130 	CTestActive* testActive = new (ELeave) CTestActive();
       
   131 	CleanupStack::PushL(testActive);
       
   132 
       
   133 	CImEmailOperation* emailOperation = CImEmailOperation::CreateReceiptL(testActive->iStatus, *(testUtils->iMsvSession), aMessageId, KMsvGlobalOutBoxIndexEntryId, aPartList, aMsvEmailTypeList, KUidMsgTypeSMTP);
       
   134 	CleanupStack::PushL(emailOperation);
       
   135 
       
   136 	testActive->StartL();
       
   137 	CActiveScheduler::Start();
       
   138 	testUtils->TestFinish(aTestNo,testActive->iStatus.Int());
       
   139 	CleanupStack::PopAndDestroy(2); // testActive, emailOperation
       
   140 	}
       
   141 
       
   142 LOCAL_C void SetAddVCardToEmailL(TBool addVCard, TMsvId serviceId)
       
   143 	{
       
   144 	CImSmtpSettings* smtpSettings = new (ELeave) CImSmtpSettings;
       
   145 	CleanupStack::PushL(smtpSettings);
       
   146 
       
   147 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   148 	TSmtpAccount smtpAccount;
       
   149 	accounts->GetSmtpAccountL(serviceId, smtpAccount);
       
   150 	accounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings);
       
   151 
       
   152 	smtpSettings->SetAddVCardToEmail(addVCard);
       
   153 	
       
   154 	accounts->SaveSmtpSettingsL(smtpAccount, *smtpSettings);
       
   155 
       
   156 	CleanupStack::PopAndDestroy(2); // smtpSettings, accounts
       
   157 	}
       
   158 
       
   159 LOCAL_C void CreateSignatureL(TMsvId serviceId)
       
   160 	{
       
   161 	testUtils->iMsvEntry->SetEntryL(serviceId);
       
   162 	CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL();
       
   163 	CleanupStack::PushL(paraFormatLayer);
       
   164 
       
   165 	CCharFormatLayer* charFormatLayer=CCharFormatLayer::NewL(); 
       
   166 	CleanupStack::PushL(charFormatLayer);
       
   167 
       
   168 	CRichText* signature=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256);
       
   169 	CleanupStack::PushL(signature);
       
   170 
       
   171 	TBuf<100> bodyContents = _L("(Signature:) Symbian Ltd.");
       
   172 	signature->InsertL(0, bodyContents);
       
   173 
       
   174 	CMsvStore* msvStore = testUtils->iMsvEntry->EditStoreL();
       
   175 	CleanupStack::PushL(msvStore);
       
   176 	
       
   177 	msvStore->StoreBodyTextL(*signature);
       
   178 	msvStore->Commit();
       
   179 	CleanupStack::PopAndDestroy(4); // msvStore, signature, charFormatLayer, paraFormatLayer
       
   180 	}
       
   181 
       
   182 LOCAL_C void SetSignatureToEmailL(TBool addSignature, TMsvId serviceId)
       
   183 	{
       
   184 	CImSmtpSettings* smtpSettings = new (ELeave) CImSmtpSettings;
       
   185 	CleanupStack::PushL(smtpSettings);
       
   186 
       
   187 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   188 	TSmtpAccount smtpAccount;
       
   189 	accounts->GetSmtpAccountL(serviceId, smtpAccount);
       
   190 	accounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings);
       
   191 
       
   192 	smtpSettings->SetAddSignatureToEmail(addSignature);
       
   193 	
       
   194 	accounts->SaveSmtpSettingsL(smtpAccount, *smtpSettings);
       
   195 
       
   196 	CleanupStack::PopAndDestroy(2); // smtpSettings, accounts
       
   197 
       
   198 	if (addSignature)
       
   199 		testUtils->WriteComment(_L("\tAdd VCard"));
       
   200 	}
       
   201 
       
   202 LOCAL_C void SetDefaultServiceL(TMsvId smtpService)
       
   203 	{
       
   204 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   205 	TSmtpAccount smtpAccount;
       
   206 	accounts->GetSmtpAccountL(smtpService, smtpAccount);
       
   207 	accounts->SetDefaultSmtpAccountL(smtpAccount);
       
   208 	
       
   209 	// is default service ??
       
   210 	accounts->GetSmtpAccountL(smtpService, smtpAccount);
       
   211 	if (smtpService != smtpAccount.iSmtpService)
       
   212 		User::Leave(KErrNotFound);
       
   213 	CleanupStack::PopAndDestroy(accounts);
       
   214 	}
       
   215 
       
   216 LOCAL_C void DoPlaintextCreateReceiptTestsL(TMsvId aMessageId)
       
   217 	{
       
   218 	TMsvPartList partList = 0;
       
   219 	TMsvEmailTypeList emailTypeList = 0;
       
   220 
       
   221 	//
       
   222 	// Plaintext messages
       
   223 	//
       
   224 	testUtils->WriteComment(_L("\tPlaintext Create Forward Message Tests"));
       
   225 
       
   226 	// basic new message with nothing!
       
   227 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   228 
       
   229 	// only body
       
   230 	partList = KMsvMessagePartBody;
       
   231 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   232 
       
   233 	// only attachment
       
   234 	partList = KMsvMessagePartAttachments;
       
   235 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   236 
       
   237 	// only body and attachment
       
   238 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments;
       
   239 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   240 
       
   241 	// basic new message with subject
       
   242 	partList = KMsvMessagePartDescription;
       
   243 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   244 
       
   245 	// only body and subject
       
   246 	partList = KMsvMessagePartBody | KMsvMessagePartDescription;
       
   247 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   248 
       
   249 	// only attachment and subject
       
   250 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   251 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   252 
       
   253 	// only body, attachment and subject 
       
   254 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   255 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   256 
       
   257 	// basic new message with originator
       
   258 	partList = KMsvMessagePartOriginator;
       
   259 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   260 
       
   261 	// only body and originator
       
   262 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator;
       
   263 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   264 
       
   265 	// only attachment and originator
       
   266 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   267 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   268 
       
   269 	// only body, attachment and originator
       
   270 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   271 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   272 
       
   273 	// basic new message with subject and originator
       
   274 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   275 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   276 
       
   277 	// only body, subject and originator
       
   278 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   279 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   280 
       
   281 	// only attachment, subject and originator
       
   282 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   283 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   284 
       
   285 	// only body, attachment, subject and originator
       
   286 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   287 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   288 
       
   289 	// basic new message with recipients
       
   290 	partList = KMsvMessagePartRecipient;
       
   291 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   292 
       
   293 	// only body and recipients
       
   294 	partList = KMsvMessagePartBody | KMsvMessagePartRecipient;
       
   295 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   296 
       
   297 	// only attachment and recipients
       
   298 	partList = KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   299 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   300 
       
   301 	// only body, attachment and recipients
       
   302 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   303 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   304 
       
   305 	// basic new message with subject and recipients
       
   306 	partList = KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   307 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   308 
       
   309 	// only body, subject and recipients
       
   310 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   311 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   312 
       
   313 	// only attachment, subject and recipients
       
   314 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   315 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   316 
       
   317 	// only body, attachment, subject and recipients
       
   318 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   319 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   320 
       
   321 	// basic new message with originator and recipients
       
   322 	partList = KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   323 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   324 
       
   325 	// only body, originator and recipients
       
   326 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   327 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   328 
       
   329 	// only attachment, originator and recipients
       
   330 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   331 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   332 
       
   333 	// only body, attachment, originator and recipients
       
   334 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   335 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   336 
       
   337 	// basic new message with subject, originator and recipients
       
   338 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   339 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   340 
       
   341 	// only body, subject, originator and recipients
       
   342 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   343 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   344 
       
   345 	// only attachment, subject, originator and recipients
       
   346 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   347 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   348 
       
   349 	// only body, attachment, subject, originator and recipients
       
   350 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   351 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   352 
       
   353 	// Create a VCard and store in the SMTP settings
       
   354 	SetAddVCardToEmailL(ETrue, smtpService);
       
   355 	testUtils->WriteComment(_L("\tPlaintext Create Forward Message with VCard Tests"));
       
   356 
       
   357 	// basic new message with VCard
       
   358 	partList = 0;
       
   359 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   360 
       
   361 	// only body and VCard
       
   362 	partList = KMsvMessagePartBody;
       
   363 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   364 
       
   365 	// only attachment and VCard
       
   366 	partList = KMsvMessagePartAttachments;
       
   367 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   368 
       
   369 	// only body, attachment and VCard
       
   370 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments;
       
   371 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   372 
       
   373 	// basic new message with subject and VCard
       
   374 	partList = KMsvMessagePartDescription;
       
   375 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   376 
       
   377 	// only body, subject and VCard
       
   378 	partList = KMsvMessagePartBody | KMsvMessagePartDescription;
       
   379 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   380 
       
   381 	// only attachment, subject and VCard
       
   382 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   383 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   384 
       
   385 	// only body, attachment, subject and VCard
       
   386 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   387 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   388 
       
   389 	// basic new message with originator and VCard
       
   390 	partList = KMsvMessagePartOriginator;
       
   391 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   392 
       
   393 	// only body, originator and VCard
       
   394 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator;
       
   395 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   396 
       
   397 	// only attachment, originator and VCard
       
   398 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   399 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   400 
       
   401 	// only body, attachment, originator and VCard
       
   402 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   403 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   404 
       
   405 	// basic new message with subject, originator and VCard
       
   406 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   407 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   408 
       
   409 	// only body, subject, originator and VCard
       
   410 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   411 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   412 
       
   413 	// only attachment, subject, originator and VCard
       
   414 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   415 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   416 
       
   417 	// only body, attachment, subject, originator and VCard
       
   418 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   419 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   420 
       
   421 	// basic new message with recipients and VCard
       
   422 	partList = KMsvMessagePartRecipient;
       
   423 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   424 
       
   425 	// only body, recipients and VCard
       
   426 	partList = KMsvMessagePartBody | KMsvMessagePartRecipient;
       
   427 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   428 
       
   429 	// only attachment, recipients and VCard
       
   430 	partList = KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   431 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   432 
       
   433 	// only body, attachment, recipients and VCard
       
   434 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   435 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   436 
       
   437 	// basic new message with subject, recipients and VCard
       
   438 	partList = KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   439 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   440 
       
   441 	// only body, subject, recipients and VCard
       
   442 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   443 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   444 
       
   445 	// only attachment, subject, recipients and VCard
       
   446 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   447 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   448 
       
   449 	// only body, attachment, subject, recipients and VCard
       
   450 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   451 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   452 
       
   453 	// basic new message with originator, recipients and VCard
       
   454 	partList = KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   455 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   456 
       
   457 	// only body, originator, recipients and VCard
       
   458 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   459 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   460 
       
   461 	// only attachment, originator, recipients and VCard
       
   462 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   463 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   464 
       
   465 	// only body, attachment, originator, recipients and VCard
       
   466 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   467 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   468 
       
   469 	// basic new message with subject, originator, recipients and VCard
       
   470 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   471 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   472 
       
   473 	// only body, subject, originator, recipients and VCard
       
   474 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   475 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   476 
       
   477 	// only attachment, subject, originator, recipients and VCard
       
   478 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   479 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   480 
       
   481 	// only body, attachment, subject, originator, recipients and VCard
       
   482 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   483 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   484 
       
   485 	// Store signature in the SMTP settings
       
   486 	SetAddVCardToEmailL(EFalse, smtpService);
       
   487 	CreateSignatureL(smtpService);
       
   488 	SetSignatureToEmailL(ETrue, smtpService);
       
   489 	testUtils->WriteComment(_L("\tPlaintext Create Forward Message with signature Tests"));
       
   490 
       
   491 	// basic new message with signature!
       
   492 	partList = 0;
       
   493 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   494 
       
   495 	// only body and signature
       
   496 	partList = KMsvMessagePartBody;
       
   497 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   498 
       
   499 	// only attachment and signature
       
   500 	partList = KMsvMessagePartAttachments;
       
   501 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   502 
       
   503 	// only body, attachment and signature
       
   504 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments;
       
   505 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   506 
       
   507 	// basic new message with subject and signature
       
   508 	partList = KMsvMessagePartDescription;
       
   509 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   510 
       
   511 	// only body, subject and signature
       
   512 	partList = KMsvMessagePartBody | KMsvMessagePartDescription;
       
   513 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   514 
       
   515 	// only attachment, subject and signature
       
   516 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   517 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   518 
       
   519 	// only body, attachment, subject and signature
       
   520 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   521 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   522 
       
   523 	// basic new message with originator and signature
       
   524 	partList = KMsvMessagePartOriginator;
       
   525 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   526 
       
   527 	// only body, originator and signature
       
   528 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator;
       
   529 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   530 
       
   531 	// only attachment, originator and signature
       
   532 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   533 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   534 
       
   535 	// only body, attachment, originator and signature
       
   536 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   537 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   538 
       
   539 	// basic new message with subject, originator and signature
       
   540 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   541 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   542 
       
   543 	// only body, subject, originator and signature
       
   544 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   545 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   546 
       
   547 	// only attachment, subject, originator and signature
       
   548 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   549 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   550 
       
   551 	// only body, attachment, subject, originator and signature
       
   552 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   553 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   554 
       
   555 	// basic new message with recipients and signature
       
   556 	partList = KMsvMessagePartRecipient;
       
   557 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   558 
       
   559 	// only body, recipients and signature
       
   560 	partList = KMsvMessagePartBody | KMsvMessagePartRecipient;
       
   561 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   562 
       
   563 	// only attachment, recipients and signature
       
   564 	partList = KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   565 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   566 
       
   567 	// only body, attachment, recipients and signature
       
   568 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   569 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   570 
       
   571 	// basic new message with subject, recipients and signature
       
   572 	partList = KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   573 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   574 
       
   575 	// only body, subject, recipients and signature
       
   576 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   577 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   578 
       
   579 	// only attachment, subject, recipients and signature
       
   580 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   581 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   582 
       
   583 	// only body, attachment, subject, recipients and signature
       
   584 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   585 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   586 
       
   587 	// basic new message with originator, recipients and signature
       
   588 	partList = KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   589 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   590 
       
   591 	// only body, originator, recipients and signature
       
   592 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   593 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   594 
       
   595 	// only attachment, originator, recipients and signature
       
   596 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   597 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   598 
       
   599 	// only body, attachment, originator, recipients and signature
       
   600 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   601 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   602 
       
   603 	// basic new message with subject, originator, recipients and signature
       
   604 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   605 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   606 
       
   607 	// only body, subject, originator, recipients and signature
       
   608 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   609 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   610 
       
   611 	// only attachment, subject, originator, recipients and signature
       
   612 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   613 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   614 
       
   615 	// only body, attachment, subject, originator, recipients and signature
       
   616 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   617 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   618 
       
   619 	// Create a VCard and store in the SMTP settings
       
   620 	SetAddVCardToEmailL(ETrue, smtpService);
       
   621 	testUtils->WriteComment(_L("\tPlaintext Create Forward Message with VCard and signature Tests"));
       
   622 
       
   623 	// basic new message with VCard and Signature!
       
   624 	partList = 0;
       
   625 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   626 
       
   627 	// only body, VCard and Signature
       
   628 	partList = KMsvMessagePartBody;
       
   629 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   630 
       
   631 	// only attachment, VCard and Signature
       
   632 	partList = KMsvMessagePartAttachments;
       
   633 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   634 
       
   635 	// only body, attachment, VCard and Signature
       
   636 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments;
       
   637 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   638 
       
   639 	// basic new message with subject, VCard and Signature
       
   640 	partList = KMsvMessagePartDescription;
       
   641 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   642 
       
   643 	// only body, subject, VCard and Signature
       
   644 	partList = KMsvMessagePartBody | KMsvMessagePartDescription;
       
   645 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   646 
       
   647 	// only attachment, subject, VCard and Signature
       
   648 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   649 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   650 
       
   651 	// only body, attachment, subject, VCard and Signature
       
   652 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription;
       
   653 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   654 
       
   655 	// basic new message with originator, VCard and Signature
       
   656 	partList = KMsvMessagePartOriginator;
       
   657 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   658 
       
   659 	// only body, originator, VCard and Signature
       
   660 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator;
       
   661 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   662 
       
   663 	// only attachment, originator, VCard and Signature
       
   664 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   665 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   666 
       
   667 	// only body, attachment, originator, VCard and Signature
       
   668 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator;
       
   669 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   670 
       
   671 	// basic new message with subject, originator, VCard and Signature
       
   672 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   673 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   674 
       
   675 	// only body, subject, originator, VCard and Signature
       
   676 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   677 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   678 
       
   679 	// only attachment, subject, originator, VCard and Signature
       
   680 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   681 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   682 
       
   683 	// only body, attachment, subject, originator, VCard and Signature
       
   684 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator;
       
   685 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   686 
       
   687 	// basic new message with recipients, VCard and Signature
       
   688 	partList = KMsvMessagePartRecipient;
       
   689 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   690 
       
   691 	// only body, recipients, VCard and Signature
       
   692 	partList = KMsvMessagePartBody | KMsvMessagePartRecipient;
       
   693 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   694 
       
   695 	// only attachment, recipients, VCard and Signature
       
   696 	partList = KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   697 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   698 
       
   699 	// only body, attachment, recipients, VCard and Signature
       
   700 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartRecipient;
       
   701 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   702 
       
   703 	// basic new message with subject, recipients, VCard and Signature
       
   704 	partList = KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   705 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   706 
       
   707 	// only body, subject, recipients, VCard and Signature
       
   708 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   709 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   710 
       
   711 	// only attachment, subject, recipients, VCard and Signature
       
   712 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   713 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   714 
       
   715 	// only body, attachment, subject, recipients, VCard and Signature
       
   716 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartRecipient;
       
   717 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   718 
       
   719 	// basic new message with originator, recipients, VCard and Signature
       
   720 	partList = KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   721 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   722 
       
   723 	// only body, originator, recipients, VCard and Signature
       
   724 	partList = KMsvMessagePartBody | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   725 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   726 
       
   727 	// only attachment, originator, recipients, VCard and Signature
       
   728 	partList = KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   729 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   730 
       
   731 	// only body, attachment, originator, recipients, VCard and Signature
       
   732 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   733 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   734 
       
   735 	// basic new message with subject, originator, recipients, VCard and Signature
       
   736 	partList = KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   737 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   738 
       
   739 	// only body, subject, originator, recipients, VCard and Signature
       
   740 	partList = KMsvMessagePartBody | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   741 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   742 
       
   743 	// only attachment, subject, originator, recipients, VCard and Signature
       
   744 	partList = KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   745 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   746 
       
   747 	// only body, attachment, subject, originator, recipients, VCard and Signature
       
   748 	partList = KMsvMessagePartBody | KMsvMessagePartAttachments | KMsvMessagePartDescription | KMsvMessagePartOriginator | KMsvMessagePartRecipient;
       
   749 	CreateReceiptL(aMessageId, partList, emailTypeList, testNo++);
       
   750 	}
       
   751 
       
   752 
       
   753 LOCAL_C TBool CompareLogsL()
       
   754 	{
       
   755 	TBool errorOccured = EFalse;
       
   756 
       
   757 	CDesCArray* correctFile = new (ELeave) CDesCArrayFlat(1);
       
   758 	CPtrCArray* resultFile = new (ELeave) CPtrCArray(1);
       
   759 
       
   760 	TParse parsedFileName;
       
   761 	TParse parsedResultFileName;
       
   762 	TFileName name;
       
   763 	name.Append(KOkFileNameEntryStructure);
       
   764 	testUtils->ResolveFile(KComponent, name, parsedFileName);
       
   765 	correctFile->AppendL(parsedFileName.FullName());
       
   766 	name.Zero();
       
   767 	name.Copy(KFileNameEntryStructure);
       
   768 	testUtils->ResolveLogFile(name, parsedResultFileName);
       
   769 	resultFile->AppendL(parsedResultFileName.FullName());
       
   770 
       
   771 	RFileReadStream file1;
       
   772 	RFileReadStream file2;
       
   773 	HBufC8* line1Buffer = HBufC8::NewLC(1024);
       
   774 	TPtr8 line1 = line1Buffer->Des();
       
   775 	TBuf8<1> aChar1;
       
   776 
       
   777 	HBufC8* line2Buffer = HBufC8::NewLC(1024);
       
   778 	TPtr8 line2 = line2Buffer->Des();
       
   779 	TBuf8<1> aChar2;
       
   780 
       
   781 	for(TInt i=0; i<correctFile->MdcaCount(); i++)
       
   782 		{
       
   783 		TFileName file1Name = correctFile->MdcaPoint(i);
       
   784 
       
   785 		TFileName file2Name = resultFile->MdcaPoint(i);
       
   786 
       
   787 		TInt error1=KErrNone;
       
   788 		TInt error2=KErrNone;
       
   789 		
       
   790 		test.Printf(_L("\n%s"), file2Name.PtrZ());
       
   791 
       
   792 		error1=file1.Open(testUtils->FileSession(), file1Name, EFileShareAny);
       
   793 		if(error1!=KErrNone)
       
   794 			{
       
   795 			errorOccured = ETrue;
       
   796 			}
       
   797 		else
       
   798 			{
       
   799 			error2=file2.Open(testUtils->FileSession(), file2Name, EFileShareAny);
       
   800 			if(error2!=KErrNone)
       
   801 				{
       
   802 				errorOccured = ETrue;
       
   803 				}
       
   804 			}
       
   805 		
       
   806 		if((error1==KErrNone)&&(error2==KErrNone))
       
   807 			{
       
   808 			// read the file into the conversion object
       
   809 			TBool finished = EFalse;
       
   810 	
       
   811 			do	{
       
   812 				line1.FillZ();
       
   813 				line1.SetLength(0);
       
   814 				// compile the lines one char at a time
       
   815 				do	{
       
   816 					TRAPD( error, file1.ReadL(aChar1, 1) ); 
       
   817 					if (error!=KErrEof)
       
   818 						line1.Append(aChar1);
       
   819 					else
       
   820 						{
       
   821 						finished = ETrue;
       
   822 						break;
       
   823 						}
       
   824 					// stop at the end of line or no more data
       
   825 					}
       
   826 				while((aChar1[0]!=0x0A)&&(line1.Length()<1024));
       
   827 
       
   828 				line2.FillZ();
       
   829 				line2.SetLength(0);
       
   830 				do	{
       
   831 					TRAPD( error, file2.ReadL(aChar2, 1) ); 
       
   832 					if (error!=KErrEof)
       
   833 						line2.Append(aChar2);
       
   834 					else
       
   835 						{
       
   836 						finished = ETrue;
       
   837 						break;
       
   838 						}
       
   839 					// stop at the end of line or no more data
       
   840 					}
       
   841 				while((aChar2[0]!=0x0A)&&(line2.Length()<1024));
       
   842 
       
   843 				// get rid of white space
       
   844    				line1.TrimRight();
       
   845    				line2.TrimRight();
       
   846    
       
   847    				if(line1.Compare(line2) != 0)
       
   848    					{
       
   849    					// error so no point in continuing to compare!!
       
   850    					errorOccured = ETrue;
       
   851    					file1.Close();
       
   852    					file2.Close();
       
   853    					delete correctFile;
       
   854    					delete resultFile;
       
   855    					CleanupStack::PopAndDestroy(2);  //line 1 , line 2
       
   856    					return ETrue;
       
   857    					}
       
   858 				}
       
   859 			while(!finished);
       
   860 			}		
       
   861 
       
   862 		file1.Close();
       
   863 		file2.Close();
       
   864 		}
       
   865 
       
   866 	delete correctFile;
       
   867 	delete resultFile;
       
   868 	CleanupStack::PopAndDestroy(2);  //line 1 , line 2
       
   869 	
       
   870 	return errorOccured;
       
   871 	}
       
   872 
       
   873 LOCAL_C void doMainL()
       
   874 	{
       
   875 	InitL();
       
   876 	if (testFailed)
       
   877 		{
       
   878 		Closedown();
       
   879 		return;
       
   880 		}
       
   881 	testUtils->GoClientSideL();
       
   882 	smtpService = testUtils->CreateSmtpServiceL();
       
   883 	pop3Service = testUtils->CreatePopServiceL();
       
   884 	testUtils->GoServerSideL();
       
   885 
       
   886 	testUtils->CreateMessageFilesL(pop3Service, KMsvGlobalInBoxIndexEntryId, _L("c:\\mailtest\\IMCM\\"));
       
   887 
       
   888 	test.Console()->SetPos(0, 6);
       
   889 	test.Printf(_L("Performing Tests:\n"));
       
   890 	
       
   891 	testUtils->GoClientSideL();
       
   892 
       
   893 	SetDefaultServiceL(smtpService);
       
   894 
       
   895 	// get a list of all email messages in the Inbox
       
   896 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   897 	delete messageSelection;
       
   898 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
   899 
       
   900 	TParse parsedFileName;
       
   901 	TFileName name(KTestMessageDir);
       
   902 	testUtils->ResolveLogFile(name, parsedFileName);
       
   903 
       
   904 //
       
   905 //	Create Plaintext Receipt tests
       
   906 //
       
   907 	test.Console()->SetPos(3, 7);
       
   908 	test.Printf(_L("Create Receipt Tests 1:"));
       
   909 	testUtils->WriteComment(_L("Test 1 - Create Plaintext Receipt Tests"));
       
   910 	//Create Receipt to normal plaintext message with no attachments
       
   911 	testUtils->WriteComment(_L("Create Receipt to Plaintext message with no atcmts Tests"));
       
   912 	TRAPD(ret,DoPlaintextCreateReceiptTestsL(messageSelection->At(5)));
       
   913 	if (ret)
       
   914 		{
       
   915 		testUtils->TestHarnessFailed(ret);
       
   916 		delete messageSelection;
       
   917 		Closedown();
       
   918 		return;
       
   919 		}
       
   920 
       
   921 	test.Console()->SetPos(3, 8);
       
   922 	test.Printf(_L("Create Receipt Tests 2:"));
       
   923 	//Create Receipt to plaintext message with attachment
       
   924 	testUtils->WriteComment(_L("Test 2 - Create Receipt to Plaintext message with atcmt Tests"));
       
   925 	TRAP(ret,DoPlaintextCreateReceiptTestsL(messageSelection->At(1)));
       
   926 	if (ret)
       
   927 		{
       
   928 		testUtils->TestHarnessFailed(ret);
       
   929 		delete messageSelection;
       
   930 		Closedown();
       
   931 		return;
       
   932 		}
       
   933 
       
   934 	test.Console()->SetPos(3, 9);
       
   935 	test.Printf(_L("Create Receipt Tests 3:"));
       
   936 	//Create Receipt to html message with attachment and no text alternative to the HTML
       
   937 	testUtils->WriteComment(_L("Test 3 - Create Receipt to HTML message with atcmt and no text alt. Tests"));
       
   938 	TRAP(ret,DoPlaintextCreateReceiptTestsL(messageSelection->At(3)));
       
   939 	if (ret)
       
   940 		{
       
   941 		testUtils->TestHarnessFailed(ret);
       
   942 		delete messageSelection;
       
   943 		Closedown();
       
   944 		return;
       
   945 		}
       
   946 
       
   947 	testUtils->FindChildrenL(KMsvGlobalOutBoxIndexEntryId, parsedFileName.FullName(), ETrue, EFalse); // writes message info (from Outbox) into files
       
   948 
       
   949 	testUtils->TestFinish(testNo-1);
       
   950 	testUtils->TestHarnessCompleted();
       
   951 
       
   952 	delete messageSelection;
       
   953 	Closedown();
       
   954 	}
       
   955 
       
   956 GLDEF_C TInt E32Main()
       
   957 	{	
       
   958 	__UHEAP_MARK;
       
   959 	test.Start(_L("T_IMCM02e Test CImEmailOperation class\n"));
       
   960 	theCleanup=CTrapCleanup::New();
       
   961 	TRAPD(ret,doMainL());
       
   962 	test(ret==KErrNone);
       
   963 	delete theCleanup;	
       
   964 	test.End();
       
   965 	test.Close();
       
   966 	__UHEAP_MARKEND;
       
   967 	User::Heap().Check();
       
   968 	return(KErrNone);
       
   969 	}