email/pop3andsmtpmtm/clientmtms/test/src/T_imcm06.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name of test harness: T_IMCM06
       
    15 // Component: IMCM
       
    16 // Brief description of test harness:
       
    17 // Tests the CImEmailMessage - GetBodyTextL(), GetMessageDigestEntriesL(), 
       
    18 // GetAttachmentsListL() for EThisMessageAndEmbeddedMessages and 
       
    19 // EThisMessageOnly types.  Also, it tests VCard,VCalenders, ICalendars and 
       
    20 // VEntries for GetAttachmentsL().  Also performs heap failure tests.
       
    21 // Detailed description of test harness:
       
    22 // As above.
       
    23 // Input files required to run test harness:
       
    24 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82201.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82201.txt
       
    25 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82202.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82202.txt
       
    26 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82203.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82203.txt
       
    27 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82204.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82204.txt
       
    28 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82205.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82205.txt
       
    29 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82206.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82206.txt
       
    30 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82207.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82207.txt
       
    31 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82208.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82208.txt
       
    32 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82209.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82209.txt
       
    33 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82210.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82210.txt
       
    34 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82211.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82211.txt
       
    35 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82212.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82212.txt
       
    36 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82213.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82213.txt
       
    37 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82214.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82214.txt
       
    38 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82215.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82215.txt
       
    39 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82216.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82216.txt
       
    40 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82217.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82217.txt
       
    41 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82218.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82218.txt
       
    42 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82219.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82219.txt
       
    43 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82220.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82220.txt
       
    44 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82221.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82221.txt
       
    45 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82222.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82222.txt
       
    46 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82223.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82223.txt
       
    47 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82224.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82224.txt
       
    48 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82225.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82225.txt
       
    49 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82226.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82226.txt
       
    50 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82227.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82227.txt
       
    51 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82228.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82228.txt
       
    52 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82229.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82229.txt
       
    53 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82230.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82230.txt
       
    54 // \MSG\IMCMTSRC\RFCT_IMCM06\rfc82231.txt		<DRIVE>:\MSGTEST\IMCM\RFCT_IMCM06\rfc82231.txt
       
    55 // Intermediate files produced while running test harness:
       
    56 // None
       
    57 // Output files produced by running test harness:
       
    58 // <DRIVE>:\msglogs\T_IMCM06.<PLATFORM>.<VARIANT>.LOG.txt
       
    59 // Description of how to build test harness:
       
    60 // cd \msg\imcm\
       
    61 // bldmake bldfiles
       
    62 // abld test build
       
    63 // Description of how to run test harness:
       
    64 // The following instructions are the same for all platforms:
       
    65 // 1. Build T_DB test harness from COMMDB component:
       
    66 // cd \commdb\group
       
    67 // bldmake bldfiles
       
    68 // abld test build t_db
       
    69 // 2. Build the test utilities:
       
    70 // cd \msg\testutils\group\
       
    71 // bldmake bldfiles
       
    72 // abld build
       
    73 // WINS running instructions:
       
    74 // 1. \epoc32\release\wins\<VARIANT>\T_IMCM06.exe can be used at the command prompt
       
    75 // or executable can be run from Windows Explorer.
       
    76 // All other platform running instructions:
       
    77 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_IMCM06.exe onto the other platform
       
    78 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into 
       
    79 // <DRIVE>:\system\libs on the other platform
       
    80 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into 
       
    81 // <DRIVE>:\system\libs on the other platform
       
    82 // 4. Run T_IMCM06.exe on the other platform
       
    83 // 
       
    84 //
       
    85 
       
    86 #include "emailtestutils.h"
       
    87 #include <miutmsg.h>
       
    88 #include <txtrich.h>
       
    89 
       
    90 #include <mmsvattachmentmanager.h>
       
    91   
       
    92 // local variables etc //
       
    93 
       
    94 _LIT(KImcmTest, "T_IMCM06 - Testing URI resolving of real messages");
       
    95 RTest test(KImcmTest);
       
    96 
       
    97 
       
    98 LOCAL_D CTrapCleanup* theCleanup;
       
    99 LOCAL_D CEmailTestUtils* testUtils;
       
   100 LOCAL_D CRichText* rText;
       
   101 LOCAL_D CParaFormatLayer* pLayer;
       
   102 LOCAL_D CCharFormatLayer* cLayer;
       
   103 LOCAL_D CActiveScheduler* scheduler;
       
   104 LOCAL_D CMsvEntrySelection* msgList;
       
   105 LOCAL_D TInt globalError;
       
   106 
       
   107 //
       
   108 
       
   109 
       
   110 LOCAL_C void Closedown()
       
   111 	{
       
   112 	if (globalError)
       
   113 		testUtils->TestHarnessFailed(globalError);
       
   114 	else
       
   115 		testUtils->TestHarnessCompleted();
       
   116 	CleanupStack::PopAndDestroy(2, scheduler);  //testUtils, scheduler
       
   117 	}
       
   118 
       
   119 //
       
   120 
       
   121 LOCAL_C TInt AttachResult1L(const RPointerArray<CMsvAttachment>& array)
       
   122 	{
       
   123 	TInt error=0;
       
   124 	error=(array.Count()==1)?KErrNone : KErrNotFound;
       
   125 	if (error)
       
   126 		{
       
   127 		testUtils->WriteComment(_L("No attachments"));
       
   128 		return error;
       
   129 		}
       
   130 	CMsvAttachment* attachmentInfo=array[0];
       
   131 	if(attachmentInfo->Type()==(CMsvAttachment::EMsvFile) || attachmentInfo->Type()==(CMsvAttachment::EMsvLinkedFile))
       
   132 		{
       
   133 		error = (attachmentInfo->FilePath() == _L("C:\\Private\\1000484b\\Mail2\\00001001_S\\3\\00100003_F\\print.bmp")) ? KErrNone : KErrNotFound;
       
   134 		if (error)
       
   135 			{
       
   136 			testUtils->WriteComment(_L("FilePath didn't match"));
       
   137 			return error;
       
   138 			}
       
   139 		}
       
   140 	else
       
   141 		testUtils->WriteComment(_L("This is a message entry. Hence filename does not exist"));
       
   142 		
       
   143 	error=(attachmentInfo->Id()==0x00100003)?KErrNone : KErrNotFound;
       
   144 	if (error)
       
   145 		{
       
   146 		testUtils->WriteComment(_L("Id didn't match"));
       
   147 		return error;
       
   148 		}
       
   149 	error=(attachmentInfo->Complete())?KErrNone : KErrNotFound;
       
   150 	if (error)
       
   151 		{
       
   152 		testUtils->WriteComment(_L("Complete didn't match"));
       
   153 		return error;
       
   154 		}
       
   155 	return error;
       
   156 	}
       
   157 	
       
   158 
       
   159 LOCAL_C TInt AttachResult3L(const RPointerArray<CMsvAttachment>& array)
       
   160 	{
       
   161 	TInt error=0;
       
   162 	CMsvAttachment* attachmentInfo;
       
   163 	error=(array.Count()==1)?KErrNone : KErrNotFound;
       
   164 	if (error)
       
   165 		{
       
   166 		testUtils->WriteComment(_L("No attachments"));
       
   167 		return error;
       
   168 		}
       
   169 	
       
   170 	attachmentInfo=array[0];
       
   171 	if(attachmentInfo->Type()==CMsvAttachment::EMsvFile || attachmentInfo->Type()==CMsvAttachment::EMsvLinkedFile)
       
   172 		{
       
   173 		error = (!attachmentInfo->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\7\\00100007_F\\Some Base64 encoded text"))) ? KErrNone : KErrNotFound;
       
   174 		if (error)
       
   175 			{
       
   176 			testUtils->WriteComment(_L("FileName didn't match"));
       
   177 			return error;
       
   178 			}
       
   179 		}
       
   180 	else
       
   181 		testUtils->WriteComment(_L("This is a message entry. Hence filename does not exist"));
       
   182 	
       
   183 	error=(attachmentInfo->Id()==0x00100007)?KErrNone : KErrNotFound;
       
   184 	if (error)
       
   185 		{
       
   186 		testUtils->WriteComment(_L("Id didn't match"));
       
   187 		return error;
       
   188 		}
       
   189 	error=(attachmentInfo->Complete())?KErrNone : KErrNotFound;
       
   190 	if (error)
       
   191 		{
       
   192 		testUtils->WriteComment(_L("Complete didn't match"));
       
   193 		return error;
       
   194 		}
       
   195 	return error;
       
   196 	}
       
   197 	
       
   198 
       
   199 LOCAL_C void TestAttachmentResultsL(TInt aTest,const RPointerArray<CMsvAttachment>& array)
       
   200 	{
       
   201 	testUtils->TestStart(aTest);
       
   202 	TInt error=0;
       
   203 	switch (aTest)
       
   204 		{
       
   205 	case 0:  //has one attachment
       
   206 		error=AttachResult1L(array);
       
   207 		break;
       
   208 	case 2:
       
   209 		error=AttachResult3L(array);
       
   210 		break;
       
   211 	case 4:
       
   212 		error=(array.Count()==3)? KErrNone:KErrNotFound;
       
   213 		break;
       
   214 	case 6:
       
   215 		error=(array.Count()==6)?KErrNone : KErrNotFound;  
       
   216 		break;
       
   217 	case 8:
       
   218 		error=(array.Count()==4)?KErrNone : KErrNotFound;  
       
   219 		break;
       
   220 	case 18:
       
   221 	case 15:
       
   222 		error=(array.Count()==1)?KErrNone : KErrNotFound;  
       
   223 		break;
       
   224 	case 5:
       
   225 	case 9:
       
   226 	case 19:
       
   227 	case 20:
       
   228 		error=(array.Count()==1)?KErrNone : KErrNotFound;  
       
   229 		break;
       
   230 	case 23:
       
   231 		error=(array.Count()==3)? KErrNone:KErrNotFound;
       
   232 		break;
       
   233 	case 25:
       
   234 		error=(array.Count()==3)?KErrNone : KErrNotFound;  
       
   235 		break;
       
   236 	case 27:
       
   237 		error=(array.Count()==1)?KErrNone : KErrNotFound;  
       
   238 		break;
       
   239 	case 28:
       
   240 		error=(array.Count()==3)?KErrNone : KErrNotFound;  
       
   241 		break;
       
   242 	case 29:
       
   243 	case 30:
       
   244 		error=(array.Count()==1)?KErrNone : KErrNotFound;  
       
   245 		break;
       
   246 	case 31:
       
   247 		error=(array.Count()==1)?KErrNone : KErrNotFound;  
       
   248 		break;				
       
   249 	default:
       
   250 		error=(array.Count()==0)?KErrNone : KErrNotFound;  
       
   251 		break;
       
   252 		}
       
   253 	testUtils->TestFinish(aTest,error);
       
   254 	if (!globalError)
       
   255 		globalError=error;
       
   256 	}
       
   257 	
       
   258 
       
   259 LOCAL_C	void TestAttachmentsResultsInEmbeddedMsgsL(TInt aTest,const RPointerArray<CMsvAttachment>& array)
       
   260 	{
       
   261 	testUtils->TestStart(aTest);
       
   262 	TInt error=0;
       
   263 	switch (aTest)
       
   264 		{
       
   265 	case 0:  //has one attachment
       
   266 		error=AttachResult1L(array);
       
   267 		break;
       
   268 	case 2:
       
   269 		error=AttachResult3L(array);
       
   270 		break;
       
   271 	case 4:
       
   272 		error=(array.Count()==3)? KErrNone:KErrNotFound;
       
   273 		break;
       
   274 	case 6:
       
   275 		error=(array.Count()==6)?KErrNone : KErrNotFound;  
       
   276 		break;
       
   277 	case 8:
       
   278 		error=(array.Count()==4)?KErrNone : KErrNotFound;  
       
   279 		break;
       
   280 	case 5:
       
   281 	case 9:
       
   282 	case 19:
       
   283 	case 20:
       
   284 		error=(array.Count()==1)?KErrNone : KErrNotFound;  
       
   285 		break;
       
   286 	case 14:  //has one attachment
       
   287 		{
       
   288 		error=(array.Count()==2)?KErrNone : KErrNotFound;  //no attachments is 2
       
   289 		if (error)
       
   290 			{
       
   291 			testUtils->WriteComment(_L("Number of attachments is wrong"));
       
   292 			break;
       
   293 			}
       
   294 		CMsvAttachment* attachmentInfo1=array[0];
       
   295 		CMsvAttachment* attachmentInfo2=array[1];
       
   296 
       
   297 		if((attachmentInfo1->Type()==CMsvAttachment::EMsvFile || attachmentInfo1->Type()==CMsvAttachment::EMsvLinkedFile ) 
       
   298 		&&(attachmentInfo2->Type()==CMsvAttachment::EMsvFile || attachmentInfo2->Type()==CMsvAttachment::EMsvLinkedFile ))
       
   299 			{
       
   300 			error = (!attachmentInfo1->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\3\\00100053_F\\WAP Security Group Meeting -- Minutes, final.doc")))
       
   301 				&& (!attachmentInfo2->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\7\\00100057_F\\state_table_change.doc"))) ? KErrNone : KErrNotFound;
       
   302 			if (error)
       
   303 				{
       
   304 				testUtils->WriteComment(_L("FileName didn't match"));
       
   305 				break;
       
   306 				}
       
   307 			}
       
   308 		else
       
   309 			testUtils->WriteComment(_L("These are message entry. Hence filenames does not exist"));
       
   310 		break;
       
   311 		}
       
   312 	case 15:
       
   313 		{
       
   314 		error=(array.Count()==2)?KErrNone : KErrNotFound;  //no attachments is 2
       
   315 		if (error)
       
   316 			{
       
   317 			testUtils->WriteComment(_L("Number of attachments is wrong"));
       
   318 			break;
       
   319 			}
       
   320 		CMsvAttachment* attachmentInfo1=array[0];
       
   321 		CMsvAttachment* attachmentInfo2=array[1];
       
   322 
       
   323 		if((attachmentInfo1->Type()==CMsvAttachment::EMsvFile || attachmentInfo1->Type()==CMsvAttachment::EMsvLinkedFile)
       
   324 		&& (attachmentInfo2->Type()==CMsvAttachment::EMsvFile || attachmentInfo2->Type()==CMsvAttachment::EMsvLinkedFile))
       
   325 			{
       
   326 		error= (!attachmentInfo1->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\e\\0010005e_F\\Attachment.ll")))
       
   327 				 && (!attachmentInfo2->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\f\\0010005f_F\\§§§.txt"))) ? KErrNone : KErrNotFound;
       
   328 			if (error)
       
   329 				{
       
   330 				testUtils->WriteComment(_L("FileName didn't match"));
       
   331 				break;
       
   332 				}
       
   333 			}
       
   334 		else
       
   335 			testUtils->WriteComment(_L("These are message entry. Hence filenames does not exist"));	
       
   336 			
       
   337 		break;
       
   338 		}
       
   339 	case 18:
       
   340 		{
       
   341 		error=(array.Count()==2)?KErrNone : KErrNotFound;  //no attachments is 2
       
   342 		if (error)
       
   343 			{
       
   344 			testUtils->WriteComment(_L("Number of attachments is wrong"));
       
   345 			break;
       
   346 			}
       
   347 		
       
   348 		CMsvAttachment* attachmentInfo1=array[0];
       
   349 		CMsvAttachment* attachmentInfo2=array[1];
       
   350 
       
   351 		if((attachmentInfo1->Type()==CMsvAttachment::EMsvFile || attachmentInfo1->Type()==CMsvAttachment::EMsvLinkedFile) 
       
   352 		&& (attachmentInfo2->Type()==CMsvAttachment::EMsvFile || attachmentInfo2->Type()==CMsvAttachment::EMsvLinkedFile))
       
   353 			{
       
   354 		error= (!attachmentInfo1->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\0\\00100070_F\\Attachment.ll")))
       
   355 				 && (!attachmentInfo2->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\1\\00100071_F\\TELECA1.TXT.pgp"))) ? KErrNone : KErrNotFound;
       
   356 			if (error)
       
   357 				{
       
   358 				testUtils->WriteComment(_L("FileName didn't match"));
       
   359 				break;
       
   360 				}
       
   361 			}
       
   362 		else
       
   363 			testUtils->WriteComment(_L("These are message entry. Hence filenames does not exist"));	
       
   364 		break;
       
   365 		}
       
   366 	case 21:
       
   367 		{
       
   368 		error=(array.Count()==1)?KErrNone : KErrNotFound;  //no attachments is 1
       
   369 		if (error)
       
   370 			{
       
   371 			testUtils->WriteComment(_L("Number of attachments is wrong"));
       
   372 			break;
       
   373 			}
       
   374 		
       
   375 		CMsvAttachment* attachmentInfo1=array[0];
       
   376 		if(attachmentInfo1->Type()==CMsvAttachment::EMsvFile || attachmentInfo1->Type()==CMsvAttachment::EMsvLinkedFile)
       
   377 			{
       
   378 		error=(!attachmentInfo1->FilePath().CompareF(_L("C:\\Private\\1000484b\\Mail2\\00001001_S\\4\\00100084_F\\Word file.doc"))) ? KErrNone : KErrNotFound;
       
   379 			if (error)
       
   380 				{
       
   381 				testUtils->WriteComment(_L("FileName didn't match"));
       
   382 				break;
       
   383 				}
       
   384 			}
       
   385 			else
       
   386 				testUtils->WriteComment(_L("This is a message entry. Hence filename does not exist"));	
       
   387 			break;
       
   388 		}
       
   389 	case 23:
       
   390 		error=(array.Count()==3)? KErrNone:KErrNotFound;
       
   391 		break;
       
   392 	case 25:
       
   393 		error=(array.Count()==3)?KErrNone : KErrNotFound;  
       
   394 		break;
       
   395 	case 27:
       
   396 		error=(array.Count()==1)? KErrNone : KErrNotFound;  
       
   397 		break;
       
   398 	case 28:
       
   399 		error=(array.Count()==3)? KErrNone : KErrNotFound;  
       
   400 		break;
       
   401 	case 29:
       
   402 	case 30:
       
   403 		error=(array.Count()==1)? KErrNone : KErrNotFound;  
       
   404 		break;
       
   405 	case 31:
       
   406 		error=(array.Count()==1)? KErrNone : KErrNotFound;  
       
   407 		break;
       
   408     default:
       
   409 		error=(array.Count()==0)?KErrNone : KErrNotFound;  
       
   410 		if (error)
       
   411 			{
       
   412 			testUtils->WriteComment(_L("Number of attachments is wrong"));
       
   413 			break;
       
   414 			}
       
   415 		break;
       
   416 		}
       
   417 	testUtils->TestFinish(aTest,error);
       
   418 	if (!globalError)
       
   419 		globalError=error;
       
   420 	}
       
   421 
       
   422 
       
   423 LOCAL_C void TestGetMsgDigestEntriesL(TInt aTest,const CMsvEntrySelection& aSel)
       
   424 	{
       
   425 	testUtils->TestStart(aTest);
       
   426 	TInt error=0;
       
   427 	switch (aTest)
       
   428 		{
       
   429 	case 14:  
       
   430 		error=(aSel.Count()==3)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   431 		if (error)
       
   432 			{
       
   433 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   434 			break;
       
   435 			}
       
   436 		error=(aSel[0]==0x0010004e && aSel[1]==0x00100050 && aSel[2]==0x00100054)?KErrNone:KErrNotFound;
       
   437 		if (error)
       
   438 			{
       
   439 			testUtils->WriteComment(_L("Ids don't match"));
       
   440 			break;
       
   441 			}
       
   442 		break;
       
   443 	case 15:
       
   444 		error=(aSel.Count()==1)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   445 		if (error)
       
   446 			{
       
   447 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   448 			break;
       
   449 			}
       
   450 		error=(aSel[0]==0x0010005b)?KErrNone:KErrNotFound;
       
   451 		if (error)
       
   452 			{
       
   453 			testUtils->WriteComment(_L("Id didn't match"));
       
   454 			break;
       
   455 			}
       
   456 		break;
       
   457 	case 16:
       
   458 		error=(aSel.Count()==1)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   459 		if (error)
       
   460 			{
       
   461 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   462 			break;
       
   463 			}
       
   464 		error=(aSel[0]==0x00100063)?KErrNone:KErrNotFound;
       
   465 		if (error)
       
   466 			{
       
   467 			testUtils->WriteComment(_L("Id didn't match"));
       
   468 			break;
       
   469 			}
       
   470 		break;
       
   471 	case 17:
       
   472 		error=(aSel.Count()==1)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   473 		if (error)
       
   474 			{
       
   475 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   476 			break;
       
   477 			}
       
   478 		error=(aSel[0]==0x00100068)?KErrNone:KErrNotFound;
       
   479 		if (error)
       
   480 			{
       
   481 			testUtils->WriteComment(_L("Id didn't match"));
       
   482 			break;
       
   483 			}
       
   484 		break;
       
   485 	case 18:
       
   486 		error=(aSel.Count()==1)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   487 		if (error)
       
   488 			{
       
   489 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   490 			break;
       
   491 			}
       
   492 		error=(aSel[0]==0x0010006d)?KErrNone:KErrNotFound;
       
   493 		if (error)
       
   494 			{
       
   495 			testUtils->WriteComment(_L("Id didn't match"));
       
   496 			break;
       
   497 			}
       
   498 		break;
       
   499 	case 21:
       
   500 		error=(aSel.Count()==1)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   501 		if (error)
       
   502 			{
       
   503 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   504 			break;
       
   505 			}
       
   506 		error=(aSel[0]==0x0010007f)?KErrNone:KErrNotFound;
       
   507 		if (error)
       
   508 			{
       
   509 			testUtils->WriteComment(_L("Id didn't match"));
       
   510 			break;
       
   511 			}
       
   512 
       
   513 		break;
       
   514 	case 24:
       
   515 		error=(aSel.Count()==2)?KErrNone:KErrNotFound;  //has 3 digest entries at the same level
       
   516 		if (error)
       
   517 			{
       
   518 			testUtils->WriteComment(_L("Number of msgdigests are wrong"));
       
   519 			break;
       
   520 			}
       
   521 		error=(aSel[0]==0x0010008e && aSel[1]==0x00100090)?KErrNone:KErrNotFound;
       
   522 		if (error)
       
   523 			{
       
   524 			testUtils->WriteComment(_L("Id didn't match"));
       
   525 			break;
       
   526 			}
       
   527 		break;
       
   528 	default:
       
   529 		error=(aSel.Count()==0)?KErrNone : KErrNotFound; 
       
   530 		break;
       
   531 		}
       
   532 	testUtils->TestFinish(aTest,error);
       
   533 	if (!globalError)
       
   534 		globalError=error;
       
   535 	}
       
   536 
       
   537 
       
   538 LOCAL_C void TestBodyTextL(TInt aTest,const CMsvEntrySelection& aSel,CImEmailMessage::TImEmailEntryType aEntryType)
       
   539 	{
       
   540 	testUtils->TestStart(aTest);
       
   541 	TInt error=0;
       
   542 	switch (aTest)
       
   543 		{
       
   544 	case 0:
       
   545 		error=(aSel.Count()==1)?KErrNone:KErrNotFound;
       
   546 		break;
       
   547 	case 1:
       
   548 		error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   549 		break;
       
   550 	case 7:
       
   551 		error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   552 		break;
       
   553 	case 9:
       
   554 		error=(aSel.Count()==2 )?KErrNone:KErrNotFound; 
       
   555 		break;
       
   556 	case 14:
       
   557 		if (aEntryType==CImEmailMessage::EThisMessageOnly)
       
   558 			error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   559 		else
       
   560 			error=(aSel.Count()==4 )?KErrNone:KErrNotFound;
       
   561 		break;
       
   562 	case 15:
       
   563 		if (aEntryType==CImEmailMessage::EThisMessageOnly)
       
   564 			error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   565 		else
       
   566 			error=(aSel.Count()==2 )?KErrNone:KErrNotFound;
       
   567 		break;
       
   568 	case 16:
       
   569 		error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   570 		break;
       
   571 	case 17:
       
   572 		if (aEntryType==CImEmailMessage::EThisMessageOnly)
       
   573 			error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   574 		else
       
   575 			error=(aSel.Count()==2 )?KErrNone:KErrNotFound;
       
   576 		break;
       
   577 	case 18:
       
   578 		if (aEntryType==CImEmailMessage::EThisMessageOnly)
       
   579 			error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   580 		else
       
   581 			error=(aSel.Count()==2 )?KErrNone:KErrNotFound;
       
   582 		break;
       
   583 	case 20:
       
   584 		error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   585 		break;
       
   586 	case 21:
       
   587 		if (aEntryType==CImEmailMessage::EThisMessageOnly)
       
   588 			error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   589 		else
       
   590 			error=(aSel.Count()==2 )?KErrNone:KErrNotFound;
       
   591 		break;
       
   592 	case 22:
       
   593 		error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   594 		break;
       
   595 	case 24:
       
   596 		if (aEntryType==CImEmailMessage::EThisMessageAndEmbeddedMessages)
       
   597 			error=(aSel.Count()==2 )?KErrNone:KErrNotFound;
       
   598 		break;
       
   599 	case 26:
       
   600 		error=(aSel.Count()==1 )?KErrNone:KErrNotFound;
       
   601 		break;
       
   602 	default:
       
   603 		break;
       
   604 		}
       
   605 	testUtils->TestFinish(aTest,error);
       
   606 	if (!globalError)
       
   607 		globalError=error;
       
   608 	}
       
   609 
       
   610 LOCAL_C void GetAttachmentInfoSelectionL(CImEmailMessage& aEmailMessage,RPointerArray<CMsvAttachment>& aAttachmentInfoArray)
       
   611 	{
       
   612 	MMsvAttachmentManager& attachmentMgr = aEmailMessage.AttachmentManager();
       
   613 	aAttachmentInfoArray.Reset();
       
   614 	CMsvAttachment* attachmentInfo;
       
   615 	for (TInt i= 0; i< attachmentMgr.AttachmentCount();i++)
       
   616 		{
       
   617 		attachmentInfo = attachmentMgr.GetAttachmentInfoL(i);
       
   618 		aAttachmentInfoArray.Append(attachmentInfo);
       
   619 		}
       
   620 	}
       
   621 
       
   622 LOCAL_C void GetAttachmentsL(TInt aTest,CImEmailMessage::TImAttachmentType aAttachmentType,CImEmailMessage::TImEmailEntryType aEntryType)
       
   623 	{	
       
   624 	RPointerArray<CMsvAttachment> attachmentArray;
       
   625 	CTestActive* testActive = new (ELeave) CTestActive;
       
   626 	CleanupStack::PushL(testActive);
       
   627 	testActive->StartL();
       
   628 	CImEmailMessage* emailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   629 	emailMessage->GetAttachmentsListL(testActive->iStatus,(*msgList)[aTest],aAttachmentType,aEntryType);
       
   630 	CActiveScheduler::Start();
       
   631 	
       
   632 	if (aTest==25 && (aAttachmentType==CImEmailMessage::EVCards || aAttachmentType==CImEmailMessage::EVEntries))  
       
   633 		{//vcards test . there is only one msg with vcard
       
   634 		testUtils->TestStart(aTest);
       
   635 		if (aAttachmentType==CImEmailMessage::EVCards && emailMessage->AttachmentManager().AttachmentCount()==1)
       
   636 	
       
   637 			testUtils->TestFinish(aTest,0);
       
   638 		else if (aAttachmentType==CImEmailMessage::EVEntries && emailMessage->AttachmentManager().AttachmentCount()==3)
       
   639 			testUtils->TestFinish(aTest,0);
       
   640 		else
       
   641 			{
       
   642 			testUtils->TestFinish(aTest,KErrNotFound);
       
   643 			globalError=KErrNotFound;
       
   644 			}
       
   645 		}
       
   646 		
       
   647 	if ((aTest==27 || aTest==29 || aTest==30) && aAttachmentType==CImEmailMessage::EICalendars)  
       
   648 		{
       
   649 		testUtils->TestStart(aTest);
       
   650 		TInt iCalCount = emailMessage->AttachmentManager().AttachmentCount();
       
   651 		if (aAttachmentType==CImEmailMessage::EICalendars && emailMessage->AttachmentManager().AttachmentCount()==1)
       
   652 			{
       
   653 			testUtils->TestFinish(aTest,0);
       
   654 			}
       
   655 		else
       
   656 			{
       
   657 			testUtils->TestFinish(aTest,KErrNotFound);
       
   658 			globalError=KErrNotFound;
       
   659 			}
       
   660 		}
       
   661 		
       
   662 	if (aTest==28 && aAttachmentType==CImEmailMessage::EVCalendars)  
       
   663 		{
       
   664 		testUtils->TestStart(aTest);
       
   665 		TInt vCalCount = emailMessage->AttachmentManager().AttachmentCount();
       
   666 		if (aAttachmentType==CImEmailMessage::EVCalendars && emailMessage->AttachmentManager().AttachmentCount()==2)
       
   667 			{
       
   668 			testUtils->TestFinish(aTest,0);
       
   669 			}
       
   670 		else
       
   671 			{
       
   672 			testUtils->TestFinish(aTest,KErrNotFound);
       
   673 			globalError=KErrNotFound;
       
   674 			}
       
   675 		}
       
   676 	
       
   677 	if (aTest==31  && (aAttachmentType==CImEmailMessage::EVCards || aAttachmentType==CImEmailMessage::EVEntries))  
       
   678 		{
       
   679 		testUtils->TestStart(aTest);
       
   680 		if (aAttachmentType==CImEmailMessage::EVCards && emailMessage->AttachmentManager().AttachmentCount()==1)
       
   681 			testUtils->TestFinish(aTest,0);
       
   682 		else if (aAttachmentType==CImEmailMessage::EVEntries && emailMessage->AttachmentManager().AttachmentCount()==1)
       
   683 			testUtils->TestFinish(aTest,0);
       
   684 		else
       
   685 			{
       
   686 			testUtils->TestFinish(aTest,KErrNotFound);
       
   687 			globalError=KErrNotFound;
       
   688 			}
       
   689 		}
       
   690 			
       
   691 	if (aAttachmentType==CImEmailMessage::EAllAttachments && aEntryType==CImEmailMessage::EThisMessageOnly)
       
   692 		{
       
   693 		RPointerArray<CMsvAttachment> attachmentArray;
       
   694 		GetAttachmentInfoSelectionL(*emailMessage,attachmentArray);
       
   695 		TestAttachmentResultsL(aTest,attachmentArray);
       
   696 		attachmentArray.ResetAndDestroy();
       
   697 		}
       
   698 	
       
   699 		
       
   700 	if (aAttachmentType==CImEmailMessage::EAllAttachments && aEntryType==CImEmailMessage::EThisMessageAndEmbeddedMessages)
       
   701 		{
       
   702 		GetAttachmentInfoSelectionL(*emailMessage,attachmentArray);
       
   703 		TestAttachmentsResultsInEmbeddedMsgsL(aTest,attachmentArray);
       
   704 		attachmentArray.ResetAndDestroy();
       
   705 		}
       
   706 	
       
   707 		
       
   708 	CleanupStack::PopAndDestroy(2,testActive); // emailMessage,testActive
       
   709 	}
       
   710 
       
   711 LOCAL_C void GetMsgDigestEntriesL(TInt aTest)
       
   712 	{
       
   713 	CTestActive* testActive = new (ELeave) CTestActive;
       
   714 	CleanupStack::PushL(testActive);
       
   715 	testActive->StartL();	
       
   716 	CImEmailMessage* emailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));	
       
   717 	emailMessage->GetMessageDigestEntriesL(testActive->iStatus,(*msgList)[aTest]);
       
   718 	CActiveScheduler::Start();	
       
   719 	TestGetMsgDigestEntriesL(aTest,emailMessage->Selection());
       
   720 	CleanupStack::PopAndDestroy(2,testActive); // emailMessage,testActive
       
   721 	}
       
   722 
       
   723 LOCAL_C void SetCharacterSetAndGetMsgDigestL(TInt aTest)
       
   724 	{
       
   725 	CTestActive* testActive = new (ELeave) CTestActive;
       
   726 	CleanupStack::PushL(testActive);
       
   727 	testActive->StartL();
       
   728 	CImEmailMessage* emailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));	
       
   729 	emailMessage->SetCharacterSetL((*msgList)[aTest], 1);
       
   730 	emailMessage->GetMessageDigestEntriesL(testActive->iStatus,(*msgList)[aTest]);
       
   731 	CActiveScheduler::Start();	
       
   732 	CleanupStack::PopAndDestroy(2, testActive); // emailMessage,testActive
       
   733 	}
       
   734 
       
   735 LOCAL_C void GetBodyTextL(TInt aTest,CImEmailMessage::TImEmailEntryType aEntryType)
       
   736 	{
       
   737 	CTestActive* testActive = new (ELeave) CTestActive;
       
   738 	CleanupStack::PushL(testActive);
       
   739 	testActive->StartL();
       
   740 	CImEmailMessage* emailMessage = CImEmailMessage::NewLC(*(testUtils->iMsvEntry));
       
   741 	rText->Reset();	
       
   742 	emailMessage->GetBodyTextL(testActive->iStatus,(*msgList)[aTest],aEntryType,*rText,*pLayer,*cLayer);
       
   743 	CActiveScheduler::Start();	
       
   744 	TestBodyTextL(aTest,emailMessage->Selection(),aEntryType);
       
   745 	CleanupStack::PopAndDestroy(2, testActive); // emailMessage,testActive
       
   746 	}
       
   747 
       
   748 LOCAL_C void GetBodyTextWithHeapFailL(TInt aTest,CImEmailMessage::TImEmailEntryType aEntryType)
       
   749 	{
       
   750 	testUtils->TestStart(1);
       
   751 	CTestActive* testActive = new (ELeave) CTestActive;
       
   752 	CleanupStack::PushL(testActive);
       
   753 	CImEmailMessage* emailMessage = NULL;
       
   754 	TBool finished = EFalse;
       
   755 #ifdef _DEBUG	
       
   756 	TInt failCount=0; 
       
   757 #endif	
       
   758 	TInt err = KErrNone;
       
   759 	while (!finished)
       
   760 		{
       
   761 		__UHEAP_FAILNEXT(failCount++);
       
   762 		TRAP(err, emailMessage=CImEmailMessage::NewL(*(testUtils->iMsvEntry)));
       
   763 		__UHEAP_RESET;
       
   764 		if (err==KErrNone)
       
   765 			{
       
   766 			finished=ETrue;
       
   767 			CleanupStack::PushL(emailMessage);
       
   768 			}
       
   769 		else
       
   770 			{
       
   771 			test(err==KErrNoMemory);
       
   772 			test(emailMessage==NULL);
       
   773 			}
       
   774 
       
   775 		}
       
   776 	testUtils->WriteComment(_L("CImEmailMessage::NewL Heapfailure test succesful"));
       
   777 	testUtils->TestFinish(1,err);
       
   778 #ifdef _DEBUG
       
   779 	failCount=0;
       
   780 #endif
       
   781 	finished=EFalse;	
       
   782 	testUtils->TestStart(2);
       
   783 	testUtils->WriteComment(_L("Testing GetBodyText with HeapFailure"));
       
   784 	while(!finished)
       
   785 		{	
       
   786 		__UHEAP_FAILNEXT(failCount++);
       
   787 		rText->Reset();
       
   788 		TRAP(err,emailMessage->GetBodyTextL(testActive->iStatus,(*msgList)[aTest],aEntryType,*rText,*pLayer,*cLayer));
       
   789 		__UHEAP_RESET;
       
   790 		if (err == KErrNone)
       
   791 			{
       
   792 			testActive->StartL();
       
   793 			CActiveScheduler::Start();	
       
   794 			}
       
   795 		else
       
   796 			test(err == KErrNoMemory);
       
   797 
       
   798 		if (err== KErrNone && testActive->iStatus.Int()== KErrNone)
       
   799 			{
       
   800 			finished=ETrue;
       
   801 			if (aEntryType==CImEmailMessage::EThisMessageOnly)
       
   802 				{
       
   803 				test(emailMessage->Selection().Count()==1);
       
   804 				test(rText->DocumentLength()==128);
       
   805 				}
       
   806 			else
       
   807 				{
       
   808 				test(emailMessage->Selection().Count()==4);
       
   809 				test(rText->DocumentLength()==128+375+327+142+3);
       
   810 				}
       
   811 			}
       
   812 		}
       
   813 	testUtils->TestFinish(2,err);
       
   814 	CleanupStack::PopAndDestroy(2,testActive); // emailMessage,testActive
       
   815 	}
       
   816 
       
   817 LOCAL_C void GetAttachmentsWithHeapFailL(TInt aTest,CImEmailMessage::TImAttachmentType aAttachmentType,CImEmailMessage::TImEmailEntryType aEntryType)
       
   818 	{
       
   819 	testUtils->TestStart(1);
       
   820 	CTestActive* testActive = new (ELeave) CTestActive;
       
   821 	CleanupStack::PushL(testActive);
       
   822 	TBool finished = EFalse;
       
   823 #ifdef _DEBUG	
       
   824 	TInt failCount=0;
       
   825 #endif	
       
   826 	TInt err = KErrNone;
       
   827 	CImEmailMessage* emailMessage=NULL;
       
   828 	while (!finished)
       
   829 		{
       
   830 		__UHEAP_FAILNEXT(failCount++);
       
   831 		TRAP(err,emailMessage= CImEmailMessage::NewL(*(testUtils->iMsvEntry)));
       
   832 		__UHEAP_RESET;
       
   833 		if (err==KErrNone)
       
   834 			{
       
   835 			finished=ETrue;
       
   836 			CleanupStack::PushL(emailMessage);
       
   837 			}
       
   838 		else
       
   839 			{
       
   840 			test(err==KErrNoMemory);
       
   841 			test(emailMessage==NULL);
       
   842 			}
       
   843 		}
       
   844 	testUtils->WriteComment(_L("CImEmailMessage::NewL tested with heapfailure"));
       
   845 	testUtils->TestFinish(1,err);
       
   846 #ifdef _DEBUG
       
   847 	failCount=0;
       
   848 #endif	
       
   849 	finished=EFalse;
       
   850 	err=KErrNone;
       
   851 	testUtils->WriteComment(_L("Testing GetAttachmentsListL with heapfailure"));
       
   852 	testUtils->TestStart(2);
       
   853 	while(!finished)
       
   854 		{
       
   855 		__UHEAP_FAILNEXT(failCount++);
       
   856 		TRAP(err,emailMessage->GetAttachmentsListL(testActive->iStatus,(*msgList)[aTest],aAttachmentType,aEntryType));
       
   857 		__UHEAP_RESET;
       
   858 		if (err == KErrNone)
       
   859 			{
       
   860 			testActive->StartL();
       
   861 			CActiveScheduler::Start();	
       
   862 			}
       
   863 		else
       
   864 			test(err == KErrNoMemory);
       
   865 		
       
   866 		if (err== KErrNone && testActive->iStatus.Int()== KErrNone)
       
   867 			{
       
   868 			finished=ETrue;
       
   869 			test(emailMessage->AttachmentManager().AttachmentCount()==6);
       
   870 		
       
   871 			_LIT(KFilePath, "C:\\Private\\1000484b\\Mail2\\00001001_S\\3\\00100013_F\\text.txt");
       
   872 			RPointerArray<CMsvAttachment> attachmentArray;
       
   873 			GetAttachmentInfoSelectionL(*emailMessage,attachmentArray);		
       
   874 			const TDesC& ref=(attachmentArray[0]->FilePath());
       
   875 			test(ref==KFilePath);
       
   876 			
       
   877 			attachmentArray.ResetAndDestroy();			
       
   878 			}
       
   879 		}
       
   880 	testUtils->TestFinish(2,err);
       
   881 	CleanupStack::PopAndDestroy(2,testActive); // emailMessage,testActive
       
   882 	}
       
   883 
       
   884 LOCAL_C void InitL()
       
   885 	{
       
   886 	scheduler = new (ELeave) CActiveScheduler;
       
   887 	CleanupStack::PushL(scheduler);
       
   888 	CActiveScheduler::Install( scheduler );
       
   889 	testUtils = CEmailTestUtils::NewLC(test);
       
   890 	testUtils->CreateAllTestDirectories();
       
   891 	testUtils->CleanMessageFolderL();
       
   892 	testUtils->GoServerSideL();
       
   893 	}
       
   894 
       
   895 LOCAL_C void doMainL()
       
   896 	{
       
   897 	InitL();
       
   898 // Read the test message into the mail directory.
       
   899 	testUtils->CreateMessageFilesL(KMsvGlobalInBoxIndexEntryId, KMsvDraftEntryId,_L("c:\\mailtest\\rfcT_IMCM06\\"));
       
   900 	testUtils->GoClientSideL();
       
   901 	testUtils->WriteComment(_L("T_IMCM06 Test CImEmailMessage Get- BodyText,Attachments,MsgDigest Methods"));
       
   902 	testUtils->WriteComment(_L("this test code creates 31 messages of various structures and uses CImEmailMessage"));
       
   903 	testUtils->WriteComment(_L("to get - attachments, text and digest entries.  It is important to maintain the order"));
       
   904 	testUtils->WriteComment(_L("of the rfc files in t_imcm06 dir because the test code results are hardwired to the "));
       
   905 	testUtils->WriteComment(_L("corresponding files i.e message ID,  attachment name."));
       
   906 
       
   907 	CMsvEntry* entry = testUtils->iMsvEntry;
       
   908 	entry->SetEntryL(KMsvDraftEntryId);
       
   909 	msgList = entry->ChildrenL();
       
   910 	CleanupStack::PushL(msgList);
       
   911 	TInt count=msgList->Count();
       
   912 	if (count)
       
   913 		testUtils->WriteComment(_L("Messages created sucessfully"));
       
   914 	else
       
   915 		{
       
   916 		testUtils->WriteComment(_L("Failed to create messages"));
       
   917 		CleanupStack::PopAndDestroy();  //list
       
   918 		Closedown();
       
   919 		return;
       
   920 		}
       
   921 //	Testing attachments
       
   922 	testUtils->WriteComment(_L("Testing Get AllAttachments in EThisMessageOnly"));
       
   923 	for (TInt i=0;i<count;i++)
       
   924 		GetAttachmentsL(i,CImEmailMessage::EAllAttachments,CImEmailMessage::EThisMessageOnly);
       
   925 	testUtils->WriteComment(_L("Testing Get AllAttachments in EThisMessageOnly finished\n"));
       
   926 
       
   927 	testUtils->WriteComment(_L("Testing Get EVCards in EThisMessageOnly"));
       
   928 	for (TInt j=0;j<count;j++)
       
   929 		GetAttachmentsL(j,CImEmailMessage::EVCards,CImEmailMessage::EThisMessageOnly);
       
   930 	testUtils->WriteComment(_L("Testing Get EVCards in EThisMessageOnly finished\n"));
       
   931 
       
   932 	testUtils->WriteComment(_L("Testing Get EVEntries in EThisMessageOnly"));
       
   933 	for (TInt k=0;k<count;k++)
       
   934 		GetAttachmentsL(k,CImEmailMessage::EVEntries,CImEmailMessage::EThisMessageOnly);
       
   935 	testUtils->WriteComment(_L("Testing Get EVEntries in EThisMessageOnly finished\n"));
       
   936 	
       
   937 	testUtils->WriteComment(_L("Testing Get EICalendars in EThisMessageOnly"));
       
   938 	for (TInt l=0;l<count;l++)
       
   939 		GetAttachmentsL(l,CImEmailMessage::EICalendars,CImEmailMessage::EThisMessageOnly);
       
   940 	testUtils->WriteComment(_L("Testing Get EICalendars in EThisMessageOnly finished\n"));
       
   941 	
       
   942 	testUtils->WriteComment(_L("Testing Get EVCalendars in EThisMessageOnly"));
       
   943 	for (TInt m=0;m<count;m++)
       
   944 		GetAttachmentsL(m,CImEmailMessage::EVCalendars,CImEmailMessage::EThisMessageOnly);
       
   945 	testUtils->WriteComment(_L("Testing Get EVCalendars in EThisMessageOnly finished\n"));
       
   946 
       
   947 	//	testing attachments in embeded messages
       
   948 	testUtils->WriteComment(_L("Testing Get AllAttachments in EThisMessageAndEmbeddedMessages"));
       
   949 	for (TInt n=0;n<count;n++)
       
   950 		GetAttachmentsL(n,CImEmailMessage::EAllAttachments,CImEmailMessage::EThisMessageAndEmbeddedMessages);
       
   951 	testUtils->WriteComment(_L("Testing Get AllAttachments in EThisMessageAndEmbeddedMessages finished\n"));
       
   952 
       
   953 	//	testing getmsgdigest entries
       
   954 	testUtils->WriteComment(_L("Testing GetMessageDigestEntriesL"));
       
   955 	for (TInt o=0;o<count;o++)
       
   956 		GetMsgDigestEntriesL(o);
       
   957 	testUtils->WriteComment(_L("Testing GetMessageDigestEntriesL finished\n"));
       
   958 
       
   959 	// This email number 14 has embedded messages and attachments
       
   960 	// Test added for the defect DEF064292: Crash in CImEmailMessage
       
   961 	testUtils->WriteComment(_L("Testing SetCharacterSetAndGetMsgDigestL"));
       
   962 	SetCharacterSetAndGetMsgDigestL(14);
       
   963 	testUtils->WriteComment(_L("Testing SetCharacterSetAndGetMsgDigestL finished\n"));
       
   964 	
       
   965 	//	testing getbody text
       
   966 	pLayer = CParaFormatLayer::NewL();
       
   967 	CleanupStack::PushL(pLayer);
       
   968 	cLayer = CCharFormatLayer::NewL();
       
   969 	CleanupStack::PushL(cLayer);
       
   970 	rText = CRichText::NewL(pLayer, cLayer);
       
   971 	CleanupStack::PushL(rText);
       
   972 
       
   973 	testUtils->WriteComment(_L("Testing GetBodyTextL for EThisMessageOnly"));
       
   974 	for (TInt p=0;p<count;p++)
       
   975 		GetBodyTextL(p,CImEmailMessage::EThisMessageOnly);
       
   976 	testUtils->WriteComment(_L("Testing GetBodyTextL for EThisMessageOnly finished"));
       
   977 	
       
   978 	testUtils->WriteComment(_L("Testing GetBodyTextL for EThisMessageAndEmbeddedMessages"));
       
   979 	for (TInt q=0;q<count;q++)
       
   980 		GetBodyTextL(q,CImEmailMessage::EThisMessageAndEmbeddedMessages);
       
   981 	testUtils->WriteComment(_L("Testing GetBodyTextL for EThisMessageAndEmbeddedMessages finished"));
       
   982 	
       
   983 	testUtils->WriteComment(_L("Testing with HeapFailure"));	
       
   984 	
       
   985 	GetBodyTextWithHeapFailL(14,CImEmailMessage::EThisMessageOnly);
       
   986 
       
   987 	testUtils->WriteComment(_L("Testing GetBodyTextWithHeapFailL for EThisMessageAndEmbeddedMessages"));
       
   988 	GetBodyTextWithHeapFailL(14,CImEmailMessage::EThisMessageAndEmbeddedMessages);
       
   989 
       
   990 	GetAttachmentsWithHeapFailL(6,CImEmailMessage::EAllAttachments,CImEmailMessage::EThisMessageOnly);
       
   991 
       
   992 	CleanupStack::PopAndDestroy(4,msgList); //newMessageList,text,player,clayer
       
   993 	Closedown();
       
   994 	}
       
   995 
       
   996 
       
   997 GLDEF_C TInt E32Main()
       
   998 	{	
       
   999 	__UHEAP_MARK;
       
  1000 	test.Start(_L("T_IMCM06 Test CImEmailMessage Get- BodyText,Attachments,MsgDigest Methods"));
       
  1001 	theCleanup=CTrapCleanup::New();
       
  1002 	TRAPD(ret,doMainL());		
       
  1003 	test(ret==KErrNone);
       
  1004 	delete theCleanup;	
       
  1005 	test.End();
       
  1006 	test.Close();
       
  1007 	__UHEAP_MARKEND;
       
  1008 	User::Heap().Check();
       
  1009 	return(KErrNone);
       
  1010 	}