messagingfw/msgtestfw/TestActions/SendAs/src/CMtfTestActionCompareEmails.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2004-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 // __ACTION_INFO_BEGIN__
       
    15 // [Action Name]
       
    16 // CompareEmailMessages
       
    17 // [Action Parameters]
       
    18 // CMsvSession&			session   <input>			: Reference to the session.
       
    19 // CMsvEntrySelection&	MailSelection1 <input>	: Reference to the
       
    20 // first mail selection
       
    21 // CMsvEntrySelection&	MailSelection2 <input>	: Reference to the
       
    22 // second mail selection
       
    23 // [Action Description]
       
    24 // Compares the email messages for size, subject, body text , html text and attachment.
       
    25 // [APIs Used]
       
    26 // CMsvEntry::SetEntry()
       
    27 // __ACTION_INFO_END__
       
    28 // 
       
    29 //
       
    30 
       
    31 /**
       
    32  @file
       
    33 */
       
    34 
       
    35 
       
    36 // User include
       
    37 #include "CMtfTestActionCompareEmails.h"
       
    38 #include "CMtfTestActionParameters.h"
       
    39 #include "TestFrameworkActionsUtils.h"
       
    40 
       
    41 #include "CMsvAttachment.h"
       
    42 #include <miutset.h>
       
    43 #include <mmsvattachmentmanager.h>
       
    44 
       
    45 //Granularity for CArrayFixFlat arrays
       
    46 const TInt KArrayGranularity = 8;
       
    47 
       
    48 /**
       
    49   NewL()
       
    50   Constructs a CMtfTestActionCompareEmails object.
       
    51   Uses two phase construction and leaves nothing on the CleanupStack.
       
    52   @internalTechnology
       
    53   @param  aTestCase          Test Case to which the Test Action belongs
       
    54   @param  aActionParameters  Action parameters, must not be NULL
       
    55   @return Created object of type CMtfTestAction
       
    56   @pre    None
       
    57   @post   None
       
    58 */
       
    59 CMtfTestAction* CMtfTestActionCompareEmails::NewL(CMtfTestCase& aTestCase,
       
    60 												  CMtfTestActionParameters* aActionParameters)
       
    61 	{
       
    62 	CMtfTestActionCompareEmails* self = 
       
    63 					new (ELeave) CMtfTestActionCompareEmails(aTestCase);
       
    64 
       
    65 	CleanupStack::PushL(self);
       
    66 	self->ConstructL(aActionParameters);
       
    67 	CleanupStack::Pop(self);
       
    68 	return self;
       
    69 	}
       
    70 	
       
    71 /**
       
    72   Constructor
       
    73   Constructs a CMtfTestActionCompareEmails object and initialises the member variables.
       
    74   @internalTechnology
       
    75   @param  aTestCase  Test Case to which the Test Action belongs
       
    76   @pre    None
       
    77   @post   None
       
    78 */
       
    79 CMtfTestActionCompareEmails::CMtfTestActionCompareEmails(CMtfTestCase& aTestCase)
       
    80 	: CMtfSynchronousTestAction(aTestCase), iParamSession(NULL), iMessageInfo1(NULL), 
       
    81 		iMessageInfo2(NULL)
       
    82 	{
       
    83 	}
       
    84 
       
    85 /**
       
    86   Destructor
       
    87   Destructor of the class CMtfTestActionCompareEmails.
       
    88   Deletes the message information stored in the CMtfTestActionUtilsEmailMessage
       
    89   objects
       
    90   @internalTechnology
       
    91   @param  None
       
    92   @pre    None
       
    93   @post   None
       
    94 */
       
    95 CMtfTestActionCompareEmails::~CMtfTestActionCompareEmails()
       
    96 	{
       
    97 	delete 	iMessageInfo1;
       
    98 	delete 	iMessageInfo2;
       
    99 	}
       
   100 
       
   101 
       
   102 /**
       
   103   ExecuteActionL
       
   104   Obtains the parameters for the test action and then calls CompareEmailMessagesL()
       
   105   function to compare the sent and the received messages, based on the download
       
   106   limits set.
       
   107   @internalTechnology 
       
   108   @pre    None
       
   109   @post   None
       
   110 */
       
   111 void CMtfTestActionCompareEmails::ExecuteActionL()
       
   112 	{
       
   113 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareEmails);
       
   114 
       
   115 	// Get the session object 
       
   116 	iParamSession = ObtainParameterReferenceL<CMsvSession>
       
   117 									(TestCase(),ActionParameters().Parameter(0));
       
   118 	
       
   119 		
       
   120 	// Get the first selection object of messages
       
   121 	CMsvEntrySelection*	msgSelectionList1 = 
       
   122 									ObtainParameterReferenceL<CMsvEntrySelection>
       
   123 									(TestCase(), ActionParameters().Parameter(1)); 
       
   124 
       
   125 	// Get the second selection object of messages
       
   126 	CMsvEntrySelection*	msgSelectionList2 = 
       
   127 									ObtainParameterReferenceL<CMsvEntrySelection>
       
   128 									(TestCase(), ActionParameters().Parameter(2)); 
       
   129 	
       
   130 
       
   131 	if( (iParamSession == NULL) || (msgSelectionList1 == NULL) || (msgSelectionList2 == NULL) )
       
   132 		{
       
   133 		// Invalid input parameter value
       
   134 		TestCase().ERR_PRINTF1(_L("Invalid session or message selection object found"));
       
   135 		TestCase().SetTestStepResult(EFail);
       
   136 		}
       
   137 	else
       
   138 		{		
       
   139 		CompareEmailsL(*msgSelectionList1, *msgSelectionList2);		
       
   140 		}
       
   141 	// Test Action is complete
       
   142 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareEmails);
       
   143 	TestCase().ActionCompletedL(*this);
       
   144 	}	
       
   145 
       
   146 /**
       
   147   CompareEmailsL
       
   148   Compares body text, html text and attachments.
       
   149   @internalTechnology 
       
   150   @pre    None
       
   151   @post   None
       
   152 */
       
   153 void CMtfTestActionCompareEmails::CompareEmailsL(
       
   154 										 const CMsvEntrySelection& aMsgSelection1,
       
   155 										 const CMsvEntrySelection& aMsgSelection2)
       
   156 	{
       
   157 	// Verify the input parameters
       
   158 	if( (!&aMsgSelection1) || (!&aMsgSelection2))	
       
   159 		{
       
   160 		TestCase().ERR_PRINTF1(_L("Invalid Message selection"));
       
   161 		User::LeaveIfError(KErrArgument);
       
   162 		}
       
   163 
       
   164 	// Get the count of messages in both the selection object.
       
   165 	TInt msgCount1 = aMsgSelection1.Count();
       
   166 	TInt msgCount2 = aMsgSelection2.Count();
       
   167 
       
   168 	TestCase().INFO_PRINTF2(_L("Message count 1 = %d"),msgCount1);
       
   169 	TestCase().INFO_PRINTF2(_L("Message count 2 = %d"),msgCount2);
       
   170 	
       
   171 	if(msgCount1 != msgCount2)
       
   172 		{
       
   173 		// Number of messages is not equal in the selections passed
       
   174 		TestCase().ERR_PRINTF1(_L("Message count in the selections not equal"));
       
   175 		TestCase().SetTestStepResult(EFail);
       
   176 		}
       
   177 
       
   178 	if(IsTestCaseStatusPass())
       
   179 		{
       
   180 		CMsvEntry* msvEntry1 = iParamSession->GetEntryL(KMsvRootIndexEntryId);
       
   181 		CleanupStack::PushL(msvEntry1);
       
   182 
       
   183 		CMsvEntry* msvEntry2 = iParamSession->GetEntryL(KMsvRootIndexEntryId);
       
   184 		CleanupStack::PushL(msvEntry2);
       
   185 
       
   186 		if((!msvEntry1) || (!msvEntry2))
       
   187 			{
       
   188 			TestCase().ERR_PRINTF1(_L("Invalid Message Entry"));
       
   189 			User::LeaveIfError(KErrGeneral);
       
   190 			}
       
   191 	
       
   192 		// Loop through the first list of messages
       
   193 		for ( TInt msgIndex1 = 0 ; (msgIndex1 < msgCount1) &&
       
   194 									  (IsTestCaseStatusPass());
       
   195 									   msgIndex1 ++)
       
   196 			{			
       
   197 			TMsvId msgId1 = aMsgSelection1.At(msgIndex1);
       
   198 			// Set the context to the first message entry
       
   199 			msvEntry1->SetEntryL(msgId1);
       
   200 			
       
   201 			TBool found = EFalse;
       
   202 
       
   203 			TestCase().INFO_PRINTF3(_L("Comparison of Message: %d,  Subject: %S"),
       
   204 							(msgIndex1 + 1), &(msvEntry1->Entry().iDescription));
       
   205 			
       
   206 			for(TInt msgIndex2 = 0; msgIndex2 < msgCount2 && !found
       
   207 														    ; msgIndex2++)	
       
   208 				{
       
   209 				TMsvId msgId2 = aMsgSelection2.At(msgIndex2);
       
   210 
       
   211 				// Set the context to the second message entry
       
   212 				msvEntry2->SetEntryL(msgId2);
       
   213 				
       
   214 				// Compare the subject field of the two messages
       
   215 				if (msvEntry1->Entry().iDescription.
       
   216 								Compare(msvEntry2->Entry().iDescription) == 0)
       
   217 					{
       
   218 					TestCase().INFO_PRINTF2(_L("Message with Subject field in the selection 1: %S found "),
       
   219 												  &(msvEntry1->Entry().iDescription));
       
   220 
       
   221 					found = ETrue;
       
   222 					
       
   223 					SetEmailMessageInfoL(*msvEntry1, *msvEntry2);
       
   224 					}
       
   225 				}	
       
   226 	
       
   227 			if ( found )
       
   228 				{
       
   229 				if(IsTestCaseStatusPass())
       
   230 					{
       
   231 					ComparePlainBodyTextL();
       
   232 					}
       
   233 				if(IsTestCaseStatusPass())
       
   234 					{
       
   235 					CompareHtmlL();
       
   236 					}
       
   237 				if(IsTestCaseStatusPass())
       
   238 					{
       
   239 					CompareAttachmentsL(*msvEntry1, *msvEntry2);
       
   240 					}
       
   241 				if(IsTestCaseStatusPass())
       
   242 					{
       
   243 					DeleteEmailMessageInfo();
       
   244 					}				
       
   245 				}
       
   246 			else{
       
   247 				TestCase().ERR_PRINTF2(_L("Email with subject %S is not found"), &msvEntry1->Entry().iDescription);
       
   248 				TestCase().SetTestStepResult(EFail);
       
   249 				}
       
   250 			}
       
   251 		// Cleanup the stack
       
   252 		CleanupStack::PopAndDestroy(msvEntry2);
       
   253 		CleanupStack::PopAndDestroy(msvEntry1);
       
   254 		}
       
   255 	}
       
   256 
       
   257 /**
       
   258   ComparePlainBodyTextL
       
   259   Compares body text.
       
   260   @internalTechnology 
       
   261   @pre    None
       
   262   @post   None
       
   263 */
       
   264 void CMtfTestActionCompareEmails::ComparePlainBodyTextL()
       
   265 	{
       
   266 
       
   267 	TestCase().INFO_PRINTF1(_L("Comparing Plain text part of the message"));
       
   268 	
       
   269 	if( iMessageInfo1->GetBodyTextSize() > 0)
       
   270 		{
       
   271 		if( iMessageInfo2->GetBodyTextSize() > 0)
       
   272 			{			
       
   273 			CParaFormatLayer*	paraFormatLayer1 = CParaFormatLayer::NewL();
       
   274 			CleanupStack::PushL(paraFormatLayer1);
       
   275 
       
   276 			CCharFormatLayer*	charFormatLayer1 = CCharFormatLayer::NewL(); 
       
   277 			CleanupStack::PushL(charFormatLayer1);
       
   278 
       
   279 			CRichText*	plainBodyText1  = CRichText::NewL( paraFormatLayer1,
       
   280 															charFormatLayer1,
       
   281 															CEditableText::EFlatStorage, 256);
       
   282 			CleanupStack::PushL(plainBodyText1);
       
   283 			
       
   284 			iMessageInfo1->GetBodyTextL(*plainBodyText1, *paraFormatLayer1,
       
   285 															*charFormatLayer1);	
       
   286 
       
   287 			// Get message body text for 2nd message
       
   288 			CParaFormatLayer*	paraFormatLayer2 = CParaFormatLayer::NewL();
       
   289 			CleanupStack::PushL(paraFormatLayer2);
       
   290 
       
   291 			CCharFormatLayer*	charFormatLayer2 = CCharFormatLayer::NewL(); 
       
   292 			CleanupStack::PushL(charFormatLayer2);
       
   293 
       
   294 			CRichText*	plainBodyText2 = CRichText::NewL( paraFormatLayer2, 
       
   295 															charFormatLayer2, 
       
   296 															CEditableText::EFlatStorage, 256);
       
   297 
       
   298 			CleanupStack::PushL(plainBodyText2);
       
   299 			
       
   300 			iMessageInfo2->GetBodyTextL(*plainBodyText2, *paraFormatLayer2,
       
   301 															*charFormatLayer2);
       
   302 			
       
   303 			// If the body text buffer is not available, fail the test case
       
   304 			if(plainBodyText1 == NULL || plainBodyText2 == NULL)
       
   305 				{
       
   306 				// Error : Body text buffer not available
       
   307 				TestCase().ERR_PRINTF1(_L("Body text buffer not available"));
       
   308 				TestCase().SetTestStepResult(EFail);
       
   309 				}			
       
   310 
       
   311 			if(IsTestCaseStatusPass())
       
   312 				{
       
   313 				TPtrC bodyText1 = plainBodyText1->Read(0);
       
   314 				TPtrC bodyText2 = plainBodyText2->Read(0);
       
   315 
       
   316 				TestCase().INFO_PRINTF3(_L("Body text size of 1st message = %d, Body text size of 2nd messaage= %d"),
       
   317 											bodyText1.Length(), bodyText2.Length());
       
   318 								
       
   319 				if( (bodyText1.Compare(bodyText2)) != 0)
       
   320 					{
       
   321 					// Error : Comparison of body text failed
       
   322 					TestCase().ERR_PRINTF1(_L("Comparison of body text failed"));
       
   323 					TestCase().SetTestStepResult(EFail);
       
   324 					}
       
   325 
       
   326 				else
       
   327 					{
       
   328 					TestCase().INFO_PRINTF1(_L("Comparison of Body text was successful"));					
       
   329 					}				
       
   330 				}
       
   331 			CleanupStack::PopAndDestroy(6, paraFormatLayer1);
       
   332 			}
       
   333 		else
       
   334 			{			
       
   335 			TestCase().ERR_PRINTF1(_L("Message 1 conntains body text, but body text was not received for 2nd message"));
       
   336 			TestCase().SetTestStepResult(EFail);
       
   337 			}
       
   338 		}
       
   339 	else
       
   340 		{
       
   341 		TestCase().INFO_PRINTF1(_L("1st message does not contain Body text part"));		
       
   342 		}
       
   343 	}
       
   344 
       
   345 
       
   346 /**
       
   347   DeleteEmailMessageInfo
       
   348   Deletes the email message info created earlier.
       
   349   @internalTechnology 
       
   350   @pre    None
       
   351   @post   None
       
   352 */
       
   353 void CMtfTestActionCompareEmails::DeleteEmailMessageInfo()
       
   354 	{	
       
   355 	delete 	iMessageInfo1;
       
   356 	iMessageInfo1 = NULL;
       
   357 		
       
   358 	delete 	iMessageInfo2 ;
       
   359 	iMessageInfo2 = NULL;
       
   360 	}
       
   361 
       
   362 /**
       
   363   SetEmailMessageInfoL
       
   364   Sets the email message for the entry specified.
       
   365   @internalTechnology 
       
   366   @pre    None
       
   367   @post   None
       
   368 */
       
   369 void CMtfTestActionCompareEmails::SetEmailMessageInfoL(CMsvEntry& aMsvEntry1, CMsvEntry& aMsvEntry2)
       
   370 	{	
       
   371 	TestCase().INFO_PRINTF1(_L("Setting information for 1st message"));
       
   372 	iMessageInfo1 = CMtfTestActionUtilsEmailMessage::NewL(aMsvEntry1, TestCase());
       
   373 		
       
   374 	TestCase().INFO_PRINTF1(_L("Setting information for 2nd message"));	
       
   375 	iMessageInfo2 = CMtfTestActionUtilsEmailMessage::NewL(aMsvEntry2, TestCase());
       
   376 	}
       
   377 
       
   378 /**
       
   379   CompareHtmlL
       
   380   Compares html text.
       
   381   @internalTechnology 
       
   382   @pre    None
       
   383   @post   None
       
   384 */
       
   385 void CMtfTestActionCompareEmails::CompareHtmlL()
       
   386 	{	
       
   387 	TPtrC htmlFileName1;
       
   388 	TInt err1 = iMessageInfo1->HtmlFileName(htmlFileName1);
       
   389 	TPtrC htmlFileName2;
       
   390 	TInt err2 = iMessageInfo2->HtmlFileName(htmlFileName2);
       
   391 	
       
   392 	if((iMessageInfo1->GetHtmlSize() > 0) && (err1 == KErrNone))
       
   393 		{
       
   394 		if( err2 == KErrNone)
       
   395 			{
       
   396 			TInt errorVal;
       
   397 			TBool diffFlag = EFalse;
       
   398 
       
   399 			// Compare the html files
       
   400 			CompareFilesL(htmlFileName1, htmlFileName2, errorVal, diffFlag);
       
   401 			
       
   402 			if (errorVal == KErrNone )
       
   403 				{
       
   404 				if ( diffFlag == EFalse )
       
   405 					{
       
   406 					TestCase().INFO_PRINTF1(_L("Comparison of Html files was successful"));
       
   407 					TestCase().INFO_PRINTF2(_L("Html file for message 1: %S"),&htmlFileName1 );
       
   408 					TestCase().INFO_PRINTF2(_L("Html file for message 2: %S"),&htmlFileName2 );					
       
   409 					}
       
   410 				else
       
   411 					{
       
   412 					// Comparison of Html files failed
       
   413 					TestCase().ERR_PRINTF1(_L("Comparison of Html files failed"));
       
   414 					TestCase().SetTestStepResult(EFail);
       
   415 					}
       
   416 				}
       
   417 			else
       
   418 				{
       
   419 				// An error occured while comparing the html files
       
   420 				TestCase().ERR_PRINTF1(_L("Error occurred while comparing Html files"));
       
   421 				TestCase().SetTestStepResult(EFail);
       
   422 				}
       
   423 			}
       
   424 		else
       
   425 			{
       
   426 			// Received message's html path was not found
       
   427 			TestCase().ERR_PRINTF1(_L("Html file path not found in the 2nd message"));
       
   428 			TestCase().SetTestStepResult(EFail);
       
   429 			}
       
   430 		}
       
   431 	else
       
   432 		{
       
   433 		TestCase().INFO_PRINTF1(_L("Html file path not found for the 1st message"));
       
   434 		}
       
   435 	}
       
   436 
       
   437 /**
       
   438   CompareFilesL
       
   439   Compares files.
       
   440   @internalTechnology 
       
   441   @pre    None
       
   442   @post   None
       
   443 */			
       
   444 void CMtfTestActionCompareEmails::CompareFilesL(const TPtrC afilePath1,
       
   445 													   const TPtrC afilePath2,
       
   446 													   TInt& aError, TBool& aDiffFlag)
       
   447 	{
       
   448 	aDiffFlag = EFalse;
       
   449 	CArrayFixFlat<TUint16> *ignoreCharList = new (ELeave)
       
   450 											CArrayFixFlat<TUint16>(KArrayGranularity);
       
   451 	CleanupStack::PushL(ignoreCharList);
       
   452 
       
   453 	// Compare the content of the attachment files
       
   454 	aError = TestFrameworkActionsUtils::CompareFilesL(afilePath1, afilePath2,
       
   455 														 EFalse, ignoreCharList, aDiffFlag);
       
   456 						
       
   457 	CleanupStack::PopAndDestroy(ignoreCharList);
       
   458 	}
       
   459 
       
   460 /**
       
   461   CompareAttachmentsL
       
   462   Compares the attachments associated with specified entries.
       
   463   @internalTechnology 
       
   464   @pre    None
       
   465   @post   None
       
   466 */
       
   467 void CMtfTestActionCompareEmails::CompareAttachmentsL(CMsvEntry& aMsvEntry1, CMsvEntry& aMsvEntry2)
       
   468 	{
       
   469 	TestCase().INFO_PRINTF1(_L("Comparing Attachments"));
       
   470 		
       
   471 	CImEmailMessage* emailMessage1 = CImEmailMessage::NewL(aMsvEntry1);
       
   472 	CleanupStack::PushL(emailMessage1);
       
   473 	
       
   474 	CImEmailMessage* emailMessage2 = CImEmailMessage::NewL(aMsvEntry2);
       
   475 	CleanupStack::PushL(emailMessage2);
       
   476 	
       
   477 	MMsvAttachmentManager& manager1 = emailMessage1->AttachmentManager();
       
   478 	MMsvAttachmentManager& manager2 = emailMessage2->AttachmentManager();
       
   479 
       
   480 	TInt msgAttachmentCount1 = manager1.AttachmentCount();
       
   481 	TInt msgAttachmentCount2 = manager2.AttachmentCount();
       
   482 
       
   483 	TestCase().INFO_PRINTF3(_L("1st message attachment count : %d, 2nd message attachment count : %d"),
       
   484 								msgAttachmentCount1,msgAttachmentCount2);
       
   485 
       
   486 	if(msgAttachmentCount1 == msgAttachmentCount2)
       
   487 		{
       
   488 		TInt index1 = 0;
       
   489 		TInt index2 = 0;
       
   490 		
       
   491 		TBool	attachmentFound = EFalse;
       
   492 		
       
   493 		for (index1 = 0, index2 = 0 ; ( IsTestCaseStatusPass()) && 
       
   494 					(index1 < msgAttachmentCount1) ; index1++)
       
   495 			{
       
   496 			attachmentFound = EFalse;
       
   497 			CMsvAttachment* attachInfo1 = manager1.GetAttachmentInfoL(index1);
       
   498 			CleanupStack::PushL(attachInfo1);
       
   499 			
       
   500 			for (index2 = 0; index2 < msgAttachmentCount2 && attachmentFound == EFalse; index2++ )
       
   501 				{
       
   502 				CMsvAttachment* attachInfo2 = manager2.GetAttachmentInfoL(index2);
       
   503 				CleanupStack::PushL(attachInfo2);
       
   504 
       
   505 				if ( attachInfo2->AttachmentName().Compare(attachInfo1->AttachmentName()) == 0 )
       
   506 					{
       
   507 					attachmentFound = ETrue;
       
   508 					
       
   509 					if (
       
   510 						(attachInfo1->Type() == CMsvAttachment::EMsvFile || attachInfo1->Type() == CMsvAttachment::EMsvLinkedFile) &&
       
   511 						(attachInfo2->Type() == CMsvAttachment::EMsvFile || attachInfo2->Type() == CMsvAttachment::EMsvLinkedFile) 
       
   512 					   )
       
   513 						{							
       
   514 						TBool comaprisonFlag = CompareAttachmentFilesL(manager1.GetAttachmentFileL(index1), manager2.GetAttachmentFileL(index2));
       
   515 						if (!comaprisonFlag)
       
   516 							{
       
   517 							 TestCase().SetTestStepResult(EFail);
       
   518 							}
       
   519 						
       
   520 						}
       
   521 					}
       
   522 				CleanupStack::PopAndDestroy(attachInfo2);
       
   523 				}
       
   524 			CleanupStack::PopAndDestroy(attachInfo1);
       
   525 			}
       
   526 			if ( !attachmentFound )
       
   527 				{
       
   528 				TestCase().ERR_PRINTF1(_L("Attachments are not identical."));
       
   529 				TestCase().SetTestStepResult(EFail);
       
   530 				}
       
   531 		}
       
   532 		else
       
   533 			{
       
   534 			TestCase().ERR_PRINTF1(_L("Attachments count not identical."));
       
   535 			TestCase().SetTestStepResult(EFail);	
       
   536 			}
       
   537 		CleanupStack::PopAndDestroy(2, emailMessage1);
       
   538 	}
       
   539 
       
   540 /**
       
   541   CompareAttachmentFiles
       
   542   Compares the file associated with the attachments.
       
   543   @internalTechnology 
       
   544   @pre    None
       
   545   @post   None
       
   546 */
       
   547 TBool CMtfTestActionCompareEmails::CompareAttachmentFilesL(RFile aFile1, RFile aFile2)
       
   548 	{
       
   549 	//Do the byte by byte comparison
       
   550 	TBool ret = ETrue;
       
   551 	TInt sz1, sz2;
       
   552 
       
   553 	User::LeaveIfError( aFile1.Size(sz1) );
       
   554 	User::LeaveIfError( aFile2.Size(sz2) );
       
   555 
       
   556 	if( sz1 != sz2 )
       
   557 		{
       
   558 		TestCase().INFO_PRINTF3( _L("File size mismatch 1(%d)   2(%d)"), sz1, sz2 );
       
   559 		ret = EFalse;
       
   560 		}
       
   561 	else
       
   562 		{
       
   563 		TBuf8<1> char1;
       
   564 		TBuf8<1> char2;
       
   565 		TInt len1, len2;
       
   566 		do
       
   567 			{
       
   568 			aFile1.Read(char1);
       
   569 			aFile2.Read(char2);
       
   570 			len1 = char1.Length();
       
   571 			len2 = char2.Length();
       
   572 			if( char1.Compare( char2 ) != 0 )
       
   573 				{
       
   574 				ret = EFalse;
       
   575 				break;
       
   576 				}
       
   577 			}
       
   578 		while( len1 && len2 );
       
   579 		}
       
   580 	return ret;
       
   581 	}