messagingappbase/smsmtm/test/src/t_smsdeliver.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) 2003-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 "t_smsdeliver.h"
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <smutset.h>
       
    20 #include <smuthdr.h>
       
    21 #include <txtrich.h>
       
    22 #include <smstestutils.h>
       
    23 #include <msvuids.h>
       
    24 #include <smsuaddr.h>
       
    25 #include <csmsaccount.h>
       
    26 
       
    27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    28 #include <tmsvsmsentry.h>
       
    29 #endif
       
    30 
       
    31 _LIT(KFailed,"Failed to complete tests.");
       
    32 _LIT(KRecipientOk,		"+447747065438");  // has to be valid number and switched on
       
    33 _LIT(KRecipientBad,		"+442071541467");
       
    34 _LIT(KRecipientFail,	"+34933753717");
       
    35 _LIT(KMessageData, "This is a simple text message");
       
    36 _LIT(KTestDeliverOneRecipientOk,		"Single recipient, deliver ok");
       
    37 _LIT(KTestDeliverOneRecipientFail, 		"Single recipient, deliver fail");
       
    38 _LIT(KTestDeliverMultiRecipientsOk_1,	"Multi (2) recipients, deliver ok"); 
       
    39 _LIT(KTestDeliverMultiRecipientsOk_2,	"Multi (2) recipients, deliver ok, but 1 fails to send");
       
    40 _LIT(KTestDeliverMultiRecipientsOk_3,	"Multi (3) recipients, deliver ok, but 1 fails to send");
       
    41 _LIT(KTestDeliverNoMatching,			"Single recipient, no matching");
       
    42 _LIT(KTestDeliverNoStatusReports,		"Single recipient, no status reports");
       
    43 _LIT(KTestDeliverNotSent,				"Single recipient, not sent");
       
    44 _LIT(KTestDeliverMultiRecipientsFail_1,	"Multi (2) recipients, deliver failure");
       
    45 _LIT(KTestDeliverMultiRecipientsMixed_1,"Multi (2) recipients, 1 deliver ok, 1 deliver failure");
       
    46 _LIT(KTestDeliverMultiRecipientsMixed_2,"Multi (2) recipients, 2 deliver failures");
       
    47 
       
    48 #if defined (__WINS__)
       
    49 _LIT(KPddName,"ECDRV");
       
    50 _LIT(KLddName,"ECOMM");
       
    51 #else	//__WINS__
       
    52 _LIT(KPddSirName,"ESIR");
       
    53 _LIT(KPddUartName,"ECUART4");
       
    54 _LIT(KLddName,"ECOMM");
       
    55 #endif	//__WINS__
       
    56 
       
    57 RTest test(_L("T_SmsDeliver Test Harness"));
       
    58 
       
    59 const TTimeIntervalMicroSeconds32 KWaitForWatchersToStart = 20000000;
       
    60 const TTimeIntervalMicroSeconds32 KWaitForWatchersToStartDisplayInterval = 5000000;
       
    61 
       
    62 LOCAL_C void DoTestsL()
       
    63 	{
       
    64 #if defined (__WINS__)
       
    65 	User::LoadPhysicalDevice(KPddName);
       
    66 	User::LoadLogicalDevice(KLddName);
       
    67 #else	//__WINS__
       
    68 	User::LoadPhysicalDevice(KPddSirName);
       
    69 	User::LoadPhysicalDevice(KPddUartName);
       
    70     User::LoadLogicalDevice(KLddName);
       
    71 #endif	//__WINS__
       
    72 
       
    73 	TInt r = StartC32();
       
    74 	if( (r != KErrNone) && (r != KErrAlreadyExists) )
       
    75 		test.Printf(_L("Failed to start C32 %d\n"), r);
       
    76 	
       
    77 	// Create and install the active scheduler
       
    78  	CActiveScheduler* scheduler= new (ELeave) CActiveScheduler();
       
    79 	CleanupStack::PushL(scheduler);
       
    80 	CActiveScheduler::Install(scheduler);
       
    81 
       
    82 	// Create the test engine
       
    83 	CTestEngine* testEngine = CTestEngine::NewL();
       
    84 	CleanupStack::PushL(testEngine);
       
    85 
       
    86 	// Do tests...
       
    87 	testEngine->DoTestsL();
       
    88 	
       
    89 	CleanupStack::PopAndDestroy(2, scheduler);	
       
    90 	}
       
    91 
       
    92 GLDEF_C TInt E32Main()
       
    93 	{	
       
    94 	__UHEAP_MARK;
       
    95 	CTrapCleanup* tc=CTrapCleanup::New();
       
    96 	TRAPD(err,DoTestsL());
       
    97 	if (err!=KErrNone)
       
    98 		User::Panic(KFailed, err);
       
    99 	delete tc;
       
   100 	test.Close();
       
   101 	__UHEAP_MARKEND;
       
   102 	return KErrNone;
       
   103 	}
       
   104 	
       
   105 /*
       
   106  *	CTestEngine
       
   107  */
       
   108 	
       
   109 CTestEngine* CTestEngine::NewL()
       
   110 	{
       
   111 	CTestEngine* self = new (ELeave) CTestEngine();
       
   112 	CleanupStack::PushL(self);
       
   113 	self->ConstructL();
       
   114 	CleanupStack::Pop(self);
       
   115 	return self;
       
   116 	}
       
   117 
       
   118 CTestEngine::~CTestEngine()
       
   119 	{
       
   120 	delete iTestUtils;
       
   121 	delete iWatchers;
       
   122 
       
   123 	iSocket.Close();
       
   124 	iSocketServ.Close();
       
   125 	}
       
   126 
       
   127 CTestEngine::CTestEngine()
       
   128 : CBase()
       
   129 	{
       
   130 	}
       
   131 	
       
   132 void CTestEngine::DoTestsL()
       
   133 	{
       
   134 
       
   135 	CTestDeliverBase* testCase = NULL;
       
   136 	
       
   137 	testCase = CTestDeliverOneRecipientOk::NewL(*iTestUtils);
       
   138 	RunTestCaseL(*testCase);
       
   139 
       
   140 	testCase = CTestDeliverMultiRecipientsOk_1::NewL(*iTestUtils);
       
   141 	RunTestCaseL(*testCase);
       
   142 
       
   143 	testCase = CTestDeliverMultiRecipientsOk_2::NewL(*iTestUtils);
       
   144 	RunTestCaseL(*testCase);
       
   145 
       
   146 	testCase = CTestDeliverMultiRecipientsOk_3::NewL(*iTestUtils);
       
   147 	RunTestCaseL(*testCase);
       
   148 
       
   149 	testCase = CTestDeliverNoMatching::NewL(*iTestUtils);
       
   150 	RunTestCaseL(*testCase);
       
   151 	
       
   152 	testCase = CTestDeliverNoStatusReports::NewL(*iTestUtils);
       
   153 	RunTestCaseL(*testCase);
       
   154 
       
   155 	testCase = CTestDeliverNotSent::NewL(*iTestUtils);
       
   156 	RunTestCaseL(*testCase);
       
   157 
       
   158 	testCase = CTestDeliverOneRecipientFail::NewL(*iTestUtils);
       
   159 	RunTestCaseL(*testCase);
       
   160 	
       
   161 	testCase = 	CTestDeliverMultiRecipientsFail_1::NewL(*iTestUtils);
       
   162 	RunTestCaseL(*testCase);
       
   163 
       
   164 	testCase = 	CTestDeliverMultiRecipientsMixed_1::NewL(*iTestUtils);
       
   165 	RunTestCaseL(*testCase);
       
   166 
       
   167 	testCase = 	CTestDeliverMultiRecipientsMixed_2::NewL(*iTestUtils);
       
   168 	RunTestCaseL(*testCase);
       
   169 	}
       
   170 	
       
   171 void CTestEngine::RunTestCaseL(CTestDeliverBase& aTestCase)
       
   172 	{
       
   173 	CleanupStack::PushL(&aTestCase);
       
   174 	aTestCase.Start();
       
   175 	CActiveScheduler::Start();
       
   176 	CleanupStack::PopAndDestroy(&aTestCase);
       
   177 	}
       
   178 
       
   179 void CTestEngine::ConstructL()
       
   180 	{
       
   181 	// This should create the SMS service, including the service settings.
       
   182 	iTestUtils = CSmsTestUtils::NewL(test);
       
   183 	
       
   184 	// Notify the system agent that the phone is on.
       
   185 	iTestUtils->NotifySaPhoneOnL();
       
   186 	
       
   187 	// Tell the tests utils to log to file
       
   188 	iTestUtils->SetLogToFile();
       
   189 	
       
   190 	// Restore the service settings.
       
   191 	iTestUtils->SetEntryL(iTestUtils->iSmsServiceId);
       
   192 	CSmsAccount* account = CSmsAccount::NewLC();
       
   193 	account->LoadSettingsL(*iTestUtils->iServiceSettings);
       
   194 	
       
   195 	// Remove the default service centres from the service settings
       
   196 	TInt count = iTestUtils->iServiceSettings->ServiceCenterCount();
       
   197 	while( count-- )
       
   198 		{
       
   199 		iTestUtils->iServiceSettings->RemoveServiceCenter(count);
       
   200 		}
       
   201 		
       
   202 	// Add the Vodafone service centre - store the settings.
       
   203 	iTestUtils->iServiceSettings->AddServiceCenterL(_L("Vodafone"), _L("+447785016005"));
       
   204 
       
   205 	// Set delivery options - do matching and make reports visible.	
       
   206 	iTestUtils->iServiceSettings->SetDeliveryReport(ETrue);
       
   207 	iTestUtils->iServiceSettings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch);
       
   208 
       
   209 	account->SaveSettingsL(*iTestUtils->iServiceSettings);
       
   210 	CleanupStack::PopAndDestroy(account);
       
   211 	
       
   212 	// Create a session with the SMS stack - note order of the next few things
       
   213 	// is important.
       
   214 	User::LeaveIfError(iSocketServ.Connect());
       
   215 	TProtocolDesc protoinfo;
       
   216 	TProtocolName protocolname(KSmsDatagram);
       
   217 	User::LeaveIfError(iSocketServ.FindProtocol(protocolname,protoinfo));
       
   218 	User::LeaveIfError(iSocket.Open(iSocketServ,protoinfo.iAddrFamily,protoinfo.iSockType,protoinfo.iProtocol));
       
   219 	
       
   220 	TSmsAddr smsaddr;
       
   221 	smsaddr.SetSmsAddrFamily(ESmsAddrSendOnly);
       
   222 	User::LeaveIfError(iSocket.Bind(smsaddr));
       
   223 	
       
   224 	// Initialise phone...
       
   225 	iTestUtils->WaitForInitializeL();
       
   226 	
       
   227 	// Start watchers...
       
   228 	StartWatcherL();
       
   229 	}
       
   230 	
       
   231 TBool CTestEngine::WatchersAlreadyRunningL()
       
   232 	{
       
   233 	RSocketServ server;
       
   234 	RSocket socket;
       
   235 
       
   236 	User::LeaveIfError(server.Connect());
       
   237 	CleanupClosePushL(server);
       
   238 
       
   239 		// test if it's there... 
       
   240 	TProtocolDesc protoInfo;
       
   241 	TProtocolName protocolname;
       
   242 	protocolname.Copy(KSmsDatagram);
       
   243 	User::LeaveIfError(server.FindProtocol(protocolname,protoInfo));
       
   244 
       
   245 	User::LeaveIfError(socket.Open(server,
       
   246 										protoInfo.iAddrFamily,
       
   247 										protoInfo.iSockType, 
       
   248 										protoInfo.iProtocol));
       
   249 	CleanupClosePushL(socket);
       
   250 
       
   251 	TSmsAddr addr;
       
   252 	addr.SetSmsAddrFamily(ESmsAddrRecvAny);
       
   253 	TInt err = socket.Bind(addr);
       
   254 
       
   255 	CleanupStack::Pop(2, &server);
       
   256 	socket.CancelAll();
       
   257 	socket.Close();
       
   258 	server.Close();
       
   259 	return (err == KErrAlreadyExists);
       
   260 	}
       
   261 	
       
   262 void CTestEngine::StartWatcherL()
       
   263 	{
       
   264 	iTestUtils->Printf(_L("Start the Watcher"));
       
   265 
       
   266 	if( WatchersAlreadyRunningL() )
       
   267 		{
       
   268 		iTestUtils->Printf(_L("Watchers are already running\n"));
       
   269 		return;
       
   270 		}
       
   271 
       
   272 	iWatchers = CTestUtilsWatcherStarter::NewL();
       
   273 
       
   274 	TTimeIntervalMicroSeconds32 wait = KWaitForWatchersToStart;
       
   275 	TBool started = EFalse;
       
   276 	while( !started && wait.Int() > 0 )
       
   277 		{
       
   278 		iTestUtils->Printf(_L("Waiting %d secs for watchers to start...\n"), wait.Int() / 1000000);
       
   279 		wait = wait.Int() - KWaitForWatchersToStartDisplayInterval.Int();
       
   280 		User::After(KWaitForWatchersToStartDisplayInterval);
       
   281 		started = WatchersAlreadyRunningL();
       
   282 		}
       
   283 
       
   284 	if( !WatchersAlreadyRunningL() )
       
   285 		{
       
   286 		iTestUtils->Printf(_L("WARNING: NBS Watcher has not started yet\n"));
       
   287 		}
       
   288 	}
       
   289 	
       
   290 /*
       
   291  * CTestDeliverBase
       
   292  */
       
   293  
       
   294 CTestDeliverBase::~CTestDeliverBase()
       
   295 	{
       
   296 	delete iEntryForObserver;
       
   297 	delete iOperation;
       
   298 	}	
       
   299 	
       
   300 void CTestDeliverBase::Start()
       
   301 	{
       
   302 	iTestUtils.Printf(_L("Starting %S\n"), &TestName());
       
   303 	iState = EClearFolders;
       
   304 	CompleteSelf();
       
   305 	}
       
   306 	
       
   307 CTestDeliverBase::CTestDeliverBase(CSmsTestUtils& aTestUtils)
       
   308 : CActive(CActive::EPriorityStandard), iTestUtils(aTestUtils)
       
   309 	{
       
   310 	CActiveScheduler::Add(this);
       
   311 	}
       
   312 	
       
   313 void CTestDeliverBase::ConstructL()
       
   314 	{
       
   315 	iEntryForObserver = Session().GetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   316 	}
       
   317 	
       
   318 void CTestDeliverBase::CompleteSelf()
       
   319 	{
       
   320 	TRequestStatus* pStat = &iStatus;
       
   321 	User::RequestComplete(pStat, KErrNone);
       
   322 	SetActive();
       
   323 	}
       
   324 	
       
   325 CMsvSession& CTestDeliverBase::Session()
       
   326 	{
       
   327 	return *iTestUtils.iMsvSession;
       
   328 	}
       
   329 
       
   330 CMsvEntry& CTestDeliverBase::MsvEntry()
       
   331 	{
       
   332 	return *iTestUtils.iMsvEntry;
       
   333 	}
       
   334 
       
   335 CSmsClientMtm& CTestDeliverBase::Client()
       
   336 	{
       
   337 	return *iTestUtils.iSmsClientMtm;
       
   338 	}
       
   339 	
       
   340 CSmsSettings& CTestDeliverBase::ServiceSettings()
       
   341 	{
       
   342 	return *iTestUtils.iServiceSettings;
       
   343 	}
       
   344 		
       
   345 void CTestDeliverBase::ClearFoldersL()
       
   346 	{
       
   347 	iTestUtils.DeleteSmsMessagesL(KMsvGlobalOutBoxIndexEntryId);
       
   348 	iTestUtils.DeleteSmsMessagesL(KMsvGlobalInBoxIndexEntryId);
       
   349 	iTestUtils.DeleteSmsMessagesL(KMsvSentEntryId);		
       
   350 	}
       
   351 	
       
   352 void CTestDeliverBase::TestComplete()
       
   353 	{
       
   354 	iTestUtils.Printf(_L("Test Complete\n"));
       
   355 	CActiveScheduler::Stop();
       
   356 	}
       
   357 	
       
   358 void CTestDeliverBase::CreateMessageL()
       
   359 	{
       
   360 	iTestUtils.Printf(_L("Creating message...\n"));
       
   361 	
       
   362 	TMsvEntry entry;
       
   363 	entry.SetVisible(ETrue); 
       
   364 	entry.SetInPreparation(ETrue); 
       
   365 	entry.iServiceId = iTestUtils.iSmsServiceId; 
       
   366 	entry.iType = KUidMsvMessageEntry; 
       
   367 	entry.iMtm = KUidMsgTypeSMS; 
       
   368 	entry.iDate.HomeTime(); 
       
   369 	entry.iSize = 0; 
       
   370 	entry.iDescription.Set(KNullDesC); 
       
   371 	entry.iDetails.Set(KNullDesC); 
       
   372 
       
   373 	// Check send options...
       
   374 	TUint sendState = KMsvSendStateWaiting; 
       
   375 	switch( ServiceSettings().Delivery() )  
       
   376 		{ 
       
   377 	case ESmsDeliveryScheduled: 
       
   378 		sendState = KMsvSendStateScheduled; 
       
   379 		break; 
       
   380 	case ESmsDeliveryUponRequest: 
       
   381 		sendState = KMsvSendStateUponRequest; 
       
   382 		break; 
       
   383 	default: 
       
   384 		sendState = KMsvSendStateWaiting; 
       
   385 		break;
       
   386 		}
       
   387 	entry.SetSendingState(sendState); 
       
   388 
       
   389 	// Create the SMS header object...
       
   390 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   391 	CleanupStack::PushL(header);
       
   392 	
       
   393 	// Set the body text...
       
   394 	iTestUtils.iRichText->Reset();
       
   395 	iTestUtils.iRichText->InsertL(0, KMessageData);
       
   396 	
       
   397 	// Copy the message settings...
       
   398 	header->SetSmsSettingsL(ServiceSettings()); 
       
   399 	
       
   400 	// Set the service centre
       
   401 	TInt defaultIndex = ServiceSettings().DefaultServiceCenter();
       
   402 	header->SetServiceCenterAddressL(ServiceSettings().GetServiceCenter(defaultIndex).Address());
       
   403 
       
   404 	// Set recipient - ask derived class
       
   405 	SetRecipientsL(*header);
       
   406 	
       
   407 	// Update entry description and details...
       
   408 	CArrayPtrFlat<CSmsNumber>& recipient = header->Recipients();
       
   409 	entry.iDetails.Set(recipient[0]->Address());
       
   410 	entry.iDescription.Set(iTestUtils.iRichText->Read(0, ServiceSettings().DescriptionLength()));
       
   411 	entry.SetInPreparation(EFalse);
       
   412 	
       
   413 	// Create the entry - set context to the global outbox.
       
   414 	MsvEntry().SetEntryL(KMsvGlobalOutBoxIndexEntryId);
       
   415 	MsvEntry().CreateL(entry);
       
   416 
       
   417 	// Create new store and save header information 
       
   418 	MsvEntry().SetEntryL(entry.Id()); 
       
   419 	CMsvStore* store = MsvEntry().EditStoreL(); 
       
   420 	CleanupStack::PushL(store); 
       
   421 	header->StoreL(*store);
       
   422 	store->StoreBodyTextL(*iTestUtils.iRichText);
       
   423 	store->CommitL(); 
       
   424 	CleanupStack::PopAndDestroy(2, header); 
       
   425 	
       
   426 	iMessageId = entry.Id();
       
   427 	}
       
   428 	
       
   429 void CTestDeliverBase::SendMessageL()
       
   430 	{
       
   431 	iTestUtils.Printf(_L("Sending message %d\n"), iMessageId);
       
   432 
       
   433 	delete iOperation;
       
   434 	iOperation = NULL;
       
   435 
       
   436 	CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection();
       
   437 	CleanupStack::PushL(sel);
       
   438 	sel->AppendL(iMessageId);
       
   439 
       
   440 	iTestUtils.DisplayMessageL(iMessageId);
       
   441 	
       
   442 	MsvEntry().SetEntryL(KMsvGlobalOutBoxIndexEntryId);
       
   443 	iOperation = MsvEntry().CopyL(*sel, iTestUtils.iSmsServiceId, iStatus);
       
   444 	CleanupStack::PopAndDestroy(sel);
       
   445 
       
   446 	SetActive();
       
   447 	}
       
   448 	
       
   449 void CTestDeliverBase::ChangeServiceSettingsL()
       
   450 	{
       
   451 	// Restore the service settings.
       
   452 	iTestUtils.SetEntryL(iTestUtils.iSmsServiceId);
       
   453 	CSmsAccount* account = CSmsAccount::NewLC();
       
   454 	account->LoadSettingsL(*iTestUtils.iServiceSettings);
       
   455 	
       
   456 	// Set the service settings 
       
   457 	iTestUtils.iServiceSettings->SetValidityPeriod(TTimeIntervalMinutes(5));
       
   458 	iTestUtils.iServiceSettings->SetDeliveryReport(ETrue);
       
   459 	iTestUtils.iServiceSettings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch);
       
   460 	
       
   461 	// Store the new service settings
       
   462 	account->SaveSettingsL(*iTestUtils.iServiceSettings);
       
   463 	CleanupStack::PopAndDestroy(account);
       
   464 	}
       
   465 	
       
   466 void CTestDeliverBase::CheckCreatedMessageL()
       
   467 	{
       
   468 	// Need to check the following - 
       
   469 	// 1. All recipients have correct delivery status - ENoAckRequested.
       
   470 	// 2. The index summary is correct - ENoAckSummary
       
   471 	// 3. The index message IS is invalid.
       
   472 	
       
   473 	iTestUtils.Printf(_L("Checking created message %d has correct flags set...\n"), iMessageId);
       
   474 		
       
   475 	// Restore the recipient...
       
   476 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   477 	CleanupStack::PushL(header);
       
   478 
       
   479 	MsvEntry().SetEntryL(iMessageId);
       
   480 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   481 	CleanupStack::PushL(store);
       
   482 	header->RestoreL(*store);
       
   483 	CleanupStack::PopAndDestroy(store);
       
   484 	
       
   485 	TInt rcptCount = header->Recipients().Count();
       
   486 	for( TInt ii = 0; ii < rcptCount; ++ii )
       
   487 		{
       
   488 		CSmsNumber* rcpt = header->Recipients()[ii];
       
   489 		iTestUtils.Printf(_L("--Recipient %d - Delivery status -> %d - should be %d (ENoAckRequested)\n"), ii, rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
   490 		iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
   491 		}
       
   492 		
       
   493 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   494 	
       
   495 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (ENoAckSummary)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::ENoAckSummary);
       
   496 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::ENoAckSummary);
       
   497 	
       
   498 	TLogId logId = 0;	
       
   499 	TBool validId = entry.MessageId(logId);
       
   500 	
       
   501 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
   502 	iTestUtils.Test()(validId == EFalse);
       
   503 	
       
   504 	CleanupStack::PopAndDestroy(header);
       
   505 	}
       
   506 	
       
   507 TMsvId CTestDeliverBase::GetObserverEntry()
       
   508 	{
       
   509 	return iMessageId;
       
   510 	}
       
   511 
       
   512 // methods from CActive
       
   513 
       
   514 void CTestDeliverBase::RunL()
       
   515 	{
       
   516 	User::LeaveIfError(iStatus.Int());
       
   517 	
       
   518 	switch( iState )
       
   519 		{
       
   520 	case EClearFolders:
       
   521 		{
       
   522 		ClearFoldersL();
       
   523 		iState = EChangeServiceSettings;
       
   524 		CompleteSelf();
       
   525 		} break;
       
   526 	case EChangeServiceSettings:
       
   527 		{
       
   528 		ChangeServiceSettingsL();
       
   529 		iState = ECreateMessage;
       
   530 		CompleteSelf();
       
   531 		} break;			
       
   532 	case ECreateMessage:
       
   533 		{
       
   534 		CreateMessageL();
       
   535 		iState = ECheckCreatedMessage;
       
   536 		CompleteSelf();
       
   537 		} break;
       
   538 	case ECheckCreatedMessage:
       
   539 		{
       
   540 		CheckCreatedMessageL();
       
   541 		iState = ESendMessage;
       
   542 		CompleteSelf();
       
   543 		} break;
       
   544 	case ESendMessage:
       
   545 		{
       
   546 		SendMessageL();
       
   547 		iState = ECheckSentMessage;
       
   548 		} break;
       
   549 	case ECheckSentMessage:
       
   550 		{
       
   551 		CheckSentMessageL();
       
   552 		
       
   553 		TMsvId entryId = GetObserverEntry();
       
   554 		
       
   555 		if( entryId != KMsvNullIndexEntryId )
       
   556 			{
       
   557 			// Need to observe something - move observer entry to specified entry 
       
   558 			// and wait for it to be updated
       
   559 			iEntryForObserver->SetEntryL(entryId);
       
   560 			iEntryForObserver->AddObserverL(*this);
       
   561 			
       
   562 			iState = EPendingDeliveryReport;
       
   563 			}
       
   564 		else
       
   565 			{
       
   566 			// Not observing anything - end of test.
       
   567 			TestComplete();
       
   568 			}
       
   569 		} break;
       
   570 	case EPendingDeliveryReport:
       
   571 		{
       
   572 		// End the test...
       
   573 		TestComplete();
       
   574 		} break;			
       
   575 	default:
       
   576 		User::Invariant();
       
   577 		break;
       
   578 		}
       
   579 	}
       
   580 	
       
   581 void CTestDeliverBase::DoCancel()
       
   582 	{
       
   583 	}
       
   584 	
       
   585 TInt CTestDeliverBase::RunError(TInt /*aError*/)
       
   586 	{
       
   587 	return KErrNone;
       
   588 	}
       
   589 	
       
   590 //	methods from MMsvEntryObserver	
       
   591 	
       
   592 void CTestDeliverBase::HandleEntryEventL(TMsvEntryEvent aEvent, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
       
   593 	{
       
   594 	__ASSERT_DEBUG( iState == EPendingDeliveryReport, User::Invariant() );
       
   595 	
       
   596 	if( aEvent == EMsvEntryChanged )
       
   597 		{
       
   598 		iTestUtils.Printf(_L("Message entry has been updated\n"));
       
   599 
       
   600 		// Check that the sent message has been updated.
       
   601 		CheckDeliveredMessageL();
       
   602 		}
       
   603 	}
       
   604 	
       
   605 /*
       
   606  * CTestDeliverOneRecipientOk
       
   607  */
       
   608  
       
   609  CTestDeliverOneRecipientOk* CTestDeliverOneRecipientOk::NewL(CSmsTestUtils& aTestUtils)
       
   610 	{
       
   611 	CTestDeliverOneRecipientOk* self = new (ELeave) CTestDeliverOneRecipientOk(aTestUtils);
       
   612 	CleanupStack::PushL(self);
       
   613 	self->ConstructL();
       
   614 	CleanupStack::Pop(self);
       
   615 	return self;	
       
   616 	}
       
   617 		
       
   618 CTestDeliverOneRecipientOk::~CTestDeliverOneRecipientOk()
       
   619 	{
       
   620 	}
       
   621 	
       
   622 CTestDeliverOneRecipientOk::CTestDeliverOneRecipientOk(CSmsTestUtils& aTestUtils)
       
   623 : CTestDeliverBase(aTestUtils)
       
   624 	{
       
   625 	}
       
   626 		
       
   627 //	 methods from CTestDeliverBase
       
   628 
       
   629 void CTestDeliverOneRecipientOk::SetRecipientsL(CSmsHeader& aHeader)
       
   630 	{
       
   631 	iTestUtils.Printf(_L("--Setting single recipient\n"));
       
   632 	
       
   633 	CSmsNumber* rcpt = CSmsNumber::NewL();
       
   634 	CleanupStack::PushL(rcpt);
       
   635 	rcpt->SetAddressL(KRecipientOk);
       
   636 	aHeader.Recipients().AppendL(rcpt);
       
   637 	CleanupStack::Pop(rcpt);
       
   638 	}
       
   639 
       
   640 void CTestDeliverOneRecipientOk::CheckSentMessageL()
       
   641 	{
       
   642 	// Need to check the following - 
       
   643 	// 1. Correct number of recipients
       
   644 	// 2. The recipient has delivery status correctly set
       
   645 	// 3. The index summary is correctly set
       
   646 	// 4. The index message ID is valid.
       
   647 	// 5. The index message ID matches that of the recipient
       
   648 	
       
   649 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
   650 		
       
   651 	// Restore the recipient...
       
   652 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   653 	CleanupStack::PushL(header);
       
   654 
       
   655 	MsvEntry().SetEntryL(iMessageId);
       
   656 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   657 	CleanupStack::PushL(store);
       
   658 	header->RestoreL(*store);
       
   659 	CleanupStack::PopAndDestroy(store);
       
   660 	
       
   661 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
   662 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
   663 	
       
   664 	CSmsNumber* rcpt = header->Recipients()[0];
       
   665 	
       
   666 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
   667 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
   668 	
       
   669 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   670 	
       
   671 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
   672 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
   673 	
       
   674 	TLogId logId = 0;	
       
   675 	TBool validId = entry.MessageId(logId);
       
   676 	
       
   677 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
   678 	iTestUtils.Test()(validId != EFalse);
       
   679 		
       
   680 	iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, rcpt->LogId());
       
   681 	iTestUtils.Test()(logId == rcpt->LogId());
       
   682 	
       
   683 	CleanupStack::PopAndDestroy(header);
       
   684 	}
       
   685 	
       
   686 void CTestDeliverOneRecipientOk::CheckDeliveredMessageL()
       
   687 	{
       
   688 	// Need to check the following - 
       
   689 	// 1. Correct number of recipients
       
   690 	// 2. The recipient has delivery status correctly set
       
   691 	// 3. The index summary is correctly set
       
   692 	
       
   693 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set...\n"), iMessageId);
       
   694 		
       
   695 	// Restore the recipient...
       
   696 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   697 	CleanupStack::PushL(header);
       
   698 
       
   699 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   700 	MsvEntry().SetEntryL(iMessageId);
       
   701 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   702 	CleanupStack::PushL(store);
       
   703 	header->RestoreL(*store);
       
   704 	CleanupStack::PopAndDestroy(store);
       
   705 	
       
   706 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
   707 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
   708 	
       
   709 	CSmsNumber* rcpt = header->Recipients()[0];
       
   710 	
       
   711 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
   712 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
   713 	
       
   714 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   715 	
       
   716 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllSuccessful)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllSuccessful);
       
   717 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllSuccessful);
       
   718 	
       
   719 	// Test is no ended - complete self to stop.
       
   720 	CompleteSelf();		
       
   721 	
       
   722 	CleanupStack::PopAndDestroy(header);
       
   723 	}
       
   724 
       
   725 const TDesC& CTestDeliverOneRecipientOk::TestName()
       
   726 	{
       
   727 	return KTestDeliverOneRecipientOk();
       
   728 	}
       
   729 	
       
   730 /*
       
   731  * CTestDeliverOneRecipientFail
       
   732  */
       
   733  
       
   734  CTestDeliverOneRecipientFail* CTestDeliverOneRecipientFail::NewL(CSmsTestUtils& aTestUtils)
       
   735 	{
       
   736 	CTestDeliverOneRecipientFail* self = new (ELeave) CTestDeliverOneRecipientFail(aTestUtils);
       
   737 	CleanupStack::PushL(self);
       
   738 	self->ConstructL();
       
   739 	CleanupStack::Pop(self);
       
   740 	return self;	
       
   741 	}
       
   742 		
       
   743 CTestDeliverOneRecipientFail::~CTestDeliverOneRecipientFail()
       
   744 	{
       
   745 	}
       
   746 	
       
   747 CTestDeliverOneRecipientFail::CTestDeliverOneRecipientFail(CSmsTestUtils& aTestUtils)
       
   748 : CTestDeliverBase(aTestUtils)
       
   749 	{
       
   750 	}
       
   751 		
       
   752 //	 methods from CTestDeliverBase
       
   753 
       
   754 void CTestDeliverOneRecipientFail::SetRecipientsL(CSmsHeader& aHeader)
       
   755 	{
       
   756 	iTestUtils.Printf(_L("--Setting single recipient\n"));
       
   757 	
       
   758 	CSmsNumber* rcpt = CSmsNumber::NewL();
       
   759 	CleanupStack::PushL(rcpt);
       
   760 	rcpt->SetAddressL(KRecipientFail);
       
   761 	aHeader.Recipients().AppendL(rcpt);
       
   762 	CleanupStack::Pop(rcpt);
       
   763 	}
       
   764 	
       
   765 void CTestDeliverOneRecipientFail::CheckSentMessageL()
       
   766 	{
       
   767 	// Need to check the following - 
       
   768 	// 1. Correct number of recipients
       
   769 	// 2. The recipient has delivery status correctly set
       
   770 	// 3. The index summary is correctly set
       
   771 	// 4. The index message ID is valid.
       
   772 	// 5. The index message ID matches that of the recipient
       
   773 	
       
   774 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
   775 		
       
   776 	// Restore the recipient...
       
   777 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   778 	CleanupStack::PushL(header);
       
   779 
       
   780 	MsvEntry().SetEntryL(iMessageId);
       
   781 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   782 	CleanupStack::PushL(store);
       
   783 	header->RestoreL(*store);
       
   784 	CleanupStack::PopAndDestroy(store);
       
   785 	
       
   786 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
   787 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
   788 	
       
   789 	CSmsNumber* rcpt = header->Recipients()[0];
       
   790 	
       
   791 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
   792 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
   793 	
       
   794 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   795 	
       
   796 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
   797 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
   798 	
       
   799 	TLogId logId = 0;	
       
   800 	TBool validId = entry.MessageId(logId);
       
   801 	
       
   802 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
   803 	iTestUtils.Test()(validId != EFalse);
       
   804 		
       
   805 	iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, rcpt->LogId());
       
   806 	iTestUtils.Test()(logId == rcpt->LogId());
       
   807 	
       
   808 	CleanupStack::PopAndDestroy(header);
       
   809 	}
       
   810 	
       
   811 void CTestDeliverOneRecipientFail::CheckDeliveredMessageL()
       
   812 	{
       
   813 	// Need to check the following - 
       
   814 	// 1. Correct number of recipients
       
   815 	// 2. The recipient has delivery status correctly set
       
   816 	// 3. The index summary is correctly set
       
   817 	
       
   818  	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set...\n"), iMessageId);
       
   819 		
       
   820 	// Restore the recipient...
       
   821 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   822 	CleanupStack::PushL(header);
       
   823 
       
   824 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   825 	MsvEntry().SetEntryL(iMessageId);
       
   826 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   827 	CleanupStack::PushL(store);
       
   828 	header->RestoreL(*store);
       
   829 	CleanupStack::PopAndDestroy(store);
       
   830 	
       
   831 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
   832 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
   833 	
       
   834 	CSmsNumber* rcpt = header->Recipients()[0];
       
   835 	
       
   836 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (EAckError)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
   837 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
   838 	
       
   839 	iTestUtils.Printf(_L("- Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt->Status(), CMsvRecipient::EFailedToSend);
       
   840 	iTestUtils.Test()(rcpt->Status()==CMsvRecipient::EFailedToSend);
       
   841 
       
   842 	iTestUtils.Printf(_L("- Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
   843 	iTestUtils.Test()(rcpt->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
   844 	
       
   845 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   846 	
       
   847 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllFailed)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllFailed);
       
   848 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllFailed);
       
   849 	
       
   850 	// Test is no ended - complete self to stop.
       
   851 	CompleteSelf();		
       
   852 	
       
   853 	CleanupStack::PopAndDestroy(header);
       
   854 	}
       
   855 
       
   856 const TDesC& CTestDeliverOneRecipientFail::TestName()
       
   857 	{
       
   858 	return KTestDeliverOneRecipientFail();
       
   859 	}
       
   860 	
       
   861 /*
       
   862  * CTestDeliverMultiRecipientsOk_1
       
   863  */
       
   864  
       
   865 CTestDeliverMultiRecipientsOk_1* CTestDeliverMultiRecipientsOk_1::NewL(CSmsTestUtils& aTestUtils)
       
   866 	{
       
   867 	CTestDeliverMultiRecipientsOk_1* self = new (ELeave) CTestDeliverMultiRecipientsOk_1(aTestUtils);
       
   868 	CleanupStack::PushL(self);
       
   869 	self->ConstructL();
       
   870 	CleanupStack::Pop(self);
       
   871 	return self;	
       
   872 	}
       
   873 		
       
   874 CTestDeliverMultiRecipientsOk_1::~CTestDeliverMultiRecipientsOk_1()
       
   875 	{
       
   876 	}
       
   877 	
       
   878 CTestDeliverMultiRecipientsOk_1::CTestDeliverMultiRecipientsOk_1(CSmsTestUtils& aTestUtils)
       
   879 : CTestDeliverBase(aTestUtils)
       
   880 	{
       
   881 	}
       
   882 	
       
   883 //	methods from CTestDeliverBase
       
   884 
       
   885 void CTestDeliverMultiRecipientsOk_1::SetRecipientsL(CSmsHeader& aHeader)
       
   886 	{
       
   887 	iTestUtils.Printf(_L("--Setting multiple (2) recipients\n"));
       
   888 	
       
   889 	CSmsNumber* rcpt0 = CSmsNumber::NewL();
       
   890 	CleanupStack::PushL(rcpt0);
       
   891 	rcpt0->SetAddressL(KRecipientOk);
       
   892 	aHeader.Recipients().AppendL(rcpt0);
       
   893 	CleanupStack::Pop(rcpt0);
       
   894 	
       
   895 	CSmsNumber* rcpt1 = CSmsNumber::NewL();
       
   896 	CleanupStack::PushL(rcpt1);
       
   897 	rcpt1->SetAddressL(KRecipientOk);
       
   898 	aHeader.Recipients().AppendL(rcpt1);
       
   899 	CleanupStack::Pop(rcpt1);
       
   900 	}
       
   901 	
       
   902 void CTestDeliverMultiRecipientsOk_1::CheckSentMessageL()
       
   903 	{
       
   904 	// Need to check the following - 
       
   905 	// 1. Correct number of recipients
       
   906 	// 2. The recipients have delivery status correctly set
       
   907 	// 3. The index summary is correctly set
       
   908 	// 4. The index message ID is valid.
       
   909 	// 5. The index message ID matches that of the recipient
       
   910 	
       
   911 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
   912 		
       
   913 	// Restore the recipient...
       
   914 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   915 	CleanupStack::PushL(header);
       
   916 
       
   917 	MsvEntry().SetEntryL(iMessageId);
       
   918 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   919 	CleanupStack::PushL(store);
       
   920 	header->RestoreL(*store);
       
   921 	CleanupStack::PopAndDestroy(store);
       
   922 	
       
   923 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
   924 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
   925 	
       
   926 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
   927 	
       
   928 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
   929 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
   930 	
       
   931 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
   932 	
       
   933 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
   934 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);	
       
   935 	
       
   936 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   937 	
       
   938 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
   939 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
   940 	
       
   941 	TLogId logId = 0;	
       
   942 	TBool validId = entry.MessageId(logId);
       
   943 	
       
   944 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
   945 	iTestUtils.Test()(validId == EFalse);
       
   946 		
       
   947 	CleanupStack::PopAndDestroy(header);
       
   948 	}
       
   949 	
       
   950 void CTestDeliverMultiRecipientsOk_1::CheckDeliveredMessageL()
       
   951 	{
       
   952 	// Need to check the following - 
       
   953 	// 1. Correct number of recipients
       
   954 	// 2. The recipient has delivery status is correctly set
       
   955 	// 3. The index summary is correctly set
       
   956 
       
   957 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set - round %d...\n"), iMessageId, ++iCheckCount);
       
   958 		
       
   959 	// Restore the recipient...
       
   960 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
   961 	CleanupStack::PushL(header);
       
   962 
       
   963 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   964 	MsvEntry().SetEntryL(iMessageId);
       
   965 	CMsvStore* store = iTestUtils.ReadStoreL();
       
   966 	CleanupStack::PushL(store);
       
   967 	header->RestoreL(*store);
       
   968 	CleanupStack::PopAndDestroy(store);
       
   969 	
       
   970 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
   971 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
   972 	
       
   973 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
   974 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
   975 	
       
   976 	TMsvSmsEntry entry = MsvEntry().Entry();
       
   977 
       
   978 	if( iCheckCount == 1 )
       
   979 		{
       
   980 		// At least one of the recipients has been delivered to ok - check the 
       
   981 		// status of recipient 0 and make decisions based on that.
       
   982 		CSmsNumber* pendingRcpt = NULL;
       
   983 		
       
   984 		if( rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck )
       
   985 			{
       
   986 			// Recipient 1 delivered to first...
       
   987 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
   988 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
   989 			
       
   990 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
   991 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
   992 			
       
   993 			pendingRcpt = rcpt0;
       
   994 			}
       
   995 		else
       
   996 			{
       
   997 			// Recipient 0 delivered to first...
       
   998 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
   999 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1000 			
       
  1001 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1002 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1003 			
       
  1004 			pendingRcpt = rcpt1;
       
  1005 			}
       
  1006 		TLogId logId = 0;	
       
  1007 		TBool validId = entry.MessageId(logId);
       
  1008 		
       
  1009 		iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  1010 		iTestUtils.Test()(validId != EFalse);
       
  1011 			
       
  1012 		iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, pendingRcpt->LogId());
       
  1013 		iTestUtils.Test()(logId == pendingRcpt->LogId());
       
  1014 		}
       
  1015 	else
       
  1016 		{
       
  1017 		// Both recipients has been delivered to ok - check the status of both
       
  1018 		// recipients
       
  1019 		iTestUtils.Printf(_L("--Second check of flags -> both recipients have been delivered to\n"));
       
  1020 		
       
  1021 		iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1022 		iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1023 	
       
  1024 		iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1025 		iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1026 		
       
  1027 		iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllSuccessful)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllSuccessful);
       
  1028 		iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllSuccessful);
       
  1029 
       
  1030 		// Test is no ended - complete self to stop.
       
  1031 		CompleteSelf();		
       
  1032 		}
       
  1033 	CleanupStack::PopAndDestroy(header);
       
  1034 	}
       
  1035 
       
  1036 const TDesC& CTestDeliverMultiRecipientsOk_1::TestName()
       
  1037 	{
       
  1038 	return KTestDeliverMultiRecipientsOk_1();
       
  1039 	}
       
  1040 	
       
  1041 /*
       
  1042  * CTestDeliverMultiRecipientsOk_2
       
  1043  */
       
  1044  
       
  1045 CTestDeliverMultiRecipientsOk_2* CTestDeliverMultiRecipientsOk_2::NewL(CSmsTestUtils& aTestUtils)
       
  1046 	{
       
  1047 	CTestDeliverMultiRecipientsOk_2* self = new (ELeave) CTestDeliverMultiRecipientsOk_2(aTestUtils);
       
  1048 	CleanupStack::PushL(self);
       
  1049 	self->ConstructL();
       
  1050 	CleanupStack::Pop(self);
       
  1051 	return self;	
       
  1052 	}
       
  1053 		
       
  1054 CTestDeliverMultiRecipientsOk_2::~CTestDeliverMultiRecipientsOk_2()
       
  1055 	{
       
  1056 	}
       
  1057 	
       
  1058 CTestDeliverMultiRecipientsOk_2::CTestDeliverMultiRecipientsOk_2(CSmsTestUtils& aTestUtils)
       
  1059 : CTestDeliverBase(aTestUtils)
       
  1060 	{
       
  1061 	}
       
  1062 	
       
  1063 //	methods from CTestDeliverBase
       
  1064 
       
  1065 void CTestDeliverMultiRecipientsOk_2::SetRecipientsL(CSmsHeader& aHeader)
       
  1066 	{
       
  1067 	iTestUtils.Printf(_L("--Setting multiple (2) recipients\n"));
       
  1068 	
       
  1069 	CSmsNumber* rcpt0 = CSmsNumber::NewL();
       
  1070 	CleanupStack::PushL(rcpt0);
       
  1071 	rcpt0->SetAddressL(KRecipientOk);
       
  1072 	aHeader.Recipients().AppendL(rcpt0);
       
  1073 	CleanupStack::Pop(rcpt0);
       
  1074 	
       
  1075 	CSmsNumber* rcpt1 = CSmsNumber::NewL();
       
  1076 	CleanupStack::PushL(rcpt1);
       
  1077 	rcpt1->SetAddressL(KRecipientBad);
       
  1078 	aHeader.Recipients().AppendL(rcpt1);
       
  1079 	CleanupStack::Pop(rcpt1);
       
  1080 	}
       
  1081 
       
  1082 void CTestDeliverMultiRecipientsOk_2::CheckSentMessageL()
       
  1083 	{
       
  1084 	// Need to check the following - 
       
  1085 	// 1. Correct number of recipients
       
  1086 	// 2. The recipients have delivery status correctly set
       
  1087 	// 3. The index summary is correctly set
       
  1088 	// 4. The index message ID is valid.
       
  1089 	// 5. The index message ID matches that of the recipient
       
  1090 	
       
  1091 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  1092 		
       
  1093 	// Restore the recipient...
       
  1094 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1095 	CleanupStack::PushL(header);
       
  1096 
       
  1097 	MsvEntry().SetEntryL(iMessageId);
       
  1098 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1099 	CleanupStack::PushL(store);
       
  1100 	header->RestoreL(*store);
       
  1101 	CleanupStack::PopAndDestroy(store);
       
  1102 	
       
  1103 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  1104 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  1105 	
       
  1106 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  1107 	
       
  1108 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1109 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1110 	
       
  1111 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  1112 	
       
  1113 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1114 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);	
       
  1115 	
       
  1116 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1117 	
       
  1118 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  1119 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  1120 	
       
  1121 	TLogId logId = 0;	
       
  1122 	TBool validId = entry.MessageId(logId);
       
  1123 	
       
  1124 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  1125 	iTestUtils.Test()(validId != EFalse);
       
  1126 		
       
  1127 	iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, rcpt0->LogId());
       
  1128 	iTestUtils.Test()(logId == rcpt0->LogId());
       
  1129 		
       
  1130 	CleanupStack::PopAndDestroy(header);
       
  1131 	}
       
  1132 	
       
  1133 void CTestDeliverMultiRecipientsOk_2::CheckDeliveredMessageL()
       
  1134 	{
       
  1135 	// Need to check the following - 
       
  1136 	// 1. Correct number of recipients
       
  1137 	// 2. The recipient has delivery status is correctly set
       
  1138 	// 3. The index summary is correctly set
       
  1139 
       
  1140 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set...\n"), iMessageId);
       
  1141 		
       
  1142 	// Restore the recipient...
       
  1143 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1144 	CleanupStack::PushL(header);
       
  1145 
       
  1146 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1147 	MsvEntry().SetEntryL(iMessageId);
       
  1148 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1149 	CleanupStack::PushL(store);
       
  1150 	header->RestoreL(*store);
       
  1151 	CleanupStack::PopAndDestroy(store);
       
  1152 	
       
  1153 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  1154 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  1155 	
       
  1156 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  1157 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  1158 	
       
  1159 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1160 
       
  1161 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1162 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1163 	
       
  1164 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1165 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1166 	
       
  1167 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllSuccessful)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllSuccessful);
       
  1168 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllSuccessful);
       
  1169 
       
  1170 	// Test is no ended - complete self to stop.
       
  1171 	CompleteSelf();		
       
  1172 
       
  1173 	CleanupStack::PopAndDestroy(header);
       
  1174 	}
       
  1175 
       
  1176 const TDesC& CTestDeliverMultiRecipientsOk_2::TestName()
       
  1177 	{
       
  1178 	return KTestDeliverMultiRecipientsOk_2();
       
  1179 	}
       
  1180 	
       
  1181 /*
       
  1182  * CTestDeliverMultiRecipientsOk_3
       
  1183  */
       
  1184  
       
  1185 CTestDeliverMultiRecipientsOk_3* CTestDeliverMultiRecipientsOk_3::NewL(CSmsTestUtils& aTestUtils)
       
  1186 	{
       
  1187 	CTestDeliverMultiRecipientsOk_3* self = new (ELeave) CTestDeliverMultiRecipientsOk_3(aTestUtils);
       
  1188 	CleanupStack::PushL(self);
       
  1189 	self->ConstructL();
       
  1190 	CleanupStack::Pop(self);
       
  1191 	return self;	
       
  1192 	}
       
  1193 		
       
  1194 CTestDeliverMultiRecipientsOk_3::~CTestDeliverMultiRecipientsOk_3()
       
  1195 	{
       
  1196 	}
       
  1197 	
       
  1198 CTestDeliverMultiRecipientsOk_3::CTestDeliverMultiRecipientsOk_3(CSmsTestUtils& aTestUtils)
       
  1199 : CTestDeliverBase(aTestUtils)
       
  1200 	{
       
  1201 	}
       
  1202 	
       
  1203 //	methods from CTestDeliverBase
       
  1204 
       
  1205 void CTestDeliverMultiRecipientsOk_3::SetRecipientsL(CSmsHeader& aHeader)
       
  1206 	{
       
  1207 	iTestUtils.Printf(_L("--Setting multiple (3) recipients\n"));
       
  1208 	
       
  1209 	CSmsNumber* rcpt0 = CSmsNumber::NewL();
       
  1210 	CleanupStack::PushL(rcpt0);
       
  1211 	rcpt0->SetAddressL(KRecipientOk);
       
  1212 	aHeader.Recipients().AppendL(rcpt0);
       
  1213 	CleanupStack::Pop(rcpt0);
       
  1214 	
       
  1215 	CSmsNumber* rcpt1 = CSmsNumber::NewL();
       
  1216 	CleanupStack::PushL(rcpt1);
       
  1217 	rcpt1->SetAddressL(KRecipientOk);
       
  1218 	aHeader.Recipients().AppendL(rcpt1);
       
  1219 	CleanupStack::Pop(rcpt1);
       
  1220 
       
  1221 	CSmsNumber* rcpt2 = CSmsNumber::NewL();
       
  1222 	CleanupStack::PushL(rcpt2);
       
  1223 	rcpt2->SetAddressL(KRecipientBad);
       
  1224 	aHeader.Recipients().AppendL(rcpt2);
       
  1225 	CleanupStack::Pop(rcpt2);
       
  1226 	}
       
  1227 
       
  1228 void CTestDeliverMultiRecipientsOk_3::CheckSentMessageL()
       
  1229 	{
       
  1230 	// Need to check the following - 
       
  1231 	// 1. Correct number of recipients
       
  1232 	// 2. The recipients have delivery status correctly set
       
  1233 	// 3. The index summary is correctly set
       
  1234 	// 4. The index message ID is valid.
       
  1235 	// 5. The index message ID matches that of the recipient
       
  1236 	
       
  1237 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  1238 		
       
  1239 	// Restore the recipient...
       
  1240 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1241 	CleanupStack::PushL(header);
       
  1242 
       
  1243 	MsvEntry().SetEntryL(iMessageId);
       
  1244 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1245 	CleanupStack::PushL(store);
       
  1246 	header->RestoreL(*store);
       
  1247 	CleanupStack::PopAndDestroy(store);
       
  1248 	
       
  1249 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 3);
       
  1250 	iTestUtils.Test()(header->Recipients().Count() == 3);
       
  1251 	
       
  1252 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  1253 	
       
  1254 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1255 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1256 	
       
  1257 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  1258 	
       
  1259 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1260 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);	
       
  1261 	
       
  1262 	CSmsNumber* rcpt2 = header->Recipients()[2];
       
  1263 	
       
  1264 	iTestUtils.Printf(_L("--Recipient 2 - Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt2->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1265 	iTestUtils.Test()(rcpt2->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1266 
       
  1267 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1268 	
       
  1269 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  1270 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  1271 	
       
  1272 	TLogId logId = 0;	
       
  1273 	TBool validId = entry.MessageId(logId);
       
  1274 	
       
  1275 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
  1276 	iTestUtils.Test()(validId == EFalse);
       
  1277 		
       
  1278 	CleanupStack::PopAndDestroy(header);
       
  1279 	}
       
  1280 	
       
  1281 void CTestDeliverMultiRecipientsOk_3::CheckDeliveredMessageL()
       
  1282 	{
       
  1283 	// Need to check the following - 
       
  1284 	// 1. Correct number of recipients
       
  1285 	// 2. The recipient has delivery status is correctly set
       
  1286 	// 3. The index summary is correctly set
       
  1287 
       
  1288 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set - round %d...\n"), iMessageId, ++iCheckCount);
       
  1289 		
       
  1290 	// Restore the recipient...
       
  1291 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1292 	CleanupStack::PushL(header);
       
  1293 
       
  1294 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1295 	MsvEntry().SetEntryL(iMessageId);
       
  1296 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1297 	CleanupStack::PushL(store);
       
  1298 	header->RestoreL(*store);
       
  1299 	CleanupStack::PopAndDestroy(store);
       
  1300 	
       
  1301 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 3);
       
  1302 	iTestUtils.Test()(header->Recipients().Count() == 3);
       
  1303 	
       
  1304 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  1305 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  1306 	CSmsNumber* rcpt2 = header->Recipients()[2];
       
  1307 	
       
  1308 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1309 		
       
  1310 	if( iCheckCount == 1 )
       
  1311 		{
       
  1312 		// At least one of the recipients has been delivered to ok - check the 
       
  1313 		// status of recipient 0 and make decisions based on that.
       
  1314 		CSmsNumber* pendingRcpt = NULL;
       
  1315 		
       
  1316 		if( rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck )
       
  1317 			{
       
  1318 			// Recipient 2 delivered to first...
       
  1319 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1320 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1321 			
       
  1322 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1323 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1324 			
       
  1325 			iTestUtils.Printf(_L("--Recipient 2 - Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt2->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1326 			iTestUtils.Test()(rcpt2->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1327 			
       
  1328 			pendingRcpt = rcpt0;
       
  1329 			}
       
  1330 		else
       
  1331 			{
       
  1332 			// Recipient 0 delivered to first...
       
  1333 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1334 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1335 			
       
  1336 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1337 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1338 			
       
  1339 			iTestUtils.Printf(_L("--Recipient 2 - Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt2->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1340 			iTestUtils.Test()(rcpt2->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1341 			
       
  1342 			pendingRcpt = rcpt1;
       
  1343 			}
       
  1344 		TLogId logId = 0;	
       
  1345 		TBool validId = entry.MessageId(logId);
       
  1346 		
       
  1347 		iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  1348 		iTestUtils.Test()(validId != EFalse);
       
  1349 			
       
  1350 		iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, pendingRcpt->LogId());
       
  1351 		iTestUtils.Test()(logId == pendingRcpt->LogId());
       
  1352 		}
       
  1353 	else
       
  1354 		{
       
  1355 		// Both recipients has been delivered to ok - check the status of both
       
  1356 		// recipients
       
  1357 		iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1358 		iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1359 		
       
  1360 		iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  1361 		iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  1362 		
       
  1363 		iTestUtils.Printf(_L("--Recipient 2 - Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt2->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1364 		iTestUtils.Test()(rcpt2->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1365 
       
  1366 		iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllSuccessful)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllSuccessful);
       
  1367 		iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllSuccessful);
       
  1368 
       
  1369 		// Test is no ended - complete self to stop.
       
  1370 		CompleteSelf();		
       
  1371 		}
       
  1372 	
       
  1373 	CleanupStack::PopAndDestroy(header);
       
  1374 	}
       
  1375 
       
  1376 const TDesC& CTestDeliverMultiRecipientsOk_3::TestName()
       
  1377 	{
       
  1378 	return KTestDeliverMultiRecipientsOk_3();
       
  1379 	}
       
  1380 	
       
  1381 /*
       
  1382  * CTestDeliverNoMatching
       
  1383  */
       
  1384  
       
  1385  CTestDeliverNoMatching* CTestDeliverNoMatching::NewL(CSmsTestUtils& aTestUtils)
       
  1386 	{
       
  1387 	CTestDeliverNoMatching* self = new (ELeave) CTestDeliverNoMatching(aTestUtils);
       
  1388 	CleanupStack::PushL(self);
       
  1389 	self->ConstructL();
       
  1390 	CleanupStack::Pop(self);
       
  1391 	return self;	
       
  1392 	}
       
  1393 		
       
  1394 CTestDeliverNoMatching::~CTestDeliverNoMatching()
       
  1395 	{
       
  1396 	}
       
  1397 	
       
  1398 CTestDeliverNoMatching::CTestDeliverNoMatching(CSmsTestUtils& aTestUtils)
       
  1399 : CTestDeliverBase(aTestUtils)
       
  1400 	{
       
  1401 	}
       
  1402 	
       
  1403 //	methods from MMsvEntryObserver	
       
  1404 	
       
  1405 void CTestDeliverNoMatching::HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/)
       
  1406 	{
       
  1407 	if( aEvent == EMsvNewChildren )
       
  1408 		{
       
  1409 		iTestUtils.Printf(_L("Received new message in Inbox - should be status report...\n"));
       
  1410 		
       
  1411 		CMsvEntrySelection* sel = static_cast<CMsvEntrySelection*>(aArg1);
       
  1412 
       
  1413 		// Check how many mesasges there are - should be just 1
       
  1414 		TInt count = sel->Count();
       
  1415 
       
  1416 		iTestUtils.Printf(_L("--Number of new messages -> %d - should be %d\n"), count, 1);
       
  1417 		iTestUtils.Test()(count == 1);
       
  1418 		
       
  1419 		// Restore the message
       
  1420 
       
  1421 		CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1422 		CleanupStack::PushL(header);
       
  1423 
       
  1424 		MsvEntry().SetEntryL((*sel)[0]);
       
  1425 		CMsvStore* store = MsvEntry().ReadStoreL();
       
  1426 		CleanupStack::PushL(store);
       
  1427 
       
  1428 		header->RestoreL(*store);
       
  1429 		iTestUtils.iRichText->Reset();
       
  1430 		store->RestoreBodyTextL(*iTestUtils.iRichText);
       
  1431 
       
  1432 		CleanupStack::PopAndDestroy(store);
       
  1433 		
       
  1434 		// Check that it's a Status Report...
       
  1435 		iTestUtils.Printf(_L("--Message type -> %d - should be %d\n"), header->Type(), CSmsPDU::ESmsStatusReport);
       
  1436 		iTestUtils.Test()(header->Type() == CSmsPDU::ESmsStatusReport);
       
  1437 		
       
  1438 		// Check the message reference
       
  1439 		TLogId logId = header->Message().LogServerId();
       
  1440 		iTestUtils.Printf(_L("--Log Server Id -> %d - should be %d\n"), logId, iLogId);
       
  1441 		iTestUtils.Test()(logId == iLogId);
       
  1442 		
       
  1443 		// Check the deliver status
       
  1444 		CSmsStatusReport& report = header->StatusReport();
       
  1445 		iTestUtils.Printf(_L("--Deliver status -> %d - should be %d (ESmsShortMessageReceivedBySME)\n"), report.Status(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1446 		iTestUtils.Test()(report.Status() == TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1447 		
       
  1448 		CleanupStack::PopAndDestroy(header);
       
  1449 		
       
  1450 		// Check that the sent message has been updated.
       
  1451 		CheckDeliveredMessageL();
       
  1452 		}
       
  1453 	}
       
  1454 				
       
  1455 //	 methods from CTestDeliverBase
       
  1456 
       
  1457 void CTestDeliverNoMatching::SetRecipientsL(CSmsHeader& aHeader)
       
  1458 	{
       
  1459 	iTestUtils.Printf(_L("--Setting single recipient\n"));
       
  1460 	
       
  1461 	CSmsNumber* rcpt = CSmsNumber::NewL();
       
  1462 	CleanupStack::PushL(rcpt);
       
  1463 	rcpt->SetAddressL(KRecipientOk);
       
  1464 	aHeader.Recipients().AppendL(rcpt);
       
  1465 	CleanupStack::Pop(rcpt);
       
  1466 	}
       
  1467 
       
  1468 void CTestDeliverNoMatching::ChangeServiceSettingsL()
       
  1469 	{
       
  1470 	// Restore the service settings.
       
  1471 	iTestUtils.SetEntryL(iTestUtils.iSmsServiceId);
       
  1472 	CSmsAccount* account = CSmsAccount::NewLC();
       
  1473 	account->LoadSettingsL(*iTestUtils.iServiceSettings);
       
  1474 	
       
  1475 	// Set the service settings 
       
  1476 	iTestUtils.iServiceSettings->SetValidityPeriod(TTimeIntervalMinutes(5));
       
  1477 	iTestUtils.iServiceSettings->SetDeliveryReport(ETrue);
       
  1478 	iTestUtils.iServiceSettings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible);
       
  1479 	
       
  1480 	// Store the new service settings
       
  1481 	account->SaveSettingsL(*iTestUtils.iServiceSettings);
       
  1482 	CleanupStack::PopAndDestroy(account);
       
  1483 	}
       
  1484 	
       
  1485 TMsvId CTestDeliverNoMatching::GetObserverEntry()
       
  1486 	{
       
  1487 	return KMsvGlobalInBoxIndexEntryId;
       
  1488 	}
       
  1489 
       
  1490 void CTestDeliverNoMatching::CheckSentMessageL()
       
  1491 	{
       
  1492 	// Need to check the following - 
       
  1493 	// 1. Correct number of recipients
       
  1494 	// 2. The recipient has delivery status correctly set
       
  1495 	// 3. The index summary is correctly set
       
  1496 	// 4. The index message ID is valid.
       
  1497 	// 5. The index message ID matches that of the recipient
       
  1498 	
       
  1499 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  1500 		
       
  1501 	// Restore the recipient...
       
  1502 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1503 	CleanupStack::PushL(header);
       
  1504 
       
  1505 	MsvEntry().SetEntryL(iMessageId);
       
  1506 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1507 	CleanupStack::PushL(store);
       
  1508 	header->RestoreL(*store);
       
  1509 	CleanupStack::PopAndDestroy(store);
       
  1510 	
       
  1511 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
  1512 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
  1513 	
       
  1514 	CSmsNumber* rcpt = header->Recipients()[0];
       
  1515 	
       
  1516 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1517 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1518 	
       
  1519 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1520 	
       
  1521 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  1522 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  1523 	
       
  1524 	TLogId logId = 0;	
       
  1525 	TBool validId = entry.MessageId(logId);
       
  1526 	
       
  1527 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  1528 	iTestUtils.Test()(validId != EFalse);
       
  1529 		
       
  1530 	iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, rcpt->LogId());
       
  1531 	iTestUtils.Test()(logId == rcpt->LogId());
       
  1532 	
       
  1533 	iLogId = rcpt->LogId();
       
  1534 	
       
  1535 	CleanupStack::PopAndDestroy(header);
       
  1536 	}
       
  1537 	
       
  1538 void CTestDeliverNoMatching::CheckDeliveredMessageL()
       
  1539 	{
       
  1540 	// Need to check the following - 
       
  1541 	// 1. Correct number of recipients
       
  1542 	// 2. The recipient has delivery status correctly set
       
  1543 	// 3. The index summary is correctly set
       
  1544 	
       
  1545 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set...\n"), iMessageId);
       
  1546 		
       
  1547 	// Restore the recipient...
       
  1548 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1549 	CleanupStack::PushL(header);
       
  1550 
       
  1551 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1552 	MsvEntry().SetEntryL(iMessageId);
       
  1553 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1554 	CleanupStack::PushL(store);
       
  1555 	header->RestoreL(*store);
       
  1556 	CleanupStack::PopAndDestroy(store);
       
  1557 	
       
  1558 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
  1559 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
  1560 	
       
  1561 	CSmsNumber* rcpt = header->Recipients()[0];
       
  1562 	
       
  1563 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1564 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1565 	
       
  1566 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1567 	
       
  1568 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  1569 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  1570 	
       
  1571 	// Test is no ended - complete self to stop.
       
  1572 	CompleteSelf();		
       
  1573 	
       
  1574 	CleanupStack::PopAndDestroy(header);
       
  1575 	}
       
  1576 
       
  1577 const TDesC& CTestDeliverNoMatching::TestName()
       
  1578 	{
       
  1579 	return KTestDeliverNoMatching();
       
  1580 	}
       
  1581 	
       
  1582 /*
       
  1583  * CTestDeliverNoStatusReports
       
  1584  */
       
  1585  
       
  1586  CTestDeliverNoStatusReports* CTestDeliverNoStatusReports::NewL(CSmsTestUtils& aTestUtils)
       
  1587 	{
       
  1588 	CTestDeliverNoStatusReports* self = new (ELeave) CTestDeliverNoStatusReports(aTestUtils);
       
  1589 	CleanupStack::PushL(self);
       
  1590 	self->ConstructL();
       
  1591 	CleanupStack::Pop(self);
       
  1592 	return self;	
       
  1593 	}
       
  1594 		
       
  1595 CTestDeliverNoStatusReports::~CTestDeliverNoStatusReports()
       
  1596 	{
       
  1597 	}
       
  1598 	
       
  1599 CTestDeliverNoStatusReports::CTestDeliverNoStatusReports(CSmsTestUtils& aTestUtils)
       
  1600 : CTestDeliverBase(aTestUtils)
       
  1601 	{
       
  1602 	}
       
  1603 				
       
  1604 //	 methods from CTestDeliverBase
       
  1605 
       
  1606 void CTestDeliverNoStatusReports::SetRecipientsL(CSmsHeader& aHeader)
       
  1607 	{
       
  1608 	iTestUtils.Printf(_L("--Setting single recipient\n"));
       
  1609 	
       
  1610 	CSmsNumber* rcpt = CSmsNumber::NewL();
       
  1611 	CleanupStack::PushL(rcpt);
       
  1612 	rcpt->SetAddressL(KRecipientOk);
       
  1613 	aHeader.Recipients().AppendL(rcpt);
       
  1614 	CleanupStack::Pop(rcpt);
       
  1615 	}
       
  1616 
       
  1617 void CTestDeliverNoStatusReports::ChangeServiceSettingsL()
       
  1618 	{
       
  1619 	// Restore the service settings.
       
  1620 	iTestUtils.SetEntryL(iTestUtils.iSmsServiceId);
       
  1621 	CSmsAccount* account = CSmsAccount::NewLC();
       
  1622 	account->LoadSettingsL(*iTestUtils.iServiceSettings);
       
  1623 	
       
  1624 	// Set the service settings 
       
  1625 	iTestUtils.iServiceSettings->SetValidityPeriod(TTimeIntervalMinutes(5));
       
  1626 	iTestUtils.iServiceSettings->SetDeliveryReport(EFalse);
       
  1627 	iTestUtils.iServiceSettings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch);
       
  1628 	
       
  1629 	// Store the new service settings
       
  1630 	account->SaveSettingsL(*iTestUtils.iServiceSettings);
       
  1631 	CleanupStack::PopAndDestroy(account);
       
  1632 	}
       
  1633 	
       
  1634 TMsvId CTestDeliverNoStatusReports::GetObserverEntry()
       
  1635 	{
       
  1636 	return KMsvNullIndexEntryId;
       
  1637 	}
       
  1638 
       
  1639 void CTestDeliverNoStatusReports::CheckSentMessageL()
       
  1640 	{
       
  1641 	// Need to check the following - 
       
  1642 	// 1. Correct number of recipients
       
  1643 	// 2. The recipient has delivery status correctly set
       
  1644 	// 3. The index summary is correctly set
       
  1645 	// 4. The index message ID is valid.
       
  1646 	// 5. The index message ID matches that of the recipient
       
  1647 	
       
  1648 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  1649 		
       
  1650 	// Restore the recipient...
       
  1651 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1652 	CleanupStack::PushL(header);
       
  1653 
       
  1654 	MsvEntry().SetEntryL(iMessageId);
       
  1655 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1656 	CleanupStack::PushL(store);
       
  1657 	header->RestoreL(*store);
       
  1658 	CleanupStack::PopAndDestroy(store);
       
  1659 	
       
  1660 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
  1661 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
  1662 	
       
  1663 	CSmsNumber* rcpt = header->Recipients()[0];
       
  1664 	
       
  1665 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1666 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1667 	
       
  1668 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1669 	
       
  1670 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (ENoAckSummary)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::ENoAckSummary);
       
  1671 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::ENoAckSummary);
       
  1672 	
       
  1673 	TLogId logId = 0;	
       
  1674 	TBool validId = entry.MessageId(logId);
       
  1675 	
       
  1676 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
  1677 	iTestUtils.Test()(validId == EFalse);
       
  1678 		
       
  1679 	CleanupStack::PopAndDestroy(header);
       
  1680 	}
       
  1681 	
       
  1682 void CTestDeliverNoStatusReports::CheckDeliveredMessageL()
       
  1683 	{
       
  1684 	User::Invariant();
       
  1685 	}
       
  1686 
       
  1687 const TDesC& CTestDeliverNoStatusReports::TestName()
       
  1688 	{
       
  1689 	return KTestDeliverNoStatusReports();
       
  1690 	}
       
  1691 	
       
  1692 /*
       
  1693  * CTestDeliverNotSent
       
  1694  */
       
  1695  
       
  1696  CTestDeliverNotSent* CTestDeliverNotSent::NewL(CSmsTestUtils& aTestUtils)
       
  1697 	{
       
  1698 	CTestDeliverNotSent* self = new (ELeave) CTestDeliverNotSent(aTestUtils);
       
  1699 	CleanupStack::PushL(self);
       
  1700 	self->ConstructL();
       
  1701 	CleanupStack::Pop(self);
       
  1702 	return self;	
       
  1703 	}
       
  1704 		
       
  1705 CTestDeliverNotSent::~CTestDeliverNotSent()
       
  1706 	{
       
  1707 	}
       
  1708 	
       
  1709 CTestDeliverNotSent::CTestDeliverNotSent(CSmsTestUtils& aTestUtils)
       
  1710 : CTestDeliverBase(aTestUtils)
       
  1711 	{
       
  1712 	}
       
  1713 				
       
  1714 //	 methods from CTestDeliverBase
       
  1715 
       
  1716 void CTestDeliverNotSent::SetRecipientsL(CSmsHeader& aHeader)
       
  1717 	{
       
  1718 	iTestUtils.Printf(_L("--Setting single recipient\n"));
       
  1719 	
       
  1720 	CSmsNumber* rcpt = CSmsNumber::NewL();
       
  1721 	CleanupStack::PushL(rcpt);
       
  1722 	rcpt->SetAddressL(KRecipientBad);
       
  1723 	aHeader.Recipients().AppendL(rcpt);
       
  1724 	CleanupStack::Pop(rcpt);
       
  1725 	}
       
  1726 
       
  1727 TMsvId CTestDeliverNotSent::GetObserverEntry()
       
  1728 	{
       
  1729 	return KMsvNullIndexEntryId;
       
  1730 	}
       
  1731 
       
  1732 void CTestDeliverNotSent::CheckSentMessageL()
       
  1733 	{
       
  1734 	// Need to check the following - 
       
  1735 	// 1. Correct number of recipients
       
  1736 	// 2. The recipient has delivery status correctly set
       
  1737 	// 3. The index summary is correctly set
       
  1738 	// 4. The index message ID is valid.
       
  1739 	// 5. The index message ID matches that of the recipient
       
  1740 	
       
  1741 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  1742 		
       
  1743 	// Restore the recipient...
       
  1744 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1745 	CleanupStack::PushL(header);
       
  1746 
       
  1747 	MsvEntry().SetEntryL(iMessageId);
       
  1748 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1749 	CleanupStack::PushL(store);
       
  1750 	header->RestoreL(*store);
       
  1751 	CleanupStack::PopAndDestroy(store);
       
  1752 	
       
  1753 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 1);
       
  1754 	iTestUtils.Test()(header->Recipients().Count() == 1);
       
  1755 	
       
  1756 	CSmsNumber* rcpt = header->Recipients()[0];
       
  1757 	
       
  1758 	iTestUtils.Printf(_L("--Delivery status -> %d - should be %d (ENoAckRequested)\n"), rcpt->AckStatus(ESmsAckTypeDelivery), CSmsNumber::ENoAckRequested);
       
  1759 	iTestUtils.Test()(rcpt->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::ENoAckRequested);
       
  1760 	
       
  1761 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1762 	
       
  1763 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (ENoAckSummary)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::ENoAckSummary);
       
  1764 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::ENoAckSummary);
       
  1765 	
       
  1766 	TLogId logId = 0;	
       
  1767 	TBool validId = entry.MessageId(logId);
       
  1768 	
       
  1769 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
  1770 	iTestUtils.Test()(validId == EFalse);
       
  1771 		
       
  1772 	CleanupStack::PopAndDestroy(header);
       
  1773 	}
       
  1774 	
       
  1775 void CTestDeliverNotSent::CheckDeliveredMessageL()
       
  1776 	{
       
  1777 	User::Invariant();
       
  1778 	}
       
  1779 
       
  1780 const TDesC& CTestDeliverNotSent::TestName()
       
  1781 	{
       
  1782 	return KTestDeliverNotSent();
       
  1783 	}
       
  1784 
       
  1785 /*
       
  1786  * CTestDeliverMultiRecipientsFail_1
       
  1787  */
       
  1788  
       
  1789 CTestDeliverMultiRecipientsFail_1* CTestDeliverMultiRecipientsFail_1::NewL(CSmsTestUtils& aTestUtils)
       
  1790 	{
       
  1791 	CTestDeliverMultiRecipientsFail_1* self = new (ELeave) CTestDeliverMultiRecipientsFail_1(aTestUtils);
       
  1792 	CleanupStack::PushL(self);
       
  1793 	self->ConstructL();
       
  1794 	CleanupStack::Pop(self);
       
  1795 	return self;	
       
  1796 	}
       
  1797 		
       
  1798 CTestDeliverMultiRecipientsFail_1::~CTestDeliverMultiRecipientsFail_1()
       
  1799 	{
       
  1800 	}
       
  1801 	
       
  1802 CTestDeliverMultiRecipientsFail_1::CTestDeliverMultiRecipientsFail_1(CSmsTestUtils& aTestUtils)
       
  1803 : CTestDeliverBase(aTestUtils)
       
  1804 	{
       
  1805 	}
       
  1806 	
       
  1807 //	methods from CTestDeliverBase
       
  1808 
       
  1809 void CTestDeliverMultiRecipientsFail_1::SetRecipientsL(CSmsHeader& aHeader)
       
  1810 	{
       
  1811 	iTestUtils.Printf(_L("--Setting multiple (3) recipients\n"));
       
  1812 	
       
  1813 	CSmsNumber* rcpt0 = CSmsNumber::NewL();
       
  1814 	CleanupStack::PushL(rcpt0);
       
  1815 	rcpt0->SetAddressL(KRecipientFail);
       
  1816 	aHeader.Recipients().AppendL(rcpt0);
       
  1817 	CleanupStack::Pop(rcpt0);
       
  1818 	
       
  1819 	CSmsNumber* rcpt1 = CSmsNumber::NewL();
       
  1820 	CleanupStack::PushL(rcpt1);
       
  1821 	rcpt1->SetAddressL(KRecipientFail);
       
  1822 	aHeader.Recipients().AppendL(rcpt1);
       
  1823 	CleanupStack::Pop(rcpt1);
       
  1824 	}
       
  1825 	
       
  1826 void CTestDeliverMultiRecipientsFail_1::CheckSentMessageL()
       
  1827 	{
       
  1828 	// Need to check the following - 
       
  1829 	// 1. Correct number of recipients
       
  1830 	// 2. The recipients have delivery status correctly set
       
  1831 	// 3. The index summary is correctly set
       
  1832 	// 4. The index message ID is valid.
       
  1833 	// 5. The index message ID matches that of the recipient
       
  1834 	
       
  1835 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  1836 		
       
  1837 	// Restore the recipient...
       
  1838 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1839 	CleanupStack::PushL(header);
       
  1840 
       
  1841 	MsvEntry().SetEntryL(iMessageId);
       
  1842 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1843 	CleanupStack::PushL(store);
       
  1844 	header->RestoreL(*store);
       
  1845 	CleanupStack::PopAndDestroy(store);
       
  1846 	
       
  1847 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  1848 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  1849 	
       
  1850 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  1851 	
       
  1852 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1853 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1854 	
       
  1855 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  1856 	
       
  1857 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1858 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);	
       
  1859 	
       
  1860 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1861 	
       
  1862 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  1863 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  1864 	
       
  1865 	TLogId logId = 0;	
       
  1866 	TBool validId = entry.MessageId(logId);
       
  1867 	
       
  1868 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
  1869 	iTestUtils.Test()(validId == EFalse);
       
  1870 		
       
  1871 	CleanupStack::PopAndDestroy(header);
       
  1872 	}
       
  1873 	
       
  1874 void CTestDeliverMultiRecipientsFail_1::CheckDeliveredMessageL()
       
  1875 	{
       
  1876 	// Need to check the following - 
       
  1877 	// 1. Correct number of recipients
       
  1878 	// 2. The recipient has delivery status is correctly set
       
  1879 	// 3. The index summary is correctly set
       
  1880 
       
  1881 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set - round %d...\n"), iMessageId, ++iCheckCount);
       
  1882 		
       
  1883 	// Restore the recipient...
       
  1884 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  1885 	CleanupStack::PushL(header);
       
  1886 
       
  1887 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  1888 	MsvEntry().SetEntryL(iMessageId);
       
  1889 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  1890 	CleanupStack::PushL(store);
       
  1891 	header->RestoreL(*store);
       
  1892 	CleanupStack::PopAndDestroy(store);
       
  1893 	
       
  1894 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  1895 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  1896 	
       
  1897 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  1898 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  1899 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  1900 		
       
  1901 	if( iCheckCount == 1 )
       
  1902 		{
       
  1903 		// At least one of the recipients has been delivered to ok - check the 
       
  1904 		// status of recipient 0 and make decisions based on that.
       
  1905 		CSmsNumber* pendingRcpt = NULL;
       
  1906 		
       
  1907 		if( rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck )
       
  1908 			{
       
  1909 			// Recipient 2 delivered to first...
       
  1910 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1911 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1912 			
       
  1913 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  1914 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  1915 			
       
  1916 			iTestUtils.Printf(_L("--Recipient 1 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt1->Status(), CMsvRecipient::EFailedToSend);
       
  1917 			iTestUtils.Test()(rcpt1->Status()==CMsvRecipient::EFailedToSend);
       
  1918 
       
  1919 			iTestUtils.Printf(_L("--Recipient 1 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt1->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1920 			iTestUtils.Test()(rcpt1->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1921 			
       
  1922 			pendingRcpt = rcpt0;
       
  1923 			}
       
  1924 		else
       
  1925 			{
       
  1926 			// Recipient 0 delivered to first...
       
  1927 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  1928 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  1929 			
       
  1930 			iTestUtils.Printf(_L("--Recipient 0 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt0->Status(), CMsvRecipient::EFailedToSend);
       
  1931 			iTestUtils.Test()(rcpt0->Status()==CMsvRecipient::EFailedToSend);
       
  1932 			
       
  1933 			iTestUtils.Printf(_L("--Recipient 0 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt0->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1934 			iTestUtils.Test()(rcpt0->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);				
       
  1935 		
       
  1936 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  1937 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  1938 			
       
  1939 			pendingRcpt = rcpt1;
       
  1940 			}
       
  1941 		TLogId logId = 0;	
       
  1942 		TBool validId = entry.MessageId(logId);
       
  1943 		
       
  1944 		iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  1945 		iTestUtils.Test()(validId != EFalse);
       
  1946 			
       
  1947 		iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, pendingRcpt->LogId());
       
  1948 		iTestUtils.Test()(logId == pendingRcpt->LogId());
       
  1949 		}
       
  1950 	else
       
  1951 		{
       
  1952 		// Both recipients has been delivered to ok - check the status of both
       
  1953 		// recipients
       
  1954 		iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  1955 		iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  1956 		
       
  1957 		iTestUtils.Printf(_L("--Recipient 0 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt0->Status(), CMsvRecipient::EFailedToSend);
       
  1958 		iTestUtils.Test()(rcpt0->Status()==CMsvRecipient::EFailedToSend);
       
  1959 	
       
  1960 		iTestUtils.Printf(_L("--Recipient 0 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt0->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1961 		iTestUtils.Test()(rcpt0->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1962 		
       
  1963 		iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  1964 		iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  1965 		
       
  1966 		iTestUtils.Printf(_L("--Recipient 1 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt1->Status(), CMsvRecipient::EFailedToSend);
       
  1967 		iTestUtils.Test()(rcpt1->Status()==CMsvRecipient::EFailedToSend);
       
  1968 				
       
  1969 		iTestUtils.Printf(_L("--Recipient 1 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt1->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1970 		iTestUtils.Test()(rcpt1->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  1971 		
       
  1972 		iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllFailed)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllFailed);
       
  1973 		iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllFailed);
       
  1974 
       
  1975 		// Test is no ended - complete self to stop.
       
  1976 		CompleteSelf();		
       
  1977 		}
       
  1978 	
       
  1979 	CleanupStack::PopAndDestroy(header);
       
  1980 	}
       
  1981 
       
  1982 const TDesC& CTestDeliverMultiRecipientsFail_1::TestName()
       
  1983 	{
       
  1984 	return KTestDeliverMultiRecipientsFail_1();
       
  1985 	}
       
  1986 
       
  1987 /*
       
  1988  * CTestDeliverMultiRecipientsMixed_1
       
  1989  */
       
  1990  
       
  1991 CTestDeliverMultiRecipientsMixed_1* CTestDeliverMultiRecipientsMixed_1::NewL(CSmsTestUtils& aTestUtils)
       
  1992 	{
       
  1993 	CTestDeliverMultiRecipientsMixed_1* self = new (ELeave) CTestDeliverMultiRecipientsMixed_1(aTestUtils);
       
  1994 	CleanupStack::PushL(self);
       
  1995 	self->ConstructL();
       
  1996 	CleanupStack::Pop(self);
       
  1997 	return self;	
       
  1998 	}
       
  1999 		
       
  2000 CTestDeliverMultiRecipientsMixed_1::~CTestDeliverMultiRecipientsMixed_1()
       
  2001 	{
       
  2002 	}
       
  2003 	
       
  2004 CTestDeliverMultiRecipientsMixed_1::CTestDeliverMultiRecipientsMixed_1(CSmsTestUtils& aTestUtils)
       
  2005 : CTestDeliverBase(aTestUtils)
       
  2006 	{
       
  2007 	}
       
  2008 	
       
  2009 //	methods from CTestDeliverBase
       
  2010 
       
  2011 void CTestDeliverMultiRecipientsMixed_1::SetRecipientsL(CSmsHeader& aHeader)
       
  2012 	{
       
  2013 	iTestUtils.Printf(_L("--Setting multiple (3) recipients\n"));
       
  2014 	
       
  2015 	CSmsNumber* rcpt0 = CSmsNumber::NewL();
       
  2016 	CleanupStack::PushL(rcpt0);
       
  2017 	rcpt0->SetAddressL(KRecipientFail);
       
  2018 	aHeader.Recipients().AppendL(rcpt0);
       
  2019 	CleanupStack::Pop(rcpt0);
       
  2020 	
       
  2021 	CSmsNumber* rcpt1 = CSmsNumber::NewL();
       
  2022 	CleanupStack::PushL(rcpt1);
       
  2023 	rcpt1->SetAddressL(KRecipientOk);
       
  2024 	aHeader.Recipients().AppendL(rcpt1);
       
  2025 	CleanupStack::Pop(rcpt1);
       
  2026 	}
       
  2027 	
       
  2028 void CTestDeliverMultiRecipientsMixed_1::CheckSentMessageL()
       
  2029 	{
       
  2030 	// Need to check the following - 
       
  2031 	// 1. Correct number of recipients
       
  2032 	// 2. The recipients have delivery status correctly set
       
  2033 	// 3. The index summary is correctly set
       
  2034 	// 4. The index message ID is valid.
       
  2035 	// 5. The index message ID matches that of the recipient
       
  2036 	
       
  2037 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  2038 		
       
  2039 	// Restore the recipient...
       
  2040 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  2041 	CleanupStack::PushL(header);
       
  2042 
       
  2043 	MsvEntry().SetEntryL(iMessageId);
       
  2044 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  2045 	CleanupStack::PushL(store);
       
  2046 	header->RestoreL(*store);
       
  2047 	CleanupStack::PopAndDestroy(store);
       
  2048 	
       
  2049 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  2050 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  2051 	
       
  2052 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  2053 	
       
  2054 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2055 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2056 	
       
  2057 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  2058 	
       
  2059 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2060 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);	
       
  2061 	
       
  2062 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  2063 	
       
  2064 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  2065 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  2066 	
       
  2067 	TLogId logId = 0;	
       
  2068 	TBool validId = entry.MessageId(logId);
       
  2069 	
       
  2070 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
  2071 	iTestUtils.Test()(validId == EFalse);
       
  2072 		
       
  2073 	CleanupStack::PopAndDestroy(header);
       
  2074 	}
       
  2075 	
       
  2076 void CTestDeliverMultiRecipientsMixed_1::CheckDeliveredMessageL()
       
  2077 	{
       
  2078 	// Need to check the following - 
       
  2079 	// 1. Correct number of recipients
       
  2080 	// 2. The recipient has delivery status is correctly set
       
  2081 	// 3. The index summary is correctly set
       
  2082 
       
  2083 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set - round %d...\n"), iMessageId, ++iCheckCount);
       
  2084 		
       
  2085 	// Restore the recipient...
       
  2086 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  2087 	CleanupStack::PushL(header);
       
  2088 
       
  2089 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  2090 	MsvEntry().SetEntryL(iMessageId);
       
  2091 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  2092 	CleanupStack::PushL(store);
       
  2093 	header->RestoreL(*store);
       
  2094 	CleanupStack::PopAndDestroy(store);
       
  2095 	
       
  2096 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  2097 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  2098 	
       
  2099 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  2100 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  2101 	
       
  2102 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  2103 		
       
  2104 	if( iCheckCount == 1 )
       
  2105 		{
       
  2106 		// At least one of the recipients has been delivered to ok - check the 
       
  2107 		// status of recipient 0 and make decisions based on that.
       
  2108 		CSmsNumber* pendingRcpt = NULL;
       
  2109 		
       
  2110 		if( rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck )
       
  2111 			{
       
  2112 			// Recipient 2 delivered to first...
       
  2113 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2114 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2115 			
       
  2116 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  2117 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  2118 			
       
  2119 			pendingRcpt = rcpt0;
       
  2120 			}
       
  2121 		else
       
  2122 			{
       
  2123 			// Recipient 0 delivered to first...
       
  2124 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  2125 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  2126 			
       
  2127 			iTestUtils.Printf(_L("--Recipient 0 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt0->Status(), CMsvRecipient::EFailedToSend);
       
  2128 			iTestUtils.Test()(rcpt0->Status()==CMsvRecipient::EFailedToSend);
       
  2129 
       
  2130 			iTestUtils.Printf(_L("--Recipient 0 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt0->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2131 			iTestUtils.Test()(rcpt0->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2132 			
       
  2133 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2134 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2135 			
       
  2136 			pendingRcpt = rcpt1;
       
  2137 			}
       
  2138 		TLogId logId = 0;	
       
  2139 		TBool validId = entry.MessageId(logId);
       
  2140 		
       
  2141 		iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  2142 		iTestUtils.Test()(validId != EFalse);
       
  2143 			
       
  2144 		iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, pendingRcpt->LogId());
       
  2145 		iTestUtils.Test()(logId == pendingRcpt->LogId());
       
  2146 		}
       
  2147 	else
       
  2148 		{
       
  2149 		// Status-reports for both recipients have been received - check the 
       
  2150 		// status of both recipients.
       
  2151 		iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  2152 		iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  2153 		
       
  2154 		iTestUtils.Printf(_L("--Recipient 0 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt0->Status(), CMsvRecipient::EFailedToSend);
       
  2155 		iTestUtils.Test()(rcpt0->Status()==CMsvRecipient::EFailedToSend);
       
  2156 
       
  2157 		iTestUtils.Printf(_L("--Recipient 0 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt0->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2158 		iTestUtils.Test()(rcpt0->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2159 		
       
  2160 		iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckSuccessful)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckSuccessful);
       
  2161 		iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful);
       
  2162 		
       
  2163 		iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EMixed)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EMixed);
       
  2164 		iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EMixed);
       
  2165 
       
  2166 		// Test is no ended - complete self to stop.
       
  2167 		CompleteSelf();		
       
  2168 		}
       
  2169 	
       
  2170 	CleanupStack::PopAndDestroy(header);
       
  2171 	}
       
  2172 
       
  2173 const TDesC& CTestDeliverMultiRecipientsMixed_1::TestName()
       
  2174 	{
       
  2175 	return KTestDeliverMultiRecipientsMixed_1();
       
  2176 	}
       
  2177 
       
  2178 /*
       
  2179  * CTestDeliverMultiRecipientsMixed_2
       
  2180  */
       
  2181 
       
  2182 CTestDeliverMultiRecipientsMixed_2* CTestDeliverMultiRecipientsMixed_2::NewL(CSmsTestUtils& aTestUtils)
       
  2183 	{
       
  2184 	CTestDeliverMultiRecipientsMixed_2* self = new (ELeave) CTestDeliverMultiRecipientsMixed_2(aTestUtils);
       
  2185 	CleanupStack::PushL(self);
       
  2186 	self->ConstructL();
       
  2187 	CleanupStack::Pop(self);
       
  2188 	return self;
       
  2189 	}
       
  2190 
       
  2191 CTestDeliverMultiRecipientsMixed_2::~CTestDeliverMultiRecipientsMixed_2()
       
  2192 	{
       
  2193 	}
       
  2194 
       
  2195 CTestDeliverMultiRecipientsMixed_2::CTestDeliverMultiRecipientsMixed_2(CSmsTestUtils& aTestUtils)
       
  2196 : CTestDeliverBase(aTestUtils)
       
  2197 	{
       
  2198 	}
       
  2199 
       
  2200 //	methods from CTestDeliverBase
       
  2201 
       
  2202 void CTestDeliverMultiRecipientsMixed_2::SetRecipientsL(CSmsHeader& aHeader)
       
  2203 	{
       
  2204 	iTestUtils.Printf(_L("--Setting multiple (2) recipients\n"));
       
  2205 
       
  2206 	CSmsNumber* rcpt0 = CSmsNumber::NewL();
       
  2207 	CleanupStack::PushL(rcpt0);
       
  2208 	rcpt0->SetAddressL(KRecipientFail);
       
  2209 	aHeader.Recipients().AppendL(rcpt0);
       
  2210 	CleanupStack::Pop(rcpt0);
       
  2211 
       
  2212 	CSmsNumber* rcpt1 = CSmsNumber::NewL();
       
  2213 	CleanupStack::PushL(rcpt1);
       
  2214 	rcpt1->SetAddressL(KRecipientFail);
       
  2215 	aHeader.Recipients().AppendL(rcpt1);
       
  2216 	CleanupStack::Pop(rcpt1);
       
  2217 	}
       
  2218 
       
  2219 void CTestDeliverMultiRecipientsMixed_2::CheckSentMessageL()
       
  2220 	{
       
  2221 	// Need to check the following -
       
  2222 	// 1. Correct number of recipients
       
  2223 	// 2. The recipients have delivery status correctly set
       
  2224 	// 3. The index summary is correctly set
       
  2225 	// 4. The index message ID is valid.
       
  2226 	// 5. The index message ID matches that of the recipient
       
  2227 
       
  2228 	iTestUtils.Printf(_L("Checking sent message %d has correct flags set...\n"), iMessageId);
       
  2229 
       
  2230 	// Restore the recipient...
       
  2231 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  2232 	CleanupStack::PushL(header);
       
  2233 
       
  2234 	MsvEntry().SetEntryL(iMessageId);
       
  2235 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  2236 	CleanupStack::PushL(store);
       
  2237 	header->RestoreL(*store);
       
  2238 	CleanupStack::PopAndDestroy(store);
       
  2239 
       
  2240 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  2241 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  2242 
       
  2243 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  2244 
       
  2245 	iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2246 	iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2247 
       
  2248 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  2249 
       
  2250 	iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2251 	iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2252 
       
  2253 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  2254 
       
  2255 	iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EPendingAcks)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EPendingAcks);
       
  2256 	iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EPendingAcks);
       
  2257 
       
  2258 	TLogId logId = 0;
       
  2259 	TBool validId = entry.MessageId(logId);
       
  2260 
       
  2261 	iTestUtils.Printf(_L("--Index message Id validity -> %d - should be %d\n"), validId, EFalse);
       
  2262 	iTestUtils.Test()(validId == EFalse);
       
  2263 
       
  2264 	CleanupStack::PopAndDestroy(header);
       
  2265 	}
       
  2266 
       
  2267 void CTestDeliverMultiRecipientsMixed_2::CheckDeliveredMessageL()
       
  2268 	{
       
  2269 	// Need to check the following -
       
  2270 	// 1. Correct number of recipients
       
  2271 	// 2. The recipient has delivery status is correctly set
       
  2272 	// 3. The index summary is correctly set
       
  2273 
       
  2274 	iTestUtils.Printf(_L("Checking delivered message %d has correct flags set - round %d...\n"), iMessageId, ++iCheckCount);
       
  2275 
       
  2276 	// Restore the recipient...
       
  2277 	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils.iRichText);
       
  2278 	CleanupStack::PushL(header);
       
  2279 
       
  2280 	MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
  2281 	MsvEntry().SetEntryL(iMessageId);
       
  2282 	CMsvStore* store = iTestUtils.ReadStoreL();
       
  2283 	CleanupStack::PushL(store);
       
  2284 	header->RestoreL(*store);
       
  2285 	CleanupStack::PopAndDestroy(store);
       
  2286 
       
  2287 	iTestUtils.Printf(_L("--Number of recipients -> %d - should be %d\n"), header->Recipients().Count(), 2);
       
  2288 	iTestUtils.Test()(header->Recipients().Count() == 2);
       
  2289 
       
  2290 	CSmsNumber* rcpt0 = header->Recipients()[0];
       
  2291 	CSmsNumber* rcpt1 = header->Recipients()[1];
       
  2292 
       
  2293 	TMsvSmsEntry entry = MsvEntry().Entry();
       
  2294 
       
  2295 	if( iCheckCount == 1 )
       
  2296 		{
       
  2297 		// At least one of the recipients has been delivered to ok - check the
       
  2298 		// status of recipient 0 and make decisions based on that.
       
  2299 		CSmsNumber* pendingRcpt = NULL;
       
  2300 
       
  2301 		if( rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck )
       
  2302 			{
       
  2303 			// Recipient 2 delivered to first...
       
  2304 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2305 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2306 
       
  2307 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  2308 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  2309 
       
  2310 			iTestUtils.Printf(_L("--Recipient 1 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt1->Status(), CMsvRecipient::EFailedToSend);
       
  2311 			iTestUtils.Test()(rcpt1->Status()==CMsvRecipient::EFailedToSend);
       
  2312 
       
  2313 			iTestUtils.Printf(_L("--Recipient 1 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt1->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2314 			iTestUtils.Test()(rcpt1->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2315 		
       
  2316 
       
  2317 			pendingRcpt = rcpt0;
       
  2318 			}
       
  2319 		else
       
  2320 			{
       
  2321 			// Recipient 0 delivered to first...
       
  2322 			iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  2323 			iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  2324 
       
  2325 			iTestUtils.Printf(_L("--Recipient 0 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt0->Status(), CMsvRecipient::EFailedToSend);
       
  2326 			iTestUtils.Test()(rcpt0->Status()==CMsvRecipient::EFailedToSend);
       
  2327 
       
  2328 			iTestUtils.Printf(_L("--Recipient 0 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt0->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2329 			iTestUtils.Test()(rcpt0->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2330 			
       
  2331 			iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EPendingAck)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EPendingAck);
       
  2332 			iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck);
       
  2333 
       
  2334 			pendingRcpt = rcpt1;
       
  2335 			}
       
  2336 		TLogId logId = 0;
       
  2337 		TBool validId = entry.MessageId(logId);
       
  2338 
       
  2339 		iTestUtils.Printf(_L("--Index message Id validity -> %d - should NOT be %d\n"), validId, EFalse);
       
  2340 		iTestUtils.Test()(validId != EFalse);
       
  2341 
       
  2342 		iTestUtils.Printf(_L("--Index message Id -> %d - should be %d\n"), logId, pendingRcpt->LogId());
       
  2343 		iTestUtils.Test()(logId == pendingRcpt->LogId());
       
  2344 		}
       
  2345 	else
       
  2346 		{
       
  2347 		// Status-reports for both recipients have been received - check the
       
  2348 		// status of both recipients.
       
  2349 		iTestUtils.Printf(_L("--Recipient 0 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt0->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  2350 		iTestUtils.Test()(rcpt0->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  2351 
       
  2352 		iTestUtils.Printf(_L("--Recipient 0 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt0->Status(), CMsvRecipient::EFailedToSend);
       
  2353 		iTestUtils.Test()(rcpt0->Status()==CMsvRecipient::EFailedToSend);
       
  2354 
       
  2355 		iTestUtils.Printf(_L("--Recipient 0 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt0->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2356 		iTestUtils.Test()(rcpt0->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2357 		
       
  2358 		iTestUtils.Printf(_L("--Recipient 1 - Delivery status -> %d - should be %d (EAckError)\n"), rcpt1->AckStatus(ESmsAckTypeDelivery), CSmsNumber::EAckError);
       
  2359 		iTestUtils.Test()(rcpt1->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError);
       
  2360 		
       
  2361 		iTestUtils.Printf(_L("--Recipient 1 - Recipient status -> %d - should be %d (EFailedToSend)\n"), rcpt1->Status(), CMsvRecipient::EFailedToSend);
       
  2362 		iTestUtils.Test()(rcpt1->Status()==CMsvRecipient::EFailedToSend);
       
  2363 
       
  2364 		iTestUtils.Printf(_L("--Recipient 1 - Error status -> %d - should not be %d (ESmsShortMessageReceivedBySME)\n"), rcpt1->Error(), TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2365 		iTestUtils.Test()(rcpt1->Error()!= TSmsStatus::ESmsShortMessageReceivedBySME);
       
  2366 		
       
  2367 		iTestUtils.Printf(_L("--Index summary -> %d - should be %d (EAllFailed)\n"), entry.AckSummary(ESmsAckTypeDelivery), TMsvSmsEntry::EAllFailed);
       
  2368 		iTestUtils.Test()(entry.AckSummary(ESmsAckTypeDelivery) == TMsvSmsEntry::EAllFailed);
       
  2369 
       
  2370 		// Test is no ended - complete self to stop.
       
  2371 		CompleteSelf();
       
  2372 		}
       
  2373 
       
  2374 	CleanupStack::PopAndDestroy(header);
       
  2375 	}
       
  2376 
       
  2377 const TDesC& CTestDeliverMultiRecipientsMixed_2::TestName()
       
  2378 	{
       
  2379 	return KTestDeliverMultiRecipientsMixed_2();
       
  2380 	}