email/pop3andsmtpmtm/clientmtms/test/src/t_imcm03.cpp
changeset 31 ebfee66fde93
parent 0 72b543305e3a
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     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_IMCM03
       
    15 // Component: IMCM
       
    16 // Owner: KP
       
    17 // Brief description of test harness:
       
    18 // Tests CImStoreMessagePart, CImRemoveMessagePart and CImEmailMessage - 
       
    19 // Storing body text and adding attachments/messages tested; Deleting 
       
    20 // attachments/messages tested; Adding/deleting multipart/related image/text 
       
    21 // is also tested.  Different combinations/ordering is used to test the 
       
    22 // creating/deleting of various folders to ensure that the structure of the 
       
    23 // message is still valid.
       
    24 // Detailed description of test harness:
       
    25 // As above
       
    26 // Input files required to run test harness:
       
    27 // \MSG\IMCMTSRC\contacts.cdb					<DRIVE>:\system\data\contacts.cdb
       
    28 // \MSG\IMCMTSRC\T_IMCM02E_Entry_Structure.txt	<DRIVE>:\msgtest\IMCM\T_IMCM02E_Entry_Structure.txt
       
    29 // \MSG\IMCMTSRC\rfc82201.txt					<DRIVE>:\msgtest\IMCM\rfc82201.txt
       
    30 // \MSG\IMCMTSRC\rfc82202.txt					<DRIVE>:\msgtest\IMCM\rfc82202.txt
       
    31 // \MSG\IMCMTSRC\rfc82203.txt					<DRIVE>:\msgtest\IMCM\rfc82203.txt
       
    32 // \MSG\IMCMTSRC\rfc82204.txt					<DRIVE>:\msgtest\IMCM\rfc82204.txt
       
    33 // \MSG\IMCMTSRC\rfc82205.txt					<DRIVE>:\msgtest\IMCM\rfc82205.txt
       
    34 // \MSG\IMCMTSRC\rfc82206.txt					<DRIVE>:\msgtest\IMCM\rfc82206.txt
       
    35 // \MSG\IMCMTSRC\Rfc82201.jig					<DRIVE>:\msgtest\IMCM\rfc822\Rfc82201.jig
       
    36 // Intermediate files produced while running test harness:
       
    37 // <DRIVE>:\msglogs\T_IMCM03\T_IMCM.log
       
    38 // <DRIVE>:\msglogs\T_IMCM03\Entry_Structure.txt
       
    39 // Output files produced by running test harness:
       
    40 // <DRIVE>:\msglogs\T_IMCM03.<PLATFORM>.<VARIANT>.LOG.txt
       
    41 // Description of how to build test harness:
       
    42 // cd \msg\imcm\
       
    43 // bldmake bldfiles
       
    44 // abld test build
       
    45 // Description of how to run test harness:
       
    46 // The following instructions are the same for all platforms:
       
    47 // 1. Build T_DB test harness from COMMDB component:
       
    48 // cd \commdb\group
       
    49 // bldmake bldfiles
       
    50 // abld test build t_db
       
    51 // 2. Build the test utilities:
       
    52 // cd \msg\testutils\group\
       
    53 // bldmake bldfiles
       
    54 // abld build
       
    55 // WINS running instructions:
       
    56 // 1. \epoc32\release\wins\<VARIANT>\T_IMCM03.exe can be used at the command prompt
       
    57 // or executable can be run from Windows Explorer.
       
    58 // All other platform running instructions:
       
    59 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_IMCM03.exe onto the other platform
       
    60 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into 
       
    61 // <DRIVE>:\system\libs on the other platform
       
    62 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into 
       
    63 // <DRIVE>:\system\libs on the other platform
       
    64 // 4. Run T_IMCM03.exe on the other platform
       
    65 // 
       
    66 //
       
    67 
       
    68 #include "emailtestutils.h"
       
    69 #include <miutlog.h>
       
    70 #include <miutmsg.h>
       
    71 #include <txtrich.h>
       
    72 
       
    73 
       
    74 
       
    75 #include <apgaplst.h>
       
    76 #include <apaflrec.h>
       
    77 #include <apgcli.h>
       
    78 #include <apacmdln.h>
       
    79 
       
    80 #include <apasvst.h> // To manually start the app list server
       
    81 
       
    82 #include <apfrec.h>
       
    83 #include <apgicnfl.h>
       
    84 #include <ecom/ecom.h>
       
    85 
       
    86 #include <cmsvattachment.h>
       
    87 #include <mmsvattachmentmanager.h>
       
    88 #include <cemailaccounts.h>
       
    89 
       
    90 LOCAL_D RFs TheFs;
       
    91  
       
    92 // local variables etc //
       
    93 
       
    94 _LIT(KImcmTest, "T_IMCM03 - Testing CImStoreMessagePart/CImRemoveMessagePart");
       
    95 RTest test(KImcmTest);
       
    96 
       
    97 LOCAL_D TMsvId pop3Service;
       
    98 LOCAL_D TMsvId smtpService;
       
    99 LOCAL_D TMsvId newMessageId;
       
   100 LOCAL_D TMsvId newHtmlMessageId;
       
   101 LOCAL_D TMsvId attachmentId;
       
   102 LOCAL_D TMsvId attachmentMessageId;
       
   103 
       
   104 LOCAL_D CTrapCleanup* theCleanup;
       
   105 
       
   106 LOCAL_D CImLog* log;
       
   107 LOCAL_D CEmailTestUtils* testUtils;
       
   108 
       
   109 #define KComponent				_L("IMCM")
       
   110 #define KTestMessageDir			_L("")
       
   111 #define KOkFileNameEntryStructure _L("T_IMCM03_Entry_Structure.txt")
       
   112  
       
   113 //
       
   114 
       
   115 
       
   116 LOCAL_C void InitL()
       
   117 	{	
       
   118 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
   119 	CActiveScheduler::Install(scheduler);
       
   120 	CleanupStack::PushL(scheduler);
       
   121 
       
   122 	testUtils = CEmailTestUtils::NewLC(test);
       
   123 	testUtils->CreateAllTestDirectories();
       
   124 	testUtils->FileSession().SetSessionPath(_L("C:\\"));
       
   125 	testUtils->ClearEmailAccountsL();
       
   126 	testUtils->CleanMessageFolderL();
       
   127 	testUtils->GoServerSideL();
       
   128 
       
   129 	log = CImLog::NewL(_L("c:\\logs\\email\\T_IMCM.log"), EAppend);
       
   130 	CleanupStack::PushL(log);
       
   131 	log->AppendComment(_L8("*** T_IMCM03 Test CImStoreMessagePart & CImRemoveMessagePart ***"));
       
   132 	TBuf8<80> buf;
       
   133 
       
   134 #if defined(__WINS__)	
       
   135 	buf.Append(_L8("WINS "));
       
   136 #else
       
   137 	buf.Append(_L8("MARM "));
       
   138 #endif
       
   139 #if defined(_UNICODE)
       
   140 	buf.Append(_L8("U"));
       
   141 #endif
       
   142 #if defined(_DEBUG)
       
   143 	buf.Append(_L8("DEB"));
       
   144 #else
       
   145 	buf.Append(_L8("REL"));
       
   146 #endif
       
   147 	log->AppendComment(buf);
       
   148 
       
   149 	// Start the app list server
       
   150 	StartupApaServerProcess();
       
   151 	}
       
   152 
       
   153 	
       
   154 LOCAL_C void Closedown()
       
   155 	{
       
   156 	log->AppendComment(_L8("**********    T_IMCM03 Tests Complete    **********"));
       
   157 	log->AppendComment(_L8(""));
       
   158 
       
   159 	CleanupStack::PopAndDestroy(3);  //testUtils, log, scheduler 
       
   160 	TheFs.Close();
       
   161 	RFbsSession::Disconnect();
       
   162 	}
       
   163 
       
   164 //
       
   165 
       
   166 LOCAL_C void CreateNewPlaintextMessageL()
       
   167 	{
       
   168 	/*
       
   169 	// Create new Plaintext message
       
   170 	*/
       
   171 	CTestActive* testActive = new (ELeave) CTestActive();
       
   172 	CleanupStack::PushL(testActive);
       
   173 
       
   174 	TMsvEmailTypeList msvEmailTypeList = 0;
       
   175 	TMsvPartList partList = (KMsvMessagePartBody | KMsvMessagePartAttachments);
       
   176 	CImEmailOperation* emailOperation = CImEmailOperation::CreateNewL(testActive->iStatus, *(testUtils->iMsvSession), KMsvGlobalOutBoxIndexEntryId, partList, msvEmailTypeList, KUidMsgTypeSMTP);
       
   177 	CleanupStack::PushL(emailOperation);
       
   178 
       
   179 	TestMsvOperationTimer* testMsvOperationTimer = TestMsvOperationTimer::NewLC(test.Console(), emailOperation, test);
       
   180 	testActive->StartL();
       
   181 	testMsvOperationTimer->IssueRequest();
       
   182 	CActiveScheduler::Start();
       
   183 
       
   184 	//check progress
       
   185 	TMsvId temp;
       
   186 	TPckgC<TMsvId> paramPack(temp);
       
   187 	const TDesC8& progBuf = emailOperation->ProgressL();
       
   188 	paramPack.Set(progBuf);
       
   189 	newMessageId = paramPack();
       
   190 	if (newMessageId != NULL)
       
   191 		log->AppendComment(_L8("\t Created New plaintext message"));
       
   192 
       
   193 	CleanupStack::PopAndDestroy(3,testActive); // emailOperation, testMsvOperationTimer
       
   194 	}
       
   195 
       
   196 LOCAL_C void CreateNewHtmlMessageL()
       
   197 	{
       
   198 	/*
       
   199 	// Create new HTML message
       
   200 	*/
       
   201 	CTestActive* testActive = new (ELeave) CTestActive();
       
   202 	CleanupStack::PushL(testActive);
       
   203 
       
   204 	TMsvEmailTypeList msvEmailTypeList = KMsvEmailTypeListMHTMLMessage;
       
   205 	TMsvPartList partList = (KMsvMessagePartBody | KMsvMessagePartAttachments);
       
   206 	CImEmailOperation* emailOperation = CImEmailOperation::CreateNewL(testActive->iStatus, *(testUtils->iMsvSession), KMsvGlobalOutBoxIndexEntryId, partList, msvEmailTypeList, KUidMsgTypeSMTP);
       
   207 	CleanupStack::PushL(emailOperation);
       
   208 
       
   209 	TestMsvOperationTimer* testMsvOperationTimer = TestMsvOperationTimer::NewLC(test.Console(), emailOperation, test);
       
   210 	testActive->StartL();
       
   211 	testMsvOperationTimer->IssueRequest();
       
   212 	CActiveScheduler::Start();
       
   213 
       
   214 	//check progress
       
   215 	TMsvId temp;	
       
   216 	TPckgC<TMsvId> paramPack(temp);
       
   217 	const TDesC8& progBuf = emailOperation->ProgressL();	
       
   218 	paramPack.Set(progBuf);
       
   219 	newHtmlMessageId=paramPack();	
       
   220 	if (newHtmlMessageId!=NULL)
       
   221 		log->AppendComment(_L8("\t Created New HTML message"));
       
   222 
       
   223 	CleanupStack::PopAndDestroy(3,testActive); // emailOperation, testMsvOperationTimer
       
   224 	}
       
   225 
       
   226 LOCAL_C void TestStoreBodyTextL(TMsvId aMessageId)
       
   227 	{
       
   228 	CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL();
       
   229 	CleanupStack::PushL(paraFormatLayer);
       
   230 
       
   231 	CCharFormatLayer* charFormatLayer=CCharFormatLayer::NewL(); 
       
   232 	CleanupStack::PushL(charFormatLayer);
       
   233 
       
   234 	CRichText* bodyText=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256);
       
   235 	CleanupStack::PushL(bodyText);
       
   236 
       
   237 	TBuf<100> bodyContents = _L("Test body contents so that we can test the store body text code.");
       
   238 	bodyText->InsertL(0, bodyContents);
       
   239 
       
   240 	CTestActive* testActive = new (ELeave) CTestActive();
       
   241 	CleanupStack::PushL(testActive);
       
   242 
       
   243 	// store the body text
       
   244 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   245 	imEmailMessage->StoreBodyTextL(aMessageId, *bodyText, testActive->iStatus);
       
   246 	testActive->StartL();
       
   247 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   248 	CleanupStack::PopAndDestroy(2,testActive); //imEmailMessage
       
   249 		
       
   250 	CRichText* validRichText1=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256);
       
   251 	CleanupStack::PushL(validRichText1);
       
   252 
       
   253 	// restore the body text
       
   254 	testActive=NULL;
       
   255 	testActive = new (ELeave) CTestActive();
       
   256 	CleanupStack::PushL(testActive);
       
   257 	imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   258 	imEmailMessage->GetBodyTextL(testActive->iStatus, aMessageId, CImEmailMessage::EThisMessageOnly, *validRichText1, *paraFormatLayer, *charFormatLayer);
       
   259 	testActive->StartL();
       
   260 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   261 
       
   262 	TBuf<100> bufa = bodyText->Read(0);
       
   263 	TBuf<100> bufb = validRichText1->Read(0);
       
   264 	test((bufa.Compare(bufb))==0);
       
   265 	CleanupStack::PopAndDestroy(4,bodyText); //testActive, imEmailMessage, validRichText1, 
       
   266 	
       
   267 	// message now contains a richtext store so try and store rich text again
       
   268 	bodyContents = _L("Some other stuff");
       
   269 	bufb.Append(bodyContents);
       
   270 
       
   271 	bodyText=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256);
       
   272 	CleanupStack::PushL(bodyText);
       
   273 	bodyText->InsertL(0, bufb);
       
   274 
       
   275 	testActive = new (ELeave) CTestActive();
       
   276 	CleanupStack::PushL(testActive);
       
   277 
       
   278 	// store the body text
       
   279 	imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   280 	imEmailMessage->StoreBodyTextL(aMessageId, *bodyText, testActive->iStatus);
       
   281 	testActive->StartL();
       
   282 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   283 	CleanupStack::PopAndDestroy(2,testActive); //imEmailMessage, 
       
   284 		
       
   285 	validRichText1=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256);
       
   286 	CleanupStack::PushL(validRichText1);
       
   287 
       
   288 	// restore the body text
       
   289 	testActive = new (ELeave) CTestActive();
       
   290 	CleanupStack::PushL(testActive);
       
   291 	imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   292 	imEmailMessage->GetBodyTextL(testActive->iStatus, aMessageId, CImEmailMessage::EThisMessageOnly, *validRichText1, *paraFormatLayer, *charFormatLayer);
       
   293 	testActive->StartL();
       
   294 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   295 
       
   296 	bufa = bodyText->Read(0);
       
   297 	bufb = validRichText1->Read(0);
       
   298 	test((bufa.Compare(bufb))==0);
       
   299 
       
   300 	CleanupStack::PopAndDestroy(6,paraFormatLayer); // , imEmailMessage, testActive, validRichText1, bodyText, charFormatLayer, 
       
   301 	_LIT8(KComment, "\t Stored Body Text to message 00%x");
       
   302 	TBuf8<80> buf;
       
   303 	buf.Format(KComment, aMessageId);
       
   304 	log->AppendComment(buf);
       
   305 	}
       
   306 
       
   307 LOCAL_C void TestAddAttachmentL(TMsvId aMessageId)
       
   308 	{
       
   309 	CTestActive* testActive = new (ELeave) CTestActive();
       
   310 	CleanupStack::PushL(testActive);
       
   311 
       
   312 	_LIT(KAttachment1, "C:\\mailtest\\IMCM\\rfc82201.txt");
       
   313 	// add an attachment to the message
       
   314 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   315 
       
   316 	// Make sure you are set on the Message Id
       
   317 	testUtils->iMsvEntry->SetEntryL(aMessageId);
       
   318 	CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
       
   319 	CleanupStack::PushL(attachmentInfo);
       
   320 	imEmailMessage->AttachmentManager().AddAttachmentL(KAttachment1, attachmentInfo, testActive->iStatus);
       
   321 	CleanupStack::Pop(attachmentInfo);	 // ownership passed to attachment manager
       
   322 
       
   323 	testActive->StartL();
       
   324 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   325 
       
   326 	TMsvId temp;	
       
   327 	TPckgC<TMsvId> paramPack(temp);
       
   328 	const TDesC8& progBuf = imEmailMessage->ProgressL();	
       
   329 	paramPack.Set(progBuf);
       
   330 	attachmentId = paramPack();	
       
   331 
       
   332 	CleanupStack::PopAndDestroy(2,testActive); // imEmailMessage, 
       
   333 	_LIT8(KComment, "\t Attachment added with Id 00%x to message 00%x");
       
   334 	TBuf8<80> buf;
       
   335 	buf.Format(KComment, attachmentId, aMessageId);
       
   336 	log->AppendComment(buf);
       
   337 	} 
       
   338 
       
   339 LOCAL_C void TestAddMessageAsAttachmentL(TMsvId aMessageId)
       
   340 	{
       
   341 	CTestActive* testActive = new (ELeave) CTestActive();
       
   342 	CleanupStack::PushL(testActive);
       
   343 
       
   344 	// add a message as an attachment to the message
       
   345 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   346 
       
   347 	// Make sure you are set on the Message Id
       
   348 	testUtils->iMsvEntry->SetEntryL(aMessageId);
       
   349 	
       
   350 	MMsvAttachmentManager& attachmentManager = imEmailMessage->AttachmentManager();
       
   351 	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvMessageEntry);
       
   352 	CleanupStack::PushL(attachment);
       
   353 	attachmentManager.AddEntryAsAttachmentL(0x10100002,attachment,testActive->iStatus);
       
   354 	CleanupStack::Pop(attachment); // ownership passed to attachment manager
       
   355 	
       
   356 	testActive->StartL(); 
       
   357 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   358 
       
   359 	TMsvId temp;	
       
   360 	TPckgC<TMsvId> paramPack(temp);
       
   361 	const TDesC8& progBuf = imEmailMessage->ProgressL();	
       
   362 	paramPack.Set(progBuf);
       
   363 	attachmentMessageId = paramPack();	
       
   364 
       
   365 	CleanupStack::PopAndDestroy(2,testActive); // imEmailMessage, 
       
   366 	_LIT8(KComment, "\t Message with Id 00%x added as attachment to message 00%x");
       
   367 	TBuf8<80> buf;
       
   368 	buf.Format(KComment, attachmentMessageId, aMessageId);
       
   369 	log->AppendComment(buf);
       
   370 	} 
       
   371 
       
   372 LOCAL_C void TestRemoveAttachmentL(TMsvId aMessageId, TMsvId aAttachmentId)
       
   373 	{
       
   374 	// remove attachment from the message
       
   375 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   376 
       
   377 	CTestActive* testActive = new (ELeave) CTestActive();
       
   378 	CleanupStack::PushL(testActive);
       
   379 
       
   380 	// Make sure you are set on the message Id
       
   381 	testUtils->iMsvEntry->SetEntryL(aMessageId);
       
   382 	TMsvAttachmentId attachmentId = aAttachmentId;
       
   383 	imEmailMessage->AttachmentManager().RemoveAttachmentL(attachmentId,testActive->iStatus);
       
   384 	testActive->StartL();
       
   385 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   386 
       
   387 	CleanupStack::PopAndDestroy(2,imEmailMessage); // testActive, 
       
   388 
       
   389 	_LIT8(KComment, "\t Attachment with Id 00%x Removed from message 00%x");
       
   390 	TBuf8<80> buf;
       
   391 	buf.Format(KComment, aAttachmentId, aMessageId);
       
   392 	log->AppendComment(buf);
       
   393 	}
       
   394 
       
   395 LOCAL_C void TestRemoveAttachedMessageL(TMsvId aMessageId, TMsvId aAttachedMessageId)
       
   396 	{
       
   397 	CTestActive* testActive = new (ELeave) CTestActive();
       
   398 	CleanupStack::PushL(testActive);
       
   399 
       
   400 	// remove attachment from the message
       
   401 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   402 	// Make sure you are set on the message Id
       
   403 	testUtils->iMsvEntry->SetEntryL(aMessageId);
       
   404 	TMsvAttachmentId attachmentId = aAttachedMessageId;
       
   405 	imEmailMessage->AttachmentManager().RemoveAttachmentL(attachmentId,testActive->iStatus);
       
   406 	testActive->StartL();
       
   407 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   408 
       
   409 	CleanupStack::PopAndDestroy(2,testActive); // imEmailMessage, 
       
   410 	_LIT8(KComment, "\t Attached Message with Id 00%x Removed from message 00%x");
       
   411 	TBuf8<80> buf;
       
   412 	buf.Format(KComment, aAttachedMessageId, aMessageId);
       
   413 	log->AppendComment(buf);
       
   414 	}
       
   415 
       
   416 LOCAL_C void TestAddRelatedAttachmentL(TMsvId aMessageId, TMsvId aRelatedPartId)
       
   417 	{
       
   418 	CTestActive* testActive = new (ELeave) CTestActive();
       
   419 	CleanupStack::PushL(testActive);
       
   420 
       
   421 	_LIT(KAttachment1, "C:\\mailtest\\IMCM\\rfc82201.txt");
       
   422 	_LIT8(KContentId, "abcdefgh.1234567@symbian.com");
       
   423 	// add an attachment to the message
       
   424 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   425 	
       
   426 	imEmailMessage->AddRelatedPartL(aMessageId, KAttachment1, testActive->iStatus, aRelatedPartId, KContentId);
       
   427 
       
   428 	testActive->StartL();
       
   429 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   430 
       
   431 	TMsvId temp;	
       
   432 	TPckgC<TMsvId> paramPack(temp);
       
   433 	const TDesC8& progBuf = imEmailMessage->ProgressL();	
       
   434 	paramPack.Set(progBuf);
       
   435 	attachmentId = paramPack();	
       
   436 
       
   437 	CleanupStack::PopAndDestroy(2,testActive); // imEmailMessage, 
       
   438 	_LIT8(KComment, "\t Attachment added with Id 00%x to message 00%x");
       
   439 	TBuf8<80> buf;
       
   440 	buf.Format(KComment, attachmentId, aMessageId);
       
   441 	log->AppendComment(buf);
       
   442 	}
       
   443 
       
   444 LOCAL_C void TestAddRelatedImageL(TMsvId aMessageId, TMsvId aRelatedPartId)
       
   445 	{
       
   446 	CTestActive* testActive = new (ELeave) CTestActive();
       
   447 	CleanupStack::PushL(testActive);
       
   448 
       
   449 	_LIT(KAttachment1, "C:\\mailtest\\rfc822\\Rfc82201.jig");
       
   450 	_LIT8(KContentId, "abcdefgh.1234567@symbian.com");
       
   451 	// add an attachment to the message
       
   452 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   453 
       
   454 	imEmailMessage->AddRelatedPartL(aMessageId, KAttachment1, testActive->iStatus, aRelatedPartId, KContentId);
       
   455 
       
   456 	testActive->StartL();
       
   457 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   458 
       
   459 	TMsvId temp;	
       
   460 	TPckgC<TMsvId> paramPack(temp);
       
   461 	const TDesC8& progBuf = imEmailMessage->ProgressL();	
       
   462 	paramPack.Set(progBuf);
       
   463 	attachmentId = paramPack();	
       
   464 
       
   465 	CleanupStack::PopAndDestroy(2,testActive); //  imEmailMessage
       
   466 	_LIT8(KComment, "\t Attachment added with Id 00%x to message 00%x");
       
   467 	TBuf8<80> buf;
       
   468 	buf.Format(KComment, attachmentId, aMessageId);
       
   469 	log->AppendComment(buf);
       
   470 	}
       
   471 
       
   472 LOCAL_C TMsvId GetRelatedPartIdL(TMsvId aMessageId)
       
   473 	{
       
   474 	CTestActive* testActive = new (ELeave) CTestActive();
       
   475 	CleanupStack::PushL(testActive);
       
   476 
       
   477 	CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   478 	imEmailMessage->FindFirstHTMLPageL(aMessageId, testActive->iStatus);
       
   479 	testActive->StartL();
       
   480 	CActiveScheduler::Start();	// wait for the asynch operation to complete
       
   481 
       
   482 	TMsvId htmlEntryId;
       
   483 	TBool found = EFalse;
       
   484 	HBufC* temp = imEmailMessage->GetUniversalResourceIdentifierL(htmlEntryId, found);
       
   485 	delete temp;
       
   486 	test(found);
       
   487 	CleanupStack::PopAndDestroy(2,testActive); // imEmailMessage, 
       
   488 	return htmlEntryId;
       
   489 	}
       
   490 
       
   491 LOCAL_C TBool CompareLogsL()
       
   492 	{
       
   493 	TBool errorOccured = EFalse;
       
   494 
       
   495 	CDesCArray* correctFile = new (ELeave) CDesCArrayFlat(1);
       
   496 	CPtrCArray* resultFile = new (ELeave) CPtrCArray(1);
       
   497 
       
   498 	TParse parsedFileName;
       
   499 	TParse parsedResultFileName;
       
   500 	TFileName name;
       
   501 	name.Append(KOkFileNameEntryStructure);
       
   502 	testUtils->ResolveFile(KComponent, name, parsedFileName);
       
   503 	correctFile->AppendL(parsedFileName.FullName());
       
   504 	name.Zero();
       
   505 	name.Copy(KFileNameEntryStructure);
       
   506 	testUtils->ResolveLogFile(name, parsedResultFileName);
       
   507 	resultFile->AppendL(parsedResultFileName.FullName());
       
   508 
       
   509 	RFileReadStream file1;
       
   510 	RFileReadStream file2;
       
   511 	HBufC8* line1Buffer = HBufC8::NewLC(1024);
       
   512 	TPtr8 line1 = line1Buffer->Des();
       
   513 	TBuf8<1> aChar1;
       
   514 
       
   515 	HBufC8* line2Buffer = HBufC8::NewLC(1024);
       
   516 	TPtr8 line2 = line2Buffer->Des();
       
   517 	TBuf8<1> aChar2;
       
   518 
       
   519 	for(TInt i=0; i<correctFile->MdcaCount(); i++)
       
   520 		{
       
   521 		TFileName file1Name = correctFile->MdcaPoint(i);
       
   522 
       
   523 		TFileName file2Name = resultFile->MdcaPoint(i);
       
   524 
       
   525 		TInt error1=KErrNone;
       
   526 		TInt error2=KErrNone;
       
   527 		
       
   528 		test.Printf(_L("\n%s"), file2Name.PtrZ());
       
   529 
       
   530 		error1=file1.Open(testUtils->FileSession(), file1Name, EFileShareAny);
       
   531 		if(error1!=KErrNone)
       
   532 			{
       
   533 			errorOccured = ETrue;
       
   534 			}
       
   535 		else
       
   536 			{
       
   537 			error2=file2.Open(testUtils->FileSession(), file2Name, EFileShareAny);
       
   538 			if(error2!=KErrNone)
       
   539 				{
       
   540 				errorOccured = ETrue;
       
   541 				}
       
   542 			}
       
   543 		
       
   544 		if((error1==KErrNone)&&(error2==KErrNone))
       
   545 			{
       
   546 			// read the file into the conversion object
       
   547 			TBool finished = EFalse;
       
   548 	
       
   549 			do	{
       
   550 				line1.FillZ();
       
   551 				line1.SetLength(0);
       
   552 				// compile the lines one char at a time
       
   553 				do	{
       
   554 					TRAPD( error, file1.ReadL(aChar1, 1) ); 
       
   555 					if (error!=KErrEof)
       
   556 						line1.Append(aChar1);
       
   557 					else
       
   558 						{
       
   559 						finished = ETrue;
       
   560 						break;
       
   561 						}
       
   562 					// stop at the end of line or no more data
       
   563 					}
       
   564 				while((aChar1[0]!=0x0A)&&(line1.Length()<1024));
       
   565 
       
   566 				line2.FillZ();
       
   567 				line2.SetLength(0);
       
   568 				do	{
       
   569 					TRAPD( error, file2.ReadL(aChar2, 1) ); 
       
   570 					if (error!=KErrEof)
       
   571 						line2.Append(aChar2);
       
   572 					else
       
   573 						{
       
   574 						finished = ETrue;
       
   575 						break;
       
   576 						}
       
   577 					// stop at the end of line or no more data
       
   578 					}
       
   579 				while((aChar2[0]!=0x0A)&&(line2.Length()<1024));
       
   580 				
       
   581 				// get rid of white space
       
   582 				line1.TrimRight();
       
   583 				line2.TrimRight();
       
   584 
       
   585 				if(line1.Compare(line2))
       
   586 					{
       
   587 					// error so no point in continuing to compare!!
       
   588 					errorOccured = ETrue;
       
   589 					file1.Close();
       
   590 					file2.Close();
       
   591 					delete correctFile;
       
   592 					delete resultFile;
       
   593 					CleanupStack::PopAndDestroy(2);  //line 1 , line 2
       
   594 					return ETrue;
       
   595 					}
       
   596 				}
       
   597 			while(!finished);
       
   598 			}		
       
   599 
       
   600 		file1.Close();
       
   601 		file2.Close();
       
   602 		}
       
   603 
       
   604 	delete correctFile;
       
   605 	delete resultFile;
       
   606 	CleanupStack::PopAndDestroy(2);  //line 1 , line 2
       
   607 	
       
   608 	return errorOccured;
       
   609 	}
       
   610 
       
   611 LOCAL_C void doMainL()
       
   612 	{
       
   613 	InitL();
       
   614 
       
   615 	testUtils->GoClientSideL();
       
   616 	testUtils->ClearEmailAccountsL();
       
   617 	smtpService = testUtils->CreateSmtpServiceL();
       
   618 	pop3Service = testUtils->CreatePopServiceL();
       
   619 	testUtils->GoServerSideL();
       
   620 
       
   621 	testUtils->FileSession().SetSessionPath(_L("c:\\"));
       
   622 
       
   623 	testUtils->CreateMessageFilesL(pop3Service, KMsvGlobalInBoxIndexEntryId, _L("c:\\mailtest\\IMCM\\"));
       
   624 
       
   625 	test.Printf(_L("\nPerforming Tests\n"));
       
   626 	
       
   627 	testUtils->GoClientSideL();
       
   628 
       
   629 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   630 	TSmtpAccount smtpAccount;
       
   631 	accounts->GetSmtpAccountL(smtpService, smtpAccount);
       
   632 	accounts->SetDefaultSmtpAccountL(smtpAccount);
       
   633 	CleanupStack::PopAndDestroy(accounts);
       
   634 
       
   635 	TParse parsedFileName;
       
   636 	TFileName name(KTestMessageDir);
       
   637 	testUtils->ResolveLogFile(name, parsedFileName);
       
   638 
       
   639 	//
       
   640 	// Test with Plaintext Messages
       
   641 	//
       
   642 	TInt testNo = 1;
       
   643 	_LIT8(KIMCMTestPassed, "Test %d passed");
       
   644 	TBuf8<80> buf;
       
   645 
       
   646 	testUtils->TestStart(testNo);
       
   647 	// test StoreBodyText when no text entry exists under message entry
       
   648 	CreateNewPlaintextMessageL();
       
   649 	TestStoreBodyTextL(newMessageId);
       
   650 	buf.Format(KIMCMTestPassed, testNo++);
       
   651 	log->AppendComment(buf);
       
   652 	testUtils->TestFinish(testNo-1);
       
   653 
       
   654 	testUtils->TestStart(testNo);
       
   655 	// test StoreBodyText when text entry exists under message entry
       
   656 	CreateNewPlaintextMessageL();
       
   657 	TestStoreBodyTextL(newMessageId);
       
   658 	TestStoreBodyTextL(newMessageId);
       
   659 	buf.Format(KIMCMTestPassed, testNo++);
       
   660 	log->AppendComment(buf);
       
   661 	testUtils->TestFinish(testNo-1);
       
   662 
       
   663 	testUtils->TestStart(testNo);
       
   664 	// test StoreBodyText when text entry exists under message entry
       
   665 	CreateNewPlaintextMessageL();
       
   666 	TestStoreBodyTextL(newMessageId);
       
   667 	TestStoreBodyTextL(newMessageId);
       
   668 	TestStoreBodyTextL(newMessageId);
       
   669 	buf.Format(KIMCMTestPassed, testNo++);
       
   670 	log->AppendComment(buf);
       
   671 	testUtils->TestFinish(testNo-1);
       
   672 
       
   673 	testUtils->TestStart(testNo);
       
   674 	// test add attachment when there are no other entries
       
   675 	CreateNewPlaintextMessageL();
       
   676 	TestAddAttachmentL(newMessageId);
       
   677 	buf.Format(KIMCMTestPassed, testNo++);
       
   678 	log->AppendComment(buf);
       
   679 	testUtils->TestFinish(testNo-1);
       
   680 
       
   681 	testUtils->TestStart(testNo);
       
   682 	// test remove attachment
       
   683 	CreateNewPlaintextMessageL();
       
   684 	TestAddAttachmentL(newMessageId);
       
   685 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   686 	buf.Format(KIMCMTestPassed, testNo++);
       
   687 	log->AppendComment(buf);
       
   688 	testUtils->TestFinish(testNo-1);
       
   689 
       
   690 	testUtils->TestStart(testNo);
       
   691 	// test StoreBodyText when there is already an entry under message entry - should create multipart/mixed
       
   692 	CreateNewPlaintextMessageL();
       
   693 	TestAddAttachmentL(newMessageId);
       
   694 	TestStoreBodyTextL(newMessageId);
       
   695 	buf.Format(KIMCMTestPassed, testNo++);
       
   696 	log->AppendComment(buf);
       
   697 	testUtils->TestFinish(testNo-1);
       
   698 
       
   699 	testUtils->TestStart(testNo);
       
   700 	// test remove attachment
       
   701 	CreateNewPlaintextMessageL();
       
   702 	TestAddAttachmentL(newMessageId);
       
   703 	TestStoreBodyTextL(newMessageId);
       
   704 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   705 	buf.Format(KIMCMTestPassed, testNo++);
       
   706 	log->AppendComment(buf);
       
   707 	testUtils->TestFinish(testNo-1);
       
   708 
       
   709 	testUtils->TestStart(testNo);
       
   710 	// test add Attachment when there is already an entry under message entry - should create multipart/mixed
       
   711 	CreateNewPlaintextMessageL();
       
   712 	TestStoreBodyTextL(newMessageId);
       
   713 	TestAddAttachmentL(newMessageId);
       
   714 	buf.Format(KIMCMTestPassed, testNo++);
       
   715 	log->AppendComment(buf);
       
   716 	testUtils->TestFinish(testNo-1);
       
   717 
       
   718 	testUtils->TestStart(testNo);
       
   719 	// test remove attachment
       
   720 	CreateNewPlaintextMessageL();
       
   721 	TestStoreBodyTextL(newMessageId);
       
   722 	TestAddAttachmentL(newMessageId);
       
   723 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   724 	buf.Format(KIMCMTestPassed, testNo++);
       
   725 	log->AppendComment(buf);
       
   726 	testUtils->TestFinish(testNo-1);
       
   727 
       
   728 	testUtils->TestStart(testNo);
       
   729 	// test StoreBodyText when there is already a multipart/mixed folder
       
   730 	CreateNewPlaintextMessageL();
       
   731 	TestStoreBodyTextL(newMessageId);
       
   732 	TestAddAttachmentL(newMessageId);
       
   733 	TestAddAttachmentL(newMessageId);
       
   734 	buf.Format(KIMCMTestPassed, testNo++);
       
   735 	log->AppendComment(buf);
       
   736 	testUtils->TestFinish(testNo-1);
       
   737 
       
   738 	testUtils->TestStart(testNo);
       
   739 	// test remove attachment
       
   740 	CreateNewPlaintextMessageL();
       
   741 	TestStoreBodyTextL(newMessageId);
       
   742 	TestAddAttachmentL(newMessageId);
       
   743 	TestAddAttachmentL(newMessageId);
       
   744 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   745 	buf.Format(KIMCMTestPassed, testNo++);
       
   746 	log->AppendComment(buf);
       
   747 	testUtils->TestFinish(testNo-1);
       
   748 
       
   749 	testUtils->TestStart(testNo);
       
   750 	// test add Attachment when there is already a multipart/mixed folder
       
   751 	CreateNewPlaintextMessageL();
       
   752 	TestAddAttachmentL(newMessageId);
       
   753 	TestAddAttachmentL(newMessageId);
       
   754 	TestStoreBodyTextL(newMessageId);
       
   755 	buf.Format(KIMCMTestPassed, testNo++);
       
   756 	log->AppendComment(buf);
       
   757 	testUtils->TestFinish(testNo-1);
       
   758 
       
   759 	testUtils->TestStart(testNo);
       
   760 	// test remove attachment
       
   761 	CreateNewPlaintextMessageL();
       
   762 	TestAddAttachmentL(newMessageId);
       
   763 	TestAddAttachmentL(newMessageId);
       
   764 	TestStoreBodyTextL(newMessageId);
       
   765 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   766 	buf.Format(KIMCMTestPassed, testNo++);
       
   767 	log->AppendComment(buf);
       
   768 	testUtils->TestFinish(testNo-1);
       
   769 
       
   770 	testUtils->TestStart(testNo);
       
   771 	// test add Attachment when there is already a multipart/mixed folder
       
   772 	CreateNewPlaintextMessageL();
       
   773 	TestAddAttachmentL(newMessageId);
       
   774 	TestStoreBodyTextL(newMessageId);
       
   775 	TestAddAttachmentL(newMessageId);
       
   776 	buf.Format(KIMCMTestPassed, testNo++);
       
   777 	log->AppendComment(buf);
       
   778 	testUtils->TestFinish(testNo-1);
       
   779 
       
   780 	testUtils->TestStart(testNo);
       
   781 	// test remove attachment
       
   782 	CreateNewPlaintextMessageL();
       
   783 	TestAddAttachmentL(newMessageId);
       
   784 	TestStoreBodyTextL(newMessageId);
       
   785 	TestAddAttachmentL(newMessageId);
       
   786 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   787 	buf.Format(KIMCMTestPassed, testNo++);
       
   788 	log->AppendComment(buf);
       
   789 	testUtils->TestFinish(testNo-1);
       
   790 
       
   791 	testUtils->TestStart(testNo);
       
   792 	//
       
   793 	// Test with HTML Messages
       
   794 	//
       
   795 	// test StoreBodyText when no text entry exists under message entry
       
   796 	CreateNewHtmlMessageL();
       
   797 	TestStoreBodyTextL(newHtmlMessageId);
       
   798 	buf.Format(KIMCMTestPassed, testNo++);
       
   799 	log->AppendComment(buf);
       
   800 	testUtils->TestFinish(testNo-1);
       
   801 
       
   802 	testUtils->TestStart(testNo);
       
   803 	// test add attachment when there are no other entries
       
   804 	CreateNewHtmlMessageL();
       
   805 	TestAddAttachmentL(newHtmlMessageId);
       
   806 	buf.Format(KIMCMTestPassed, testNo++);
       
   807 	log->AppendComment(buf);
       
   808 	testUtils->TestFinish(testNo-1);
       
   809 
       
   810 	testUtils->TestStart(testNo);
       
   811 	// test remove attachment
       
   812 	CreateNewHtmlMessageL();
       
   813 	TestAddAttachmentL(newHtmlMessageId);
       
   814 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   815 	buf.Format(KIMCMTestPassed, testNo++);
       
   816 	log->AppendComment(buf);
       
   817 	testUtils->TestFinish(testNo-1);
       
   818 
       
   819 	testUtils->TestStart(testNo);
       
   820 	// test StoreBodyText when there is already an entry under message entry - should create multipart/mixed
       
   821 	CreateNewHtmlMessageL();
       
   822 	TestAddAttachmentL(newHtmlMessageId);
       
   823 	TestStoreBodyTextL(newHtmlMessageId);
       
   824 	buf.Format(KIMCMTestPassed, testNo++);
       
   825 	log->AppendComment(buf);
       
   826 	testUtils->TestFinish(testNo-1);
       
   827 
       
   828 	testUtils->TestStart(testNo);
       
   829 	// test remove attachment
       
   830 	CreateNewHtmlMessageL();
       
   831 	TestAddAttachmentL(newHtmlMessageId);
       
   832 	TestStoreBodyTextL(newHtmlMessageId);
       
   833 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   834 	buf.Format(KIMCMTestPassed, testNo++);
       
   835 	log->AppendComment(buf);
       
   836 	testUtils->TestFinish(testNo-1);
       
   837 
       
   838 	testUtils->TestStart(testNo);
       
   839 	// test add Attachment when there is already an entry under message entry - should create multipart/mixed
       
   840 	CreateNewHtmlMessageL();
       
   841 	TestStoreBodyTextL(newHtmlMessageId);
       
   842 	TestAddAttachmentL(newHtmlMessageId);
       
   843 	buf.Format(KIMCMTestPassed, testNo++);
       
   844 	log->AppendComment(buf);
       
   845 	testUtils->TestFinish(testNo-1);
       
   846 
       
   847 	testUtils->TestStart(testNo);
       
   848 	// test remove attachment
       
   849 	CreateNewHtmlMessageL();
       
   850 	TestStoreBodyTextL(newHtmlMessageId);
       
   851 	TestAddAttachmentL(newHtmlMessageId);
       
   852 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   853 	buf.Format(KIMCMTestPassed, testNo++);
       
   854 	log->AppendComment(buf);
       
   855 	testUtils->TestFinish(testNo-1);
       
   856 
       
   857 	testUtils->TestStart(testNo);
       
   858 	// test StoreBodyText when there is already a multipart/mixed folder
       
   859 	CreateNewHtmlMessageL();
       
   860 	TestStoreBodyTextL(newHtmlMessageId);
       
   861 	TestAddAttachmentL(newHtmlMessageId);
       
   862 	TestAddAttachmentL(newHtmlMessageId);
       
   863 	buf.Format(KIMCMTestPassed, testNo++);
       
   864 	log->AppendComment(buf);
       
   865 	testUtils->TestFinish(testNo-1);
       
   866 
       
   867 	testUtils->TestStart(testNo);
       
   868 	// test remove attachment
       
   869 	CreateNewHtmlMessageL();
       
   870 	TestStoreBodyTextL(newHtmlMessageId);
       
   871 	TestAddAttachmentL(newHtmlMessageId);
       
   872 	TestAddAttachmentL(newHtmlMessageId);
       
   873 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   874 	buf.Format(KIMCMTestPassed, testNo++);
       
   875 	log->AppendComment(buf);
       
   876 	testUtils->TestFinish(testNo-1);
       
   877 
       
   878 	testUtils->TestStart(testNo);
       
   879 	// test add Attachment when there is already a multipart/mixed folder
       
   880 	CreateNewHtmlMessageL();
       
   881 	TestAddAttachmentL(newHtmlMessageId);
       
   882 	TestAddAttachmentL(newHtmlMessageId);
       
   883 	TestStoreBodyTextL(newHtmlMessageId);
       
   884 	buf.Format(KIMCMTestPassed, testNo++);
       
   885 	log->AppendComment(buf);
       
   886 	testUtils->TestFinish(testNo-1);
       
   887 
       
   888 	testUtils->TestStart(testNo);
       
   889 	// test remove attachment
       
   890 	CreateNewHtmlMessageL();
       
   891 	TestAddAttachmentL(newHtmlMessageId);
       
   892 	TestAddAttachmentL(newHtmlMessageId);
       
   893 	TestStoreBodyTextL(newHtmlMessageId);
       
   894 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   895 	buf.Format(KIMCMTestPassed, testNo++);
       
   896 	log->AppendComment(buf);
       
   897 	testUtils->TestFinish(testNo-1);
       
   898 
       
   899 	testUtils->TestStart(testNo);
       
   900 	// test add Attachment when there is already a multipart/mixed folder
       
   901 	CreateNewHtmlMessageL();
       
   902 	TestAddAttachmentL(newMessageId);
       
   903 	TestStoreBodyTextL(newMessageId);
       
   904 	TestAddAttachmentL(newMessageId);
       
   905 	buf.Format(KIMCMTestPassed, testNo++);
       
   906 	log->AppendComment(buf);
       
   907 	testUtils->TestFinish(testNo-1);
       
   908 
       
   909 	testUtils->TestStart(testNo);
       
   910 	// test remove attachment
       
   911 	CreateNewHtmlMessageL();
       
   912 	TestAddAttachmentL(newMessageId);
       
   913 	TestStoreBodyTextL(newMessageId);
       
   914 	TestAddAttachmentL(newMessageId);
       
   915 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
   916 	buf.Format(KIMCMTestPassed, testNo++);
       
   917 	log->AppendComment(buf);
       
   918 	testUtils->TestFinish(testNo-1);
       
   919 
       
   920 	testUtils->TestStart(testNo);
       
   921 	//
       
   922 	// test adding of attachments which are related to HTML entries
       
   923 	//
       
   924 
       
   925 	// test StoreBodyText when no text entry exists under message entry
       
   926 	CreateNewHtmlMessageL();
       
   927 	TestStoreBodyTextL(newHtmlMessageId);
       
   928 	// find the id of the HTML part
       
   929 	TMsvId relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   930 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   931 	buf.Format(KIMCMTestPassed, testNo++);
       
   932 	log->AppendComment(buf);
       
   933 	testUtils->TestFinish(testNo-1);
       
   934 
       
   935 	testUtils->TestStart(testNo);
       
   936 	// test add attachment when there are no other entries
       
   937 	CreateNewHtmlMessageL();
       
   938 	// find the id of the HTML part
       
   939 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   940 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   941 	buf.Format(KIMCMTestPassed, testNo++);
       
   942 	log->AppendComment(buf);
       
   943 	testUtils->TestFinish(testNo-1);
       
   944 
       
   945 	testUtils->TestStart(testNo);
       
   946 	// test remove attachment
       
   947 	CreateNewHtmlMessageL();
       
   948 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   949 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   950 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   951 	buf.Format(KIMCMTestPassed, testNo++);
       
   952 	log->AppendComment(buf);
       
   953 	testUtils->TestFinish(testNo-1);
       
   954 
       
   955 	testUtils->TestStart(testNo);
       
   956 	// test StoreBodyText when there is already an entry under message entry - should create multipart/mixed
       
   957 	CreateNewHtmlMessageL();
       
   958 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   959 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   960 	TestStoreBodyTextL(newHtmlMessageId);
       
   961 	buf.Format(KIMCMTestPassed, testNo++);
       
   962 	log->AppendComment(buf);
       
   963 	testUtils->TestFinish(testNo-1);
       
   964 
       
   965 	testUtils->TestStart(testNo);
       
   966 	// test remove attachment
       
   967 	CreateNewHtmlMessageL();
       
   968 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   969 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   970 	TestStoreBodyTextL(newHtmlMessageId);
       
   971 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   972 	buf.Format(KIMCMTestPassed, testNo++);
       
   973 	log->AppendComment(buf);
       
   974 	testUtils->TestFinish(testNo-1);
       
   975 
       
   976 	testUtils->TestStart(testNo);
       
   977 	// test add Attachment when there is already an entry under message entry - should create multipart/mixed
       
   978 	CreateNewHtmlMessageL();
       
   979 	TestStoreBodyTextL(newHtmlMessageId);
       
   980 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   981 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   982 	buf.Format(KIMCMTestPassed, testNo++);
       
   983 	log->AppendComment(buf);
       
   984 	testUtils->TestFinish(testNo-1);
       
   985 
       
   986 	testUtils->TestStart(testNo);
       
   987 	// test remove attachment
       
   988 	CreateNewHtmlMessageL();
       
   989 	TestStoreBodyTextL(newHtmlMessageId);
       
   990 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
   991 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
   992 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
   993 	buf.Format(KIMCMTestPassed, testNo++);
       
   994 	log->AppendComment(buf);
       
   995 	testUtils->TestFinish(testNo-1);
       
   996 
       
   997 	testUtils->TestStart(testNo);
       
   998 	// test StoreBodyText when there is already a multipart/mixed folder
       
   999 	CreateNewHtmlMessageL();
       
  1000 	TestStoreBodyTextL(newHtmlMessageId);
       
  1001 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1002 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1003 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1004 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1005 	buf.Format(KIMCMTestPassed, testNo++);
       
  1006 	log->AppendComment(buf);
       
  1007 	testUtils->TestFinish(testNo-1);
       
  1008 
       
  1009 	testUtils->TestStart(testNo);
       
  1010 	// test remove attachment
       
  1011 	CreateNewHtmlMessageL();
       
  1012 	TestStoreBodyTextL(newHtmlMessageId);
       
  1013 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1014 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1015 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1016 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1017 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
  1018 	buf.Format(KIMCMTestPassed, testNo++);
       
  1019 	log->AppendComment(buf);
       
  1020 	testUtils->TestFinish(testNo-1);
       
  1021 
       
  1022 	testUtils->TestStart(testNo);
       
  1023 	// test add Attachment when there is already a multipart/mixed folder
       
  1024 	CreateNewHtmlMessageL();
       
  1025 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1026 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1027 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1028 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1029 	TestStoreBodyTextL(newHtmlMessageId);
       
  1030 	buf.Format(KIMCMTestPassed, testNo++);
       
  1031 	log->AppendComment(buf);
       
  1032 	testUtils->TestFinish(testNo-1);
       
  1033 
       
  1034 	testUtils->TestStart(testNo);
       
  1035 	// test remove attachment
       
  1036 	CreateNewHtmlMessageL();
       
  1037 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1038 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1039 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1040 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1041 	TestStoreBodyTextL(newHtmlMessageId);
       
  1042 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
  1043 	buf.Format(KIMCMTestPassed, testNo++);
       
  1044 	log->AppendComment(buf);
       
  1045 	testUtils->TestFinish(testNo-1);
       
  1046 
       
  1047 	testUtils->TestStart(testNo);
       
  1048 	// test add Attachment when there is already a multipart/mixed folder
       
  1049 	CreateNewHtmlMessageL();
       
  1050 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1051 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1052 	TestStoreBodyTextL(newHtmlMessageId);
       
  1053 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1054 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1055 	buf.Format(KIMCMTestPassed, testNo++);
       
  1056 	log->AppendComment(buf);
       
  1057 	testUtils->TestFinish(testNo-1);
       
  1058 
       
  1059 	testUtils->TestStart(testNo);
       
  1060 	// test remove attachment
       
  1061 	CreateNewHtmlMessageL();
       
  1062 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1063 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1064 	TestStoreBodyTextL(newHtmlMessageId);
       
  1065 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1066 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1067 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
  1068 	buf.Format(KIMCMTestPassed, testNo++);
       
  1069 	log->AppendComment(buf);
       
  1070 	testUtils->TestFinish(testNo-1);
       
  1071 
       
  1072 	testUtils->TestStart(testNo);
       
  1073 	//
       
  1074 	// Test with HTML Messages
       
  1075 	//
       
  1076 
       
  1077 	// test StoreBodyText when there is already an entry under message entry - should create multipart/mixed
       
  1078 	CreateNewHtmlMessageL();
       
  1079 	TestAddAttachmentL(newHtmlMessageId);
       
  1080 	TestStoreBodyTextL(newHtmlMessageId);
       
  1081 	// find the id of the HTML part
       
  1082 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1083 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1084 	buf.Format(KIMCMTestPassed, testNo++);
       
  1085 	log->AppendComment(buf);
       
  1086 	testUtils->TestFinish(testNo-1);
       
  1087 
       
  1088 	testUtils->TestStart(testNo);
       
  1089 	// test remove attachment
       
  1090 	CreateNewHtmlMessageL();
       
  1091 	TestAddAttachmentL(newHtmlMessageId);
       
  1092 	TestStoreBodyTextL(newHtmlMessageId);
       
  1093 	// find the id of the HTML part
       
  1094 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1095 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1096 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId); //KEVAL - PROBLEM here!!
       
  1097 	buf.Format(KIMCMTestPassed, testNo++);
       
  1098 	log->AppendComment(buf);
       
  1099 	testUtils->TestFinish(testNo-1);
       
  1100 
       
  1101 	testUtils->TestStart(testNo);
       
  1102 	// test add Attachment when there is already an entry under message entry - should create multipart/mixed
       
  1103 	CreateNewHtmlMessageL();
       
  1104 	TestStoreBodyTextL(newHtmlMessageId);
       
  1105 	// find the id of the HTML part
       
  1106 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1107 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1108 	TestAddAttachmentL(newHtmlMessageId);
       
  1109 	buf.Format(KIMCMTestPassed, testNo++);
       
  1110 	log->AppendComment(buf);
       
  1111 	testUtils->TestFinish(testNo-1);
       
  1112 
       
  1113 	testUtils->TestStart(testNo);
       
  1114 	// test remove attachment
       
  1115 	CreateNewHtmlMessageL();
       
  1116 	TestStoreBodyTextL(newHtmlMessageId);
       
  1117 	// find the id of the HTML part
       
  1118 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1119 	TestAddRelatedImageL(newHtmlMessageId, relatedPartId);
       
  1120 	TestAddAttachmentL(newHtmlMessageId);
       
  1121 	TestRemoveAttachmentL(newHtmlMessageId, attachmentId);
       
  1122 	buf.Format(KIMCMTestPassed, testNo++);
       
  1123 	log->AppendComment(buf);
       
  1124 	testUtils->TestFinish(testNo-1);
       
  1125 
       
  1126 	testUtils->TestStart(testNo);
       
  1127 	//
       
  1128 	// Test Add Message as Attachment functionality
       
  1129 	//
       
  1130 
       
  1131 	//
       
  1132 	// Test with Plaintext Messages
       
  1133 	//
       
  1134 
       
  1135 	// test add attachment when there are no other entries
       
  1136 	CreateNewPlaintextMessageL();
       
  1137 	TestAddMessageAsAttachmentL(newMessageId);
       
  1138 	buf.Format(KIMCMTestPassed, testNo++);
       
  1139 	log->AppendComment(buf);
       
  1140 	testUtils->TestFinish(testNo-1);
       
  1141 
       
  1142 	testUtils->TestStart(testNo);
       
  1143 	// test remove attachment
       
  1144 	CreateNewPlaintextMessageL();
       
  1145 	TestAddMessageAsAttachmentL(newMessageId);
       
  1146 	TestRemoveAttachedMessageL(newMessageId, attachmentMessageId);
       
  1147 	buf.Format(KIMCMTestPassed, testNo++);
       
  1148 	log->AppendComment(buf);
       
  1149 	testUtils->TestFinish(testNo-1);
       
  1150 
       
  1151 	testUtils->TestStart(testNo);
       
  1152 	// test StoreBodyText when there is already an entry under message entry - should create multipart/mixed
       
  1153 	CreateNewPlaintextMessageL();
       
  1154 	TestAddMessageAsAttachmentL(newMessageId);
       
  1155 	TestStoreBodyTextL(newMessageId);
       
  1156 	buf.Format(KIMCMTestPassed, testNo++);
       
  1157 	log->AppendComment(buf);
       
  1158 	testUtils->TestFinish(testNo-1);
       
  1159 
       
  1160 	testUtils->TestStart(testNo);
       
  1161 	// test remove attachment
       
  1162 	CreateNewPlaintextMessageL();
       
  1163 	TestAddMessageAsAttachmentL(newMessageId);
       
  1164 	TestStoreBodyTextL(newMessageId);
       
  1165 	TestRemoveAttachedMessageL(newMessageId, attachmentMessageId);
       
  1166 	buf.Format(KIMCMTestPassed, testNo++);
       
  1167 	log->AppendComment(buf);
       
  1168 	testUtils->TestFinish(testNo-1);
       
  1169 
       
  1170 	testUtils->TestStart(testNo);
       
  1171 	// test add Attachment when there is already an entry under message entry - should create multipart/mixed
       
  1172 	CreateNewPlaintextMessageL();
       
  1173 	TestStoreBodyTextL(newMessageId);
       
  1174 	TestAddMessageAsAttachmentL(newMessageId);
       
  1175 	buf.Format(KIMCMTestPassed, testNo++);
       
  1176 	log->AppendComment(buf);
       
  1177 	testUtils->TestFinish(testNo-1);
       
  1178 
       
  1179 	testUtils->TestStart(testNo);
       
  1180 	// test remove attachment
       
  1181 	CreateNewPlaintextMessageL();
       
  1182 	TestStoreBodyTextL(newMessageId);
       
  1183 	TestAddMessageAsAttachmentL(newMessageId);
       
  1184 	TestRemoveAttachedMessageL(newMessageId, attachmentMessageId);
       
  1185 	buf.Format(KIMCMTestPassed, testNo++);
       
  1186 	log->AppendComment(buf);
       
  1187 	testUtils->TestFinish(testNo-1);
       
  1188 
       
  1189 	testUtils->TestStart(testNo);
       
  1190 	// test StoreBodyText when there is already a multipart/mixed folder
       
  1191 	CreateNewPlaintextMessageL();
       
  1192 	TestStoreBodyTextL(newMessageId);
       
  1193 	TestAddMessageAsAttachmentL(newMessageId);
       
  1194 	TestAddMessageAsAttachmentL(newMessageId);
       
  1195 	buf.Format(KIMCMTestPassed, testNo++);
       
  1196 	log->AppendComment(buf);
       
  1197 	testUtils->TestFinish(testNo-1);
       
  1198 
       
  1199 	testUtils->TestStart(testNo);
       
  1200 	// test remove attachment
       
  1201 	CreateNewPlaintextMessageL();
       
  1202 	TestStoreBodyTextL(newMessageId);
       
  1203 	TestAddMessageAsAttachmentL(newMessageId);
       
  1204 	TestAddMessageAsAttachmentL(newMessageId);
       
  1205 	TestRemoveAttachedMessageL(newMessageId, attachmentMessageId);
       
  1206 	buf.Format(KIMCMTestPassed, testNo++);
       
  1207 	log->AppendComment(buf);
       
  1208 	testUtils->TestFinish(testNo-1);
       
  1209 
       
  1210 	testUtils->TestStart(testNo);
       
  1211 	// test add Attachment when there is already a multipart/mixed folder
       
  1212 	CreateNewPlaintextMessageL();
       
  1213 	TestAddMessageAsAttachmentL(newMessageId);
       
  1214 	TestAddMessageAsAttachmentL(newMessageId);
       
  1215 	TestStoreBodyTextL(newMessageId);
       
  1216 	buf.Format(KIMCMTestPassed, testNo++);
       
  1217 	log->AppendComment(buf);
       
  1218 	testUtils->TestFinish(testNo-1);
       
  1219 
       
  1220 	testUtils->TestStart(testNo);
       
  1221 	// test remove attachment
       
  1222 	CreateNewPlaintextMessageL();
       
  1223 	TestAddMessageAsAttachmentL(newMessageId);
       
  1224 	TestAddMessageAsAttachmentL(newMessageId);
       
  1225 	TestStoreBodyTextL(newMessageId);
       
  1226 	TestRemoveAttachedMessageL(newMessageId, attachmentMessageId);
       
  1227 	buf.Format(KIMCMTestPassed, testNo++);
       
  1228 	log->AppendComment(buf);
       
  1229 	testUtils->TestFinish(testNo-1);
       
  1230 
       
  1231 	testUtils->TestStart(testNo);
       
  1232 	// test add Attachment when there is already a multipart/mixed folder
       
  1233 	CreateNewPlaintextMessageL();
       
  1234 	TestAddMessageAsAttachmentL(newMessageId);
       
  1235 	TestStoreBodyTextL(newMessageId);
       
  1236 	TestAddMessageAsAttachmentL(newMessageId);
       
  1237 	buf.Format(KIMCMTestPassed, testNo++);
       
  1238 	log->AppendComment(buf);
       
  1239 	testUtils->TestFinish(testNo-1);
       
  1240 
       
  1241 	testUtils->TestStart(testNo);
       
  1242 	// test remove attachment
       
  1243 	CreateNewPlaintextMessageL();
       
  1244 	TestAddMessageAsAttachmentL(newMessageId);
       
  1245 	TestStoreBodyTextL(newMessageId);
       
  1246 	TestAddMessageAsAttachmentL(newMessageId);
       
  1247 	TestRemoveAttachedMessageL(newMessageId, attachmentMessageId);
       
  1248 	buf.Format(KIMCMTestPassed, testNo++);
       
  1249 	log->AppendComment(buf);
       
  1250 	testUtils->TestFinish(testNo-1);
       
  1251 
       
  1252 	testUtils->TestStart(testNo);
       
  1253 	// Add message as attachment and normal attachment
       
  1254 	CreateNewPlaintextMessageL();
       
  1255 	TestAddMessageAsAttachmentL(newMessageId);
       
  1256 	TestAddAttachmentL(newMessageId);
       
  1257 	buf.Format(KIMCMTestPassed, testNo++);
       
  1258 	log->AppendComment(buf);
       
  1259 	testUtils->TestFinish(testNo-1);
       
  1260 
       
  1261 	testUtils->TestStart(testNo);
       
  1262 	// Add message as attachment and normal attachment
       
  1263 	CreateNewPlaintextMessageL();
       
  1264 	TestAddAttachmentL(newMessageId);
       
  1265 	TestAddMessageAsAttachmentL(newMessageId);
       
  1266 	buf.Format(KIMCMTestPassed, testNo++);
       
  1267 	log->AppendComment(buf);
       
  1268 	testUtils->TestFinish(testNo-1);
       
  1269 
       
  1270 	testUtils->TestStart(testNo);
       
  1271 	// Add message as attachment and normal attachment and store body text
       
  1272 	CreateNewPlaintextMessageL();
       
  1273 	TestAddMessageAsAttachmentL(newMessageId);
       
  1274 	TestAddAttachmentL(newMessageId);
       
  1275 	TestStoreBodyTextL(newMessageId);
       
  1276 	buf.Format(KIMCMTestPassed, testNo++);
       
  1277 	log->AppendComment(buf);
       
  1278 	testUtils->TestFinish(testNo-1);
       
  1279 
       
  1280 	testUtils->TestStart(testNo);
       
  1281 	// Add message as attachment and normal attachment
       
  1282 	CreateNewPlaintextMessageL();
       
  1283 	TestAddMessageAsAttachmentL(newMessageId);
       
  1284 	TestAddAttachmentL(newMessageId);
       
  1285 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
  1286 	buf.Format(KIMCMTestPassed, testNo++);
       
  1287 	log->AppendComment(buf);
       
  1288 	testUtils->TestFinish(testNo-1);
       
  1289 
       
  1290 	testUtils->TestStart(testNo);
       
  1291 	// Add message as attachment and normal attachment and store body text
       
  1292 	CreateNewPlaintextMessageL();
       
  1293 	TestAddAttachmentL(newMessageId);
       
  1294 	TestAddMessageAsAttachmentL(newMessageId);
       
  1295 	TestStoreBodyTextL(newMessageId);
       
  1296 	buf.Format(KIMCMTestPassed, testNo++);
       
  1297 	log->AppendComment(buf);
       
  1298 	testUtils->TestFinish(testNo-1);
       
  1299 
       
  1300 	testUtils->TestStart(testNo);
       
  1301 	// Add message as attachment and normal attachment
       
  1302 	CreateNewPlaintextMessageL();
       
  1303 	TestAddMessageAsAttachmentL(newMessageId);
       
  1304 	TestAddAttachmentL(newMessageId);
       
  1305 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
  1306 	buf.Format(KIMCMTestPassed, testNo++);
       
  1307 	log->AppendComment(buf);
       
  1308 	testUtils->TestFinish(testNo-1);
       
  1309 
       
  1310 	testUtils->TestStart(testNo);
       
  1311 	//
       
  1312 	// Test with HTML Messages
       
  1313 	//
       
  1314 	
       
  1315 	// test add attachment when there are no other entries
       
  1316 	CreateNewHtmlMessageL();
       
  1317 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1318 	buf.Format(KIMCMTestPassed, testNo++);
       
  1319 	log->AppendComment(buf);
       
  1320 	testUtils->TestFinish(testNo-1);
       
  1321 
       
  1322 	testUtils->TestStart(testNo);
       
  1323 	// test remove attachment
       
  1324 	CreateNewHtmlMessageL();
       
  1325 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1326 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1327 	buf.Format(KIMCMTestPassed, testNo++);
       
  1328 	log->AppendComment(buf);
       
  1329 	testUtils->TestFinish(testNo-1);
       
  1330 
       
  1331 	testUtils->TestStart(testNo);
       
  1332 	// test StoreBodyText when there is already an entry under message entry - should create multipart/mixed
       
  1333 	CreateNewHtmlMessageL();
       
  1334 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1335 	TestStoreBodyTextL(newHtmlMessageId);
       
  1336 	buf.Format(KIMCMTestPassed, testNo++);
       
  1337 	log->AppendComment(buf);
       
  1338 	testUtils->TestFinish(testNo-1);
       
  1339 
       
  1340 	testUtils->TestStart(testNo);
       
  1341 	// test remove attachment
       
  1342 	CreateNewHtmlMessageL();
       
  1343 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1344 	TestStoreBodyTextL(newHtmlMessageId);
       
  1345 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1346 	buf.Format(KIMCMTestPassed, testNo++);
       
  1347 	log->AppendComment(buf);
       
  1348 	testUtils->TestFinish(testNo-1);
       
  1349 
       
  1350 	testUtils->TestStart(testNo);
       
  1351 	// test add Attachment when there is already an entry under message entry - should create multipart/mixed
       
  1352 	CreateNewHtmlMessageL();
       
  1353 	TestStoreBodyTextL(newHtmlMessageId);
       
  1354 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1355 	buf.Format(KIMCMTestPassed, testNo++);
       
  1356 	log->AppendComment(buf);
       
  1357 	testUtils->TestFinish(testNo-1);
       
  1358 
       
  1359 	testUtils->TestStart(testNo);
       
  1360 	// test remove attachment
       
  1361 	CreateNewHtmlMessageL();
       
  1362 	TestStoreBodyTextL(newHtmlMessageId);
       
  1363 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1364 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1365 	buf.Format(KIMCMTestPassed, testNo++);
       
  1366 	log->AppendComment(buf);
       
  1367 	testUtils->TestFinish(testNo-1);
       
  1368 
       
  1369 	testUtils->TestStart(testNo);
       
  1370 	// test StoreBodyText when there is already a multipart/mixed folder
       
  1371 	CreateNewHtmlMessageL();
       
  1372 	TestStoreBodyTextL(newHtmlMessageId);
       
  1373 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1374 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1375 	buf.Format(KIMCMTestPassed, testNo++);
       
  1376 	log->AppendComment(buf);
       
  1377 	testUtils->TestFinish(testNo-1);
       
  1378 
       
  1379 	testUtils->TestStart(testNo);
       
  1380 	// test remove attachment
       
  1381 	CreateNewHtmlMessageL();
       
  1382 	TestStoreBodyTextL(newHtmlMessageId);
       
  1383 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1384 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1385 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1386 	buf.Format(KIMCMTestPassed, testNo++);
       
  1387 	log->AppendComment(buf);
       
  1388 	testUtils->TestFinish(testNo-1);
       
  1389 
       
  1390 	testUtils->TestStart(testNo);
       
  1391 	// test add Attachment when there is already a multipart/mixed folder
       
  1392 	CreateNewHtmlMessageL();
       
  1393 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1394 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1395 	TestStoreBodyTextL(newHtmlMessageId);
       
  1396 	buf.Format(KIMCMTestPassed, testNo++);
       
  1397 	log->AppendComment(buf);
       
  1398 	testUtils->TestFinish(testNo-1);
       
  1399 
       
  1400 	testUtils->TestStart(testNo);
       
  1401 	// test remove attachment
       
  1402 	CreateNewHtmlMessageL();
       
  1403 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1404 	TestStoreBodyTextL(newHtmlMessageId);
       
  1405 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1406 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1407 	buf.Format(KIMCMTestPassed, testNo++);
       
  1408 	log->AppendComment(buf);
       
  1409 	testUtils->TestFinish(testNo-1);
       
  1410 
       
  1411 	testUtils->TestStart(testNo);
       
  1412 	// test add Attachment when there is already a multipart/mixed folder
       
  1413 	CreateNewHtmlMessageL();
       
  1414 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1415 	TestStoreBodyTextL(newHtmlMessageId);
       
  1416 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1417 	buf.Format(KIMCMTestPassed, testNo++);
       
  1418 	log->AppendComment(buf);
       
  1419 	testUtils->TestFinish(testNo-1);
       
  1420 
       
  1421 	testUtils->TestStart(testNo);
       
  1422 	// test remove attachment
       
  1423 	CreateNewHtmlMessageL();
       
  1424 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1425 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1426 	TestStoreBodyTextL(newHtmlMessageId);
       
  1427 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1428 	buf.Format(KIMCMTestPassed, testNo++);
       
  1429 	log->AppendComment(buf);
       
  1430 	testUtils->TestFinish(testNo-1);
       
  1431 
       
  1432 	testUtils->TestStart(testNo);
       
  1433 	//
       
  1434 	// test adding of attachments which are related to HTML entries
       
  1435 	//
       
  1436 
       
  1437 	// test adding message as attachment
       
  1438 	CreateNewHtmlMessageL();
       
  1439 	// find the id of the HTML part
       
  1440 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1441 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1442 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1443 	buf.Format(KIMCMTestPassed, testNo++);
       
  1444 	log->AppendComment(buf);
       
  1445 	testUtils->TestFinish(testNo-1);
       
  1446 
       
  1447 	testUtils->TestStart(testNo);
       
  1448 	// test remove attachment
       
  1449 	CreateNewHtmlMessageL();
       
  1450 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1451 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1452 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1453 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1454 	buf.Format(KIMCMTestPassed, testNo++);
       
  1455 	log->AppendComment(buf);
       
  1456 	testUtils->TestFinish(testNo-1);
       
  1457 
       
  1458 	testUtils->TestStart(testNo);
       
  1459 	// test adding message as attachment
       
  1460 	CreateNewHtmlMessageL();
       
  1461 	// find the id of the HTML part
       
  1462 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1463 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1464 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1465 	buf.Format(KIMCMTestPassed, testNo++);
       
  1466 	log->AppendComment(buf);
       
  1467 	testUtils->TestFinish(testNo-1);
       
  1468 
       
  1469 	testUtils->TestStart(testNo);
       
  1470 	// test remove attachment
       
  1471 	CreateNewHtmlMessageL();
       
  1472 	relatedPartId = GetRelatedPartIdL(newHtmlMessageId);
       
  1473 	TestAddMessageAsAttachmentL(newHtmlMessageId);
       
  1474 	TestAddRelatedAttachmentL(newHtmlMessageId, relatedPartId);
       
  1475 	TestRemoveAttachedMessageL(newHtmlMessageId, attachmentMessageId);
       
  1476 	buf.Format(KIMCMTestPassed, testNo++);
       
  1477 	log->AppendComment(buf);
       
  1478 	testUtils->TestFinish(testNo-1);
       
  1479 
       
  1480 	testUtils->TestStart(testNo);
       
  1481 	// Add message as attachment and normal attachment
       
  1482 	CreateNewHtmlMessageL();
       
  1483 	TestAddMessageAsAttachmentL(newMessageId);
       
  1484 	TestAddAttachmentL(newMessageId);
       
  1485 	buf.Format(KIMCMTestPassed, testNo++);
       
  1486 	log->AppendComment(buf);
       
  1487 	testUtils->TestFinish(testNo-1);
       
  1488 
       
  1489 	testUtils->TestStart(testNo);
       
  1490 	// Add message as attachment and normal attachment
       
  1491 	CreateNewHtmlMessageL();
       
  1492 	TestAddAttachmentL(newMessageId);
       
  1493 	TestAddMessageAsAttachmentL(newMessageId);
       
  1494 	buf.Format(KIMCMTestPassed, testNo++);
       
  1495 	log->AppendComment(buf);
       
  1496 	testUtils->TestFinish(testNo-1);
       
  1497 
       
  1498 	testUtils->TestStart(testNo);
       
  1499 	// Add message as attachment and normal attachment and store body text
       
  1500 	CreateNewHtmlMessageL();
       
  1501 	TestAddMessageAsAttachmentL(newMessageId);
       
  1502 	TestAddAttachmentL(newMessageId);
       
  1503 	TestStoreBodyTextL(newMessageId);
       
  1504 	buf.Format(KIMCMTestPassed, testNo++);
       
  1505 	log->AppendComment(buf);
       
  1506 	testUtils->TestFinish(testNo-1);
       
  1507 
       
  1508 	testUtils->TestStart(testNo);
       
  1509 	// Add message as attachment and normal attachment
       
  1510 	CreateNewHtmlMessageL();
       
  1511 	TestAddMessageAsAttachmentL(newMessageId);
       
  1512 	TestAddAttachmentL(newMessageId);
       
  1513 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
  1514 	buf.Format(KIMCMTestPassed, testNo++);
       
  1515 	log->AppendComment(buf);
       
  1516 	testUtils->TestFinish(testNo-1);
       
  1517 
       
  1518 	testUtils->TestStart(testNo);
       
  1519 	// Add message as attachment and normal attachment and store body text
       
  1520 	CreateNewHtmlMessageL();
       
  1521 	TestAddAttachmentL(newMessageId);
       
  1522 	TestAddMessageAsAttachmentL(newMessageId);
       
  1523 	TestStoreBodyTextL(newMessageId);
       
  1524 	buf.Format(KIMCMTestPassed, testNo++);
       
  1525 	log->AppendComment(buf);
       
  1526 	testUtils->TestFinish(testNo-1);
       
  1527 
       
  1528 	testUtils->TestStart(testNo);
       
  1529 	// Add message as attachment and normal attachment
       
  1530 	CreateNewHtmlMessageL();
       
  1531 	TestAddMessageAsAttachmentL(newMessageId);
       
  1532 	TestAddAttachmentL(newMessageId);
       
  1533 	TestRemoveAttachmentL(newMessageId, attachmentId);
       
  1534 	buf.Format(KIMCMTestPassed, testNo++);
       
  1535 	log->AppendComment(buf);
       
  1536 	testUtils->TestFinish(testNo-1);
       
  1537 
       
  1538 	testUtils->FindChildrenL(KMsvGlobalOutBoxIndexEntryId, parsedFileName.FullName(), ETrue, EFalse); // writes message info (from Outbox) into files
       
  1539 
       
  1540 	testUtils->TestStart(testNo++);
       
  1541 	TBool error = CompareLogsL();
       
  1542 	if (error)
       
  1543 		{
       
  1544 		testUtils->TestFinish(testNo-1, KErrGeneral);
       
  1545 		testUtils->TestHarnessFailed(KErrGeneral);
       
  1546 		}
       
  1547 	else 
       
  1548 		{
       
  1549 		testUtils->TestFinish(testNo-1);
       
  1550 		testUtils->TestHarnessCompleted();
       
  1551 		}
       
  1552 
       
  1553 
       
  1554 	Closedown();
       
  1555 	
       
  1556 	// shouldn't have to do this, but convertor plugins aren't 
       
  1557 	// doing it yet so we get a false memory leak so remove this
       
  1558 	// when they fix that.
       
  1559 	REComSession::FinalClose();
       
  1560 	}
       
  1561 
       
  1562 GLDEF_C TInt E32Main()
       
  1563 	{	
       
  1564 	FbsStartup();
       
  1565 	TInt ret=RFbsSession::Connect();
       
  1566 		test(!ret);
       
  1567          	
       
  1568     // set up the directory structure
       
  1569     ret = TheFs.Connect();
       
  1570 		test(ret==KErrNone);
       
  1571 
       
  1572 
       
  1573 	
       
  1574 	__UHEAP_MARK;
       
  1575 	test.Start(_L("T_IMCM03 Test CImStoreMessagePart/CImRemoveMessagePart classes"));
       
  1576 
       
  1577 	theCleanup=CTrapCleanup::New();
       
  1578 	TRAP(ret,doMainL());		
       
  1579 	test(ret==KErrNone);
       
  1580 	delete theCleanup;
       
  1581 	test.End();
       
  1582 	test.Close();
       
  1583 	__UHEAP_MARKEND;
       
  1584 	User::Heap().Check();
       
  1585 	return(KErrNone);
       
  1586 	}