messagingappbase/smsmtm/test/src/T_smutTE.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <smss.rsg>
       
    17 #include <csmsaccount.h>
       
    18 #include <csmsemailfields.h>
       
    19 
       
    20 #include "T_smutTE.h"
       
    21 #include <gsmuieoperations.h>
       
    22 
       
    23 const TUid KUidMsvSmsEmailFieldsStream	= {0x10204C9D};
       
    24 const TInt KLogID1 = 123456789;
       
    25 const TInt KLogID2 = 987654321;
       
    26 const TInt KLogID3 = 118888;
       
    27 
       
    28 CSmutTest::CSmutTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest,CTestStep& aTestStep)
       
    29 : CSmsTestBase(aSmsTest, aScriptFile, aNextTest), iTestStep(aTestStep)
       
    30 	{
       
    31 	}
       
    32 
       
    33 void CSmutTest::RunAutoL()
       
    34 	{
       
    35 	}
       
    36 	
       
    37 CSmutTest::~CSmutTest()
       
    38 	{
       
    39 	delete iSmsHeader;
       
    40 	delete iRichText;
       
    41 	delete iParaLayer;
       
    42 	delete iCharLayer;
       
    43 	if(iDBSession)
       
    44 	  {
       
    45 	  iDBSession->Close();
       
    46 	  }
       
    47 	delete iDBSession;	
       
    48 	}
       
    49 
       
    50 void CSmutTest::ConstructL()
       
    51 	{
       
    52 	iSmsTest.SetLogToFile();
       
    53 
       
    54 	iSelection = new (ELeave) CMsvEntrySelection();
       
    55 	iTimer = CTestTimer::NewL();
       
    56 
       
    57 	iParaLayer =CParaFormatLayer::NewL();
       
    58 	iCharLayer = CCharFormatLayer::NewL();
       
    59 	iRichText = CRichText::NewL(iParaLayer, iCharLayer, CEditableText::EFlatStorage,256);
       
    60 	iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion());	
       
    61 
       
    62 	CActiveScheduler::Add(this);
       
    63 	}
       
    64 
       
    65 CSmutTest* CSmutTest::NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest,CTestStep& aTestStep)
       
    66 	{
       
    67 	CSmutTest* self = new (ELeave) CSmutTest(aSmsTest, aScriptFile, aNextTest, aTestStep);
       
    68 	CleanupStack::PushL(self);
       
    69 
       
    70 	self->ConstructL();
       
    71 
       
    72 	return self;
       
    73 	}
       
    74 
       
    75 void CSmutTest::ShowMenuL()
       
    76 	{
       
    77 	}
       
    78 
       
    79 TVerdict CSmutTest::TestSettingsL()
       
    80 	{
       
    81 	iTestStep.INFO_PRINTF1(_L("Testing Create Settings..."));
       
    82 
       
    83 	iSmsTest.SetEntryL(iSmsTest.iSmsServiceId);
       
    84 
       
    85 	// First we test all the features of the class CSmsSettings
       
    86 	// We give them different values and compare if it works
       
    87 
       
    88 	CSmsSettings* settings = CSmsSettings::NewLC();
       
    89 	if(!CompareSettings(*settings, *settings))
       
    90 		{
       
    91 		CleanupStack::PopAndDestroy(settings);
       
    92 		return EFail;	
       
    93 		}
       
    94 	if(!TestSettingsMembersL(*settings))
       
    95 		{
       
    96 		CleanupStack::PopAndDestroy(settings);
       
    97 		return EFail;	
       
    98 		}
       
    99 	TestMessageSettingsMembersL(*settings);
       
   100 
       
   101 	// Lets copy the values to a different instance
       
   102 	CSmsSettings* smsSettings=CSmsSettings::NewLC();
       
   103 	smsSettings->CopyL(*settings);
       
   104 	if(!CompareSettings(*smsSettings, *settings))
       
   105 		{
       
   106 		CleanupStack::PopAndDestroy(2,settings);
       
   107 		return EFail;	
       
   108 		}
       
   109 	CleanupStack::PopAndDestroy(smsSettings);
       
   110 	smsSettings = NULL;
       
   111 	iTestStep.INFO_PRINTF1(_L("Test CSmsSettings::CopyL() passed"));
       
   112 
       
   113 	//	Lets create a sms service in the file system with these values
       
   114 	TestStoreRestoreSettingsL(*settings);
       
   115 
       
   116 	// Lets make the previous test again; Lets give a settings instance some
       
   117 	// values, store it, restore it and see that the values are still the same
       
   118 	CSmsSettings* set2=CSmsSettings::NewLC();
       
   119 	set2->AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010"));
       
   120 	set2->AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010"));
       
   121 	set2->AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010"));
       
   122 	set2->AddServiceCenterL(_L("Radiolinja3"),_L("+358508771010"));
       
   123 	set2->AddServiceCenterL(_L("Radiolinja4"),_L("+358508771010"));
       
   124 	set2->SetDefaultServiceCenter(1);
       
   125 	iSmsTest(set2->DefaultServiceCenter()==1);
       
   126 	// Validity Period	
       
   127 	set2->SetValidityPeriod(ESmsVPSixHours);
       
   128 	if(set2->ValidityPeriod().Int()!=ESmsVPSixHours)
       
   129 		{
       
   130 		CleanupStack::PopAndDestroy(2,settings);
       
   131 		return EFail;	
       
   132 		}
       
   133 	// Reply Quoted
       
   134 	set2->SetReplyQuoted(EFalse);
       
   135 	if(set2->ReplyQuoted())
       
   136 		{
       
   137 		CleanupStack::PopAndDestroy(2,settings);
       
   138 		return EFail;	
       
   139 		}
       
   140 	// Reject Duplicate 
       
   141 	set2->SetRejectDuplicate(ETrue);
       
   142 	if(!set2->RejectDuplicate())
       
   143 		{
       
   144 		CleanupStack::PopAndDestroy(2,settings);
       
   145 		return EFail;	
       
   146 		}
       
   147 	// Delivery Method
       
   148 	set2->SetDelivery(ESmsDeliveryUponRequest);
       
   149 	if(set2->Delivery()!=ESmsDeliveryUponRequest)
       
   150 		{
       
   151 		CleanupStack::PopAndDestroy(2,settings);
       
   152 		return EFail;	
       
   153 		}
       
   154 	// Delivery Report
       
   155 	set2->SetDeliveryReport(ETrue);
       
   156 	if(!set2->DeliveryReport())
       
   157 		{
       
   158 		CleanupStack::PopAndDestroy(2,settings);
       
   159 		return EFail;	
       
   160 		}
       
   161 	// Reply Path
       
   162 	set2->SetReplyPath(EFalse);
       
   163 	if(set2->ReplyPath())
       
   164 		{
       
   165 		CleanupStack::PopAndDestroy(2,settings);
       
   166 		return EFail;	
       
   167 		}
       
   168 	// Message Conversion
       
   169 	set2->SetMessageConversion(ESmsConvPIDNone);
       
   170 	if(set2->MessageConversion()!=ESmsConvPIDNone)
       
   171 		{
       
   172 		CleanupStack::PopAndDestroy(2,settings);
       
   173 		return EFail;	
       
   174 		}
       
   175 	// Can Concatenate
       
   176 	set2->SetCanConcatenate(ETrue);
       
   177 	if(!set2->CanConcatenate())
       
   178 		{
       
   179 		CleanupStack::PopAndDestroy(2,settings);
       
   180 		return EFail;	
       
   181 		}
       
   182 	// Character Set
       
   183 	set2->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
       
   184 	if(set2->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet8Bit)
       
   185 		{
       
   186 		CleanupStack::PopAndDestroy(2,settings);
       
   187 		return EFail;	
       
   188 		}
       
   189 	// Validity period format
       
   190 	set2->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet);
       
   191 	if(set2->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet)
       
   192 		{
       
   193 		CleanupStack::PopAndDestroy(2,settings);
       
   194 		return EFail;	
       
   195 		}
       
   196 	// Status Report Handling
       
   197 	set2->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible);
       
   198 	if(set2->StatusReportHandling()!=CSmsSettings::EMoveReportToInboxVisible)
       
   199 		{
       
   200 		CleanupStack::PopAndDestroy(2,settings);
       
   201 		return EFail;	
       
   202 		}
       
   203 	// Special Message Handling
       
   204 	set2->SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible);
       
   205 	if(set2->SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxVisible)
       
   206 		{
       
   207 		CleanupStack::PopAndDestroy(2,settings);
       
   208 		return EFail;	
       
   209 		}
       
   210 
       
   211 	if(!TestStoreRestoreSettingsL(*set2))
       
   212 		{
       
   213 		CleanupStack::PopAndDestroy(2,settings);
       
   214 		return EFail;	
       
   215 		}
       
   216 
       
   217 	set2->SetClass2Folder(123);
       
   218 	if(!TestStoreRestoreSettingsL(*set2))
       
   219 		{
       
   220 		CleanupStack::PopAndDestroy(2,settings);
       
   221 		return EFail;	
       
   222 		}
       
   223 
       
   224 	CleanupStack::PopAndDestroy(set2);
       
   225 
       
   226 	iSmsTest.iServiceSettings->CopyL(*settings);  // Lets copy the current setting to the service settings
       
   227 
       
   228 	if(!CompareSettings(*iSmsTest.iServiceSettings, *settings))
       
   229 		{
       
   230 		CleanupStack::PopAndDestroy(settings);
       
   231 		return EFail;	
       
   232 		}
       
   233 
       
   234 	iTestStep.INFO_PRINTF1(_L("CSmsSettings::CopyL() 2"));
       
   235 	CleanupStack::PopAndDestroy(settings);
       
   236 	iTestStep.INFO_PRINTF1(_L("Test Create Settings Passed"));
       
   237 	TestSettingsStoreToCommDbL();
       
   238 	iTestStep.INFO_PRINTF1(_L("Test Create Settings Passed"));
       
   239 	return EPass;
       
   240 	}
       
   241 
       
   242 
       
   243 TBool CSmutTest::CompareSettingsFiles(
       
   244 	RFs& aFs, const TDesC& aCompare1, const TDesC& aCompare2
       
   245 	)
       
   246 	{
       
   247 	TBool identical = ETrue;
       
   248 
       
   249 	RFileReadStream stream1;
       
   250 	RFileReadStream stream2;
       
   251 
       
   252 	// Open each stream for binary read.
       
   253 	stream1.Open(aFs, aCompare1, EFileStream | EFileRead);
       
   254 	stream2.Open(aFs, aCompare2, EFileStream | EFileRead);
       
   255 
       
   256 	TInt ret1 = KErrNone;
       
   257 	TInt ret2 = KErrNone;
       
   258 	TBool finished = EFalse;
       
   259 	TUint8 byte1 = 0;
       
   260 	TUint8 byte2 = 0;
       
   261 
       
   262 	while (!finished)
       
   263 		{
       
   264 		TRAP(ret1, byte1 = stream1.ReadUint8L());
       
   265 		TRAP(ret2, byte2 = stream2.ReadUint8L());
       
   266 
       
   267 		if (byte1 != byte2 || ret1 == KErrEof || ret2 == KErrEof)
       
   268 			{
       
   269 			// Either file data or lengths differ.
       
   270 			if ((byte1 != byte2) || (ret1 != ret2))
       
   271 				identical = EFalse;
       
   272 			finished = ETrue;
       
   273 			}
       
   274 		}
       
   275 
       
   276 	stream1.Close();
       
   277 	stream2.Close();
       
   278 
       
   279 	return identical;
       
   280 	}
       
   281 
       
   282 TBool CSmutTest::TestStoreRestoreSettingsL(const CSmsSettings& aSettings)
       
   283 	{
       
   284 	StoreSettingsL(aSettings);
       
   285 
       
   286 	// Lets read the service and see it the values are still ok
       
   287 	CSmsSettings* set1=CSmsSettings::NewLC();
       
   288 
       
   289 	RestoreSettingsL(*set1);
       
   290 
       
   291 	if(!CompareSettings(*set1, aSettings))
       
   292 		{
       
   293 		CleanupStack::PopAndDestroy(set1);
       
   294 		return EFalse;	
       
   295 		}
       
   296 
       
   297 	CleanupStack::PopAndDestroy(set1);
       
   298 	
       
   299 	return ETrue;
       
   300 	}
       
   301 
       
   302 TBool CSmutTest::TestSettingsMembersL(CSmsSettings& aSettings)
       
   303 	{
       
   304 	// Status Report Handling (what should be done to report messages)
       
   305 	aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisible);
       
   306 	if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxInvisible)
       
   307 		{
       
   308 		return EFalse;
       
   309 		}
       
   310 	aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible);
       
   311 	if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxVisible)
       
   312 		{
       
   313 		return EFalse;	
       
   314 		}
       
   315 	aSettings.SetStatusReportHandling(CSmsSettings::EDiscardReport);
       
   316 	if(aSettings.StatusReportHandling()!=CSmsSettings::EDiscardReport)
       
   317 		{
       
   318 		return EFalse;
       
   319 		}
       
   320 	aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch);
       
   321 	if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxInvisibleAndMatch)
       
   322 		{
       
   323 		return EFalse;	
       
   324 		}
       
   325 	aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch);
       
   326 	if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxVisibleAndMatch)
       
   327 		{
       
   328 		return EFalse;	
       
   329 		}
       
   330 	aSettings.SetStatusReportHandling(CSmsSettings::EDiscardReportAndMatch);
       
   331 	if(aSettings.StatusReportHandling()!=CSmsSettings::EDiscardReportAndMatch)
       
   332 		{
       
   333 		return EFalse;	
       
   334 		}
       
   335 	iTestStep.INFO_PRINTF1(_L("Test Status Report Handling Passed"));
       
   336 
       
   337 	// SC handling
       
   338 	aSettings.AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010"));
       
   339 	aSettings.AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010"));
       
   340 	aSettings.AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010"));
       
   341 	aSettings.AddServiceCenterL(_L("Radiolinja3"),_L("+358508771010"));
       
   342 	aSettings.AddServiceCenterL(_L("Radiolinja4"),_L("+358508771010"));
       
   343 	if(aSettings.GetServiceCenter(0).Name()!=_L("Radiolinja0"))
       
   344 		{
       
   345 		return EFalse;	
       
   346 		}
       
   347 	aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-3);
       
   348 	aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-2);
       
   349 	if(aSettings.GetServiceCenter(1).Name()!=_L("Radiolinja1"))
       
   350 		{
       
   351 		return EFalse;	
       
   352 		}
       
   353 	if(aSettings.GetServiceCenter(2).Name()!=_L("Radiolinja4"))
       
   354 		{
       
   355 		return EFalse;	
       
   356 		}
       
   357 	if(aSettings.GetServiceCenter(2).Address()!=_L("+358508771010"))
       
   358 		{
       
   359 		return EFalse;	
       
   360 		}
       
   361 	aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1);
       
   362 	aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1);
       
   363 	aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1);
       
   364 	//	aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); // this would be -1
       
   365 	aSettings.AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010"));
       
   366 	aSettings.AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010"));
       
   367 	aSettings.AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010"));
       
   368 	aSettings.SetDefaultServiceCenter(1);
       
   369 	if(aSettings.DefaultServiceCenter()!=1)
       
   370 		{
       
   371 		return EFalse;	
       
   372 		}
       
   373 	aSettings.SetDefaultServiceCenter(2);
       
   374 	if(aSettings.DefaultServiceCenter()!=2)
       
   375 		{
       
   376 		return EFalse;	
       
   377 		}
       
   378 	iTestStep.INFO_PRINTF1(_L("Test Default SC Passed"));
       
   379 
       
   380 	// Special Message Handling (what should be done to special messages)
       
   381 	aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxInvisible);
       
   382 	if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxInvisible)
       
   383 		{
       
   384 		return EFalse;	
       
   385 		}
       
   386 	aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible);
       
   387 	if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxVisible)
       
   388 		{
       
   389 		return EFalse;	
       
   390 		}
       
   391 	aSettings.SetSpecialMessageHandling(CSmsSettings::EDiscardReport);
       
   392 	if(aSettings.SpecialMessageHandling()!=CSmsSettings::EDiscardReport)
       
   393 		{
       
   394 		return EFalse;	
       
   395 		}
       
   396 	aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch);
       
   397 	if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxInvisibleAndMatch)
       
   398 		{
       
   399 		return EFalse;	
       
   400 		}
       
   401 	aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch);
       
   402 	if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxVisibleAndMatch)
       
   403 		{
       
   404 		return EFalse;	
       
   405 		}
       
   406 	aSettings.SetSpecialMessageHandling(CSmsSettings::EDiscardReportAndMatch);
       
   407 	if(aSettings.SpecialMessageHandling()!=CSmsSettings::EDiscardReportAndMatch)
       
   408 		{
       
   409 		return EFalse;	
       
   410 		}
       
   411 	iTestStep.INFO_PRINTF1(_L("Test Special Message Handling Passed"));
       
   412 
       
   413 	//CommDbAction
       
   414 	aSettings.SetCommDbAction(CSmsSettings::ENone);
       
   415 	if(aSettings.CommDbAction() != CSmsSettings::ENone)
       
   416 		{
       
   417 		return EFalse;	
       
   418 		}
       
   419 	aSettings.SetCommDbAction(CSmsSettings::EStoreToCommDb);
       
   420 	if(aSettings.CommDbAction() != CSmsSettings::EStoreToCommDb)
       
   421 		{
       
   422 		return EFalse;	
       
   423 		}
       
   424 	iTestStep.INFO_PRINTF1(_L("Test CommDb Action Passed"));
       
   425 
       
   426 	//SmsBearerAction
       
   427 	aSettings.SetSmsBearerAction(CSmsSettings::ENone);
       
   428 	if(aSettings.SmsBearerAction() != CSmsSettings::ENone)
       
   429 		{
       
   430 		return EFalse;	
       
   431 		}
       
   432 	aSettings.SetSmsBearerAction(CSmsSettings::EStoreToCommDb);
       
   433 	if(aSettings.SmsBearerAction() != CSmsSettings::EStoreToCommDb)
       
   434 		{
       
   435 		return EFalse;	
       
   436 		}
       
   437 	iTestStep.INFO_PRINTF1(_L("Test SMS Bearer Action Passed"));
       
   438 
       
   439 	//SmsBearer
       
   440 	aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly);
       
   441 	if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerPacketOnly)
       
   442 		{
       
   443 		return EFalse;	
       
   444 		}
       
   445 	aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly);
       
   446 	if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerPacketOnly)
       
   447 		{
       
   448 		return EFalse;	
       
   449 		}
       
   450 	aSettings.SetSmsBearer(CSmsSettings::ESmsBearerCircuitOnly);
       
   451 	if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerCircuitOnly)
       
   452 		{
       
   453 		return EFalse;	
       
   454 		}
       
   455 	aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketPreferred);
       
   456 	if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerPacketPreferred)
       
   457 		{
       
   458 		return EFalse;	
       
   459 		}
       
   460 	aSettings.SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred);
       
   461 	if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerCircuitPreferred)
       
   462 		{
       
   463 		return EFalse;	
       
   464 		}
       
   465 	iTestStep.INFO_PRINTF1(_L("Test SMS Bearer Passed"));
       
   466 
       
   467 	// Reply Quoted
       
   468 	aSettings.SetReplyQuoted(EFalse);
       
   469 	if(aSettings.ReplyQuoted())
       
   470 		{
       
   471 		return EFalse;	
       
   472 		}
       
   473 	aSettings.SetReplyQuoted(ETrue);
       
   474 	if(!aSettings.ReplyQuoted())
       
   475 		{
       
   476 		return EFalse;	
       
   477 		}
       
   478 	iTestStep.INFO_PRINTF1(_L("Test Reply Quoted Passed"));
       
   479 
       
   480 	// Delivery Method
       
   481 	aSettings.SetDelivery(ESmsDeliveryUponRequest);
       
   482 	if(aSettings.Delivery()!=ESmsDeliveryUponRequest)
       
   483 		{
       
   484 		return EFalse;	
       
   485 		}
       
   486 	aSettings.SetDelivery(ESmsDeliveryScheduled);
       
   487 	if(aSettings.Delivery()!=ESmsDeliveryScheduled)
       
   488 		{
       
   489 		return EFalse;
       
   490 		}
       
   491 	aSettings.SetDelivery(ESmsDeliveryImmediately);
       
   492 	if(aSettings.Delivery()!=ESmsDeliveryImmediately)
       
   493 		{
       
   494 		return EFalse;	
       
   495 		}
       
   496 	iTestStep.INFO_PRINTF1(_L("Test Delivery Passed"));
       
   497 
       
   498 	// Class2Folder
       
   499 	if(aSettings.Class2Folder() != KMsvGlobalInBoxIndexEntryId)
       
   500 		{
       
   501 		return EFalse;	
       
   502 		}
       
   503 	aSettings.SetClass2Folder(1);
       
   504 	if(aSettings.Class2Folder() != 1)
       
   505 		{
       
   506 		return EFalse;
       
   507 		}
       
   508 	iTestStep.INFO_PRINTF1(_L("Test Class2Folder Passed"));	
       
   509 
       
   510 	// Description length
       
   511 	if(aSettings.DescriptionLength() != KSmsDescriptionLength)
       
   512 		{
       
   513 		return EFalse;
       
   514 		}
       
   515 	aSettings.SetDescriptionLength(100);
       
   516 	if(aSettings.DescriptionLength() != 100)
       
   517 		{
       
   518 		return EFalse;
       
   519 		}
       
   520 	iTestStep.INFO_PRINTF1(_L("Test DescriptionLength Passed"));	
       
   521 	
       
   522 	return ETrue;
       
   523 	}
       
   524 
       
   525 TBool CSmutTest::TestMessageSettingsMembersL(CSmsMessageSettings& aSettings)
       
   526 	{
       
   527 
       
   528 	// Reject Duplicate 
       
   529 	aSettings.SetRejectDuplicate(ETrue);
       
   530 	if(!aSettings.RejectDuplicate())
       
   531 		{
       
   532 		return EFalse;	
       
   533 		}
       
   534 	aSettings.SetRejectDuplicate(EFalse);
       
   535 	if(aSettings.RejectDuplicate())
       
   536 		{
       
   537 		return EFalse;	
       
   538 		}
       
   539 	
       
   540 	iTestStep.INFO_PRINTF1(_L("Test Reject Duplicate Passed"));
       
   541 
       
   542 	// Delivery Report
       
   543 	aSettings.SetDeliveryReport(ETrue);
       
   544 	if(!aSettings.DeliveryReport())
       
   545 		{
       
   546 		return EFalse;	
       
   547 		}
       
   548 	aSettings.SetDeliveryReport(EFalse);
       
   549 	if(aSettings.DeliveryReport())
       
   550 		{
       
   551 		return EFalse;	
       
   552 		}
       
   553 	iTestStep.INFO_PRINTF1(_L("Test Delivery Report Passed"));
       
   554 
       
   555 	// Reply Path
       
   556 	aSettings.SetReplyPath(EFalse);
       
   557 	if(aSettings.ReplyPath()!=EFalse)
       
   558 		{
       
   559 		return EFalse;	
       
   560 		}
       
   561 	aSettings.SetReplyPath(ETrue);
       
   562 	if(!aSettings.ReplyPath())
       
   563 		{
       
   564 		return EFalse;	
       
   565 		}
       
   566 	iTestStep.INFO_PRINTF1(_L("Test Reply Path Passed"));
       
   567 
       
   568 	// Validity period format
       
   569 	aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFNone);
       
   570 	if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFNone)
       
   571 		{
       
   572 		return EFalse;	
       
   573 		}
       
   574 	aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFEnhanced);
       
   575 	if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFEnhanced)
       
   576 		{
       
   577 		return EFalse;	
       
   578 		}
       
   579 	aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger);
       
   580 	if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFInteger)
       
   581 		{
       
   582 		return EFalse;	
       
   583 		}
       
   584 	aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet);
       
   585 	if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet)
       
   586 		{
       
   587 		return EFalse;	
       
   588 		}
       
   589 	iTestStep.INFO_PRINTF1(_L("Test Validity Period Format Passed"));
       
   590 
       
   591 	// Message Conversion (following conversions are supported)
       
   592 	aSettings.SetMessageConversion(ESmsConvFax);
       
   593 	if(aSettings.MessageConversion()!=ESmsConvFax)
       
   594 		{
       
   595 		return EFalse;	
       
   596 		}
       
   597 	aSettings.SetMessageConversion(ESmsConvX400);
       
   598 	if(aSettings.MessageConversion()!=ESmsConvX400)
       
   599 		{
       
   600 		return EFalse;	
       
   601 		}
       
   602 	aSettings.SetMessageConversion(ESmsConvPaging);
       
   603 	if(aSettings.MessageConversion()!=ESmsConvPaging)
       
   604 		{
       
   605 		return EFalse;	
       
   606 		}
       
   607 	aSettings.SetMessageConversion(ESmsConvMail);
       
   608 	if(aSettings.MessageConversion()!=ESmsConvMail)
       
   609 		{
       
   610 		return EFalse;	
       
   611 		}
       
   612 	aSettings.SetMessageConversion(ESmsConvErmes);
       
   613 	if(aSettings.MessageConversion()!=ESmsConvErmes)
       
   614 		{
       
   615 		return EFalse;	
       
   616 		}
       
   617 	aSettings.SetMessageConversion(ESmsConvSpeech);
       
   618 	if(aSettings.MessageConversion()!=ESmsConvSpeech)
       
   619 		{
       
   620 		return EFalse;	
       
   621 		}
       
   622 	aSettings.SetMessageConversion(ESmsConvPIDNone);
       
   623 	if(aSettings.MessageConversion()!=ESmsConvPIDNone)
       
   624 		{
       
   625 		return EFalse;	
       
   626 		}
       
   627 	iTestStep.INFO_PRINTF1(_L("Test Message Conversion Passed"));
       
   628 
       
   629 	// Validity Period	
       
   630 	aSettings.SetValidityPeriod(ESmsVPHour);
       
   631 	if(aSettings.ValidityPeriod().Int()!=ESmsVPHour)
       
   632 		{
       
   633 		return EFalse;	
       
   634 		}
       
   635 	aSettings.SetValidityPeriod(ESmsVPSixHours);
       
   636 	if(aSettings.ValidityPeriod().Int()!=ESmsVPSixHours)
       
   637 		{
       
   638 		return EFalse;	
       
   639 		}
       
   640 	aSettings.SetValidityPeriod(ESmsVP24Hours);
       
   641 	if(aSettings.ValidityPeriod().Int()!=ESmsVP24Hours)
       
   642 		{
       
   643 		return EFalse;	
       
   644 		}
       
   645 	aSettings.SetValidityPeriod(ESmsVPMaximum);
       
   646 	if(aSettings.ValidityPeriod().Int()!=ESmsVPMaximum)
       
   647 		{
       
   648 		return EFalse;	
       
   649 		}
       
   650 	aSettings.SetValidityPeriod(ESmsVPWeek);
       
   651 	if(aSettings.ValidityPeriod().Int()!=ESmsVPWeek)
       
   652 		{
       
   653 		return EFalse;	
       
   654 		}
       
   655 	iTestStep.INFO_PRINTF1(_L("Test Validity Period Passed"));
       
   656 
       
   657 	// Can Concatenate (write messages with more than 160 characters)
       
   658 	aSettings.SetCanConcatenate(ETrue);
       
   659 	if(!aSettings.CanConcatenate())
       
   660 		{
       
   661 		return EFalse;	
       
   662 		}
       
   663 	aSettings.SetCanConcatenate(EFalse);
       
   664 	if(aSettings.CanConcatenate()!=EFalse)
       
   665 		{
       
   666 		return EFalse;	
       
   667 		}
       
   668 	iTestStep.INFO_PRINTF1(_L("Test Can Concatenate Passed"));
       
   669 
       
   670 	// Character Set (following character sets are supported)
       
   671 	aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
       
   672 	if(aSettings.CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit)
       
   673 		{
       
   674 		return EFalse;	
       
   675 		}
       
   676 	aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2);
       
   677 	if(aSettings.CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabetUCS2)
       
   678 		{
       
   679 		return EFalse;	
       
   680 		}
       
   681 	aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
       
   682 	if(aSettings.CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet8Bit)
       
   683 		{
       
   684 		return EFalse;	
       
   685 		}
       
   686 	iTestStep.INFO_PRINTF1(_L("Test Character Set Passed"));
       
   687 	
       
   688 	return ETrue;
       
   689 	}
       
   690 
       
   691 TBool CSmutTest::CompareSettings(const CSmsSettings& aLeft, const CSmsSettings& aRight, TBool aTestSC)
       
   692 	{
       
   693 	TCompare compare(CompareMessageSettings(aLeft, aRight));
       
   694 
       
   695 	compare(aLeft.CommDbAction() == aRight.CommDbAction());
       
   696 	compare(aLeft.SmsBearerAction() == aRight.SmsBearerAction());
       
   697 	compare(aLeft.SmsBearer() == aRight.SmsBearer());
       
   698 	compare(aLeft.Delivery() == aRight.Delivery());
       
   699 	compare(CompareBools(aLeft.ReplyQuoted(), aRight.ReplyQuoted()));
       
   700 	compare(aLeft.SpecialMessageHandling() == aRight.SpecialMessageHandling());
       
   701 	compare(aLeft.StatusReportHandling() == aRight.StatusReportHandling());
       
   702 
       
   703 	if (aTestSC)
       
   704 		{
       
   705 		compare(aLeft.DefaultServiceCenter() == aRight.DefaultServiceCenter());
       
   706 		compare(aLeft.ServiceCenterCount() == aRight.ServiceCenterCount());
       
   707 
       
   708 		TInt count = aLeft.ServiceCenterCount();
       
   709 
       
   710 		while (count--)
       
   711 			{
       
   712 			compare(CompareServiceCenters(aLeft.GetServiceCenter(count), aRight.GetServiceCenter(count)));
       
   713 			}
       
   714 		}		
       
   715 
       
   716 	compare(aLeft.Class2Folder() == aRight.Class2Folder());
       
   717 	compare(aLeft.DescriptionLength() == aRight.DescriptionLength());
       
   718 
       
   719 	return compare;
       
   720 	}
       
   721 
       
   722 TBool CSmutTest::CompareMessageSettings(const CSmsMessageSettings& aLeft, const CSmsMessageSettings& aRight)
       
   723 	{
       
   724 	TCompare compare(CompareBools(aLeft.CanConcatenate(), aRight.CanConcatenate()));
       
   725 	compare(aLeft.CharacterSet() == aRight.CharacterSet());
       
   726 	compare(CompareBools(aLeft.DeliveryReport(), aRight.DeliveryReport()));
       
   727 	compare(aLeft.MessageConversion() == aRight.MessageConversion());
       
   728 	compare(CompareBools(aLeft.RejectDuplicate(), aRight.RejectDuplicate()));
       
   729 	compare(CompareBools(aLeft.ReplyPath(), aRight.ReplyPath()));
       
   730 	compare(aLeft.ValidityPeriod() == aRight.ValidityPeriod());
       
   731 	compare(aLeft.ValidityPeriodFormat() == aRight.ValidityPeriodFormat());
       
   732 	return compare;
       
   733 	}
       
   734 
       
   735 void CSmutTest::TestSettingsRestoreDefectL()
       
   736 	{
       
   737 	//Test fix for defects EDNAALR-4KTKTD (CSmsSettings::RestoreL() should leave if stream not present)
       
   738 	//and EDNAALR-4KTKLP (CSmsSettings::InternalizeL() causes memory leak)
       
   739 
       
   740 	CSmsSettings* settings = CSmsSettings::NewLC();
       
   741 
       
   742 	//Test defect fix for EDNAALR-4KTKTD (CSmsSettings::RestoreL() should leave if stream not present)
       
   743 	const TMsvId id = iSmsTest.CreateDummyMessageToSendL();
       
   744 	Session().CleanupEntryPushL(id);
       
   745 	iSmsTest.SetEntryL(id);
       
   746 
       
   747 	iTestStep.INFO_PRINTF1(_L("TestSettingsRestoreDefectL Created dummy message"));
       
   748 
       
   749 	TRAPD(err, RestoreSettingsL(*settings));
       
   750 
       
   751 	iTestStep.INFO_PRINTF2(_L("TestSettingsRestoreDefectL RestoreL 1 with error %d"), err);
       
   752 	iTestStep.INFO_PRINTF2(_L("Expected %d"), KErrNotFound);
       
   753 	iSmsTest(err == KErrNotFound);
       
   754 
       
   755 	//Test defect fix for EDNAALR-4KTKLP (CSmsSettings::InternalizeL() causes memory leak)
       
   756 	//	iSmsTest.SetEntryL(id);
       
   757 	StoreSettingsL(*settings);
       
   758 
       
   759 	iTestStep.INFO_PRINTF1(_L("TestSettingsRestoreDefectL StoreL 1"));
       
   760 
       
   761 	settings->AddServiceCenterL(_L("Unknown"), _L("447785016005"));
       
   762 
       
   763 	RestoreSettingsL(*settings);
       
   764 
       
   765 	Session().CleanupEntryPop();
       
   766 	Session().RemoveEntry(id);
       
   767 
       
   768 	CleanupStack::PopAndDestroy(settings);
       
   769 	iTestStep.INFO_PRINTF1(_L("TestSettingsRestoreDefectL RestoreL 2"));
       
   770 	}
       
   771 
       
   772 
       
   773 TBool CSmutTest::TestSettingsStoreToCommDbL()
       
   774 	{
       
   775 	iTestStep.INFO_PRINTF1(_L("Test Store Settings to CommDb"));
       
   776 	
       
   777 	CSmsSettings* settings1 = CSmsSettings::NewLC();
       
   778 	CSmsSettings* settings2 = CSmsSettings::NewLC();
       
   779 
       
   780 	if(!CompareSettings(*settings1, *settings2))
       
   781 		{
       
   782 		CleanupStack::PopAndDestroy(2,settings1);
       
   783 		return EFalse;	
       
   784 		}
       
   785 
       
   786 	settings1->SetCommDbAction(CSmsSettings::EStoreToCommDb);
       
   787 	settings1->AddServiceCenterL(_L("Vodafone"), _L("+447785016005"));
       
   788 	settings1->SetDeliveryReport(ETrue);
       
   789 	settings1->SetValidityPeriod(1000);
       
   790 
       
   791 	iSmsTest.SetEntryL(iSmsTest.iSmsServiceId);
       
   792 
       
   793 	StoreSettingsL(*settings1);
       
   794 	iTestStep.INFO_PRINTF1(_L("\tNew Settings..."));
       
   795 	if(!CompareSettingsAndCommDbL(*settings1))
       
   796 		{
       
   797 		CleanupStack::PopAndDestroy(2,settings1);
       
   798 		return EFalse;	
       
   799 		}
       
   800 
       
   801 	settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+3854354433"));
       
   802 
       
   803 	StoreSettingsL(*settings1);
       
   804 	iTestStep.INFO_PRINTF1(_L("\tSC Address Changed..."));
       
   805 	if(!CompareSettingsAndCommDbL(*settings1))
       
   806 		{
       
   807 		CleanupStack::PopAndDestroy(2,settings1);
       
   808 		return EFalse;	
       
   809 		}
       
   810 	
       
   811 	settings1->SetDeliveryReport(EFalse);
       
   812 
       
   813 	StoreSettingsL(*settings1);
       
   814 	iTestStep.INFO_PRINTF1(_L("\tDelivery Report Changed..."));
       
   815 	if(!CompareSettingsAndCommDbL(*settings1))
       
   816 		{
       
   817 		CleanupStack::PopAndDestroy(2,settings1);
       
   818 		return EFalse;	
       
   819 		}
       
   820 
       
   821 	settings1->SetValidityPeriod(2000);
       
   822 
       
   823 	StoreSettingsL(*settings1);
       
   824 	iTestStep.INFO_PRINTF1(_L("\tValidity Period Changed..."));
       
   825 	if(!CompareSettingsAndCommDbL(*settings1))
       
   826 		{
       
   827 		CleanupStack::PopAndDestroy(2,settings1);
       
   828 		return EFalse;	
       
   829 		}
       
   830 
       
   831 	settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+48996655888"));
       
   832 	settings1->SetDeliveryReport(ETrue);
       
   833 	settings1->SetValidityPeriod(3000);
       
   834 
       
   835 	StoreSettingsL(*settings1);
       
   836 	iTestStep.INFO_PRINTF1(_L("\tAll Settings Changed..."));
       
   837 	if(!CompareSettingsAndCommDbL(*settings1))
       
   838 		{
       
   839 		CleanupStack::PopAndDestroy(2,settings1);
       
   840 		return EFalse;	
       
   841 		}
       
   842 
       
   843 	settings1->AddServiceCenterL(_L("Radio"), _L("+385669988"));
       
   844 	settings1->SetDefaultServiceCenter(settings1->ServiceCenterCount()-1);
       
   845 
       
   846 	StoreSettingsL(*settings1);
       
   847 	iTestStep.INFO_PRINTF1(_L("\tDefaultSC Changed..."));
       
   848 	if(!CompareSettingsAndCommDbL(*settings1))
       
   849 		{
       
   850 		CleanupStack::PopAndDestroy(2,settings1);
       
   851 		return EFalse;	
       
   852 		}
       
   853 
       
   854 	settings1->SetCommDbAction(CSmsSettings::ENone);
       
   855 	settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+123456789"));
       
   856 	settings1->SetDeliveryReport(EFalse);
       
   857 	settings1->SetValidityPeriod(4000);
       
   858 
       
   859 	iTestStep.INFO_PRINTF1(_L("\tTesting Setting Different from CommDb..."));
       
   860 	if(CompareSettingsAndCommDbL(*settings1))
       
   861 		{
       
   862 		CleanupStack::PopAndDestroy(2,settings1);
       
   863 		return EFalse;	
       
   864 		}
       
   865 
       
   866 	TInt count = settings1->ServiceCenterCount();
       
   867 
       
   868 	while (count--)
       
   869 		{
       
   870 		settings1->RemoveServiceCenter(count);
       
   871 		}
       
   872 
       
   873 	iTestStep.INFO_PRINTF1(_L("\tTesting Setting Different from CommDb..."));
       
   874 	if(CompareSettingsAndCommDbL(*settings1))
       
   875 		{
       
   876 		CleanupStack::PopAndDestroy(2,settings1);
       
   877 		return EFalse;	
       
   878 		}
       
   879 
       
   880 	iTestStep.INFO_PRINTF1(_L("\tRestore settings from store..."));
       
   881 	RestoreSettingsL(*settings2);
       
   882 	if(!CompareSettingsAndCommDbL(*settings2))
       
   883 		{
       
   884 		CleanupStack::PopAndDestroy(2,settings1);
       
   885 		return EFalse;	
       
   886 		}
       
   887 
       
   888 	//Test SMS Bearer
       
   889 
       
   890 	iTestStep.INFO_PRINTF1(_L("\tTest Store SMS Bearer..."));
       
   891 
       
   892 	//Test 1
       
   893 
       
   894 	settings1->SetSmsBearerAction(CSmsSettings::EStoreToCommDb);
       
   895 	settings1->SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly);
       
   896 
       
   897 	StoreSettingsL(*settings1);
       
   898 	if(!CompareSettingsAndSmsBearerL(*settings1))
       
   899 		{
       
   900 		CleanupStack::PopAndDestroy(2,settings1);
       
   901 		return EFalse;	
       
   902 		}
       
   903 	
       
   904 	//Test 2
       
   905 
       
   906 	settings1->SetSmsBearer(CSmsSettings::ESmsBearerCircuitOnly);
       
   907 	if(CompareSettingsAndSmsBearerL(*settings1))
       
   908 		{
       
   909 		CleanupStack::PopAndDestroy(2,settings1);
       
   910 		return EFalse;	
       
   911 		}
       
   912 
       
   913 	//Test 3
       
   914 
       
   915 	StoreSettingsL(*settings1);
       
   916 	if(!CompareSettingsAndSmsBearerL(*settings1))
       
   917 		{
       
   918 		CleanupStack::PopAndDestroy(2,settings1);
       
   919 		return EFalse;	
       
   920 		}
       
   921 
       
   922 	RestoreSettingsL(*settings2);
       
   923 	if(!CompareSettingsAndSmsBearerL(*settings2))
       
   924 		{
       
   925 		return EFalse;	
       
   926 		}
       
   927 
       
   928 	//Test 4
       
   929 
       
   930 	settings1->SetSmsBearerAction(CSmsSettings::ENone);
       
   931 	StoreSettingsL(*settings1);
       
   932 	if(!CompareSettingsAndSmsBearerL(*settings1))
       
   933 		{
       
   934 		CleanupStack::PopAndDestroy(2,settings1);
       
   935 		return EFalse;	
       
   936 		}
       
   937 
       
   938 	//Test 5
       
   939 
       
   940 	settings1->SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred);
       
   941 	if(CompareSettingsAndSmsBearerL(*settings1))
       
   942 		{
       
   943 		CleanupStack::PopAndDestroy(2,settings1);
       
   944 		return EFalse;	
       
   945 		}
       
   946 	StoreSettingsL(*settings1);
       
   947 	if(CompareSettingsAndSmsBearerL(*settings1))
       
   948 		{
       
   949 		CleanupStack::PopAndDestroy(2,settings1);
       
   950 		return EFalse;	
       
   951 		}
       
   952 
       
   953 	CleanupStack::PopAndDestroy(2,settings1); // settings2
       
   954 	
       
   955 	return ETrue;
       
   956 	}
       
   957 
       
   958 TBool CSmutTest::CompareSettingsAndCommDbL(const CSmsSettings& aSettings) const
       
   959 	{
       
   960 	TCompare compare = ETrue;
       
   961 	TBuf<256> scAddress;
       
   962 	CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord);
       
   963 	globalSettingsRecord.LoadL(*iDBSession);
       
   964 	CCDModemBearerRecord *modemBearerRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
       
   965 	CleanupStack::PushL(modemBearerRecord);
       
   966 	modemBearerRecord->SetRecordId(((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iModemForPhoneServicesAndSMS); 
       
   967 	modemBearerRecord->LoadL(*iDBSession);
       
   968 	scAddress = modemBearerRecord->iMessageCentreNumber;
       
   969 
       
   970 	if (aSettings.DefaultServiceCenter() < 0 || !aSettings.ServiceCenterCount())
       
   971 		{
       
   972 		compare(!scAddress.Length());
       
   973 		}
       
   974 	else
       
   975 		{
       
   976 		compare(scAddress == aSettings.GetServiceCenter(aSettings.DefaultServiceCenter()).Address());
       
   977 		}
       
   978 	
       
   979 	TUint32 valPeriod = 0;
       
   980 	valPeriod = modemBearerRecord->iMessageValidityPeriod;
       
   981 	compare(valPeriod == (TUint32) aSettings.ValidityPeriod().Int());
       
   982 	
       
   983 	TBool delReport = EFalse;
       
   984 	delReport = modemBearerRecord->iMessageDeliveryReport;
       
   985 	compare(delReport ? aSettings.DeliveryReport() : !aSettings.DeliveryReport());
       
   986 
       
   987 	CleanupStack::PopAndDestroy(modemBearerRecord);	
       
   988 
       
   989 	return compare;
       
   990 	}
       
   991 
       
   992 TBool CSmutTest::CompareSettingsAndSmsBearerL(const CSmsSettings& aSettings) const
       
   993 	{
       
   994 	TUint32 smsBearer=0;
       
   995 	CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord);
       
   996 	TRAPD(err, globalSettingsRecord.LoadL(*iDBSession));
       
   997 	if(err == KErrNone)
       
   998 		{
       
   999 		smsBearer = ((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer;		
       
  1000 		}	
       
  1001 	TCompare compare(smsBearer == (TUint32) aSettings.SmsBearer());
       
  1002 	return compare;
       
  1003 	}
       
  1004 
       
  1005 void CSmutTest::StoreNumberL(const CSmsNumber& aNumber, TUid aStreamId)
       
  1006 	{
       
  1007 	CMsvStore* store = iSmsTest.EditStoreL(); // lets edit the entry
       
  1008 	CleanupStack::PushL(store);
       
  1009 
       
  1010 	RMsvWriteStream out;
       
  1011 	out.AssignLC(*store, aStreamId);		// file stream id ok?
       
  1012 	aNumber.ExternalizeL(out);				// lets extrenalise the instance
       
  1013 	out.CommitL();
       
  1014 	store->CommitL();
       
  1015 
       
  1016 	CleanupStack::PopAndDestroy(2, store);
       
  1017 	}
       
  1018 
       
  1019 void CSmutTest::RestoreNumberL(CSmsNumber& rNumber, TUid aStreamId)
       
  1020 	{
       
  1021 	CMsvStore* store = iSmsTest.ReadStoreL(); // prepare the store for reading
       
  1022 	CleanupStack::PushL(store);
       
  1023 
       
  1024 	RMsvReadStream in;
       
  1025 	in.OpenLC(*store, aStreamId);		// lets open the store for 
       
  1026 	rNumber.InternalizeL(in);				// internalising the address/name
       
  1027 
       
  1028 	CleanupStack::PopAndDestroy(2, store);
       
  1029 	}
       
  1030 
       
  1031 void CSmutTest::StoreHeaderL(const CSmsHeader& aHeader)
       
  1032 	{
       
  1033 	CMsvStore* store = iSmsTest.EditStoreL();
       
  1034 	CleanupStack::PushL(store);
       
  1035 
       
  1036 	aHeader.StoreL(*store);
       
  1037 	store->CommitL();
       
  1038 
       
  1039 	CleanupStack::PopAndDestroy(store);
       
  1040 	}
       
  1041 
       
  1042 void CSmutTest::RestoreHeaderL(CSmsHeader& aHeader)
       
  1043 	{
       
  1044 	CMsvStore* store = iSmsTest.ReadStoreL();
       
  1045 	CleanupStack::PushL(store);
       
  1046 
       
  1047 	aHeader.RestoreL(*store);
       
  1048 
       
  1049 	CleanupStack::PopAndDestroy(store);
       
  1050 	}
       
  1051 
       
  1052 void CSmutTest::StoreSettingsL(const CSmsSettings& aSettings)
       
  1053 	{
       
  1054 	CSmsAccount* account = CSmsAccount::NewLC();
       
  1055 	account->SaveSettingsL(aSettings);
       
  1056 	CleanupStack::PopAndDestroy(account);    
       
  1057 	}
       
  1058 
       
  1059 void CSmutTest::RestoreSettingsL(CSmsSettings& aSettings)
       
  1060 	{
       
  1061 	CSmsAccount* account = CSmsAccount::NewLC();
       
  1062 	account->LoadSettingsL(aSettings);
       
  1063 	CleanupStack::PopAndDestroy(account);    
       
  1064 	}
       
  1065 
       
  1066 TBool CSmutTest::CompareServiceCenters(const CSmsServiceCenter& aLeft, const CSmsServiceCenter& aRight)
       
  1067 	{
       
  1068 	TCompare compare(aLeft.Name() == aRight.Name());
       
  1069 	compare(aLeft.Address() == aRight.Address());
       
  1070 	return compare;	
       
  1071 	}
       
  1072 
       
  1073 TBool CSmutTest::CompareNumbers(const CSmsNumber& aLeft, const CSmsNumber& aRight)
       
  1074 	{
       
  1075 	TCompare compare(aLeft.Name() == aRight.Name());
       
  1076 	compare(aLeft.Address() == aRight.Address());
       
  1077 	compare(aLeft.LogId() == aRight.LogId());
       
  1078 	compare(aLeft.AckStatus(ESmsAckTypeDelivery) == aRight.AckStatus(ESmsAckTypeDelivery));	
       
  1079 	return compare;
       
  1080 	}
       
  1081 
       
  1082 TVerdict CSmutTest::TestNumberL()
       
  1083 	{
       
  1084 	iTestStep.INFO_PRINTF1(_L("Testing Preparing test CSmsNumber..."));
       
  1085 
       
  1086 	TMsvId id=iSmsTest.CreateDummyMessageToSendL();
       
  1087 	Session().CleanupEntryPushL(id);
       
  1088 	iSmsTest.SetEntryL(id);
       
  1089 
       
  1090 	CSmsNumber* number0=CSmsNumber::NewL();  
       
  1091 	CleanupStack::PushL(number0);
       
  1092 
       
  1093 	CSmsNumber* number=CSmsNumber::NewL();  // create the instance
       
  1094 	CleanupStack::PushL(number);
       
  1095 
       
  1096 	// Testing the features of CSmsNumber
       
  1097 	// The max length for a name is 256 characters
       
  1098 	// The max length for a number is 20 characters
       
  1099 
       
  1100 // Lets take an ordinary number, test it, then store and restore it
       
  1101 // and see if the values are still ok.
       
  1102 
       
  1103 	number->SetNameL(_L("Radiolinja1"));	
       
  1104 	number->SetAddressL(_L("+358508771010")); 
       
  1105 	number->SetLogId(KLogID1);	
       
  1106 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful);
       
  1107 
       
  1108 	if(number->Name()!=_L("Radiolinja1")) // name ok?
       
  1109 		{
       
  1110 		CleanupStack::PopAndDestroy(2, number0);
       
  1111 		Session().CleanupEntryPop();
       
  1112 		Session().RemoveEntry(id);
       
  1113 		return EFail;	
       
  1114 		}
       
  1115 	if(number->Address()!=_L("+358508771010")) // number ok?
       
  1116 		{
       
  1117 		CleanupStack::PopAndDestroy(2, number0);
       
  1118 		Session().CleanupEntryPop();
       
  1119 		Session().RemoveEntry(id);
       
  1120 		return EFail;	
       
  1121 		}
       
  1122 	if(number->LogId() != KLogID1)
       
  1123 		{
       
  1124 		CleanupStack::PopAndDestroy(2, number0);
       
  1125 		Session().CleanupEntryPop();
       
  1126 		Session().RemoveEntry(id);
       
  1127 		return EFail;	
       
  1128 		}
       
  1129 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckSuccessful)
       
  1130 		{
       
  1131 		CleanupStack::PopAndDestroy(2, number0);
       
  1132 		Session().CleanupEntryPop();
       
  1133 		Session().RemoveEntry(id);
       
  1134 		return EFail;	
       
  1135 		}
       
  1136 
       
  1137 	StoreNumberL(*number);
       
  1138 	RestoreNumberL(*number0);
       
  1139 	if(!CompareNumbers(*number0, *number))
       
  1140 		{
       
  1141 		CleanupStack::PopAndDestroy(2, number0);
       
  1142 		Session().CleanupEntryPop();
       
  1143 		Session().RemoveEntry(id);
       
  1144 		return EFail;
       
  1145 		}
       
  1146 	
       
  1147 // Lets try the max length of the telephone address, store and
       
  1148 // restore it and see if it works
       
  1149 
       
  1150 	number->SetNameL(_L("Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?"));
       
  1151 	number->SetAddressL(_L("+0123456789012345678"));
       
  1152 	number->SetLogId(KLogID2);	
       
  1153 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckError);
       
  1154 
       
  1155 	if(number->Name()!=_L("Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?"))
       
  1156 		{
       
  1157 		CleanupStack::PopAndDestroy(2, number0);
       
  1158 		Session().CleanupEntryPop();
       
  1159 		Session().RemoveEntry(id);
       
  1160 		return EFail;	
       
  1161 		}
       
  1162 	if(number->Address()!=_L("+0123456789012345678"))
       
  1163 		{
       
  1164 		CleanupStack::PopAndDestroy(2, number0);
       
  1165 		Session().CleanupEntryPop();
       
  1166 		Session().RemoveEntry(id);
       
  1167 		return EFail;	
       
  1168 		}
       
  1169 	if(number->LogId() != KLogID2)
       
  1170 		{
       
  1171 		CleanupStack::PopAndDestroy(2, number0);
       
  1172 		Session().CleanupEntryPop();
       
  1173 		Session().RemoveEntry(id);
       
  1174 		return EFail;	
       
  1175 		}
       
  1176 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckError)
       
  1177 		{
       
  1178 		CleanupStack::PopAndDestroy(2, number0);
       
  1179 		Session().CleanupEntryPop();
       
  1180 		Session().RemoveEntry(id);
       
  1181 		return EFail;	
       
  1182 		}
       
  1183 
       
  1184 	StoreNumberL(*number);
       
  1185 	RestoreNumberL(*number0);
       
  1186 	if(!CompareNumbers(*number, *number0))
       
  1187 		{
       
  1188 		CleanupStack::PopAndDestroy(2, number0);
       
  1189 		Session().CleanupEntryPop();
       
  1190 		Session().RemoveEntry(id);
       
  1191 		return EFail;	
       
  1192 		}
       
  1193 // Lets use special Scandinavian letters both in the name and
       
  1194 // address, store and restore and see if they are ok
       
  1195 	number->SetNameL(_L("ÖÄÅåöä"));
       
  1196 	number->SetAddressL(_L("åäöÅÄÖ"));
       
  1197 	number->SetLogId(KLogID1);	
       
  1198 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful);
       
  1199 
       
  1200 	if(number->Name()!=_L("ÖÄÅåöä"))
       
  1201 		{
       
  1202 		CleanupStack::PopAndDestroy(2, number0);
       
  1203 		Session().CleanupEntryPop();
       
  1204 		Session().RemoveEntry(id);
       
  1205 		return EFail;	
       
  1206 		}
       
  1207 	if(number->Address()!=_L("åäöÅÄÖ"))
       
  1208 		{
       
  1209 		CleanupStack::PopAndDestroy(2, number0);
       
  1210 		Session().CleanupEntryPop();
       
  1211 		Session().RemoveEntry(id);
       
  1212 		return EFail;	
       
  1213 		}
       
  1214 	if(number->LogId() != KLogID1)
       
  1215 		{
       
  1216 		CleanupStack::PopAndDestroy(2, number0);
       
  1217 		Session().CleanupEntryPop();
       
  1218 		Session().RemoveEntry(id);
       
  1219 		return EFail;
       
  1220 		}
       
  1221 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckSuccessful)
       
  1222 		{
       
  1223 		CleanupStack::PopAndDestroy(2, number0);
       
  1224 		Session().CleanupEntryPop();
       
  1225 		Session().RemoveEntry(id);
       
  1226 		return EFail;	
       
  1227 		}
       
  1228 
       
  1229 	StoreNumberL(*number);
       
  1230 	RestoreNumberL(*number0);
       
  1231 	iSmsTest(CompareNumbers(*number, *number0));
       
  1232 
       
  1233 //  Lets try if both the number and the name can be empty,
       
  1234 //	store and restore it and see if they still match
       
  1235 	number->SetNameL(_L(""));
       
  1236 	number->SetAddressL(_L(""));
       
  1237 	number->SetLogId(KLogID2);	
       
  1238 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckError);
       
  1239 
       
  1240 	if(number->Name()!=_L(""))
       
  1241 		{
       
  1242 		CleanupStack::PopAndDestroy(2, number0);
       
  1243 		Session().CleanupEntryPop();
       
  1244 		Session().RemoveEntry(id);
       
  1245 		return EFail;
       
  1246 		}
       
  1247 	if(number->Address()!=_L(""))
       
  1248 		{
       
  1249 		CleanupStack::PopAndDestroy(2, number0);
       
  1250 		Session().CleanupEntryPop();
       
  1251 		Session().RemoveEntry(id);
       
  1252 		return EFail;	
       
  1253 		}
       
  1254 	if(number->LogId() != KLogID2)
       
  1255 		{
       
  1256 		CleanupStack::PopAndDestroy(2, number0);
       
  1257 		Session().CleanupEntryPop();
       
  1258 		Session().RemoveEntry(id);
       
  1259 		return EFail;	
       
  1260 		}
       
  1261 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckError)
       
  1262 		{
       
  1263 		CleanupStack::PopAndDestroy(2, number0);
       
  1264 		Session().CleanupEntryPop();
       
  1265 		Session().RemoveEntry(id);
       
  1266 		return EFail;
       
  1267 		}
       
  1268 
       
  1269 	StoreNumberL(*number);
       
  1270 	RestoreNumberL(*number0);
       
  1271 	if(!CompareNumbers(*number, *number0))
       
  1272 		{
       
  1273 		CleanupStack::PopAndDestroy(2, number0);
       
  1274 		Session().CleanupEntryPop();
       
  1275 		Session().RemoveEntry(id);
       
  1276 		return EFail;	
       
  1277 		}
       
  1278 
       
  1279 //  Lets try [alt+255] as both the name and number, store and	
       
  1280 //  restore it and see if it works
       
  1281 	number->SetNameL(_L(" ")); //alt+255
       
  1282 	number->SetAddressL(_L(" "));
       
  1283 	number->SetLogId(KLogID1);	
       
  1284 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful);
       
  1285 
       
  1286 	if(number->Name()!=_L(" "))
       
  1287 		{
       
  1288 		CleanupStack::PopAndDestroy(2, number0);
       
  1289 		Session().CleanupEntryPop();
       
  1290 		Session().RemoveEntry(id);
       
  1291 		return EFail;		
       
  1292 		}
       
  1293 	if(number->Address()!=_L(" "))
       
  1294 		{
       
  1295 		CleanupStack::PopAndDestroy(2, number0);
       
  1296 		Session().CleanupEntryPop();
       
  1297 		Session().RemoveEntry(id);
       
  1298 		return EFail;		
       
  1299 		}
       
  1300 	if(number->LogId() != KLogID1)
       
  1301 		{
       
  1302 		CleanupStack::PopAndDestroy(2, number0);
       
  1303 		Session().CleanupEntryPop();
       
  1304 		Session().RemoveEntry(id);
       
  1305 		return EFail;		
       
  1306 		}
       
  1307 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckSuccessful)
       
  1308 		{
       
  1309 		CleanupStack::PopAndDestroy(2, number0);
       
  1310 		Session().CleanupEntryPop();
       
  1311 		Session().RemoveEntry(id);
       
  1312 		return EFail;		
       
  1313 		}
       
  1314 
       
  1315 	StoreNumberL(*number);
       
  1316 	RestoreNumberL(*number0);
       
  1317 	iSmsTest(CompareNumbers(*number, *number0));
       
  1318 
       
  1319 // Test CSmsNumber::CopyL()
       
  1320 
       
  1321 	number->SetNameL(_L("DavidCuando"));	
       
  1322 	number->SetAddressL(_L("+447747065627")); 
       
  1323 	number->SetLogId(KLogID3);	
       
  1324 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EPendingAck);
       
  1325 
       
  1326 	if(number->Name()!=_L("DavidCuando"))
       
  1327 		{
       
  1328 		CleanupStack::PopAndDestroy(2, number0);
       
  1329 		Session().CleanupEntryPop();
       
  1330 		Session().RemoveEntry(id);
       
  1331 		return EFail;	
       
  1332 		}
       
  1333 	if(number->Address()!=_L("+447747065627"))
       
  1334 		{
       
  1335 		CleanupStack::PopAndDestroy(2, number0);
       
  1336 		Session().CleanupEntryPop();
       
  1337 		Session().RemoveEntry(id);	
       
  1338 		return EFail;
       
  1339 		}
       
  1340 	if(number->LogId() != KLogID3)
       
  1341 		{
       
  1342 		CleanupStack::PopAndDestroy(2, number0);
       
  1343 		Session().CleanupEntryPop();
       
  1344 		Session().RemoveEntry(id);	
       
  1345 		return EFail;
       
  1346 		}
       
  1347 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EPendingAck)
       
  1348 		{
       
  1349 		CleanupStack::PopAndDestroy(2, number0);
       
  1350 		Session().CleanupEntryPop();
       
  1351 		Session().RemoveEntry(id);	
       
  1352 		return EFail;
       
  1353 		}
       
  1354 
       
  1355 	number0->CopyL(*number);
       
  1356 	if(!CompareNumbers(*number0, *number))
       
  1357 		{
       
  1358 		CleanupStack::PopAndDestroy(2, number0);
       
  1359 		Session().CleanupEntryPop();
       
  1360 		Session().RemoveEntry(id);	
       
  1361 		return EFail;
       
  1362 		}
       
  1363 
       
  1364 	CleanupStack::PopAndDestroy(2, number0);
       
  1365 
       
  1366 // Test NewL(CSmsNumber&)
       
  1367 
       
  1368 	number=CSmsNumber::NewL();  // create the instance
       
  1369 	CleanupStack::PushL(number);
       
  1370 
       
  1371 	number->SetNameL(_L("DavidCuando"));	
       
  1372 	number->SetAddressL(_L("+447747065627")); 
       
  1373 	number->SetLogId(KLogID3);	
       
  1374 	number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EPendingAck);
       
  1375 
       
  1376 	if(number->Name()!=_L("DavidCuando"))
       
  1377 		{
       
  1378 		CleanupStack::PopAndDestroy(number);
       
  1379 		Session().CleanupEntryPop();
       
  1380 		Session().RemoveEntry(id);
       
  1381 		return EFail;		
       
  1382 		}
       
  1383 	if(number->Address()!=_L("+447747065627"))
       
  1384 		{
       
  1385 		CleanupStack::PopAndDestroy(number);
       
  1386 		Session().CleanupEntryPop();
       
  1387 		Session().RemoveEntry(id);		
       
  1388 		return EFail;
       
  1389 		}
       
  1390 	if(number->LogId() != KLogID3)
       
  1391 		{
       
  1392 		CleanupStack::PopAndDestroy(number);
       
  1393 		Session().CleanupEntryPop();
       
  1394 		Session().RemoveEntry(id);		
       
  1395 		return EFail;
       
  1396 		}
       
  1397 	if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EPendingAck)
       
  1398 		{
       
  1399 		CleanupStack::PopAndDestroy(number);
       
  1400 		Session().CleanupEntryPop();
       
  1401 		Session().RemoveEntry(id);		
       
  1402 		return EFail;
       
  1403 		}
       
  1404 
       
  1405 	number0=CSmsNumber::NewL(*number);  
       
  1406 	CleanupStack::PushL(number0);
       
  1407 
       
  1408 	if(!CompareNumbers(*number0, *number))
       
  1409 		{
       
  1410 		CleanupStack::PopAndDestroy(2, number);
       
  1411 		Session().CleanupEntryPop();
       
  1412 		Session().RemoveEntry(id);
       
  1413 		return EFail;		
       
  1414 		}
       
  1415 	CleanupStack::PopAndDestroy(2, number);
       
  1416 
       
  1417 	//Test for defect EDNMOHN-4LDDK8
       
  1418 	number=CSmsNumber::NewL();  // create the instance
       
  1419 	CleanupStack::PushL(number);
       
  1420 
       
  1421 	StoreNumberL(*number);
       
  1422 	RestoreNumberL(*number);
       
  1423 
       
  1424 	number->SetAddressL(_L("+4477676545"));
       
  1425 	//End Test for defect  EDNMOHN-4LDDK8
       
  1426 
       
  1427 	CleanupStack::PopAndDestroy(number);
       
  1428 
       
  1429 	Session().CleanupEntryPop();
       
  1430 	Session().RemoveEntry(id);
       
  1431 	
       
  1432 	iTestStep.INFO_PRINTF1(_L("Test CSmsNumber Passed."));
       
  1433 	return EPass;
       
  1434 	}
       
  1435 	
       
  1436 void CSmutTest::StoreEmailFieldsL(const CSmsEmailFields& aEmailFields)
       
  1437 	{
       
  1438 	CMsvStore* store = iSmsTest.EditStoreL(); 
       
  1439 	CleanupStack::PushL(store);
       
  1440 
       
  1441 	aEmailFields.StoreL(*store);
       
  1442 	store->CommitL();
       
  1443 
       
  1444 	CleanupStack::PopAndDestroy(store);
       
  1445 	}
       
  1446 
       
  1447 void CSmutTest::RestoreEmailFieldsL(CSmsEmailFields& aEmailFields)
       
  1448 	{
       
  1449 	CMsvStore* store = iSmsTest.ReadStoreL(); // prepare the store for reading
       
  1450 	CleanupStack::PushL(store);
       
  1451 	
       
  1452 	aEmailFields.RestoreL(*store);
       
  1453 
       
  1454 	CleanupStack::PopAndDestroy(store);
       
  1455 	}
       
  1456 	
       
  1457 TBool CSmutTest::CompareEmailFields(const CSmsEmailFields& aFields1, const CSmsEmailFields& aFields2)
       
  1458 	{
       
  1459 	TBool same = CompareEmailFieldsAddresses(aFields1.Addresses(), aFields2.Addresses());
       
  1460 	if( same )
       
  1461 		same = (aFields2.Subject().Compare(aFields1.Subject()) == 0);
       
  1462 	if( same )
       
  1463 		same = (!aFields2.HasAddress()&&!aFields1.HasAddress() || aFields2.HasAddress()&&aFields1.HasAddress());
       
  1464 	if( same )
       
  1465 		same = (aFields2.Length() == aFields1.Length());
       
  1466 	return same;
       
  1467 	}
       
  1468 	
       
  1469 TBool CSmutTest::CompareEmailFieldsAddresses(const MDesCArray& aAddresses1, const MDesCArray& aAddresses2)
       
  1470 	{
       
  1471 	TBool same = (aAddresses1.MdcaCount() == aAddresses2.MdcaCount());
       
  1472 	if( same )
       
  1473 		{
       
  1474 		TInt count = aAddresses1.MdcaCount();
       
  1475 		while( same && count-- > 0)
       
  1476 			{
       
  1477 			same = (aAddresses2.MdcaPoint(count).Compare(aAddresses1.MdcaPoint(count)) == 0);
       
  1478 			}
       
  1479 		}		
       
  1480 	return same;
       
  1481 	}
       
  1482 	
       
  1483 TVerdict CSmutTest::TestEmailFieldsL()
       
  1484 	{
       
  1485 	iTestStep.INFO_PRINTF1(_L("Preparing test CSmsEmailFields..."));
       
  1486 
       
  1487 	TMsvId id=iSmsTest.CreateDummyMessageToSendL();
       
  1488 	Session().CleanupEntryPushL(id);
       
  1489 	iSmsTest.SetEntryL(id);
       
  1490 
       
  1491 	_LIT(KTestAddress, "support@symbian.com");
       
  1492 	_LIT(KTestSubject, "Happy Days!");
       
  1493 	
       
  1494 	// Test CSmsEmailFields::NewL()
       
  1495 	CSmsEmailFields* fields1 = CSmsEmailFields::NewL();
       
  1496 	CleanupStack::PushL(fields1);
       
  1497 	
       
  1498 	if(fields1->Addresses().MdcaCount()!=0)
       
  1499 		{
       
  1500 		CleanupStack::PopAndDestroy(fields1);
       
  1501 		Session().CleanupEntryPop();
       
  1502 		Session().RemoveEntry(id);
       
  1503 		return EFail;
       
  1504 		}
       
  1505 	if(fields1->Subject().Compare(KNullDesC()) != 0)
       
  1506 		{
       
  1507 		CleanupStack::PopAndDestroy(fields1);
       
  1508 		Session().CleanupEntryPop();
       
  1509 		Session().RemoveEntry(id);
       
  1510 		return EFail;	
       
  1511 		}
       
  1512 	if(fields1->HasAddress())
       
  1513 		{
       
  1514 		CleanupStack::PopAndDestroy(fields1);
       
  1515 		Session().CleanupEntryPop();
       
  1516 		Session().RemoveEntry(id);
       
  1517 		return EFail;	
       
  1518 		}
       
  1519 	if(fields1->Length() != 0)
       
  1520 		{
       
  1521 		CleanupStack::PopAndDestroy(fields1);
       
  1522 		Session().CleanupEntryPop();
       
  1523 		Session().RemoveEntry(id);
       
  1524 		return EFail;	
       
  1525 		}
       
  1526 	
       
  1527 	// Test address and subject accessors, has-address, length and reset methods
       
  1528 	fields1->AddAddressL(KNullDesC);	// empty address - does nothing!
       
  1529 	if(fields1->Addresses().MdcaCount()!=0)
       
  1530 		{
       
  1531 		CleanupStack::PopAndDestroy(fields1);
       
  1532 		Session().CleanupEntryPop();
       
  1533 		Session().RemoveEntry(id);
       
  1534 		return EFail;		
       
  1535 		}
       
  1536 	if(fields1->Subject().Compare(KNullDesC()) != 0)
       
  1537 		{
       
  1538 		CleanupStack::PopAndDestroy(fields1);
       
  1539 		Session().CleanupEntryPop();
       
  1540 		Session().RemoveEntry(id);
       
  1541 		return EFail;		
       
  1542 		}
       
  1543 	if(fields1->HasAddress())
       
  1544 		{
       
  1545 		CleanupStack::PopAndDestroy(fields1);
       
  1546 		Session().CleanupEntryPop();
       
  1547 		Session().RemoveEntry(id);
       
  1548 		return EFail;		
       
  1549 		}
       
  1550 	if(fields1->Length() != 0)
       
  1551 		{
       
  1552 		CleanupStack::PopAndDestroy(fields1);
       
  1553 		Session().CleanupEntryPop();
       
  1554 		Session().RemoveEntry(id);
       
  1555 		return EFail;		
       
  1556 		}
       
  1557 	
       
  1558 	fields1->AddAddressL(KTestAddress);
       
  1559 	if(fields1->Addresses().MdcaCount()!=1)
       
  1560 		{
       
  1561 		CleanupStack::PopAndDestroy(fields1);
       
  1562 		Session().CleanupEntryPop();
       
  1563 		Session().RemoveEntry(id);
       
  1564 		return EFail;	
       
  1565 		}
       
  1566 	if(fields1->Addresses().MdcaPoint(0).Compare(KTestAddress) != 0)
       
  1567 		{
       
  1568 		CleanupStack::PopAndDestroy(fields1);
       
  1569 		Session().CleanupEntryPop();
       
  1570 		Session().RemoveEntry(id);
       
  1571 		return EFail;	
       
  1572 		}
       
  1573 	if(!fields1->HasAddress())
       
  1574 		{
       
  1575 		CleanupStack::PopAndDestroy(fields1);
       
  1576 		Session().CleanupEntryPop();
       
  1577 		Session().RemoveEntry(id);
       
  1578 		return EFail;	
       
  1579 		}
       
  1580 	if(fields1->Length() != KTestAddress().Length() + 1)
       
  1581 		{
       
  1582 		CleanupStack::PopAndDestroy(fields1);
       
  1583 		Session().CleanupEntryPop();
       
  1584 		Session().RemoveEntry(id);
       
  1585 		return EFail;	
       
  1586 		}
       
  1587 
       
  1588 	fields1->SetSubjectL(KTestSubject);
       
  1589 	if(!fields1->HasAddress())
       
  1590 		{
       
  1591 		CleanupStack::PopAndDestroy(fields1);
       
  1592 		Session().CleanupEntryPop();
       
  1593 		Session().RemoveEntry(id);
       
  1594 		return EFail;	
       
  1595 		}
       
  1596 	if(fields1->Length() != KTestAddress().Length() + KTestSubject().Length() + 2)
       
  1597 		{
       
  1598 		CleanupStack::PopAndDestroy(fields1);
       
  1599 		Session().CleanupEntryPop();
       
  1600 		Session().RemoveEntry(id);
       
  1601 		return EFail;	
       
  1602 		}
       
  1603 	
       
  1604 	fields1->Reset();
       
  1605 	if(fields1->Addresses().MdcaCount()!=0)
       
  1606 		{
       
  1607 		CleanupStack::PopAndDestroy(fields1);
       
  1608 		Session().CleanupEntryPop();
       
  1609 		Session().RemoveEntry(id);
       
  1610 		return EFail;	
       
  1611 		}
       
  1612 	if(fields1->Subject().Compare(KNullDesC()) != 0)
       
  1613 		{
       
  1614 		CleanupStack::PopAndDestroy(fields1);
       
  1615 		Session().CleanupEntryPop();
       
  1616 		Session().RemoveEntry(id);
       
  1617 		return EFail;	
       
  1618 		}
       
  1619 	if(fields1->HasAddress())
       
  1620 		{
       
  1621 		CleanupStack::PopAndDestroy(fields1);
       
  1622 		Session().CleanupEntryPop();
       
  1623 		Session().RemoveEntry(id);
       
  1624 		return EFail;	
       
  1625 		}
       
  1626 	if(fields1->Length() != 0)
       
  1627 		{
       
  1628 		CleanupStack::PopAndDestroy(fields1);
       
  1629 		Session().CleanupEntryPop();
       
  1630 		Session().RemoveEntry(id);
       
  1631 		return EFail;	
       
  1632 		}
       
  1633 	
       
  1634 	fields1->SetSubjectL(KTestSubject);
       
  1635 	if(fields1->Subject().Compare(KTestSubject) != 0)
       
  1636 		{
       
  1637 		CleanupStack::PopAndDestroy(fields1);
       
  1638 		Session().CleanupEntryPop();
       
  1639 		Session().RemoveEntry(id);
       
  1640 		return EFail;	
       
  1641 		}
       
  1642 	if(fields1->HasAddress())
       
  1643 		{
       
  1644 		CleanupStack::PopAndDestroy(fields1);
       
  1645 		Session().CleanupEntryPop();
       
  1646 		Session().RemoveEntry(id);
       
  1647 		return EFail;	
       
  1648 		}
       
  1649 	if(fields1->Length() != KTestSubject().Length() + 2)
       
  1650 		{
       
  1651 		CleanupStack::PopAndDestroy(fields1);
       
  1652 		Session().CleanupEntryPop();
       
  1653 		Session().RemoveEntry(id);
       
  1654 		return EFail;	
       
  1655 		}
       
  1656 	
       
  1657 	fields1->AddAddressL(KTestAddress);
       
  1658 	if(fields1->Addresses().MdcaCount()!=1)
       
  1659 		{
       
  1660 		CleanupStack::PopAndDestroy(fields1);
       
  1661 		Session().CleanupEntryPop();
       
  1662 		Session().RemoveEntry(id);
       
  1663 		return EFail;		
       
  1664 		}
       
  1665 	if(fields1->Addresses().MdcaPoint(0).Compare(KTestAddress) != 0)
       
  1666 		{
       
  1667 		CleanupStack::PopAndDestroy(fields1);
       
  1668 		Session().CleanupEntryPop();
       
  1669 		Session().RemoveEntry(id);
       
  1670 		return EFail;		
       
  1671 		}
       
  1672 	if(!fields1->HasAddress())
       
  1673 		{
       
  1674 		CleanupStack::PopAndDestroy(fields1);
       
  1675 		Session().CleanupEntryPop();
       
  1676 		Session().RemoveEntry(id);
       
  1677 		return EFail;		
       
  1678 		}
       
  1679 	if(fields1->Length() != KTestAddress().Length() + KTestSubject().Length() + 2)
       
  1680 		{
       
  1681 		CleanupStack::PopAndDestroy(fields1);
       
  1682 		Session().CleanupEntryPop();
       
  1683 		Session().RemoveEntry(id);
       
  1684 		return EFail;		
       
  1685 		}
       
  1686 
       
  1687 	// Test multiple addresses - add empty address -> not added	
       
  1688 	fields1->AddAddressL(KNullDesC);
       
  1689 	if(fields1->Addresses().MdcaCount()!=1)
       
  1690 		{
       
  1691 		CleanupStack::PopAndDestroy(fields1);
       
  1692 		Session().CleanupEntryPop();
       
  1693 		Session().RemoveEntry(id);
       
  1694 		return EFail;		
       
  1695 		}
       
  1696 	
       
  1697 	_LIT(KTestAddress2, "support2@symbian.com");
       
  1698 	fields1->AddAddressL(KTestAddress2);
       
  1699 	if(fields1->Addresses().MdcaCount()!=2)
       
  1700 		{
       
  1701 		CleanupStack::PopAndDestroy(fields1);
       
  1702 		Session().CleanupEntryPop();
       
  1703 		Session().RemoveEntry(id);
       
  1704 		return EFail;		
       
  1705 		}
       
  1706 	if(fields1->Addresses().MdcaPoint(1).Compare(KTestAddress2) != 0)
       
  1707 		{
       
  1708 		CleanupStack::PopAndDestroy(fields1);
       
  1709 		Session().CleanupEntryPop();
       
  1710 		Session().RemoveEntry(id);
       
  1711 		return EFail;		
       
  1712 		}
       
  1713 	if(!fields1->HasAddress())
       
  1714 		{
       
  1715 		CleanupStack::PopAndDestroy(fields1);
       
  1716 		Session().CleanupEntryPop();
       
  1717 		Session().RemoveEntry(id);
       
  1718 		return EFail;		
       
  1719 		}
       
  1720 	// NOTE - length check; 3 -> 2 for subject delimiters, 1 for address comma separtor.
       
  1721 	if(fields1->Length() != KTestAddress().Length() + KTestAddress2().Length() + KTestSubject().Length() + 3)
       
  1722 		{
       
  1723 		CleanupStack::PopAndDestroy(fields1);
       
  1724 		Session().CleanupEntryPop();
       
  1725 		Session().RemoveEntry(id);
       
  1726 		return EFail;		
       
  1727 		}
       
  1728 	
       
  1729 	// Test copy factory c'tor
       
  1730 	CSmsEmailFields* fields2 = CSmsEmailFields::NewL(*fields1);
       
  1731 	CleanupStack::PushL(fields2);
       
  1732 
       
  1733 	if(!CompareEmailFields(*fields2, *fields1))
       
  1734 		{
       
  1735 		CleanupStack::PopAndDestroy(2,fields1);
       
  1736 		Session().CleanupEntryPop();
       
  1737 		Session().RemoveEntry(id);
       
  1738 		return EFail;	
       
  1739 		}
       
  1740 	
       
  1741 	// Test store and restore
       
  1742 	StoreEmailFieldsL(*fields1);
       
  1743 	fields2->Reset();
       
  1744 	RestoreEmailFieldsL(*fields2);
       
  1745 
       
  1746 	if(!CompareEmailFields(*fields2, *fields1))
       
  1747 		{
       
  1748 		CleanupStack::PopAndDestroy(2,fields1);
       
  1749 		Session().CleanupEntryPop();
       
  1750 		Session().RemoveEntry(id);
       
  1751 		return EFail;	
       
  1752 		}
       
  1753 	
       
  1754 	fields1->Reset();
       
  1755 	StoreEmailFieldsL(*fields1);
       
  1756 	RestoreEmailFieldsL(*fields2);
       
  1757 
       
  1758 	if(!CompareEmailFields(*fields2, *fields1))
       
  1759 		{
       
  1760 		CleanupStack::PopAndDestroy(2,fields1);
       
  1761 		Session().CleanupEntryPop();
       
  1762 		Session().RemoveEntry(id);
       
  1763 		return EFail;	
       
  1764 		}
       
  1765 	
       
  1766 	CleanupStack::PopAndDestroy(2, fields1);
       
  1767 	
       
  1768 	// Test parsing - expected data.
       
  1769 	_LIT(KTestBodyData, "Some body text#( )#");
       
  1770 
       
  1771 	_LIT(KTestParseAddress1, "user1@symbian.com");
       
  1772 	_LIT(KTestParseSubject1, "");
       
  1773 	_LIT(KTestEmail1, "user1@symbian.com Some body text#( )#");
       
  1774 	if(!TestEmailFieldsParsePassL(KTestEmail1, KTestParseAddress1, KTestParseSubject1, KTestBodyData))
       
  1775 		{
       
  1776 		Session().CleanupEntryPop();
       
  1777 		Session().RemoveEntry(id);
       
  1778 		return EFail;	
       
  1779 		}
       
  1780 
       
  1781 	_LIT(KTestParseFullAddress1, "Some User <user1@symbian.com>");
       
  1782 	_LIT(KTestEmail2, "Some User <user1@symbian.com> Some body text#( )#");
       
  1783 	if(!TestEmailFieldsParsePassL(KTestEmail2, KTestParseFullAddress1, KTestParseSubject1, KTestBodyData))
       
  1784 		{
       
  1785 		Session().CleanupEntryPop();
       
  1786 		Session().RemoveEntry(id);
       
  1787 		return EFail;	
       
  1788 		}
       
  1789 
       
  1790 	_LIT(KTestParseAddress2, "user2@symbian.com");
       
  1791 	_LIT(KTestParseSubject2, "subject (2)");
       
  1792 	_LIT(KTestEmail3, "user2@symbian.com##subject (2)#Some body text#( )#");
       
  1793 	if(!TestEmailFieldsParsePassL(KTestEmail3, KTestParseAddress2, KTestParseSubject2, KTestBodyData))
       
  1794 		{
       
  1795 		Session().CleanupEntryPop();
       
  1796 		Session().RemoveEntry(id);
       
  1797 		return EFail;	
       
  1798 		}
       
  1799 
       
  1800 	_LIT(KTestParseFullAddress2, "Some User <user2@symbian.com>");
       
  1801 	_LIT(KTestEmail4, "Some User <user2@symbian.com>##subject (2)#Some body text#( )#");
       
  1802 	if(!TestEmailFieldsParsePassL(KTestEmail4, KTestParseFullAddress2, KTestParseSubject2, KTestBodyData))
       
  1803 		{
       
  1804 		Session().CleanupEntryPop();
       
  1805 		Session().RemoveEntry(id);
       
  1806 		return EFail;
       
  1807 		}
       
  1808 
       
  1809 	_LIT(KTestParseAddress3, "user3@symbian.com");
       
  1810 	_LIT(KTestParseSubject3, "subject #3");
       
  1811 	_LIT(KTestEmail5, "user3@symbian.com(subject #3)Some body text#( )#");
       
  1812 	if(!TestEmailFieldsParsePassL(KTestEmail5, KTestParseAddress3, KTestParseSubject3, KTestBodyData))
       
  1813 		{
       
  1814 		Session().CleanupEntryPop();
       
  1815 		Session().RemoveEntry(id);
       
  1816 		return EFail;	
       
  1817 		}
       
  1818 
       
  1819 	_LIT(KTestParseFullAddress3, "Some User <user3@symbian.com>");
       
  1820 	_LIT(KTestEmail6, "Some User <user3@symbian.com>(subject #3)Some body text#( )#");
       
  1821 	if(!TestEmailFieldsParsePassL(KTestEmail6, KTestParseFullAddress3, KTestParseSubject3, KTestBodyData))
       
  1822 		{
       
  1823 		Session().CleanupEntryPop();
       
  1824 		Session().RemoveEntry(id);
       
  1825 		return EFail;
       
  1826 		}
       
  1827 	
       
  1828 	_LIT(KTestParseAddress4, "user4@symbian.com");
       
  1829 	_LIT(KTestParseSubject4, "");
       
  1830 	_LIT(KTestEmail7, "user4@symbian.com()Some body text#( )#");
       
  1831 	if(!TestEmailFieldsParsePassL(KTestEmail7, KTestParseAddress4, KTestParseSubject4, KTestBodyData))
       
  1832 		{
       
  1833 		Session().CleanupEntryPop();
       
  1834 		Session().RemoveEntry(id);
       
  1835 		return EFail;
       
  1836 		}
       
  1837 
       
  1838 	_LIT(KTestParseFullAddress4, "Some User <user4@symbian.com>");
       
  1839 	_LIT(KTestEmail8, "Some User <user4@symbian.com>()Some body text#( )#");
       
  1840 	if(!TestEmailFieldsParsePassL(KTestEmail8, KTestParseFullAddress4, KTestParseSubject4, KTestBodyData))
       
  1841 		{
       
  1842 		Session().CleanupEntryPop();
       
  1843 		Session().RemoveEntry(id);
       
  1844 		return EFail;	
       
  1845 		}
       
  1846 
       
  1847 	_LIT(KTestParseAddress5, "user5@symbian.com");
       
  1848 	_LIT(KTestParseSubject5, "");
       
  1849 	_LIT(KTestEmail9, "user5@symbian.com###Some body text#( )#");
       
  1850 	if(!TestEmailFieldsParsePassL(KTestEmail9, KTestParseAddress5, KTestParseSubject5, KTestBodyData))
       
  1851 		{
       
  1852 		Session().CleanupEntryPop();
       
  1853 		Session().RemoveEntry(id);
       
  1854 		return EFail;	
       
  1855 		}
       
  1856 
       
  1857 	_LIT(KTestParseFullAddress5, "Some User <user5@symbian.com>");
       
  1858 	_LIT(KTestEmail10, "Some User <user5@symbian.com>###Some body text#( )#");
       
  1859 	if(!TestEmailFieldsParsePassL(KTestEmail10, KTestParseFullAddress5, KTestParseSubject5, KTestBodyData))
       
  1860 		{
       
  1861 		Session().CleanupEntryPop();
       
  1862 		Session().RemoveEntry(id);
       
  1863 		return EFail;	
       
  1864 		}
       
  1865 
       
  1866 	// Test parsing - corrupt but parse-able data.
       
  1867 	_LIT(KTestCorruptAddress1,	"user1@symbian.com");
       
  1868 	_LIT(KTestCorruptSubject1,	"smiley ;");
       
  1869 	_LIT(KTestCorruptBody1,		" subject)Some body text");
       
  1870 	_LIT(KTestCorruptEmail1,	"user1@symbian.com(smiley ;) subject)Some body text");
       
  1871 	if(!TestEmailFieldsParsePassL(KTestCorruptEmail1, KTestCorruptAddress1, KTestCorruptSubject1, KTestCorruptBody1))
       
  1872 		{
       
  1873 		Session().CleanupEntryPop();
       
  1874 		Session().RemoveEntry(id);
       
  1875 		return EFail;	
       
  1876 		}
       
  1877 	
       
  1878 	_LIT(KTestCorruptAddress2,	"user1@symbian.com");
       
  1879 	_LIT(KTestCorruptSubject2,	"");
       
  1880 	_LIT(KTestCorruptBody2,		"(bad subject)Some body text");
       
  1881 	_LIT(KTestCorruptEmail2,	"user1@symbian.com (bad subject)Some body text");
       
  1882 	if(!TestEmailFieldsParsePassL(KTestCorruptEmail2, KTestCorruptAddress2, KTestCorruptSubject2, KTestCorruptBody2))
       
  1883 		{
       
  1884 		Session().CleanupEntryPop();
       
  1885 		Session().RemoveEntry(id);
       
  1886 		return EFail;	
       
  1887 		}
       
  1888 
       
  1889 	_LIT(KTestCorruptAddress3,	"user1@symbian.com");
       
  1890 	_LIT(KTestCorruptSubject3,	"");
       
  1891 	_LIT(KTestCorruptBody3,		"bad subject##Some body text");
       
  1892 	_LIT(KTestCorruptEmail3,	"user1@symbian.com###bad subject##Some body text");
       
  1893 	if(!TestEmailFieldsParsePassL(KTestCorruptEmail3, KTestCorruptAddress3, KTestCorruptSubject3, KTestCorruptBody3))
       
  1894 		{
       
  1895 		Session().CleanupEntryPop();
       
  1896 		Session().RemoveEntry(id);
       
  1897 		return EFail;	
       
  1898 		}
       
  1899 	
       
  1900 	// Test parsing - corrupt and fail.
       
  1901 	_LIT(KTestFailEmail1,	"user#domain1.domain2 Some body text");
       
  1902 	if(!TestEmailFieldsParseFailL(KTestFailEmail1))
       
  1903 		{
       
  1904 		Session().CleanupEntryPop();
       
  1905 		Session().RemoveEntry(id);
       
  1906 		return EFail;	
       
  1907 		}
       
  1908 	
       
  1909 	_LIT(KTestFailEmail2,	"user@domain1.domain2+Some+body+text");
       
  1910 	if(!TestEmailFieldsParseFailL(KTestFailEmail2))
       
  1911 		{
       
  1912 		Session().CleanupEntryPop();
       
  1913 		Session().RemoveEntry(id);
       
  1914 		return EFail;	
       
  1915 		}
       
  1916 
       
  1917 	_LIT(KTestFailEmail3,	"user@domain1.domain2##(subject)Some+body+text");
       
  1918 	if(!TestEmailFieldsParseFailL(KTestFailEmail3))
       
  1919 		{
       
  1920 		Session().CleanupEntryPop();
       
  1921 		Session().RemoveEntry(id);
       
  1922 		return EFail;
       
  1923 		}
       
  1924 
       
  1925 	_LIT(KTestFailEmail4,	"user@domain1.domain2(##subject#Some+body+text");
       
  1926 	if(!TestEmailFieldsParseFailL(KTestFailEmail4))
       
  1927 		{
       
  1928 		Session().CleanupEntryPop();
       
  1929 		Session().RemoveEntry(id);
       
  1930 		return EFail;	
       
  1931 		}
       
  1932 
       
  1933 	_LIT(KTestFailEmail5,	"user1@symbian.com#bad subject#Some body text");
       
  1934 	if(!TestEmailFieldsParseFailL(KTestFailEmail5))
       
  1935 		{
       
  1936 		Session().CleanupEntryPop();
       
  1937 		Session().RemoveEntry(id);
       
  1938 		return EFail;	
       
  1939 		}
       
  1940 	
       
  1941 	// Test composing - ok
       
  1942 	_LIT(KTestComposeAddress1,	"user1@domain1.domain2");
       
  1943 	_LIT(KTestComposeSubject1,	"");
       
  1944 	_LIT(KTestComposeFields1,	"user1@domain1.domain2 ");
       
  1945 	if(!TestEmailFieldsComposeL(KTestComposeFields1, KTestComposeAddress1, KNullDesC, KTestComposeSubject1))
       
  1946 		{
       
  1947 		Session().CleanupEntryPop();
       
  1948 		Session().RemoveEntry(id);
       
  1949 		return EFail;	
       
  1950 		}
       
  1951 	
       
  1952 	_LIT(KTestComposeAddress2,	"user2@domain1.domain2");
       
  1953 	_LIT(KTestComposeSubject2,	"a subject");
       
  1954 	_LIT(KTestComposeFields2,	"user2@domain1.domain2(a subject)");
       
  1955 	if(!TestEmailFieldsComposeL(KTestComposeFields2, KTestComposeAddress2, KNullDesC, KTestComposeSubject2))
       
  1956 		{
       
  1957 		Session().CleanupEntryPop();
       
  1958 		Session().RemoveEntry(id);
       
  1959 		return EFail;	
       
  1960 		}
       
  1961 
       
  1962 	_LIT(KTestComposeFields3,	"user1@domain1.domain2,user2@domain1.domain2 ");
       
  1963 	if(!TestEmailFieldsComposeL(KTestComposeFields3, KTestComposeAddress1, KTestComposeAddress2, KTestComposeSubject1))
       
  1964 		{
       
  1965 		Session().CleanupEntryPop();
       
  1966 		Session().RemoveEntry(id);
       
  1967 		return EFail;	
       
  1968 		}
       
  1969 	
       
  1970 	_LIT(KTestComposeFields4,	"user2@domain1.domain2,user1@domain1.domain2(a subject)");
       
  1971 	if(!TestEmailFieldsComposeL(KTestComposeFields4, KTestComposeAddress2, KTestComposeAddress1, KTestComposeSubject2))
       
  1972 		{
       
  1973 			Session().CleanupEntryPop();
       
  1974 		Session().RemoveEntry(id);
       
  1975 		return EFail;	
       
  1976 		}
       
  1977 
       
  1978 	// Testing composing - fail, no address.
       
  1979 	CSmsEmailFields* fields3 = CSmsEmailFields::NewL();
       
  1980 	CleanupStack::PushL(fields3);
       
  1981 	
       
  1982 	fields3->AddAddressL(KNullDesC);
       
  1983 	fields3->SetSubjectL(KTestSubject);
       
  1984 
       
  1985 	fields3->ComposeLC();
       
  1986 	
       
  1987 	iSmsTest(err==KErrCorrupt);
       
  1988 	
       
  1989 	CleanupStack::PopAndDestroy(fields3);
       
  1990 
       
  1991 	Session().CleanupEntryPop();
       
  1992 	Session().RemoveEntry(id);
       
  1993 	
       
  1994 	iTestStep.INFO_PRINTF1(_L("Test EmailFields Passed"));
       
  1995 	return EPass;
       
  1996 	}
       
  1997 	
       
  1998 TBool CSmutTest::TestEmailFieldsParsePassL(const TDesC& aMessage, const TDesC& aAddress, const TDesC& aSubject, const TDesC& aBody)
       
  1999 	{
       
  2000 	CSmsEmailFields* fields = CSmsEmailFields::NewL();
       
  2001 	CleanupStack::PushL(fields);
       
  2002 	
       
  2003 	TInt pos = fields->ParseL(aMessage);
       
  2004 	
       
  2005 	TPtrC body(aMessage.Mid(pos));
       
  2006 	if(!fields->HasAddress())
       
  2007 		{
       
  2008 		CleanupStack::PopAndDestroy(fields);
       
  2009 		return EFalse;	
       
  2010 		}
       
  2011 	if(fields->Addresses().MdcaCount()!=1)
       
  2012 		{
       
  2013 		CleanupStack::PopAndDestroy(fields);
       
  2014 		return EFalse;	
       
  2015 		}
       
  2016 	if(fields->Addresses().MdcaPoint(0).Compare(aAddress) != 0)
       
  2017 		{
       
  2018 		CleanupStack::PopAndDestroy(fields);
       
  2019 		return EFalse;	
       
  2020 		}
       
  2021 	if(fields->Subject().Compare(aSubject) != 0)
       
  2022 		{
       
  2023 		CleanupStack::PopAndDestroy(fields);
       
  2024 		return EFalse;	
       
  2025 		}
       
  2026 	if(body.Compare(aBody) != 0)
       
  2027 		{
       
  2028 		CleanupStack::PopAndDestroy(fields);
       
  2029 		return EFalse;	
       
  2030 		}
       
  2031 	
       
  2032 	CleanupStack::PopAndDestroy(fields);
       
  2033 	return ETrue;
       
  2034 	}
       
  2035 
       
  2036 TBool CSmutTest::TestEmailFieldsParseFailL(const TDesC& aMessage)
       
  2037 	{
       
  2038 	CSmsEmailFields* fields = CSmsEmailFields::NewL();
       
  2039 	CleanupStack::PushL(fields);
       
  2040 	
       
  2041 	TInt pos = fields->ParseL(aMessage);
       
  2042 	
       
  2043 	CleanupStack::PopAndDestroy(fields);	
       
  2044 	
       
  2045 	return (pos == KErrCorrupt);
       
  2046 	}
       
  2047 
       
  2048 TBool CSmutTest::TestEmailFieldsComposeL(const TDesC& aFields, const TDesC& aAddress1, const TDesC& aAddress2, const TDesC& aSubject)
       
  2049 	{
       
  2050 	CSmsEmailFields* fields = CSmsEmailFields::NewL();
       
  2051 	CleanupStack::PushL(fields);
       
  2052 	
       
  2053 	fields->AddAddressL(aAddress1);
       
  2054 	fields->AddAddressL(aAddress2);
       
  2055 	fields->SetSubjectL(aSubject);
       
  2056 	HBufC* buffer = fields->ComposeLC();	
       
  2057 	
       
  2058 	TBool result = aFields.Compare(*buffer) == 0;
       
  2059 	CleanupStack::PopAndDestroy(2, fields);	// fields, buffer
       
  2060 		
       
  2061 	return result;
       
  2062 	}
       
  2063 
       
  2064 TVerdict CSmutTest::TestHeaderL()
       
  2065 	{
       
  2066 
       
  2067 	// Testing class CSmsHeader
       
  2068 	iTestStep.INFO_PRINTF1(_L("Testing CSmsHeader..."));
       
  2069 	
       
  2070 	// A CSmsHeader can be of 6 different types
       
  2071 	// First we test constructing ESmsDeliver
       
  2072 	delete iSmsHeader; // deleting the previous one
       
  2073 	iSmsHeader = NULL;
       
  2074 	iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText); // constructing
       
  2075 	if(iSmsHeader->Type()!=CSmsPDU::ESmsDeliver)	// type ok?
       
  2076 		{
       
  2077 		return EFail;	
       
  2078 		}
       
  2079 
       
  2080 	CSmsDeliver& deliver = iSmsHeader->Deliver();  // lets get the CSmsPDU of the CSmsHeader
       
  2081 	const CSmsDeliver& deliver2 = iSmsHeader->Deliver();
       
  2082 
       
  2083 	if(deliver.Type() != CSmsPDU::ESmsDeliver)// Are the types ok?
       
  2084 		{
       
  2085 		return EFail;	
       
  2086 		}
       
  2087 	if(deliver2.Type() != CSmsPDU::ESmsDeliver)
       
  2088 		{
       
  2089 		return EFail;	
       
  2090 		}
       
  2091 
       
  2092 		
       
  2093 	// Lets access the CSmsMessage of our header
       
  2094 	CSmsMessage& message=iSmsHeader->Message();
       
  2095 	//Get the operations
       
  2096 	CSmsReplyAddressOperations& operations = STATIC_CAST(CSmsReplyAddressOperations&,message.GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat));		
       
  2097 	//Add address
       
  2098 	TPtrC replyAddress(_L("+447583927594"));
       
  2099 	operations.AddReplyAddressL(replyAddress);
       
  2100 	
       
  2101 	//get the address back
       
  2102 	if(iSmsHeader->ReplyAddressL()!=_L("+447583927594"))
       
  2103 		{
       
  2104 		return EFail;		
       
  2105 		}
       
  2106 		
       
  2107 	// Add a from address and make sure that the reply address is still used instead
       
  2108 	iSmsHeader->SetFromAddressL(_L("+358503367709"));
       
  2109 	//get the address back
       
  2110 	if(iSmsHeader->ReplyAddressL()!=_L("+447583927594"))
       
  2111 		{
       
  2112 		return EFail;		
       
  2113 		}
       
  2114 		
       
  2115 	// Type ESmsCommand
       
  2116 	delete iSmsHeader; // deleting previous
       
  2117 	iSmsHeader = NULL;
       
  2118 	iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsCommand,*iRichText);
       
  2119 	if(iSmsHeader->Type()!=CSmsPDU::ESmsCommand)
       
  2120 		{
       
  2121 		return EFail;	
       
  2122 		}
       
  2123 
       
  2124 	CSmsCommand& command=iSmsHeader->Command();
       
  2125 	const CSmsCommand& command2=iSmsHeader->Command();
       
  2126 
       
  2127 	if(command.Type() != CSmsPDU::ESmsCommand)
       
  2128 		{
       
  2129 		return EFail;	
       
  2130 		}
       
  2131 	if(command2.Type() != CSmsPDU::ESmsCommand)
       
  2132 		{
       
  2133 		return EFail;	
       
  2134 		}
       
  2135 
       
  2136 	// Type ESmsStatusReport
       
  2137 	delete iSmsHeader; // deleting the previous one
       
  2138 	iSmsHeader = NULL;
       
  2139 	iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsStatusReport,*iRichText);
       
  2140 	if(iSmsHeader->Type()!=CSmsPDU::ESmsStatusReport)
       
  2141 		{
       
  2142 		return EFail;	
       
  2143 		}
       
  2144 
       
  2145 	CSmsStatusReport& statusreport=iSmsHeader->StatusReport();
       
  2146 	const CSmsStatusReport& statusreport2=iSmsHeader->StatusReport();
       
  2147 
       
  2148 	if(statusreport.Type() != CSmsPDU::ESmsStatusReport)
       
  2149 		{
       
  2150 		return EFail;	
       
  2151 		}
       
  2152 	if(statusreport2.Type() != CSmsPDU::ESmsStatusReport)
       
  2153 		{
       
  2154 		return EFail;	
       
  2155 		}
       
  2156 
       
  2157 	// Type ESmsSubmit
       
  2158 	delete iSmsHeader; // deleting the previous one
       
  2159 	iSmsHeader = NULL;
       
  2160 	iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText);
       
  2161 	if(iSmsHeader->Type()!=CSmsPDU::ESmsSubmit)
       
  2162 		{
       
  2163 		return EFail;	
       
  2164 		}
       
  2165 
       
  2166 	CSmsSubmit& submit=iSmsHeader->Submit();
       
  2167 	const CSmsSubmit& submit2=iSmsHeader->Submit();
       
  2168 
       
  2169 	if(submit.Type() != CSmsPDU::ESmsSubmit)
       
  2170 		{
       
  2171 		return EFail;	
       
  2172 		}
       
  2173 	if(submit2.Type() != CSmsPDU::ESmsSubmit)
       
  2174 		{
       
  2175 		return EFail;	
       
  2176 		}
       
  2177 
       
  2178 	// Lets access the CSmsMessage of our header
       
  2179 	CSmsMessage& message1=iSmsHeader->Message();
       
  2180 	const CSmsMessage& message2=iSmsHeader->Message();
       
  2181 
       
  2182 	if(message1.Type() != CSmsPDU::ESmsSubmit)
       
  2183 		{
       
  2184 		return EFail;		
       
  2185 		}
       
  2186 	if(message2.Type() != CSmsPDU::ESmsSubmit)
       
  2187 		{
       
  2188 		return EFail;		
       
  2189 		}
       
  2190 
       
  2191 	// Lets test the features of CSmsHeader with different values
       
  2192 	iSmsHeader->SetReplyPathProvided(ETrue);
       
  2193 	if(!iSmsHeader->ReplyPathProvided())
       
  2194 		{
       
  2195 		return EFail;		
       
  2196 		}
       
  2197 	iSmsHeader->SetReplyPathProvided(EFalse);
       
  2198 	if(iSmsHeader->ReplyPathProvided())
       
  2199 		{
       
  2200 		return EFail;		
       
  2201 		}
       
  2202 
       
  2203 	iSmsHeader->SetBioMsgIdType(EBioMsgIdUnknown);
       
  2204 	if(iSmsHeader->BioMsgIdType()!=EBioMsgIdUnknown)
       
  2205 		{
       
  2206 		return EFail;		
       
  2207 		}
       
  2208 	iSmsHeader->SetBioMsgIdType(EBioMsgIdIana);
       
  2209 	if(iSmsHeader->BioMsgIdType()!=EBioMsgIdIana)
       
  2210 		{
       
  2211 		return EFail;		
       
  2212 		}
       
  2213 	iSmsHeader->SetBioMsgIdType(EBioMsgIdNbs);
       
  2214 	if(iSmsHeader->BioMsgIdType()!=EBioMsgIdNbs)
       
  2215 		{
       
  2216 		return EFail;		
       
  2217 		}
       
  2218 	iSmsHeader->SetBioMsgIdType(EBioMsgIdWap);
       
  2219 	if(iSmsHeader->BioMsgIdType()!=EBioMsgIdWap)
       
  2220 		{
       
  2221 		return EFail;		
       
  2222 		}
       
  2223 	iSmsHeader->SetBioMsgIdType(EBioMsgIdWapSecure);
       
  2224 	if(iSmsHeader->BioMsgIdType()!=EBioMsgIdWapSecure)
       
  2225 		{
       
  2226 		return EFail;		
       
  2227 		}
       
  2228 
       
  2229 	// Lets set the service center number
       
  2230 	iSmsHeader->SetServiceCenterAddressL(_L("+350508771010"));
       
  2231 	if(iSmsHeader->ServiceCenterAddress()!=_L("+350508771010"))
       
  2232 		{
       
  2233 		return EFail;		
       
  2234 		}
       
  2235 
       
  2236 	// Lets set one recipient for the message
       
  2237 	CArrayPtrFlat<CSmsNumber>& recipients = iSmsHeader->Recipients();
       
  2238 	CSmsNumber* number=CSmsNumber::NewL();
       
  2239 	CleanupStack::PushL(number);
       
  2240 	number->SetAddressL(_L("+358503367709"));
       
  2241 	recipients.AppendL(number);
       
  2242 	CleanupStack::Pop();
       
  2243 
       
  2244 	// Setting settings of the message
       
  2245 	CSmsSettings* smsset = CSmsSettings::NewL();
       
  2246 	CleanupStack::PushL(smsset);
       
  2247 	smsset->AddServiceCenterL(_L("Hippo"), _L("+358508771010"));
       
  2248 	smsset->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
       
  2249 	smsset->SetDelivery(ESmsDeliveryImmediately);
       
  2250 	smsset->SetDeliveryReport(EFalse);
       
  2251 	smsset->SetMessageConversion(ESmsConvPIDNone);
       
  2252 	smsset->SetRejectDuplicate(ETrue);
       
  2253 	smsset->SetReplyPath(EFalse);
       
  2254 	smsset->SetValidityPeriod(ESmsVP24Hours);
       
  2255 	smsset->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet);
       
  2256 	// And copying them to the CSmsHeader
       
  2257 	iSmsHeader->SetSmsSettingsL(*smsset);
       
  2258 	CleanupStack::PopAndDestroy(smsset);
       
  2259 
       
  2260 	CSmsSettings* smsset2 = CSmsSettings::NewL();
       
  2261 	CleanupStack::PushL(smsset2);
       
  2262 	// Lets get the same setting from the CSmsHeader
       
  2263 	iSmsHeader->GetSmsSettingsL(*smsset2);
       
  2264 	// And compare that they are ok!
       
  2265 	if(smsset2->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit)
       
  2266 		{
       
  2267 		CleanupStack::PopAndDestroy(smsset2);
       
  2268 		return EFail;	
       
  2269 		}
       
  2270 	if(smsset2->DeliveryReport())
       
  2271 		{
       
  2272 		CleanupStack::PopAndDestroy(smsset2);
       
  2273 		return EFail;	
       
  2274 		}
       
  2275 	if(smsset2->MessageConversion()!=ESmsConvPIDNone)
       
  2276 		{
       
  2277 		CleanupStack::PopAndDestroy(smsset2);
       
  2278 		return EFail;	
       
  2279 		}
       
  2280 	if(!smsset2->RejectDuplicate())
       
  2281 		{
       
  2282 		CleanupStack::PopAndDestroy(smsset2);
       
  2283 		return EFail;	
       
  2284 		}
       
  2285 	if(smsset2->ReplyPath())
       
  2286 		{
       
  2287 		CleanupStack::PopAndDestroy(smsset2);
       
  2288 		return EFail;	
       
  2289 		}
       
  2290 	if(smsset2->ValidityPeriod().Int()!=ESmsVP24Hours)
       
  2291 		{
       
  2292 		CleanupStack::PopAndDestroy(smsset2);
       
  2293 		return EFail;	
       
  2294 		}
       
  2295 	if(smsset2->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet)
       
  2296 		{
       
  2297 		CleanupStack::PopAndDestroy(smsset2);
       
  2298 		return EFail;	
       
  2299 		}
       
  2300 	CleanupStack::PopAndDestroy(smsset2);
       
  2301 
       
  2302 	//Test Set/FromAddress()
       
  2303 	iSmsHeader->SetFromAddressL(_L("+358503367709"));
       
  2304 	if(iSmsHeader->ReplyAddressL()!=_L("+358503367709"))
       
  2305 		{
       
  2306 		return EFail;		
       
  2307 		}
       
  2308 	
       
  2309 	//Test Set/EmailFields()
       
  2310 	_LIT(KTestAddress, "user@domain1.domain2");
       
  2311 	_LIT(KTestSubject, "a subject");
       
  2312 
       
  2313 	CSmsEmailFields* fields1 = CSmsEmailFields::NewL();
       
  2314 	CleanupStack::PushL(fields1);
       
  2315 	
       
  2316 	fields1->AddAddressL(KTestAddress);
       
  2317 	fields1->SetSubjectL(KTestSubject);
       
  2318 
       
  2319 	// Test the PID field value - should be ESmsConvPIDNone...
       
  2320 	CSmsSettings* smsset3 = CSmsSettings::NewL();
       
  2321 	CleanupStack::PushL(smsset3);
       
  2322 
       
  2323 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2324 	if(smsset3->MessageConversion()!=ESmsConvPIDNone)
       
  2325 		{
       
  2326 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2327 		return EFail;	
       
  2328 		}
       
  2329 
       
  2330 	// Set the email fields - check the email fields and the PID value (should 
       
  2331 	// be ESmsConvMail).
       
  2332 	iSmsHeader->SetEmailFieldsL(*fields1);
       
  2333 	const CSmsEmailFields& fields2 = iSmsHeader->EmailFields();
       
  2334 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2335 	
       
  2336 	if(!CompareEmailFields(*fields1, fields2))
       
  2337 		{
       
  2338 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2339 		return EFail;	
       
  2340 		}
       
  2341 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2342 		{
       
  2343 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2344 		return EFail;		
       
  2345 		}
       
  2346 	
       
  2347 	// Reset the fields and then set back in the header - should reset the PID
       
  2348 	// value to ESmsConvPIDNone
       
  2349 	fields1->Reset();
       
  2350 	iSmsHeader->SetEmailFieldsL(*fields1);
       
  2351 	
       
  2352 	const CSmsEmailFields& fields3 = iSmsHeader->EmailFields();
       
  2353 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2354 	
       
  2355 	if(!CompareEmailFields(*fields1, fields3))
       
  2356 		{
       
  2357 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2358 		return EFail;	
       
  2359 		}
       
  2360 	if(smsset3->MessageConversion()!=ESmsConvPIDNone)
       
  2361 		{
       
  2362 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2363 		return EFail;	
       
  2364 		}
       
  2365 	
       
  2366 	// Set the reply email fields - check email fields (both address and subject)
       
  2367 	// and the PID value (should be ESmsConvMail)
       
  2368 	_LIT(KEmailReplySubjectFormat,	"Re: %S");
       
  2369 	_LIT(KEmailReplySubject,		"Re: a subject");
       
  2370 
       
  2371 	// First test with no subject...
       
  2372 	fields1->AddAddressL(KTestAddress);
       
  2373 	
       
  2374 	iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat);
       
  2375 	const CSmsEmailFields& replyFields1 = iSmsHeader->EmailFields();
       
  2376 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2377 	
       
  2378 	if(!CompareEmailFieldsAddresses(replyFields1.Addresses(), fields1->Addresses()))
       
  2379 		{
       
  2380 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2381 		return EFail;	
       
  2382 		}
       
  2383 	if(replyFields1.Subject().Compare(KNullDesC) != 0)
       
  2384 		{
       
  2385 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2386 		return EFail;	
       
  2387 		}
       
  2388 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2389 		{
       
  2390 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2391 		return EFail;	
       
  2392 		}
       
  2393 	
       
  2394 	// Now set the subject...
       
  2395 	fields1->SetSubjectL(KTestSubject);
       
  2396 
       
  2397 	iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat);
       
  2398 	const CSmsEmailFields& replyFields2 = iSmsHeader->EmailFields();
       
  2399 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2400 	
       
  2401 	if(!CompareEmailFieldsAddresses(replyFields2.Addresses(), fields1->Addresses()))
       
  2402 		{
       
  2403 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2404 		return EFail;	
       
  2405 		}
       
  2406 	if(replyFields2.Subject().Compare(KEmailReplySubject()) != 0)
       
  2407 		{
       
  2408 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2409 		return EFail;	
       
  2410 		}
       
  2411 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2412 		{
       
  2413 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2414 		return EFail;	
       
  2415 		}
       
  2416 	
       
  2417 	// Repeat - test for (lack of) Re: chain.
       
  2418 	fields1->SetSubjectL(KEmailReplySubject);
       
  2419 	
       
  2420 	iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat);
       
  2421 	const CSmsEmailFields& replyFields3 = iSmsHeader->EmailFields();
       
  2422 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2423 	
       
  2424 	if(!CompareEmailFieldsAddresses(replyFields3.Addresses(), fields1->Addresses()))
       
  2425 		{
       
  2426 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2427 		return EFail;	
       
  2428 		}
       
  2429 	if(replyFields3.Subject().Compare(KEmailReplySubject()) != 0)
       
  2430 		{
       
  2431 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2432 		return EFail;	
       
  2433 		}
       
  2434 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2435 		{
       
  2436 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2437 		return EFail;	
       
  2438 		}
       
  2439 	
       
  2440 	// Set the forward email fields - check email fields (both address and subject)
       
  2441 	// and the PID value (should be ESmsConvMail)
       
  2442 	_LIT(KEmailForwardSubjectFormat,	"Fw: %S");
       
  2443 	_LIT(KEmailForwardSubject,			"Fw: a subject");
       
  2444 	
       
  2445 	// First test with no subject...
       
  2446 	fields1->Reset();
       
  2447 	fields1->AddAddressL(KTestAddress);
       
  2448 
       
  2449 	iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat);
       
  2450 	const CSmsEmailFields& forwardFields1 = iSmsHeader->EmailFields();
       
  2451 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2452 	
       
  2453 	if(forwardFields1.HasAddress())
       
  2454 		{
       
  2455 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2456 		return EFail;	
       
  2457 		}
       
  2458 	if(forwardFields1.Addresses().MdcaCount()!=0)
       
  2459 		{
       
  2460 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2461 		return EFail;	
       
  2462 		}
       
  2463 	if(forwardFields1.Subject().Compare(KNullDesC) != 0)
       
  2464 		{
       
  2465 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2466 		return EFail;	
       
  2467 		}
       
  2468 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2469 		{
       
  2470 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2471 		return EFail;	
       
  2472 		}
       
  2473 
       
  2474 	// Now set the subject...
       
  2475 	fields1->SetSubjectL(KTestSubject);
       
  2476 
       
  2477 	iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat);
       
  2478 	const CSmsEmailFields& forwardFields2 = iSmsHeader->EmailFields();
       
  2479 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2480 	
       
  2481 	if(forwardFields2.HasAddress())
       
  2482 		{
       
  2483 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2484 		return EFail;	
       
  2485 		}
       
  2486 	if(forwardFields2.Addresses().MdcaCount()!=0)
       
  2487 		{
       
  2488 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2489 		return EFail;	
       
  2490 		}
       
  2491 	if(forwardFields2.Subject().Compare(KEmailForwardSubject()) != 0)
       
  2492 		{
       
  2493 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2494 		return EFail;	
       
  2495 		}
       
  2496 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2497 		{
       
  2498 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2499 		return EFail;	
       
  2500 		}
       
  2501 	
       
  2502 	// Repeat - test for (lack of) Fw: chain.
       
  2503 	fields1->SetSubjectL(KEmailForwardSubject);
       
  2504 	
       
  2505 	iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat);
       
  2506 	const CSmsEmailFields& forwardFields3 = iSmsHeader->EmailFields();
       
  2507 	iSmsHeader->GetSmsSettingsL(*smsset3);
       
  2508 	
       
  2509 	if(forwardFields3.HasAddress())
       
  2510 		{
       
  2511 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2512 		return EFail;	
       
  2513 		}
       
  2514 	if(forwardFields3.Addresses().MdcaCount()!=0)
       
  2515 		{
       
  2516 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2517 		return EFail;	
       
  2518 		}
       
  2519 	if(forwardFields3.Subject().Compare(KEmailForwardSubject()) != 0)
       
  2520 		{
       
  2521 		CleanupStack::PopAndDestroy(smsset3);
       
  2522 		CleanupStack::PopAndDestroy(fields1);
       
  2523 		return EFail;	
       
  2524 		}
       
  2525 	if(smsset3->MessageConversion()!=ESmsConvMail)
       
  2526 		{
       
  2527 		CleanupStack::PopAndDestroy(2,smsset3);
       
  2528 		return EFail;	
       
  2529 		}
       
  2530 
       
  2531 	// Reset the fields and set back in the header.
       
  2532 	fields1->Reset();
       
  2533 	iSmsHeader->SetEmailFieldsL(*fields1);
       
  2534 
       
  2535 	CleanupStack::PopAndDestroy(2, fields1);
       
  2536 
       
  2537 	//Lets store and restore the CSmsHeader and test that the values are right
       
  2538 	TMsvId id = iSmsTest.CreateDummyMessageToSendL();
       
  2539 	Session().CleanupEntryPushL(id);
       
  2540 	iSmsTest.SetEntryL(id);
       
  2541 	
       
  2542 	StoreHeaderL(*iSmsHeader);
       
  2543 	
       
  2544 	// Check that the email fields stream is not present, as there is no email
       
  2545 	// fields data.
       
  2546 	CMsvStore* store1 = iSmsTest.ReadStoreL();
       
  2547 	CleanupStack::PushL(store1);
       
  2548 	if(store1->IsPresentL(KUidMsvSmsEmailFieldsStream))
       
  2549 		{
       
  2550 		CleanupStack::PopAndDestroy(store1);
       
  2551 		return EFail;	
       
  2552 		}
       
  2553 	CleanupStack::PopAndDestroy(store1);
       
  2554 
       
  2555 	CSmsHeader* header1 = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText);
       
  2556 	CleanupStack::PushL(header1);
       
  2557 
       
  2558 	RestoreHeaderL(*header1);
       
  2559 
       
  2560 	//Values ok?
       
  2561 	if(iSmsHeader->Type()!=header1->Type())
       
  2562 		{
       
  2563 		CleanupStack::PopAndDestroy(header1);
       
  2564 		Session().CleanupEntryPop();
       
  2565 		Session().RemoveEntry(id);	
       
  2566 		return EFail;
       
  2567 		}
       
  2568 	if(header1->ReplyPathProvided())
       
  2569 		{
       
  2570 		CleanupStack::PopAndDestroy(header1);
       
  2571 		Session().CleanupEntryPop();
       
  2572 		Session().RemoveEntry(id);	
       
  2573 		return EFail;	
       
  2574 		}
       
  2575 	if(header1->ServiceCenterAddress()!=_L("+350508771010"))
       
  2576 		{
       
  2577 		CleanupStack::PopAndDestroy(header1);
       
  2578 		Session().CleanupEntryPop();
       
  2579 		Session().RemoveEntry(id);	
       
  2580 		return EFail;	
       
  2581 		}
       
  2582 	if(iSmsHeader->Recipients().Count()!=header1->Recipients().Count())
       
  2583 		{
       
  2584 		CleanupStack::PopAndDestroy(header1);
       
  2585 		Session().CleanupEntryPop();
       
  2586 		Session().RemoveEntry(id);	
       
  2587 		return EFail;	
       
  2588 		}
       
  2589 	if(iSmsHeader->BioMsgIdType()!=header1->BioMsgIdType())
       
  2590 		{
       
  2591 		CleanupStack::PopAndDestroy(header1);
       
  2592 		Session().CleanupEntryPop();
       
  2593 		Session().RemoveEntry(id);	
       
  2594 		return EFail;	
       
  2595 		}
       
  2596 	if(iSmsHeader->ReplyAddressL()!=header1->ReplyAddressL())
       
  2597 		{
       
  2598 		CleanupStack::PopAndDestroy(header1);
       
  2599 		Session().CleanupEntryPop();
       
  2600 		Session().RemoveEntry(id);	
       
  2601 		return EFail;	
       
  2602 		}
       
  2603 
       
  2604 	// Lets get the setting of the message
       
  2605 	CSmsSettings* smsset4 = CSmsSettings::NewL();
       
  2606 	CleanupStack::PushL(smsset4);
       
  2607 	header1->GetSmsSettingsL(*smsset4);
       
  2608 
       
  2609 	// And compare that they are the original values
       
  2610 	if(smsset4->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit)
       
  2611 		{
       
  2612 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2613 		Session().CleanupEntryPop();
       
  2614 		Session().RemoveEntry(id);	
       
  2615 		return EFail;	
       
  2616 		}
       
  2617 	if(smsset4->DeliveryReport())
       
  2618 		{
       
  2619 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2620 		Session().CleanupEntryPop();
       
  2621 		Session().RemoveEntry(id);	
       
  2622 		return EFail;		
       
  2623 		}
       
  2624 	if(smsset4->MessageConversion()!=ESmsConvPIDNone)
       
  2625 		{
       
  2626 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2627 		Session().CleanupEntryPop();
       
  2628 		Session().RemoveEntry(id);	
       
  2629 		return EFail;		
       
  2630 		}
       
  2631 	if(!smsset4->RejectDuplicate())
       
  2632 		{
       
  2633 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2634 		Session().CleanupEntryPop();
       
  2635 		Session().RemoveEntry(id);	
       
  2636 		return EFail;		
       
  2637 		}
       
  2638 	if(smsset4->ReplyPath())
       
  2639 		{
       
  2640 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2641 		Session().CleanupEntryPop();
       
  2642 		Session().RemoveEntry(id);	
       
  2643 		return EFail;		
       
  2644 		}
       
  2645 	if(smsset4->ValidityPeriod().Int()!=ESmsVP24Hours)
       
  2646 		{
       
  2647 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2648 		Session().CleanupEntryPop();
       
  2649 		Session().RemoveEntry(id);	
       
  2650 		return EFail;		
       
  2651 		}
       
  2652 	if(smsset4->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet)
       
  2653 		{
       
  2654 		CleanupStack::PopAndDestroy(2,smsset4);
       
  2655 		Session().CleanupEntryPop();
       
  2656 		Session().RemoveEntry(id);	
       
  2657 		return EFail;		
       
  2658 		}
       
  2659 	
       
  2660 	CleanupStack::PopAndDestroy(2, header1);
       
  2661 	
       
  2662 	// Test with email fields data.
       
  2663 	CSmsEmailFields* fields8 = CSmsEmailFields::NewL();
       
  2664 	CleanupStack::PushL(fields8);
       
  2665 	fields8->AddAddressL(KTestAddress);
       
  2666 	fields8->SetSubjectL(KTestSubject);
       
  2667 	iSmsHeader->SetEmailFieldsL(*fields8);
       
  2668 	
       
  2669 	StoreHeaderL(*iSmsHeader);
       
  2670 
       
  2671 	// Check that the email fields stream is  present, as there is now email
       
  2672 	// fields data.
       
  2673 	CMsvStore* store2 = iSmsTest.EditStoreL();
       
  2674 	CleanupStack::PushL(store2);
       
  2675 	if(!store2->IsPresentL(KUidMsvSmsEmailFieldsStream))
       
  2676 		{
       
  2677 		CleanupStack::PopAndDestroy(2,store2);
       
  2678 		Session().CleanupEntryPop();
       
  2679 		Session().RemoveEntry(id);	
       
  2680 		return EFail;	
       
  2681 		}
       
  2682 	CleanupStack::PopAndDestroy(store2);
       
  2683 
       
  2684 	CSmsHeader* header2 = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText);
       
  2685 	CleanupStack::PushL(header2);
       
  2686 
       
  2687 	RestoreHeaderL(*header2);
       
  2688 
       
  2689 	if(iSmsHeader->Type()!=header2->Type())
       
  2690 		{
       
  2691 		CleanupStack::PopAndDestroy(2,store2);
       
  2692 		Session().CleanupEntryPop();
       
  2693 		Session().RemoveEntry(id);	
       
  2694 		return EFail;	
       
  2695 		}
       
  2696 	if(header2->ReplyPathProvided())
       
  2697 		{
       
  2698 		CleanupStack::PopAndDestroy(2,store2);
       
  2699 		Session().CleanupEntryPop();
       
  2700 		Session().RemoveEntry(id);	
       
  2701 		return EFail;	
       
  2702 		}
       
  2703 	if(header2->ServiceCenterAddress()!=_L("+350508771010"))
       
  2704 		{
       
  2705 		CleanupStack::PopAndDestroy(2,store2);
       
  2706 		Session().CleanupEntryPop();
       
  2707 		Session().RemoveEntry(id);	
       
  2708 		return EFail;	
       
  2709 		}
       
  2710 	if(iSmsHeader->Recipients().Count()!=header2->Recipients().Count())
       
  2711 		{
       
  2712 		CleanupStack::PopAndDestroy(2,store2);
       
  2713 		Session().CleanupEntryPop();
       
  2714 		Session().RemoveEntry(id);	
       
  2715 		return EFail;	
       
  2716 		}
       
  2717 	if(iSmsHeader->BioMsgIdType()!=header2->BioMsgIdType())
       
  2718 		{
       
  2719 		CleanupStack::PopAndDestroy(2,store2);
       
  2720 		Session().CleanupEntryPop();
       
  2721 		Session().RemoveEntry(id);	
       
  2722 		return EFail;	
       
  2723 		}
       
  2724 	if(iSmsHeader->ReplyAddressL()!=header2->ReplyAddressL())
       
  2725 		{
       
  2726 		CleanupStack::PopAndDestroy(2,store2);
       
  2727 		Session().CleanupEntryPop();
       
  2728 		Session().RemoveEntry(id);	
       
  2729 		return EFail;	
       
  2730 		}
       
  2731 
       
  2732 	CSmsSettings* smsset5 = CSmsSettings::NewL();
       
  2733 	CleanupStack::PushL(smsset5);
       
  2734 	header2->GetSmsSettingsL(*smsset5);
       
  2735 
       
  2736 	if(smsset5->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit)
       
  2737 		{
       
  2738 		CleanupStack::PopAndDestroy(2,store2);
       
  2739 		Session().CleanupEntryPop();
       
  2740 		Session().RemoveEntry(id);	
       
  2741 		return EFail;	
       
  2742 		}
       
  2743 	if(smsset5->DeliveryReport())
       
  2744 		{
       
  2745 		CleanupStack::PopAndDestroy(2,store2);
       
  2746 		Session().CleanupEntryPop();
       
  2747 		Session().RemoveEntry(id);	
       
  2748 		return EFail;	
       
  2749 		}
       
  2750 	if(smsset5->MessageConversion()!=ESmsConvMail)
       
  2751 		{
       
  2752 		CleanupStack::PopAndDestroy(2,store2);
       
  2753 		Session().CleanupEntryPop();
       
  2754 		Session().RemoveEntry(id);	
       
  2755 		return EFail;	
       
  2756 		}
       
  2757 	if(!smsset5->RejectDuplicate())
       
  2758 		{
       
  2759 		CleanupStack::PopAndDestroy(2,store2);
       
  2760 		Session().CleanupEntryPop();
       
  2761 		Session().RemoveEntry(id);	
       
  2762 		return EFail;	
       
  2763 		}
       
  2764 	if(smsset5->ReplyPath())
       
  2765 		{
       
  2766 		CleanupStack::PopAndDestroy(2,store2);
       
  2767 		Session().CleanupEntryPop();
       
  2768 		Session().RemoveEntry(id);	
       
  2769 		return EFail;	
       
  2770 		}
       
  2771 	if(smsset5->ValidityPeriod().Int()!=ESmsVP24Hours)
       
  2772 		{
       
  2773 		CleanupStack::PopAndDestroy(2,store2);
       
  2774 		Session().CleanupEntryPop();
       
  2775 		Session().RemoveEntry(id);	
       
  2776 		return EFail;	
       
  2777 		}
       
  2778 	if(smsset5->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet)
       
  2779 		{
       
  2780 		CleanupStack::PopAndDestroy(2,store2);
       
  2781 		Session().CleanupEntryPop();
       
  2782 		Session().RemoveEntry(id);	
       
  2783 		return EFail;	
       
  2784 		}
       
  2785 	
       
  2786 	const CSmsEmailFields& fields9 = iSmsHeader->EmailFields();
       
  2787 	if(!CompareEmailFields(*fields8, fields9))
       
  2788 		{
       
  2789 		CleanupStack::PopAndDestroy(2,store2);
       
  2790 		Session().CleanupEntryPop();
       
  2791 		Session().RemoveEntry(id);
       
  2792 		return EFail;	
       
  2793 		}
       
  2794 	
       
  2795 	CleanupStack::PopAndDestroy(3, fields8);
       
  2796 	
       
  2797 	//Test NewL that takes a CSmsMessage - pretend it's an email message.
       
  2798 	RFs fs;
       
  2799 	User::LeaveIfError(fs.Connect());
       
  2800 	CleanupClosePushL(fs);
       
  2801 	
       
  2802 	// Test un-corrupt email - add an appropriate email message
       
  2803 	_LIT(KTestEmailAddress1, 	"user@domain1.domain2");
       
  2804 	_LIT(KTestEmailSubject1, 	"a subject");
       
  2805 	_LIT(KTestEmailBody1,		"some body text");
       
  2806 	_LIT(KTestEmailMessage1,	"user@domain1.domain2##a subject#some body text");
       
  2807 
       
  2808 	CSmsMessage* email1 = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, CSmsEditorBuffer::NewL(*iRichText), EFalse);
       
  2809 	CleanupStack::PushL(email1);
       
  2810 	
       
  2811 	CSmsBufferBase& buffer1 = email1->Buffer();
       
  2812 	buffer1.Reset();
       
  2813 	buffer1.InsertL(0, KTestEmailMessage1());
       
  2814 	
       
  2815 	// Set the PID for email.
       
  2816 	CSmsPDU& pdu1 = email1->SmsPDU();
       
  2817 	if( pdu1.ProtocolIdentifierPresent() )
       
  2818 		{
       
  2819 		pdu1.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking);
       
  2820 		pdu1.SetTelematicDeviceIndicator(TSmsProtocolIdentifier::ESmsTelematicDevice);
       
  2821 		pdu1.SetTelematicDeviceType(TSmsProtocolIdentifier::ESmsInternetElectronicMail);
       
  2822 		}
       
  2823 
       
  2824 	// create a new SMS header
       
  2825 	delete iSmsHeader;
       
  2826 	iSmsHeader = NULL;
       
  2827 	CleanupStack::Pop(email1);
       
  2828 	
       
  2829 	TRAPD(err,iSmsHeader = CSmsHeader::NewL(email1))
       
  2830 	if(err)
       
  2831 		{
       
  2832 		delete email1;	
       
  2833 		}
       
  2834 
       
  2835 	// Check that the header is correct...
       
  2836 	// Email fields...
       
  2837 	const CSmsEmailFields& fields10 = iSmsHeader->EmailFields();
       
  2838 	if(!fields10.HasAddress())
       
  2839 		{
       
  2840 		CleanupStack::PopAndDestroy(&fs);
       
  2841 		Session().CleanupEntryPop();
       
  2842 		Session().RemoveEntry(id);	
       
  2843 		return EFail;
       
  2844 		}
       
  2845 	if(fields10.Addresses().MdcaCount()!=1)
       
  2846 		{
       
  2847 		CleanupStack::PopAndDestroy(&fs);
       
  2848 		Session().CleanupEntryPop();
       
  2849 		Session().RemoveEntry(id);	
       
  2850 		return EFail;	
       
  2851 		}
       
  2852 	if(fields10.Addresses().MdcaPoint(0).Compare(KTestEmailAddress1) != 0)
       
  2853 		{
       
  2854 		CleanupStack::PopAndDestroy(&fs);
       
  2855 		Session().CleanupEntryPop();
       
  2856 		Session().RemoveEntry(id);	
       
  2857 		return EFail;	
       
  2858 		}
       
  2859 	if(fields10.Subject().Compare(KTestEmailSubject1) != 0)
       
  2860 		{
       
  2861 		CleanupStack::PopAndDestroy(&fs);
       
  2862 		Session().CleanupEntryPop();
       
  2863 		Session().RemoveEntry(id);	
       
  2864 		return EFail;	
       
  2865 		}
       
  2866 	
       
  2867 	// Message body...
       
  2868 	CSmsBufferBase& body1 = iSmsHeader->Message().Buffer();
       
  2869 	TInt length1 = body1.Length();
       
  2870 	HBufC* buf1 = HBufC::NewLC(length1);
       
  2871 	TPtr bufPtr1(buf1->Des());
       
  2872 	body1.Extract(bufPtr1, 0, length1);
       
  2873 	
       
  2874 	if(bufPtr1.Compare(KTestEmailBody1) != 0)
       
  2875 		{
       
  2876 		CleanupStack::PopAndDestroy(2,buf1);
       
  2877 		Session().CleanupEntryPop();
       
  2878 		Session().RemoveEntry(id);	
       
  2879 		return EFail;	
       
  2880 		}
       
  2881 	
       
  2882 	CleanupStack::PopAndDestroy(buf1);
       
  2883 
       
  2884 	// Test corrupt email.
       
  2885 	_LIT(KTestEmailBody2,		"user@domain1.domain2##a subjectsome body text");
       
  2886 	_LIT(KTestEmailMessage2,	"user@domain1.domain2##a subjectsome body text");
       
  2887 
       
  2888 	CSmsMessage* email2 = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, CSmsEditorBuffer::NewL(*iRichText), EFalse);
       
  2889 	CleanupStack::PushL(email2);
       
  2890 	
       
  2891 	CSmsBufferBase& buffer2 = email2->Buffer();
       
  2892 	buffer2.Reset();
       
  2893 	buffer2.InsertL(0, KTestEmailMessage2());
       
  2894 	
       
  2895 	// Set the PID for email.
       
  2896 	CSmsPDU& pdu2 = email2->SmsPDU();
       
  2897 	if( pdu2.ProtocolIdentifierPresent() )
       
  2898 		{
       
  2899 		pdu2.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking);
       
  2900 		pdu2.SetTelematicDeviceIndicator(TSmsProtocolIdentifier::ESmsTelematicDevice);
       
  2901 		pdu2.SetTelematicDeviceType(TSmsProtocolIdentifier::ESmsInternetElectronicMail);
       
  2902 		}
       
  2903 
       
  2904 	// create a new SMS header
       
  2905 	delete iSmsHeader;
       
  2906 	iSmsHeader = NULL;
       
  2907 	iSmsHeader = CSmsHeader::NewL(email2); 
       
  2908 	CleanupStack::Pop(email2);
       
  2909 
       
  2910 	// Check that the header is correct...
       
  2911 	// Email fields...
       
  2912 	const CSmsEmailFields& fields11 = iSmsHeader->EmailFields();
       
  2913 	if(fields11.HasAddress())
       
  2914 		{
       
  2915 		CleanupStack::PopAndDestroy(&fs);
       
  2916 		Session().CleanupEntryPop();
       
  2917 		Session().RemoveEntry(id);	
       
  2918 		return EFail;	
       
  2919 		}
       
  2920 	if(fields11.Addresses().MdcaCount()!=0)
       
  2921 		{
       
  2922 		CleanupStack::PopAndDestroy(&fs);
       
  2923 		Session().CleanupEntryPop();
       
  2924 		Session().RemoveEntry(id);	
       
  2925 		return EFail;	
       
  2926 		}
       
  2927 	if(fields11.Subject().Compare(KNullDesC) != 0)
       
  2928 		{
       
  2929 		CleanupStack::PopAndDestroy(&fs);
       
  2930 		Session().CleanupEntryPop();
       
  2931 		Session().RemoveEntry(id);	
       
  2932 		return EFail;	
       
  2933 		}
       
  2934 	if(fields11.Length() != 0)
       
  2935 		{
       
  2936 		CleanupStack::PopAndDestroy(&fs);
       
  2937 		Session().CleanupEntryPop();
       
  2938 		Session().RemoveEntry(id);	
       
  2939 		return EFail;	
       
  2940 		}
       
  2941 	
       
  2942 	// Message body...
       
  2943 	CSmsBufferBase& body2 = iSmsHeader->Message().Buffer();
       
  2944 	TInt length2 = body2.Length();
       
  2945 	HBufC* buf2 = HBufC::NewLC(length2);
       
  2946 	TPtr bufPtr2(buf2->Des());
       
  2947 	body2.Extract(bufPtr2, 0, length2);
       
  2948 	
       
  2949 	if(bufPtr2.Compare(KTestEmailBody2) != 0)
       
  2950 		{
       
  2951 		CleanupStack::PopAndDestroy(2,buf2);
       
  2952 		Session().CleanupEntryPop();
       
  2953 		Session().RemoveEntry(id);	
       
  2954 		return EFail;		
       
  2955 		}
       
  2956 	
       
  2957 //	delete email1;
       
  2958 	CleanupStack::PopAndDestroy(buf2);
       
  2959 	
       
  2960 	CleanupStack::PopAndDestroy(&fs);
       
  2961 
       
  2962 	Session().CleanupEntryPop();
       
  2963 	Session().RemoveEntry(id);
       
  2964 	
       
  2965 	iTestStep.INFO_PRINTF1(_L("Test CSmsHeader Passed."));
       
  2966 	
       
  2967 	return EPass;
       
  2968 	}
       
  2969 
       
  2970 _LIT(KGetDescriptionTestMessage, "Finland to win the ice hockey world champs");
       
  2971 
       
  2972 #include <emsuserpromptie.h>
       
  2973 #include <emssoundie.h>
       
  2974 _LIT8(KUserMelody, 	"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
       
  2975 	  "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"); // Melody file
       
  2976 
       
  2977 _LIT(KTestEmsVariousMsg1,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
       
  2978 
       
  2979 TVerdict CSmutTest::TestSmsEmsExtensionsL()
       
  2980 // Test the modifications for EMS
       
  2981 	{
       
  2982 	
       
  2983 	iTestStep.INFO_PRINTF1(_L("Testing EMS Extensions..."));
       
  2984 	
       
  2985 	// Set up a standard sms message first
       
  2986 	iRichText->Reset();
       
  2987 	iRichText->InsertL(0, KTestEmsVariousMsg1);
       
  2988 	// Make a Deliver so we can get at the protocol identifier
       
  2989 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText);
       
  2990 	CleanupStack::PushL(header);
       
  2991 
       
  2992 	// Create 2 EMS Melody objects followed by a User Prompt Indicator
       
  2993 
       
  2994 	// Create first Melody EMS object
       
  2995 	CEmsSoundIE* object = CEmsSoundIE::NewL(KUserMelody());
       
  2996 	CleanupStack::PushL(object);	
       
  2997 	// Insert the sound object after the 5th byte of the message
       
  2998 	object->SetStartPosition(5);
       
  2999 	// Add it to the CSmsMessage
       
  3000 	header->Message().AddEMSInformationElementL(*object);
       
  3001 	CleanupStack::PopAndDestroy(object);	
       
  3002 
       
  3003 	// Create a second Melody EMS object 
       
  3004 	CEmsSoundIE* object2 = CEmsSoundIE::NewL(KUserMelody());
       
  3005 	CleanupStack::PushL(object2);	
       
  3006 	// Insert the sound object after the 5th byte of the message
       
  3007 	object2->SetStartPosition(5);
       
  3008 	// Add it to the CSmsMessage
       
  3009 	header->Message().AddEMSInformationElementL(*object2);
       
  3010 	CleanupStack::PopAndDestroy(object2);
       
  3011 
       
  3012 	// Create a user prompt indicator and tell it there are 2 EMS objects
       
  3013 	CEmsUserPrompt* prompt = CEmsUserPrompt::NewL(2);
       
  3014 	CleanupStack::PushL(prompt);	
       
  3015 	// Add it after the 5th byte of the message
       
  3016 	prompt->SetStartPosition(5);
       
  3017 	// Add it to the CSmsMessage
       
  3018 	header->Message().AddEMSInformationElementL(*prompt);
       
  3019 	CleanupStack::PopAndDestroy(prompt);
       
  3020  
       
  3021 	// Test the TMsvSmsEntry derived class
       
  3022 	TMsvSmsEntry entry;
       
  3023 	// Check the Existing sms message for User Prompt indicator
       
  3024 	const RPointerArray<const CEmsInformationElement>&  emsElements= header->Message().GetEMSInformationElementsL();
       
  3025 	// Loop through the array checking for a user prompt indicator element
       
  3026 	for(TInt i=0;i<emsElements.Count();i++)
       
  3027 		{
       
  3028 		if(emsElements[i]->Identifier() == CSmsInformationElement::ESmsEnhancedUserPromptIndicator)
       
  3029 			{
       
  3030 			// Set user prompt indicator bit in iMtmData2
       
  3031 			entry.SetUserPromptIndicator(ETrue);
       
  3032 			break;
       
  3033 			}
       
  3034 		}
       
  3035 	// Check the user prompt indicator is set
       
  3036 	if(!entry.UserPromptIndicator())
       
  3037 		{
       
  3038 		iTestStep.ERR_PRINTF1(_L("Cannot set user prompt."));
       
  3039 		CleanupStack::PopAndDestroy(header);
       
  3040 		return EFail;
       
  3041 		}
       
  3042 	// Check we can clear it
       
  3043 	entry.SetUserPromptIndicator(EFalse);
       
  3044 	if(entry.UserPromptIndicator())
       
  3045 		{
       
  3046 		iTestStep.ERR_PRINTF1(_L("Cannot clear user prompt."));
       
  3047 		CleanupStack::PopAndDestroy(header);
       
  3048 		return EFail;	
       
  3049 		}
       
  3050 
       
  3051 	// Convenient reference to PDU
       
  3052 	CSmsDeliver& pdu = STATIC_CAST(CSmsDeliver&,header->Message().SmsPDU());
       
  3053 	// Set up the Protocol Identifier to read back
       
  3054 	pdu.SetPIDType(TSmsProtocolIdentifier::ESmsPIDShortMessageType);
       
  3055 	pdu.SetShortMessageType(TSmsProtocolIdentifier::ESmsReplaceShortMessageType1);
       
  3056 
       
  3057 	// Read from the pdu and set the TMsvSmsEntry copy
       
  3058 	entry.SetProtocolIdentifier(*pdu.ProtocolIdentifier());
       
  3059 	// Read it back and check the value
       
  3060 	if(entry.ProtocolIdentifier() != *pdu.ProtocolIdentifier())
       
  3061 		{
       
  3062 		iTestStep.ERR_PRINTF1(_L("TMsvSmsEntry::ProtocolIdentifier corrupt."));
       
  3063 		CleanupStack::PopAndDestroy(header);
       
  3064 		return EFail;
       
  3065 		}
       
  3066 
       
  3067 	CleanupStack::PopAndDestroy(); //header
       
  3068 	
       
  3069 	iTestStep.INFO_PRINTF1(_L("Test EMS Extensions Passed."));
       
  3070 	
       
  3071 	return EPass;
       
  3072 
       
  3073 	}
       
  3074 
       
  3075 TVerdict CSmutTest::TestSmsUtilitiesL()
       
  3076 	{
       
  3077 	iTestStep.INFO_PRINTF1(_L("Testing TSmsUtilities...."));
       
  3078 
       
  3079 	iRichText->Reset();
       
  3080 	iRichText->InsertL(0, KGetDescriptionTestMessage);
       
  3081 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText);
       
  3082 	CleanupStack::PushL(header);
       
  3083 
       
  3084 	if(!TestSmsUtilities1L(*header))
       
  3085 		{
       
  3086 		CleanupStack::PopAndDestroy(header); //header
       
  3087 		return EFail;	
       
  3088 		}
       
  3089 		
       
  3090 	if(!TestSmsUtilities2L(*header))
       
  3091 		{
       
  3092 		CleanupStack::PopAndDestroy(header); //header
       
  3093 		return EFail;	
       
  3094 		}
       
  3095 		
       
  3096 	if(!TestSmsUtilities3L(*header))
       
  3097 		{
       
  3098 		CleanupStack::PopAndDestroy(header); //header
       
  3099 		return EFail;	
       
  3100 		}
       
  3101 
       
  3102 	CleanupStack::PopAndDestroy(); //header
       
  3103 	
       
  3104 	iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities Passed."));
       
  3105 	
       
  3106 	return EPass;
       
  3107 	}
       
  3108 
       
  3109 TBool CSmutTest::TestSmsUtilities1L(CSmsHeader& aHeader)
       
  3110 /**
       
  3111  * @test Tests TSmsUtilities::GetDescription()
       
  3112  */
       
  3113 	{
       
  3114 	
       
  3115 	iTestStep.INFO_PRINTF1(_L("Testing TSmsUtilities::GetDescription() - use varying values to test trucation"));
       
  3116 
       
  3117 	RResourceFile resFile;
       
  3118 	iSmsTest.OpenResourceFileL(KSmsResourceFile, resFile);
       
  3119 	CleanupClosePushL(resFile);
       
  3120 
       
  3121 	//Test GetDescription()
       
  3122 
       
  3123 	TPtrC buf(KGetDescriptionTestMessage);
       
  3124 	const TInt maxLength = buf.Length();
       
  3125 	HBufC* desBuf = HBufC::NewLC(maxLength);
       
  3126 	TPtr desc = desBuf->Des();
       
  3127 
       
  3128 	for( TInt length=1; length <= maxLength; ++length )
       
  3129 		{
       
  3130 		iTestStep.INFO_PRINTF2(_L("-> trucating to length %d"), length);
       
  3131 
       
  3132 		desc.Zero();
       
  3133 		User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc, length));
       
  3134 
       
  3135 		iTestStep.INFO_PRINTF2(_L("-> GetDescription() : %S"), &desc);
       
  3136 		
       
  3137 		if(desc.Length()>length)
       
  3138 			{
       
  3139 			CleanupStack::PopAndDestroy(2,desBuf);
       
  3140 			return EFalse;	
       
  3141 			}
       
  3142 		if(desc != buf.Left(desc.Length()) ) //this won't work if buf contains CEditableText::EParagraphDelimiter
       
  3143 			{
       
  3144 			CleanupStack::PopAndDestroy(2,desBuf);
       
  3145 			return EFalse;		
       
  3146 			}
       
  3147 		}
       
  3148 	desc.Zero();
       
  3149 
       
  3150 	//Test Special Message Indication
       
  3151 
       
  3152 	iTestStep.INFO_PRINTF1(_L("Testing Special Message Indications..."));
       
  3153 
       
  3154 	CSmsPDU& pdu = aHeader.Message().SmsPDU();
       
  3155 	CSmsUserData& userData = pdu.UserData();
       
  3156 	TBuf8<2> msgInd;
       
  3157 	msgInd.Copy(_L("AA"));
       
  3158 
       
  3159 	//Add information element
       
  3160 	msgInd[0] = TSmsUtilities::EEmailMessageWaiting;
       
  3161 	msgInd[1] = 0x00000001; //1 message
       
  3162 
       
  3163 	iTestStep.INFO_PRINTF1(_L("\tAdding information element (Email) to UD"));
       
  3164 	userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd);
       
  3165 	User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc));
       
  3166 	if(!CheckDescriptionL(resFile, R_MESSAGE_INDICATION_EMAIL_ONE, desc, 2))
       
  3167 		{
       
  3168 		CleanupStack::PopAndDestroy(2,desBuf);
       
  3169 		return EFalse;	
       
  3170 		}
       
  3171 
       
  3172 	// Set the maximum length of desc to be less than the description.
       
  3173 	// The description should truncate to fit into desc.
       
  3174 	User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc, 10));
       
  3175 	if(desc.Length() != 10) //Check that the Length of desc is the specified max length.
       
  3176 		{
       
  3177 		CleanupStack::PopAndDestroy(2,desBuf);
       
  3178 		return EFalse;	
       
  3179 		}
       
  3180 
       
  3181 	if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EVoiceMessageWaiting, R_MESSAGE_INDICATION_VOICEMAIL_ONE))
       
  3182 		{
       
  3183 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3184 		return EFalse;	
       
  3185 		}
       
  3186 	
       
  3187 	if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EFaxMessageWaiting, R_MESSAGE_INDICATION_FAX_ONE))
       
  3188 		{
       
  3189 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3190 		return EFalse;	
       
  3191 		}
       
  3192 	if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EEmailMessageWaiting, R_MESSAGE_INDICATION_EMAIL_ONE))
       
  3193 		{
       
  3194 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3195 		return EFalse;	
       
  3196 		}
       
  3197 	if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EOtherMessageWaiting, R_MESSAGE_INDICATION_OTHER_ONE))
       
  3198 		{
       
  3199 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3200 		return EFalse;		
       
  3201 		}
       
  3202 			
       
  3203 	//Test video message waiting indication
       
  3204 	iTestStep.INFO_PRINTF1(_L("Testing video message waiting indications..."));	
       
  3205 	if(!TestVideoMessageIndicationPduL(resFile, aHeader, R_MESSAGE_INDICATION_VIDEOMESSAGE_ONE))
       
  3206 		{
       
  3207 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3208 		return EFalse;		
       
  3209 		}
       
  3210 	
       
  3211 	//Test enhanced voice mail waiting indication
       
  3212 	iTestStep.INFO_PRINTF1(_L("Testing enhanced voice mail indications..."));	
       
  3213 	if(!TestEnhancedVoiceMailIndicationPduL(resFile, aHeader, R_MESSAGE_INDICATION_ENHANCED_VOICEMAIL_ONE))
       
  3214 		{
       
  3215 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3216 		return EFalse;		
       
  3217 		}
       
  3218 	
       
  3219 	//Test multiple indications.
       
  3220 	iTestStep.INFO_PRINTF1(_L("Testing multiple indications..."));
       
  3221 	//Add a video message waiting notification (9 video messages)
       
  3222 	CSmsSpecialSMSMessageOperations& operations = STATIC_CAST(CSmsSpecialSMSMessageOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication));
       
  3223 	
       
  3224 	TBool toStore=ETrue;
       
  3225 	TUint8 messageCount=9;
       
  3226 	TUint8 totalMessageCount=messageCount;
       
  3227 	TSmsMessageIndicationType messageIndicationType=EGsmSmsExtendedMessageTypeWaiting;
       
  3228 	TExtendedSmsIndicationType extendedType=EGsmSmsVideoMessageWaiting;
       
  3229 	TSmsMessageProfileType messageProfileType=EGsmSmsProfileId1;
       
  3230 	
       
  3231 	operations.RemoveAllSpecialMessageIndicationsL();
       
  3232 	operations.AddSpecialMessageIndicationL(toStore,messageIndicationType,
       
  3233 								extendedType,messageProfileType,messageCount);
       
  3234 	//Add an enhanced voicemail notification (5 enhanced voice mails)
       
  3235 	CSmsEnhancedVoiceMailOperations& enhancedOperations = STATIC_CAST(CSmsEnhancedVoiceMailOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation));
       
  3236 	enhancedOperations.RemoveEnhancedVoiceMailIEL();
       
  3237 	//Create CEnhancedVoiceMailNotification
       
  3238 	CEnhancedVoiceMailNotification* enhancedVoiceMailNotification=CEnhancedVoiceMailNotification::NewL();
       
  3239 	CleanupStack::PushL(enhancedVoiceMailNotification);
       
  3240 	messageCount=5;
       
  3241 	totalMessageCount+=messageCount;
       
  3242 	enhancedVoiceMailNotification->SetNumberOfVoiceMessages(messageCount);
       
  3243 	enhancedOperations.AddEnhancedVoiceMailIEL(*enhancedVoiceMailNotification);
       
  3244 	CleanupStack::PopAndDestroy(enhancedVoiceMailNotification);
       
  3245 	
       
  3246 	//Add an email message waiting notification (1 email)
       
  3247 	msgInd[0] = TSmsUtilities::EEmailMessageWaiting;
       
  3248 	msgInd[1] = 0x00000001; 
       
  3249 	userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd);
       
  3250 	totalMessageCount++;
       
  3251 	
       
  3252 	//Add a fax waiting notification (2 faxes)
       
  3253 	msgInd[0] = TSmsUtilities::EFaxMessageWaiting;
       
  3254 	msgInd[1] = 0x00000002; 
       
  3255 	userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd);
       
  3256 	totalMessageCount+=2;
       
  3257 	
       
  3258 	//Add a voice mail waiting notification (3 voice mails)
       
  3259 	msgInd[0] = TSmsUtilities::EVoiceMessageWaiting;
       
  3260 	msgInd[1] = 0x00000003; 
       
  3261 	userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd);
       
  3262 	totalMessageCount+=3;
       
  3263 	
       
  3264 	User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc));	
       
  3265 	if(!CheckDescriptionL(resFile, R_MESSAGE_INDICATION_OTHER_MANY, desc, totalMessageCount))
       
  3266 		{
       
  3267 		CleanupStack::PopAndDestroy(2, &resFile);
       
  3268 		return EFalse;	
       
  3269 		}
       
  3270 	iTestStep.INFO_PRINTF1(_L("Passed"));
       
  3271 
       
  3272 	CleanupStack::PopAndDestroy(2, &resFile);
       
  3273 	
       
  3274 	return ETrue;
       
  3275 	}
       
  3276 
       
  3277 CSmsMessage* CSmutTest::CreateSmsMessageLC(const TDesC8& aHexPdu) const
       
  3278 	{
       
  3279 	HBufC8* binaryPdu = ConvertToBinaryLC(aHexPdu);
       
  3280 	TGsmSms pdu;
       
  3281 	pdu.SetPdu(*binaryPdu);
       
  3282 	CleanupStack::PopAndDestroy(binaryPdu);
       
  3283 	CSmsMessage* message = CSmsMessage::NewL(iSmsTest.FileSession(), pdu, CSmsBuffer::NewL());
       
  3284 	CleanupStack::PushL(message);
       
  3285 	return message;
       
  3286 	}
       
  3287 
       
  3288 HBufC8* CSmutTest::ConvertToBinaryLC(const TDesC8& aHex) const
       
  3289 	{
       
  3290 	const TInt len = aHex.Length();
       
  3291 	if (len % 2 != 0)
       
  3292 		User::Leave(KErrArgument);
       
  3293 
       
  3294 	HBufC8* pdu = HBufC8::NewLC(len / 2);
       
  3295 	TPtr8 ptr(pdu->Des());
       
  3296 
       
  3297 	for (TInt i = 0; i < len; i += 2)
       
  3298 		{
       
  3299 		TLex8 lex(aHex.Mid(i, 2));
       
  3300 		TUint8 val;
       
  3301 		User::LeaveIfError(lex.Val(val, EHex));
       
  3302 		ptr.Append(val);
       
  3303 		}
       
  3304 
       
  3305 	return pdu;
       
  3306 	}
       
  3307 
       
  3308 _LIT(KGetDetailsResult, "\t\tNum In: \"%S\" Name Out: \"%S\"");
       
  3309 
       
  3310 TBool CSmutTest::TestSmsUtilities2L(CSmsHeader& aHeader)
       
  3311 	{
       
  3312 	//Test GetDetails
       
  3313 
       
  3314 	iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities::GetDetails()"));
       
  3315 
       
  3316 	_LIT(KLongTel, "+378458932945284754456302945754938539");
       
  3317 
       
  3318 	_LIT(KMikkoTel, "+358503367709");
       
  3319 	_LIT(KMikkoFirst, "Mikko");
       
  3320 	_LIT(KMikkoLast, "Rintala");
       
  3321 	_LIT(KMikkoEmail, "mikko@nokia.com");
       
  3322 
       
  3323 	_LIT(KUnqualifiedTel, "8503367710");
       
  3324 	_LIT(KUnqualifiedTel1, "+358503367710");
       
  3325 	_LIT(KUnqualifiedFirst, "Unq");
       
  3326 	_LIT(KUnqualifiedLast, "Wallified");
       
  3327 	_LIT(KUnqualifiedEmail, "unqalified@diysurgery.com");
       
  3328 
       
  3329 	//	_LIT(KAnthonyTel, " + 4 "); //is valid
       
  3330 	_LIT(KAnthonyTel, "+ 7 "); //is valid
       
  3331 	_LIT(KAnthonyFirst, "Anthony");
       
  3332 	_LIT(KAnthonyLast, "Alexander");
       
  3333 	_LIT(KAnthonyEmail, "test@symbian.com");
       
  3334 
       
  3335 	_LIT(KHarriTel, "+8"); //is valid
       
  3336 	_LIT(KHarriFirst, "HarriHarriHarriHarriHarriHarriHarri");
       
  3337 	_LIT(KHarriLast, "RäisänenRäisänenRäisänenRäisänenRäisänen");
       
  3338 	_LIT(KHarriEmail, "harri@nokia.com");
       
  3339 
       
  3340 	_LIT(KDupTel, "+44207435676");
       
  3341 	_LIT(KDupFirst1, "Keval");
       
  3342 	_LIT(KDupLast1, "Pindoria");
       
  3343 	_LIT(KDupFirst2, "Jackie");
       
  3344 	_LIT(KDupLast2, "Chan");
       
  3345 	
       
  3346 	_LIT(KBadTel1, "This is a bad Telephone");
       
  3347 	_LIT(KBadTel2, " 5  ");
       
  3348 	_LIT(KBadTel3, "5+");
       
  3349 	_LIT(KBadTel4, "*5565434556");
       
  3350 
       
  3351 	_LIT(KBadFirst, "BadFirstName");
       
  3352 	_LIT(KBadLast, "BadLastName");
       
  3353 
       
  3354 	_LIT(KNoNameTel, "+449005434");
       
  3355 
       
  3356 	_LIT(KDummy, "+44444");
       
  3357 
       
  3358 	TRAPD(err, iSmsTest.DeleteContactsFileL());
       
  3359 	
       
  3360 	if(err != KErrNotFound && err != KErrNone)
       
  3361 		{
       
  3362 		return EFalse;	
       
  3363 		}
       
  3364 
       
  3365 	iTestStep.INFO_PRINTF1(_L("\tTesting without contacts"));
       
  3366 
       
  3367 	//Simple test
       
  3368 	TPtrC testTel(KMikkoTel);
       
  3369 	TBuf<KSmsDetailsLength> details;
       
  3370 
       
  3371 	aHeader.Message().SetToFromAddressL(testTel);
       
  3372 	TSmsUtilities::GetDetails(iSmsTest.FileSession(), aHeader.Message(), details);
       
  3373 	iTestStep.INFO_PRINTF3(KGetDetailsResult, &testTel, &details);
       
  3374 	if(testTel.FindF(details) == KErrNotFound) //details should contain testTel as there is no contact.
       
  3375 		{
       
  3376 		return EFalse;	
       
  3377 		}
       
  3378 
       
  3379 	if(!TestInvalidContact(testTel, details))
       
  3380 		{
       
  3381 		return EFalse;		
       
  3382 		}
       
  3383 
       
  3384 	testTel.Set(KAnthonyTel);
       
  3385 	aHeader.Message().SetToFromAddressL(testTel);
       
  3386 	err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aHeader.Message(), details);
       
  3387 	iTestStep.INFO_PRINTF3(KGetDetailsResult, &testTel, &details);
       
  3388 	if(testTel.FindF(details) == KErrNotFound) //details should contain testTel as there is no contact.
       
  3389 		{
       
  3390 		return EFalse;		
       
  3391 		}
       
  3392 	if(err != KErrNone)
       
  3393 		{
       
  3394 		return EFalse;	
       
  3395 		}
       
  3396 
       
  3397 	if(!TestInvalidContact(testTel, details))
       
  3398 		{
       
  3399 		return EFalse;		
       
  3400 		}
       
  3401 
       
  3402 	// Testing with long telephone number. 
       
  3403 	// The telephone number should truncate to fit into details.
       
  3404 	if(!TestInvalidContact(KLongTel, details))
       
  3405 		{
       
  3406 		return EFalse;		
       
  3407 		}
       
  3408 	if(details.Length() != KSmsDetailsLength) //Length of details should be the default max length.
       
  3409 		{
       
  3410 		return EFalse;	
       
  3411 		}
       
  3412 
       
  3413 	//Add contacts
       
  3414 
       
  3415 	iTestStep.INFO_PRINTF1(_L("\tAdding Contacts"));
       
  3416 
       
  3417 	//Adding good telephone numbers
       
  3418 
       
  3419 	TContactItemId contId = iSmsTest.CreateContactL(KAnthonyFirst, KAnthonyLast, KAnthonyTel, KAnthonyEmail);
       
  3420 	if(contId == KNullContactId)
       
  3421 		{
       
  3422 		return EFalse;	
       
  3423 		}
       
  3424 
       
  3425 	contId = iSmsTest.CreateContactL(KMikkoFirst, KMikkoLast, KMikkoTel, KMikkoEmail);
       
  3426 	if(contId == KNullContactId)
       
  3427 		{
       
  3428 		return EFalse;	
       
  3429 		}
       
  3430 
       
  3431 	contId = iSmsTest.CreateContactL(KUnqualifiedFirst, KUnqualifiedLast, KUnqualifiedTel, KUnqualifiedEmail);
       
  3432 	if(contId == KNullContactId)
       
  3433 		{
       
  3434 		return EFalse;	
       
  3435 		}
       
  3436 
       
  3437 	contId = iSmsTest.CreateContactL(KHarriFirst, KHarriLast, KHarriTel, KHarriEmail);
       
  3438 	if(contId == KNullContactId)
       
  3439 		{
       
  3440 		return EFalse;	
       
  3441 		}
       
  3442 
       
  3443 	//Adding a duplicate telephone
       
  3444 
       
  3445 	contId = iSmsTest.CreateContactL(KDupFirst1, KDupLast1, KDupTel, KNullDesC);
       
  3446 	if(contId == KNullContactId)
       
  3447 		{
       
  3448 		return EFalse;	
       
  3449 		}
       
  3450 
       
  3451 	contId = iSmsTest.CreateContactL(KDupFirst2, KDupLast2, KDupTel, KNullDesC);
       
  3452 	if(contId == KNullContactId)
       
  3453 		{
       
  3454 		return EFalse;	
       
  3455 		}
       
  3456 
       
  3457 	//Adding bad telephone numbers
       
  3458 
       
  3459 	contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel1, KNullDesC);
       
  3460 	if(contId == KNullContactId)
       
  3461 		{
       
  3462 		return EFalse;	
       
  3463 		}
       
  3464 
       
  3465 	contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel2, KNullDesC);
       
  3466 	if(contId == KNullContactId)
       
  3467 		{
       
  3468 		return EFalse;	
       
  3469 		}
       
  3470 
       
  3471 	contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel3, KNullDesC);
       
  3472 	if(contId == KNullContactId)
       
  3473 		{
       
  3474 		return EFalse;	
       
  3475 		}
       
  3476 
       
  3477 	contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel4, KNullDesC);
       
  3478 	if(contId == KNullContactId)
       
  3479 		{
       
  3480 		return EFalse;	
       
  3481 		}
       
  3482 
       
  3483 	//Adding no name contact
       
  3484 
       
  3485 	contId = iSmsTest.CreateContactL(KNullDesC, KNullDesC, KNoNameTel, KNullDesC);
       
  3486 	if(contId == KNullContactId)
       
  3487 		{
       
  3488 		return EFalse;	
       
  3489 		}
       
  3490 
       
  3491 	iTestStep.INFO_PRINTF1(_L("\tTesting with valid telephone numbers"));
       
  3492 
       
  3493 	if(!TestValidTel(KAnthonyTel, KAnthonyFirst, KAnthonyLast, KNullDesC, details))
       
  3494 		{
       
  3495 		return EFalse;	
       
  3496 		}
       
  3497 		
       
  3498 	if(!TestValidTel(KMikkoTel, KMikkoFirst, KMikkoLast, KNullDesC, details))
       
  3499 		{
       
  3500 		return EFalse;	
       
  3501 		}
       
  3502 	// Test below was added for INC040050. The number of digits matched
       
  3503 	// against in GetDetails changed and resulted in undesirable behaviour
       
  3504 	// when searching for an unqualified number with a fully qualified number.
       
  3505 	if(!TestValidTel(KUnqualifiedTel1, KUnqualifiedFirst, KUnqualifiedLast, KNullDesC, details))
       
  3506 		{
       
  3507 		return EFalse;	
       
  3508 		}
       
  3509 	if(!TestValidTel(KHarriTel, _L("Räisänen"), KNullDesC, _L("Harri"), details))
       
  3510 		{
       
  3511 		return EFalse;	
       
  3512 		}
       
  3513 
       
  3514 	iTestStep.INFO_PRINTF1(_L("\tTesting with invalid telephone numbers"));
       
  3515 
       
  3516 	if(!TestInvalidTelephone(KBadTel1, details))
       
  3517 		{
       
  3518 		return EFalse;	
       
  3519 		}
       
  3520 	if(!TestInvalidTelephone(KBadTel2, details))
       
  3521 		{
       
  3522 		return EFalse;		
       
  3523 		}
       
  3524 	if(!TestInvalidTelephone(KBadTel3, details))
       
  3525 		{
       
  3526 		return EFalse;		
       
  3527 		}
       
  3528 	if(!TestInvalidTelephone(KBadTel4, details))
       
  3529 		{
       
  3530 		return EFalse;		
       
  3531 		}
       
  3532 
       
  3533 	iTestStep.INFO_PRINTF1(_L("\tTesting with duplicate telephone numbers"));
       
  3534 
       
  3535 	if(!TestDuplicateContact(KDupTel, details))
       
  3536 		{
       
  3537 		return EFalse;	
       
  3538 		}
       
  3539 
       
  3540 	iTestStep.INFO_PRINTF1(_L("\tTesting No Names telephone number"));
       
  3541 
       
  3542 	if(!TestInvalidContact(KNoNameTel, details))
       
  3543 		{
       
  3544 		return EFalse;	
       
  3545 		}
       
  3546 	if(!TestInvalidContact(KDummy, details))
       
  3547 		{
       
  3548 		return EFalse;	
       
  3549 		}
       
  3550 
       
  3551 	iTestStep.INFO_PRINTF1(_L("Passed"));
       
  3552 	
       
  3553 	return ETrue;
       
  3554 	}
       
  3555 
       
  3556 TBool CSmutTest::TestValidTel(const TDesC& aTel, const TDesC& aExpect1, const TDesC& aExpect2, const TDesC& aNotExpect, TDes& rDetails)
       
  3557 	{
       
  3558 	TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, rDetails);
       
  3559 	iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &rDetails);
       
  3560 
       
  3561 	if (aExpect1.Length())
       
  3562 		{
       
  3563 		if(rDetails.FindF(aExpect1) == KErrNotFound)
       
  3564 			{
       
  3565 			return EFalse;	
       
  3566 			}	
       
  3567 		}
       
  3568 		
       
  3569 
       
  3570 	if (aExpect2.Length())
       
  3571 		{
       
  3572 		if(rDetails.FindF(aExpect2) == KErrNotFound)
       
  3573 			{
       
  3574 			return EFalse;	
       
  3575 			}
       
  3576 		}
       
  3577 		
       
  3578 
       
  3579 	if (aNotExpect.Length())
       
  3580 		{
       
  3581 		if(rDetails.FindF(aNotExpect) != KErrNotFound)
       
  3582 			{
       
  3583 			return EFalse;		
       
  3584 			}	
       
  3585 		}
       
  3586 		
       
  3587 	if(err != KErrNone)
       
  3588 		{
       
  3589 		return EFalse;
       
  3590 		}
       
  3591 	
       
  3592 	return ETrue;
       
  3593 	}
       
  3594 
       
  3595 TBool CSmutTest::TestInvalidTelephone(const TDesC& aTel, TDes& aDetails)
       
  3596 	{
       
  3597 	TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails);
       
  3598 	iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &aDetails);
       
  3599 	if(aTel.FindF(aDetails) == KErrNotFound)	//aDetails should contain aTel as aTel is invalid.
       
  3600 		{
       
  3601 		return EFalse;	
       
  3602 		}
       
  3603 	if(err != KErrNone)
       
  3604 		{
       
  3605 		return EFalse;	
       
  3606 		}
       
  3607 	
       
  3608 	return ETrue;
       
  3609 	}	
       
  3610 
       
  3611 TBool CSmutTest::TestInvalidContact(const TDesC& aTel, TDes& aDetails)
       
  3612 	{
       
  3613 	TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails);
       
  3614 	iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &aDetails);
       
  3615 	
       
  3616 	if(aTel.FindF(aDetails) == KErrNotFound) //aDetails should contain aTel as the contact is invalid.
       
  3617 		{
       
  3618 		return EFalse;
       
  3619 		}
       
  3620 	if(err != KErrNone)
       
  3621 		{
       
  3622 		return EFalse;	
       
  3623 		}
       
  3624 	return ETrue;
       
  3625 	}
       
  3626 
       
  3627 TBool CSmutTest::TestDuplicateContact(const TDesC& aTel, TDes& aDetails)
       
  3628 	{
       
  3629 	TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails);
       
  3630 	iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &aDetails);
       
  3631 	if(aTel.FindF(aDetails) == KErrNotFound) //aDetails should contain aTel as there is duplicate contact.
       
  3632 		{
       
  3633 		return EFalse;	
       
  3634 		}
       
  3635 	if(err != KErrNone)
       
  3636 		{
       
  3637 		return EFalse;	
       
  3638 		}
       
  3639 	
       
  3640 	return ETrue;
       
  3641 	}
       
  3642 
       
  3643 TBool CSmutTest::TestSmsUtilities3L(CSmsHeader& aHeader)
       
  3644 	{
       
  3645 	iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities::ServiceIdL()"));
       
  3646 
       
  3647 	TMsvId id2 = KMsvNullIndexEntryId;
       
  3648 	// First tested function is ServiceIdL()
       
  3649 	TSmsUtilities::ServiceIdL(*iSmsTest.iMsvEntry, id2);
       
  3650 	if(id2 != iSmsTest.iSmsServiceId)
       
  3651 		{
       
  3652 		return EFalse;	
       
  3653 		}
       
  3654 	iTestStep.INFO_PRINTF1(_L("\tPassed"));
       
  3655 
       
  3656 	iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities::PopulateMsgEntry()"));
       
  3657 	TMsvEntry entry;
       
  3658 	TSmsUtilities::PopulateMsgEntry(entry,aHeader.Message(), iSmsTest.iSmsServiceId);
       
  3659 	// todo More tests
       
  3660 	iTestStep.INFO_PRINTF1(_L("\tPassed"));
       
  3661 	
       
  3662 	return ETrue;
       
  3663 	}
       
  3664 
       
  3665 TBool CSmutTest::TestSpecialSmsMessageIndicationPduL(RResourceFile& aResFile, TSmsUtilities::TSmsUtilitiesSpecialMessageType aMessageType, TInt aId)
       
  3666 	{
       
  3667 	iTestStep.INFO_PRINTF2(_L("\tTestSpecialSmsMessageIndicationPduL Type=%d..."), aMessageType);
       
  3668 
       
  3669 	const TUint8 KMaxCount = 0xFF;
       
  3670 	for (TUint8 i = 0; i < KMaxCount; i++)
       
  3671 		{
       
  3672 		TInt resId = aId;
       
  3673 		if (i != 1)
       
  3674 			resId++;
       
  3675 
       
  3676 		if(!TestSpecialSmsMessageIndicationPduL(aResFile, STATIC_CAST(TUint8, aMessageType), i, resId))
       
  3677 			{
       
  3678 			return EFalse;	
       
  3679 			}
       
  3680 		if(!TestSpecialSmsMessageIndicationPduL(aResFile, STATIC_CAST(TUint8, aMessageType | 0x80), i, resId))
       
  3681 			{
       
  3682 			return EFalse;	
       
  3683 			}
       
  3684 		}
       
  3685 
       
  3686 	iTestStep.INFO_PRINTF1(_L("Passed"));
       
  3687 	
       
  3688 	return ETrue;
       
  3689 	}
       
  3690 
       
  3691 TBool CSmutTest::TestSpecialSmsMessageIndicationPduL(RResourceFile& aResFile, TUint8 aMessageType, TUint8 aMessageCount, TInt aId)
       
  3692 	{
       
  3693 	_LIT8(KFaxIndicationPdu, "440B916407586704F900002010011153710406040102810200");
       
  3694 	const TInt KIndicationPosition = 44;
       
  3695 	TBuf<KSmsDescriptionLength> desc;
       
  3696 
       
  3697 	//Replace the Message Indication in this PDU
       
  3698 	RMobileSmsMessaging::TMobileSmsGsmTpdu miPdu(KFaxIndicationPdu);
       
  3699 	_LIT8(KFormat, "%02X%02X");
       
  3700 	TPtr8 ptr(&miPdu[KIndicationPosition], 0, 4);
       
  3701 	ptr.AppendFormat(KFormat, aMessageType, aMessageCount);
       
  3702 
       
  3703 
       
  3704 	CSmsMessage* msg = CreateSmsMessageLC(miPdu);
       
  3705 	User::LeaveIfError(TSmsUtilities::GetDescription(*msg, desc));
       
  3706 	CleanupStack::PopAndDestroy(msg);
       
  3707 	
       
  3708 	if (aMessageCount != 1)
       
  3709 		return CheckDescriptionL(aResFile, aId, desc, aMessageCount);
       
  3710 	else
       
  3711 		return CheckDescriptionL(aResFile, aId, desc);
       
  3712 	}	
       
  3713 	
       
  3714 TBool CSmutTest::TestVideoMessageIndicationPduL(RResourceFile& aResFile, CSmsHeader& aHeader, TInt aId)
       
  3715 	{
       
  3716 	//remove any enhanced voice mail indications
       
  3717 	CSmsEnhancedVoiceMailOperations& enhancedOperations = STATIC_CAST(CSmsEnhancedVoiceMailOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation));
       
  3718 	if(enhancedOperations.ContainsEnhancedVoiceMailIEL())
       
  3719 		{
       
  3720 		enhancedOperations.RemoveEnhancedVoiceMailIEL();	
       
  3721 		}
       
  3722 
       
  3723 	const TUint8 KMaxCount = 0xFF;
       
  3724 	for (TUint8 i = 0; i < KMaxCount; i++)
       
  3725 		{
       
  3726 		TInt resId = aId;
       
  3727 		if (i != 1)
       
  3728 			resId++;
       
  3729 
       
  3730 		if(!TestVideoMessageIndicationPduL(aResFile, i, aHeader, resId))
       
  3731 			{
       
  3732 			return EFalse;	
       
  3733 			}
       
  3734 		}
       
  3735 
       
  3736 	iTestStep.INFO_PRINTF1(_L("Passed"));
       
  3737 	
       
  3738 	return ETrue;
       
  3739 	}
       
  3740 	
       
  3741 
       
  3742 TBool CSmutTest::TestVideoMessageIndicationPduL(RResourceFile& aResFile, TUint8 aMessageCount, CSmsHeader& aHeader, TInt aId)
       
  3743 	{
       
  3744 	//Get the operations
       
  3745 	CSmsSpecialSMSMessageOperations& operations = STATIC_CAST(CSmsSpecialSMSMessageOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication));
       
  3746 	
       
  3747 	TBool toStore=ETrue;
       
  3748 	TSmsMessageIndicationType messageIndicationType=EGsmSmsExtendedMessageTypeWaiting;
       
  3749 	TExtendedSmsIndicationType extendedType=EGsmSmsVideoMessageWaiting;
       
  3750 	TSmsMessageProfileType messageProfileType=EGsmSmsProfileId1;
       
  3751 	TBuf<KSmsDescriptionLength> desc;
       
  3752 	
       
  3753 	operations.RemoveAllSpecialMessageIndicationsL();
       
  3754 	operations.AddSpecialMessageIndicationL(toStore,messageIndicationType,
       
  3755 								extendedType,messageProfileType,aMessageCount);
       
  3756 	
       
  3757 	User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc));
       
  3758 	
       
  3759 	if(!CheckDescriptionL(aResFile, aId, desc, aMessageCount))
       
  3760 		{
       
  3761 		operations.RemoveAllSpecialMessageIndicationsL();
       
  3762 		return EFalse;	
       
  3763 		}
       
  3764 	operations.RemoveAllSpecialMessageIndicationsL();	
       
  3765 	return ETrue;
       
  3766 	}
       
  3767 
       
  3768 TBool CSmutTest::TestEnhancedVoiceMailIndicationPduL(RResourceFile& aResFile, CSmsHeader& aHeader, TInt aId)
       
  3769 	{
       
  3770 	//remove any special message indications
       
  3771 	CSmsSpecialSMSMessageOperations& operations = STATIC_CAST(CSmsSpecialSMSMessageOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication));
       
  3772 	operations.RemoveAllSpecialMessageIndicationsL();
       
  3773 	
       
  3774 	const TUint8 KMaxCount = 0xFF;
       
  3775 	for (TUint8 i = 0; i < KMaxCount; i++)
       
  3776 		{
       
  3777 		TInt resId = aId;
       
  3778 		if (i != 1)
       
  3779 			resId++;
       
  3780 
       
  3781 		if(!TestEnhancedVoiceMailIndicationPduL(aResFile, i, aHeader, resId))
       
  3782 			{
       
  3783 			return EFalse;	
       
  3784 			}
       
  3785 		}
       
  3786 
       
  3787 	iTestStep.INFO_PRINTF1(_L("Passed"));
       
  3788 	
       
  3789 	return ETrue;
       
  3790 	}
       
  3791 	
       
  3792 
       
  3793 TBool CSmutTest::TestEnhancedVoiceMailIndicationPduL(RResourceFile& aResFile, TUint8 aMessageCount, CSmsHeader& aHeader, TInt aId)
       
  3794 	{	
       
  3795 	//get the operations class
       
  3796 	CSmsEnhancedVoiceMailOperations& enhancedOperations = STATIC_CAST(CSmsEnhancedVoiceMailOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation));
       
  3797 	//remove any enhanced voice mail indications
       
  3798 	if(enhancedOperations.ContainsEnhancedVoiceMailIEL())
       
  3799 		{
       
  3800 		enhancedOperations.RemoveEnhancedVoiceMailIEL();	
       
  3801 		}
       
  3802 	//Create CEnhancedVoiceMailNotification
       
  3803 	CEnhancedVoiceMailNotification* enhancedVoiceMailNotification=CEnhancedVoiceMailNotification::NewL();
       
  3804 	CleanupStack::PushL(enhancedVoiceMailNotification);
       
  3805 
       
  3806 	//Set the properties
       
  3807 	TSmsMessageProfileType messageProfileType=EGsmSmsProfileId1;
       
  3808 	enhancedVoiceMailNotification->SetProfile(messageProfileType);
       
  3809 	enhancedVoiceMailNotification->SetStorage(ETrue);
       
  3810 	enhancedVoiceMailNotification->SetNumberOfVoiceMessages(aMessageCount);
       
  3811 	
       
  3812 	enhancedOperations.AddEnhancedVoiceMailIEL(*enhancedVoiceMailNotification);
       
  3813 	CleanupStack::PopAndDestroy(enhancedVoiceMailNotification);
       
  3814 	
       
  3815 	TBuf<KSmsDescriptionLength> desc;
       
  3816 	User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc));
       
  3817 	if(!CheckDescriptionL(aResFile, aId, desc, aMessageCount))
       
  3818 		{
       
  3819 		return EFalse;	
       
  3820 		}
       
  3821 	
       
  3822 	
       
  3823 	return ETrue;
       
  3824 	}
       
  3825 	
       
  3826 
       
  3827 TBool CSmutTest::CheckDescriptionL(RResourceFile& aResFile, TInt aId, TRefByValue<const TDesC> aDesc, ...)
       
  3828 	{
       
  3829 	const TDesC& ref = aDesc;
       
  3830 
       
  3831 	TBuf<256> resDesc;
       
  3832 	TBuf<256> resString;
       
  3833 
       
  3834 	VA_LIST list;
       
  3835 	VA_START(list, aDesc);
       
  3836 
       
  3837 	iSmsTest.ReadResourceStringL(aResFile, aId, resString);
       
  3838 	resDesc.AppendFormatList(resString, list);
       
  3839 
       
  3840 	if (ref != resDesc)
       
  3841 		{
       
  3842 		iTestStep.INFO_PRINTF3(_L("\tMISMATCH Desc \"%S\" Resource \"%S\""), &ref, &resDesc);
       
  3843 		return EFalse;
       
  3844 		}
       
  3845 		
       
  3846 	return ETrue;
       
  3847 	}
       
  3848 
       
  3849 TBool CSmutTest::CheckSmsEntry(
       
  3850 							const TMsvSmsEntry& aEntry, 
       
  3851 							TBool aClassExpected, 
       
  3852 							TSmsDataCodingScheme::TSmsClass aClass, 
       
  3853 							TUint8 aPID, 
       
  3854 							TBool aUPI, 
       
  3855 							TMsvSmsEntry::TMsvSmsEntryAckSummary aDeliverySummary, 
       
  3856 							TBool aValidMessageId, 
       
  3857 							TInt32 aMessageId) const
       
  3858 	{
       
  3859 	TCompare retVal(ETrue);
       
  3860 
       
  3861 	TSmsDataCodingScheme::TSmsClass dummyClass;
       
  3862 
       
  3863 	retVal((aEntry.Class(dummyClass) && aClassExpected) || (!aEntry.Class(dummyClass) && !aClassExpected));
       
  3864 
       
  3865 	if (aClassExpected)
       
  3866 		retVal(dummyClass == aClass);
       
  3867 
       
  3868 	retVal(aEntry.ProtocolIdentifier() == aPID);
       
  3869 	retVal((aEntry.UserPromptIndicator() && aUPI) || (!aEntry.UserPromptIndicator() && !aUPI));
       
  3870 
       
  3871 	retVal(aEntry.AckSummary(ESmsAckTypeDelivery) == aDeliverySummary);
       
  3872 
       
  3873 	TInt32 dummyMessageId;
       
  3874 
       
  3875 	retVal( (aEntry.MessageId(dummyMessageId) && aValidMessageId) || (!aEntry.MessageId(dummyMessageId) && !aValidMessageId) );
       
  3876 	if( aValidMessageId )
       
  3877 		retVal( dummyMessageId == aMessageId );
       
  3878 
       
  3879 	return retVal;
       
  3880 	}
       
  3881 
       
  3882 TVerdict CSmutTest::TestSmsEntryL()
       
  3883 	{
       
  3884 	iTestStep.INFO_PRINTF1(_L("Testing TMsvSmsEntry..."));
       
  3885 
       
  3886 	TMsvSmsEntry entry;
       
  3887 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3888 		{
       
  3889 		return EFail;	
       
  3890 		}
       
  3891 
       
  3892 	entry.SetUserPromptIndicator(ETrue);
       
  3893 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3894 		{
       
  3895 		return EFail;	
       
  3896 		}
       
  3897 	entry.SetUserPromptIndicator(EFalse);
       
  3898 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3899 		{
       
  3900 		return EFail;	
       
  3901 		}
       
  3902 	entry.SetProtocolIdentifier(123);
       
  3903 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 123, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3904 		{
       
  3905 		return EFail;	
       
  3906 		}
       
  3907 	entry.SetProtocolIdentifier(100);
       
  3908 	entry.SetUserPromptIndicator(ETrue);
       
  3909 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3910 		{
       
  3911 		return EFail;	
       
  3912 		}
       
  3913 	entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass0);
       
  3914 	if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass0, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3915 		{
       
  3916 		return EFail;	
       
  3917 		}
       
  3918 	entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass1);
       
  3919 	if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass1, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3920 		{
       
  3921 		return EFail;	
       
  3922 		}
       
  3923 	entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass2);
       
  3924 	if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass2, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3925 			{
       
  3926 		return EFail;	
       
  3927 		}
       
  3928 	entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass3);
       
  3929 	if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass3, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3930 			{
       
  3931 		return EFail;	
       
  3932 		}
       
  3933 	entry.SetClass(EFalse);
       
  3934 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass3, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3935 		{
       
  3936 		return EFail;	
       
  3937 		}
       
  3938 		
       
  3939 	entry.SetUserPromptIndicator(EFalse);
       
  3940 	if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass3, 100, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0))
       
  3941 			{
       
  3942 		return EFail;	
       
  3943 		}
       
  3944 	entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass0);
       
  3945 	
       
  3946 	TInt classCounter, upiCounter, classDef, deliverySummary, messageIdValid;
       
  3947 	TSmsDataCodingScheme::TSmsClass tempClass;
       
  3948 	TMsvSmsEntry::TMsvSmsEntryAckSummary tempDelivery;
       
  3949 	TUint8 pidCounter;
       
  3950 	TInt32 messageId = KLogID1;
       
  3951 
       
  3952 	for (classCounter = 0; classCounter < 4; classCounter++)
       
  3953 		{
       
  3954 		for (pidCounter = 0; pidCounter < 128; pidCounter++)
       
  3955 			{
       
  3956 			for (upiCounter = 0; upiCounter < 2; upiCounter++)
       
  3957 				{
       
  3958 				for (classDef = 0; classDef < 2; classDef++)
       
  3959 					{
       
  3960 					for( deliverySummary = 0; deliverySummary < 5; ++deliverySummary )
       
  3961 						{
       
  3962 						for( messageIdValid = 0; messageIdValid < 2; ++messageIdValid)
       
  3963 							{
       
  3964 							entry = TMsvSmsEntry();
       
  3965 							tempClass = static_cast<TSmsDataCodingScheme::TSmsClass>(classCounter);
       
  3966 							tempDelivery = static_cast<TMsvSmsEntry::TMsvSmsEntryAckSummary>(deliverySummary);
       
  3967 							entry.SetClass(classDef, tempClass);
       
  3968 							entry.SetProtocolIdentifier(pidCounter);
       
  3969 							entry.SetUserPromptIndicator(upiCounter);
       
  3970 							entry.SetAckSummary(ESmsAckTypeDelivery, tempDelivery);
       
  3971 							entry.SetMessageId(messageId, messageIdValid);
       
  3972 							if(!CheckSmsEntry(entry, classDef, tempClass, pidCounter, upiCounter, tempDelivery, messageIdValid, messageId))
       
  3973 								{
       
  3974 								return EFail;	
       
  3975 								}
       
  3976 							}
       
  3977 						}
       
  3978 					}
       
  3979 				}
       
  3980 			}
       
  3981 		}
       
  3982 	
       
  3983 	for (classCounter = 0; classCounter < 4; classCounter++)
       
  3984 		{
       
  3985 		for (pidCounter = 0; pidCounter < 128; pidCounter++)
       
  3986 			{
       
  3987 			for (upiCounter = 0; upiCounter < 2; upiCounter++)
       
  3988 				{
       
  3989 				for (classDef = 0; classDef < 2; classDef++)
       
  3990 					{
       
  3991 					for( deliverySummary = 0; deliverySummary < 5; ++deliverySummary )
       
  3992 						{
       
  3993 						for( messageIdValid = 0; messageIdValid < 2; ++messageIdValid)
       
  3994 							{
       
  3995 							tempClass = static_cast<TSmsDataCodingScheme::TSmsClass>(classCounter);
       
  3996 							tempDelivery = static_cast<TMsvSmsEntry::TMsvSmsEntryAckSummary>(deliverySummary);
       
  3997 							entry.SetClass(classDef, tempClass);
       
  3998 							entry.SetProtocolIdentifier(pidCounter);
       
  3999 							entry.SetUserPromptIndicator(upiCounter);
       
  4000 							entry.SetAckSummary(ESmsAckTypeDelivery, tempDelivery);
       
  4001 							entry.SetMessageId(messageId, messageIdValid);
       
  4002 							if(!CheckSmsEntry(entry, classDef, tempClass, pidCounter, upiCounter, tempDelivery, messageIdValid, messageId))
       
  4003 								{
       
  4004 								return EFail;	
       
  4005 								}
       
  4006 							}
       
  4007 						}
       
  4008 					}
       
  4009 				}
       
  4010 			}
       
  4011 		}
       
  4012 
       
  4013 	iTestStep.INFO_PRINTF1(_L("Test TMsvSmsEntry Passed."));	
       
  4014 	return EPass;
       
  4015 	}