messagingfw/scheduledsendmtm/test/unit/src/t_schedulesend.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "t_schedulesend.h"	
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <msvuids.h>
       
    20 #include "pigeonservermtm.h"
       
    21 #include <msvsysagentaction.h>
       
    22 #include <msvschedulesettings.h>
       
    23 #include <tmsvschedulesettingsutils.h>
       
    24 #include <centralrepository.h>
       
    25 
       
    26 #include "t_schsendshare.h"
       
    27 
       
    28 #include <e32property.h>
       
    29 TBool definedPhonePwrValue = EFalse;
       
    30 TBool definedSIMStatusValue = EFalse;
       
    31 TBool definedNetworkStatusValue = EFalse;
       
    32 
       
    33 _LIT(KPigeonDataComponentFileName, "z:\\resource\\messaging\\mtm\\pigeon.rsc");
       
    34 _LIT(KFailed,"Failed to complete tests.");
       
    35 _LIT(KScheduleSendTestPanic, "SchSendTst");
       
    36 
       
    37 _LIT(KTestScheduleSendScheduleMultiple,			"Schedule multiple messages");
       
    38 _LIT(KTestScheduleSendReScheduleTime_1,			"ReSechedule multiple messages, for same time");
       
    39 _LIT(KTestScheduleSendReScheduleTime_2,			"ReSechedule multiple messages, for differnt times");
       
    40 _LIT(KTestScheduleSendReScheduleConditions_1,	"ReSechedule multiple messages, for conditions, no timeout - conditions met");
       
    41 _LIT(KTestScheduleSendReScheduleConditions_2,	"ReSechedule multiple messages, for conditions, with timeout - conditions met");
       
    42 _LIT(KTestScheduleSendReScheduleConditions_3,	"ReSechedule multiple messages, for conditions, with timeout - timeout will occur");
       
    43 _LIT(KTestScheduleSendReScheduleMixed_1,		"ReSechedule multiple messages, for time and conditions, with timeout - conditions met");
       
    44 _LIT(KTestScheduleSendFailed_1,					"Fail multiple messages");
       
    45 _LIT(KTestScheduleSendFailed_2,					"Fail multiple messages after second re-schedule");
       
    46 
       
    47 _LIT(KStateUnknown,			"KMsvSendStateUnknown");
       
    48 _LIT(KStateUponRequest, 	"KMsvSendStateUponRequest");
       
    49 _LIT(KStateWaiting,			"KMsvSendStateWaiting");
       
    50 _LIT(KStateSending,			"KMsvSendStateSending");
       
    51 _LIT(KStateScheduled,		"KMsvSendStateScheduled");
       
    52 _LIT(KStateResend,			"KMsvSendStateResend");
       
    53 _LIT(KStateSuspended,		"KMsvSendStateSuspended");
       
    54 _LIT(KStateFailed,			"KMsvSendStateFailed");
       
    55 _LIT(KStateSent,			"KMsvSendStateSent");
       
    56 _LIT(KStateNotApplicable,	"KMsvSendStateNotApplicable");
       
    57 _LIT(KBoolTrue, 			"ETrue");
       
    58 _LIT(KBoolFalse, 			"EFalse");
       
    59 
       
    60 RTest test(_L("T_ScheduleSend Test Harness"));
       
    61 
       
    62 LOCAL_C void CreateVariablesL()
       
    63 	{
       
    64 	TInt testState;
       
    65 	if(KErrNone != RProperty::Get(KUidSystemCategory, KMsvTestUidPhonePwrValue, testState))
       
    66 		{
       
    67 		User::LeaveIfError(RProperty::Define(KUidSystemCategory, KMsvTestUidPhonePwrValue, RProperty::EInt));	// Qualified: No leavescan error
       
    68 		definedPhonePwrValue = ETrue;
       
    69 		}
       
    70 	if(KErrNone != RProperty::Get(KUidSystemCategory, KMsvTestUidSIMStatusValue, testState))
       
    71 		{
       
    72 		User::LeaveIfError(RProperty::Define(KUidSystemCategory, KMsvTestUidSIMStatusValue, RProperty::EInt));	// Qualified: No leavescan error
       
    73 		definedSIMStatusValue = ETrue;
       
    74 		}
       
    75 	if(KErrNone != RProperty::Get(KUidSystemCategory, KMsvTestUidNetworkStatusValue, testState))
       
    76 		{
       
    77 		User::LeaveIfError(RProperty::Define(KUidSystemCategory, KMsvTestUidNetworkStatusValue, RProperty::EInt));	// Qualified: No leavescan error
       
    78 		definedNetworkStatusValue = ETrue;
       
    79 		}
       
    80 	}
       
    81 	
       
    82 LOCAL_C void DeleteVariablesL()
       
    83 	{
       
    84 	if(definedPhonePwrValue)
       
    85 		{
       
    86 		User::LeaveIfError(RProperty::Delete(KUidSystemCategory, KMsvTestUidPhonePwrValue));
       
    87 		}
       
    88 	if(definedSIMStatusValue)
       
    89 		{
       
    90 		User::LeaveIfError(RProperty::Delete(KUidSystemCategory, KMsvTestUidSIMStatusValue));
       
    91 		}
       
    92 	if(definedNetworkStatusValue)
       
    93 		{
       
    94 		User::LeaveIfError(RProperty::Delete(KUidSystemCategory, KMsvTestUidNetworkStatusValue));
       
    95 		}
       
    96 	}	
       
    97 
       
    98 LOCAL_C void DoTestsL()
       
    99 	{
       
   100 	// Create and install the active scheduler
       
   101  	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
   102 	CleanupStack::PushL(scheduler);
       
   103 	CActiveScheduler::Install(scheduler);
       
   104 	
       
   105 	// Create the test engine
       
   106 	CTestEngine* testEngine = CTestEngine::NewL(test);
       
   107 	CleanupStack::PushL(testEngine);
       
   108 
       
   109 	CreateVariablesL();
       
   110 
       
   111 	// Do tests...
       
   112 	testEngine->DoTestsL();
       
   113 
       
   114 	DeleteVariablesL();
       
   115 
       
   116 	CleanupStack::PopAndDestroy(2, scheduler);
       
   117 	}
       
   118 
       
   119 GLDEF_C TInt E32Main()
       
   120 	{	
       
   121 	__UHEAP_MARK;
       
   122 	CTrapCleanup* tc=CTrapCleanup::New();
       
   123 	TRAPD(err,DoTestsL());
       
   124 	if (err!=KErrNone)
       
   125 		User::Panic(KFailed, err);
       
   126 	delete tc;
       
   127 	test.Close();
       
   128 	__UHEAP_MARKEND;
       
   129 	return KErrNone;
       
   130 	}
       
   131 	
       
   132 /*
       
   133  * CScheduleSendTestUtils
       
   134  */
       
   135 
       
   136 CScheduleSendTestUtils* CScheduleSendTestUtils::NewL(RTest& aTest, TUint aCreationFlags)
       
   137 	{
       
   138 	CScheduleSendTestUtils* self = new (ELeave) CScheduleSendTestUtils(aTest);
       
   139 	CleanupStack::PushL(self);
       
   140 	self->ConstructL(aCreationFlags);
       
   141 	CleanupStack::Pop(self);
       
   142 	return self;	
       
   143 	}
       
   144 
       
   145 CScheduleSendTestUtils::~CScheduleSendTestUtils()
       
   146 	{
       
   147 	CMsvTestUtils::Reset();
       
   148 	
       
   149 	}
       
   150 	
       
   151 CScheduleSendTestUtils::CScheduleSendTestUtils(RTest& aTest)
       
   152 : CMsvTestUtils(aTest)
       
   153 	{
       
   154 	}
       
   155 	
       
   156 TMsvId CScheduleSendTestUtils::ServiceId()
       
   157 	{
       
   158 	return iServiceId;
       
   159 	}
       
   160 
       
   161 void CScheduleSendTestUtils::ConstructL(TUint aCreationFlags)
       
   162 	{
       
   163 	CMsvTestUtils::ConstructL(aCreationFlags);
       
   164 	}
       
   165 	
       
   166 void CScheduleSendTestUtils::InstallPigeonMtmGroupL()
       
   167 	{
       
   168 	InstallMtmGroupL(KPigeonDataComponentFileName);
       
   169 	}
       
   170 
       
   171 void CScheduleSendTestUtils::CreatePigeonServerMtmRegL()
       
   172 	{
       
   173 	// Don't bother - use resource file!
       
   174 	}
       
   175 	
       
   176 void CScheduleSendTestUtils::DeletePigeonMessagesL(TMsvId aFolder)
       
   177 	{
       
   178 	SetEntryL(aFolder);
       
   179 	CMsvEntrySelection* sel = ChildrenWithMtmLC(KUidMsgTypePigeon);
       
   180 
       
   181 	TInt count = sel->Count();
       
   182 
       
   183 	while( count-- )
       
   184 		{
       
   185 		DeleteEntryL(sel->At(count));
       
   186 		}
       
   187 
       
   188 	CleanupStack::PopAndDestroy(sel);
       
   189 	}
       
   190 	
       
   191 void CScheduleSendTestUtils::NotifySaPhoneOnL()
       
   192 	{
       
   193 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidPhonePwrValue, EMsvTestPhoneOn));
       
   194 	}
       
   195 
       
   196 void CScheduleSendTestUtils::NotifySaPhoneOffL()
       
   197 	{
       
   198 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidPhonePwrValue, EMsvTestPhoneOff));
       
   199 	}
       
   200 
       
   201 void CScheduleSendTestUtils::NotifySaSimOkL()
       
   202 	{
       
   203 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidSIMStatusValue, EMsvTestSimOk));
       
   204 	}
       
   205 
       
   206 void CScheduleSendTestUtils::NotifySaSimNotPresentL()
       
   207 	{
       
   208 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidSIMStatusValue, EMsvTestSimNotPresent));
       
   209 	}
       
   210 
       
   211 void CScheduleSendTestUtils::NotifySaNetworkAvailableL()
       
   212 	{
       
   213 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidNetworkStatusValue, EMsvTestNetworkAvailable));
       
   214 	}
       
   215 
       
   216 void CScheduleSendTestUtils::NotifySaNetworkUnAvailableL()
       
   217 	{
       
   218 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidNetworkStatusValue, EMsvTestNetworkUnAvailable));
       
   219 	}
       
   220 	
       
   221 void CScheduleSendTestUtils::UpdateSysAgentConditionsL()
       
   222 	{
       
   223 	CMsvSysAgentActions* actions = new (ELeave) CMsvSysAgentActions();
       
   224 	CleanupStack::PushL(actions);
       
   225 
       
   226 	CRepository* repository = CRepository::NewLC(KUidMsgTypePigeon);
       
   227 	// load existing settings
       
   228 	TRAPD(error, TMsvScheduleSettingsUtils::LoadSysAgentSettingsL(*actions, *repository));
       
   229 	if( error==KErrNone )
       
   230 		{
       
   231 		// Reset the conditions - leave the default action.
       
   232 		actions->Reset();
       
   233 		}
       
   234 	
       
   235 	// Add the conditions
       
   236 	TMsvSysAgentConditionAction condAction;
       
   237 	condAction.iUseDefaultSysAgentAction = ETrue;
       
   238 
       
   239 	condAction.iCondition.iVariable = KMsvTestUidSIMStatus;
       
   240 	condAction.iCondition.iState = EMsvTestSimOk;
       
   241 
       
   242 	condAction.iCondition.iType = TMsvCondition::EMsvSchSendEquals;
       
   243 	actions->AppendL(condAction);
       
   244 
       
   245 	condAction.iCondition.iVariable = KMsvTestUidNetworkStatus;
       
   246 	condAction.iCondition.iState = EMsvTestNetworkAvailable;
       
   247 
       
   248 	condAction.iCondition.iType = TMsvCondition::EMsvSchSendEquals;
       
   249 	actions->AppendL(condAction);
       
   250 
       
   251 	// save these settings
       
   252 	TMsvScheduleSettingsUtils::SaveSysAgentSettingsL(*actions, *repository);	
       
   253 	CleanupStack::PopAndDestroy(2, actions); 
       
   254 	}
       
   255 	
       
   256 void CScheduleSendTestUtils::UpdatePendingConditionsTimeoutL(TTimeIntervalMinutes aTimeout)
       
   257 	{
       
   258 	CMsvScheduleSettings* settings = CMsvScheduleSettings::NewL();
       
   259 	CleanupStack::PushL(settings);
       
   260 
       
   261 	// access sms account settings
       
   262 	CRepository* repository = CRepository::NewLC(KUidMsgTypePigeon);
       
   263 	TMsvScheduleSettingsUtils::LoadScheduleSettingsL(*settings, *repository);
       
   264 
       
   265 	// Store the pending conditions timeout
       
   266 	settings->SetPendingConditionsTimeout(aTimeout);
       
   267 
       
   268 	// save these settings
       
   269 	TMsvScheduleSettingsUtils::SaveScheduleSettingsL(*settings, *repository);
       
   270 	CleanupStack::PopAndDestroy(2, settings);
       
   271 	}
       
   272 
       
   273 //	Methods from CMsvTestUtils
       
   274 
       
   275 void CScheduleSendTestUtils::CreateServicesL()
       
   276 	{
       
   277 	iServiceId = CreateServiceL(KUidMsgTypePigeon, EFalse, ETrue);
       
   278 	}
       
   279 	
       
   280 void CScheduleSendTestUtils::DeleteServicesL()
       
   281 	{
       
   282 	DeleteServiceL(KUidMsgTypePigeon);
       
   283 	}
       
   284 	
       
   285 void CScheduleSendTestUtils::InstallMtmGroupsL()
       
   286 	{
       
   287 	InstallPigeonMtmGroupL();
       
   288 	}
       
   289 
       
   290 void CScheduleSendTestUtils::CreateServerMtmRegsL()
       
   291 	{
       
   292 	CreatePigeonServerMtmRegL();
       
   293 	}
       
   294 	
       
   295 //	Methods from CTestUtils
       
   296  
       
   297 void CScheduleSendTestUtils::Panic(TInt aPanic)
       
   298 	{
       
   299 	User::Panic(KScheduleSendTestPanic, aPanic);
       
   300 	}
       
   301 	
       
   302 /*
       
   303  *	CTestEngine
       
   304  */
       
   305  
       
   306 CTestEngine* CTestEngine::NewL(RTest& aTest)
       
   307 	{
       
   308 	CTestEngine* self = new (ELeave) CTestEngine();
       
   309 	CleanupStack::PushL(self);
       
   310 	self->ConstructL(aTest);
       
   311 	CleanupStack::Pop(self);
       
   312 	return self;
       
   313 	}
       
   314 	
       
   315 CTestEngine::~CTestEngine()
       
   316 	{
       
   317 	delete iTestUtils;
       
   318 	}
       
   319 	
       
   320 CTestEngine::CTestEngine()
       
   321 :CBase()
       
   322 	{
       
   323 	}
       
   324 	
       
   325 void CTestEngine::ConstructL(RTest& aTest)
       
   326 	{
       
   327 	iTestUtils = CScheduleSendTestUtils::NewL(aTest);
       
   328 	
       
   329 	// Install the pigeon MTM.
       
   330 	iTestUtils->InstallMtmGroupsL();
       
   331 	}
       
   332 	
       
   333 void CTestEngine::DoTestsL()
       
   334 	{
       
   335 	CTestScheduleSendBase* testCase = NULL;
       
   336 
       
   337 	testCase = CTestSchedule::NewL(*iTestUtils);
       
   338 	testCase->Start();
       
   339 	CActiveScheduler::Start();
       
   340 	delete testCase;	
       
   341 
       
   342 	testCase = CTestReScheduleTime_1::NewL(*iTestUtils);
       
   343 	testCase->Start();
       
   344 	CActiveScheduler::Start();
       
   345 	delete testCase;
       
   346 			
       
   347 	testCase = CTestReScheduleTime_2::NewL(*iTestUtils);
       
   348 	testCase->Start();
       
   349 	CActiveScheduler::Start();
       
   350 	delete testCase;	
       
   351 
       
   352 	testCase = CTestRescheduleConditions_1::NewL(*iTestUtils);
       
   353 	testCase->Start();
       
   354 	CActiveScheduler::Start();
       
   355 	delete testCase;
       
   356 
       
   357 	testCase = CTestRescheduleConditions_2::NewL(*iTestUtils);
       
   358 	testCase->Start();
       
   359 	CActiveScheduler::Start();
       
   360 	delete testCase;
       
   361 	testCase = CTestRescheduleConditions_3::NewL(*iTestUtils);
       
   362 	testCase->Start();
       
   363 	CActiveScheduler::Start();
       
   364 	delete testCase;
       
   365 
       
   366 	testCase = CTestRescheduleMixed_1::NewL(*iTestUtils);
       
   367 	testCase->Start();
       
   368 	CActiveScheduler::Start();
       
   369 	delete testCase;
       
   370 
       
   371 	testCase = CTestFailed_1::NewL(*iTestUtils);
       
   372 	testCase->Start();
       
   373 	CActiveScheduler::Start();
       
   374 	delete testCase;		
       
   375 
       
   376 	
       
   377 	iTestUtils->TestHarnessCompleted();	
       
   378 	}
       
   379 	
       
   380 /*
       
   381  * CTestFolderObserver
       
   382  */
       
   383 	
       
   384 CTestFolderObserver* CTestFolderObserver::NewL(MTestFolderObserverCallback& aCallback, TMsvId aFolderId)
       
   385 	{
       
   386 	CTestFolderObserver* self = new (ELeave) CTestFolderObserver(aCallback, aFolderId);
       
   387 	CleanupStack::PushL(self);
       
   388 	self->ConstructL();
       
   389 	CleanupStack::Pop(self);
       
   390 	return self;
       
   391 	}
       
   392 
       
   393 CTestFolderObserver::~CTestFolderObserver()
       
   394 	{
       
   395 	delete iEntryForObserver;
       
   396 	}
       
   397 
       
   398 CTestFolderObserver::CTestFolderObserver(MTestFolderObserverCallback& aCallback, TMsvId aFolderId)
       
   399 : CBase(), iCallback(aCallback), iFolderId(aFolderId)
       
   400 	{
       
   401 	}
       
   402 
       
   403 void CTestFolderObserver::ConstructL()
       
   404 	{
       
   405 	iEntryForObserver = iCallback.CreateEntryL(iFolderId);
       
   406 	}
       
   407 
       
   408 void CTestFolderObserver::StartObserverL()
       
   409 	{
       
   410 	iEntryForObserver->AddObserverL(*this);
       
   411 	}
       
   412 	
       
   413 void CTestFolderObserver::StopObserver()
       
   414 	{
       
   415 	iEntryForObserver->RemoveObserver(*this);
       
   416 	}	
       
   417 
       
   418 // methods from MMsvEntryObserver
       
   419 
       
   420 void CTestFolderObserver::HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/)
       
   421 	{
       
   422 	CMsvEntrySelection* sel = (CMsvEntrySelection*)(aArg1);
       
   423 	
       
   424 	// The messages in the outbox have been updated - check them.
       
   425 	if(  aEvent == EMsvNewChildren )
       
   426 		{
       
   427 		TInt count = sel->Count();
       
   428 
       
   429 		for( TInt i=0; i < count; ++i )
       
   430 			{
       
   431 			// Notify the callback
       
   432 			iCallback.UpdatedMessageL(iFolderId, sel->At(i));
       
   433 			}
       
   434 		}	
       
   435 	}
       
   436 	
       
   437 /*
       
   438  * CTestScheduleSendBase
       
   439  */
       
   440  
       
   441 CTestScheduleSendBase::~CTestScheduleSendBase()
       
   442 	{
       
   443 	delete iSelection;
       
   444 	delete iPendingSent;
       
   445 	delete iOutboxObserver;
       
   446 	delete iSentFolderObserver;
       
   447 	delete iOperation;
       
   448 	}	
       
   449 	
       
   450 void CTestScheduleSendBase::Start()
       
   451 	{
       
   452 	iTestUtils.Printf(_L("Starting %S\n"), &TestName());
       
   453 	iState = EClearFolders;
       
   454 	CompleteSelf();
       
   455 	}
       
   456 	
       
   457 CTestScheduleSendBase::CTestScheduleSendBase(CScheduleSendTestUtils& aTestUtils)
       
   458 : CActive(CActive::EPriorityStandard), iTestUtils(aTestUtils)
       
   459 	{
       
   460 	CActiveScheduler::Add(this);
       
   461 	}
       
   462 	
       
   463 void CTestScheduleSendBase::ConstructL()
       
   464 	{
       
   465 	iSelection = new (ELeave) CMsvEntrySelection();
       
   466 	iPendingSent = new (ELeave) CMsvEntrySelection();
       
   467 	iOutboxObserver = CTestFolderObserver::NewL(*this, KMsvGlobalOutBoxIndexEntryId);
       
   468 	iSentFolderObserver = CTestFolderObserver::NewL(*this, KMsvSentEntryId);
       
   469 	}
       
   470 	
       
   471 void CTestScheduleSendBase::CompleteSelf()
       
   472 	{
       
   473 	TRequestStatus* pStat = &iStatus;
       
   474 	User::RequestComplete(pStat, KErrNone);
       
   475 	SetActive();
       
   476 	}
       
   477 	
       
   478 CMsvSession& CTestScheduleSendBase::Session()
       
   479 	{
       
   480 	return *iTestUtils.iMsvSession;
       
   481 	}
       
   482 
       
   483 CMsvEntry& CTestScheduleSendBase::MsvEntry()
       
   484 	{
       
   485 	return *iTestUtils.iMsvEntry;
       
   486 	}
       
   487 
       
   488 void CTestScheduleSendBase::ClearFoldersL()
       
   489 	{
       
   490 	iTestUtils.DeletePigeonMessagesL(KMsvGlobalOutBoxIndexEntryId);
       
   491 	iTestUtils.DeletePigeonMessagesL(KMsvGlobalInBoxIndexEntryId);
       
   492 	iTestUtils.DeletePigeonMessagesL(KMsvSentEntryId);		
       
   493 	}
       
   494 	
       
   495 void CTestScheduleSendBase::TestComplete()
       
   496 	{
       
   497 	iTestUtils.Printf(_L("Test Complete\n"));
       
   498 	CActiveScheduler::Stop();
       
   499 	}
       
   500 	
       
   501 TMsvId CTestScheduleSendBase::CreateMessageL(TTime& aTime, TInt aError)
       
   502 	{
       
   503 	iTestUtils.Printf(_L("Creating message...\n"));
       
   504 	
       
   505 	TMsvEntry entry;
       
   506 	entry.SetVisible(ETrue); 
       
   507 	entry.SetInPreparation(EFalse); 
       
   508 	entry.iServiceId = KMsvLocalServiceIndexEntryId; 
       
   509 	entry.iType = KUidMsvMessageEntry; 
       
   510 	entry.iMtm = KUidMsgTypePigeon; 
       
   511 	entry.iDate = aTime; 
       
   512 	entry.iSize = 0; 
       
   513 	entry.iDescription.Set(KNullDesC); 
       
   514 	entry.iDetails.Set(KNullDesC); 
       
   515 	entry.iError = aError;
       
   516 	entry.SetOffPeak(EFalse);
       
   517 	entry.SetScheduled(EFalse);	
       
   518 	entry.SetSendingState(KMsvSendStateWaiting);
       
   519 	
       
   520 	// Create the entry - set context to the global outbox.
       
   521 	MsvEntry().SetEntryL(KMsvGlobalOutBoxIndexEntryId);
       
   522 	MsvEntry().CreateL(entry);
       
   523 	
       
   524 	return entry.Id();
       
   525 	}
       
   526 	
       
   527 void CTestScheduleSendBase::TransferCommandL(TInt aCommand)
       
   528 	{
       
   529 	delete iOperation;
       
   530 	iOperation = NULL;
       
   531 	
       
   532 	iOperation = Session().TransferCommandL(*iSelection, aCommand, _L8("aaaa"), iStatus);
       
   533 	SetActive();
       
   534 	}
       
   535 	
       
   536 void CTestScheduleSendBase::UpdateSysAgentConditionsL()
       
   537 	{
       
   538 	CompleteSelf();
       
   539 	}
       
   540 	
       
   541 /**
       
   542 Notifies the test case that the messages have been scheduled successfully.
       
   543 
       
   544 The test case can indicate whether this is the end of the test.
       
   545 
       
   546 @return
       
   547 A value of ETrue if this is the end of the test.
       
   548 */
       
   549 TBool CTestScheduleSendBase::NotifyMessagesScheduledL()
       
   550 	{
       
   551 	return EFalse;
       
   552 	}
       
   553 	
       
   554 const TDesC& CTestScheduleSendBase::GetStateText(TInt aState) const 
       
   555 	{
       
   556 	switch( aState )
       
   557 		{
       
   558 	case KMsvSendStateUnknown:
       
   559 		return KStateUnknown();
       
   560 	case KMsvSendStateUponRequest:
       
   561 		return KStateUponRequest();
       
   562 	case KMsvSendStateWaiting:
       
   563 		return KStateWaiting();
       
   564 	case KMsvSendStateSending:
       
   565 		return KStateSending();
       
   566 	case KMsvSendStateScheduled:
       
   567 		return KStateScheduled();
       
   568 	case KMsvSendStateResend:
       
   569 		return KStateResend();
       
   570 	case KMsvSendStateSuspended:
       
   571 		return KStateSuspended();
       
   572 	case KMsvSendStateFailed:
       
   573 		return KStateFailed();
       
   574 	case KMsvSendStateSent:
       
   575 		return KStateSent();
       
   576 	case KMsvSendStateNotApplicable:
       
   577 		return KStateNotApplicable();
       
   578 	default:
       
   579 		break;
       
   580 		}
       
   581 	return KNullDesC();
       
   582 	}
       
   583 	
       
   584 const TDesC& CTestScheduleSendBase::GetBoolText(TBool aBool) const
       
   585 	{
       
   586 	if( aBool )
       
   587 		return KBoolTrue();
       
   588 	return KBoolFalse();
       
   589 	}
       
   590 
       
   591 void CTestScheduleSendBase::CheckMessageDetailsL(TMsvId aId, TInt aState, TBool aScheduled, TBool aCheckPendingConditions)
       
   592 	{
       
   593 	// Need to check the following details on the message - 
       
   594 	// 1. Correct sending state.
       
   595 	// 2. Scheduled flag.
       
   596 	// 3. Pending conditions flag
       
   597 	iTestUtils.Printf(_L("!!Checking message %d...\n"), aId);
       
   598 	
       
   599 	MsvEntry().SetEntryL(KMsvGlobalOutBoxIndexEntryId);
       
   600 	MsvEntry().SetEntryL(aId);
       
   601 	TMsvEntry entry = MsvEntry().Entry();
       
   602 			
       
   603 	iTestUtils.Printf(_L("->Sending state is %S (%d) - should be %S (%d)\n"), &GetStateText(entry.SendingState()), entry.SendingState(), &GetStateText(aState), aState);
       
   604 	iTestUtils.Test()(entry.SendingState() == (TUint) aState);
       
   605 	
       
   606 	if( aScheduled )
       
   607 		{
       
   608 		iTestUtils.Printf(_L("->Scheduled flag is %S (%d) - should be %S\n"), &GetBoolText(entry.Scheduled()), entry.Scheduled(), &GetBoolText(ETrue));
       
   609 		iTestUtils.Test()(entry.Scheduled() != EFalse);
       
   610 		}
       
   611 	else
       
   612 		{
       
   613 		iTestUtils.Printf(_L("->Scheduled flag is %S (%d) - should be %S\n"), &GetBoolText(entry.Scheduled()), entry.Scheduled(), &GetBoolText(EFalse));
       
   614 		iTestUtils.Test()(entry.Scheduled() == EFalse);
       
   615 		}
       
   616 
       
   617 	// The pending conditons flag should be true if aCheckPendingConditions is 
       
   618 	// true and the entry error is KErrorActionConditions
       
   619 	if( aCheckPendingConditions && entry.iError == KErrorActionConditions && entry.SendingState()!= KMsvSendStateSent && entry.SendingState()!=KMsvSendStateResend)
       
   620 		{
       
   621 		iTestUtils.Printf(_L("->Pending conditions flag is %S (%d) - should be %S\n"), &GetBoolText(entry.PendingConditions()), entry.PendingConditions(), &GetBoolText(ETrue));
       
   622 		iTestUtils.Test()(entry.PendingConditions() != EFalse);
       
   623 		}
       
   624 	else
       
   625 		{
       
   626 		iTestUtils.Printf(_L("->Pending conditions flag is %S (%d) - should be %S\n"), &GetBoolText(entry.PendingConditions()), entry.PendingConditions(), &GetBoolText(EFalse));
       
   627 		iTestUtils.Test()(entry.PendingConditions() == EFalse);
       
   628 		}
       
   629 	
       
   630 	// Check the scheduled time - do this if sending state is KMsvSendStateSent
       
   631 	if( aState == KMsvSendStateSent )
       
   632 		{
       
   633 		TTime now;
       
   634 		now.HomeTime();
       
   635 		
       
   636 		_LIT(KTimeFormat, "%-B%:0%J%:1%T%:2%S%:3%+B");
       
   637 		
       
   638 		TBuf<32> scheduledTime;
       
   639 		entry.iDate.FormatL(scheduledTime, KTimeFormat);
       
   640 
       
   641 		TBuf<32> currentTime;
       
   642 		now.FormatL(currentTime, KTimeFormat);
       
   643 
       
   644 		if( entry.PendingConditions() )
       
   645 			{
       
   646 			if( ConditionsMet() )
       
   647 				{
       
   648 				iTestUtils.Printf(_L("->Message scheduled for conditions -> met, timeout is %S - should be after current time %S\n"), &scheduledTime, &currentTime);
       
   649 				iTestUtils.Test()(entry.iDate > now);
       
   650 				}
       
   651 			else
       
   652 				{
       
   653 				iTestUtils.Printf(_L("->Message scheduled for conditions -> not met, timeout is %S - should be same or before current time %S\n"), &scheduledTime, &currentTime);
       
   654 				iTestUtils.Test()(entry.iDate <= now);
       
   655 				}
       
   656 			}
       
   657 		else
       
   658 			{
       
   659 			iTestUtils.Printf(_L("->Message scheduled for %S - should be same or before current time %S\n"), &scheduledTime, &currentTime);
       
   660 			iTestUtils.Test()(entry.iDate <= now);			
       
   661 			}
       
   662 		}
       
   663 	}
       
   664 	
       
   665 void CTestScheduleSendBase::CheckCreatedMessagesL()
       
   666 	{
       
   667 	// Need to check the following on all pigeon messages in the outbox - 
       
   668 	// 1. Correct sending state - KMsvSendStateWaiting.
       
   669 	// 2. Scheduled flag is false.
       
   670 	// 3. Pending conditions is false.
       
   671 	
       
   672 	iTestUtils.Printf(_L("Checking for new pigeon messages in the outbox...\n"));
       
   673 	
       
   674 	MsvEntry().SetEntryL(KMsvGlobalOutBoxIndexEntryId);
       
   675 	
       
   676 	CMsvEntrySelection* sel = iTestUtils.ChildrenWithMtmLC(KUidMsgTypePigeon);
       
   677 	
       
   678 	iTestUtils.Printf(_L("->Number of pigeon messages is %d - should be %d\n"), sel->Count(), iSelection->Count());
       
   679 	iTestUtils.Test()(sel->Count() == iSelection->Count());
       
   680 	
       
   681 	TInt count = sel->Count();
       
   682 	
       
   683 	for( TInt i=0; i < count; ++i )
       
   684 		{
       
   685 		CheckMessageDetailsL(sel->At(i), KMsvSendStateWaiting, EFalse, EFalse);
       
   686 		}
       
   687 	
       
   688 	CleanupStack::PopAndDestroy(sel);
       
   689 	}
       
   690 	
       
   691 void CTestScheduleSendBase::CheckScheduledMessagesL()
       
   692 	{
       
   693 	// Need to check the following on all pigeon messages in the outbox - 
       
   694 	// 1. Correct sending state - ask derived class
       
   695 	// 2. Scheduled flag is not false.
       
   696 	// 3. Pending conditions is not false if the message error code is KErrorActionConditions.
       
   697 	
       
   698 	iTestUtils.Printf(_L("Checking for scheduled pigeon messages in the outbox...\n"));
       
   699 	
       
   700 	MsvEntry().SetEntryL(KMsvGlobalOutBoxIndexEntryId);
       
   701 	
       
   702 	CMsvEntrySelection* sel = iTestUtils.ChildrenWithMtmLC(KUidMsgTypePigeon);
       
   703 	
       
   704 	iTestUtils.Printf(_L("->Number of pigeon messages is %d - should be %d\n"), sel->Count(), iSelection->Count());
       
   705 	iTestUtils.Test()(sel->Count() == iSelection->Count());
       
   706 	
       
   707 	TInt count = sel->Count();
       
   708 	
       
   709 	for( TInt i=0; i < count; ++i )
       
   710 		{
       
   711 		TInt state = ScheduledState();
       
   712 		TBool scheduled = state == KMsvSendStateResend || state == KMsvSendStateScheduled;
       
   713 		CheckMessageDetailsL(sel->At(i), state, scheduled, ETrue);
       
   714 		}
       
   715 	
       
   716 	CleanupStack::PopAndDestroy(sel);	
       
   717 	}
       
   718 		
       
   719 void CTestScheduleSendBase::CheckPreSendMessageL(TMsvId aId)
       
   720 	{
       
   721 	// Need to check the following on all pigeon messages in the outbox - 
       
   722 	// 1. Correct sending state - ask derived class (noramlly KMsvSendStateWaiting).
       
   723 	// 2. Scheduled flag is not false.
       
   724 	// 3. Pending conditions is not false if the message error code is KErrorActionConditions.
       
   725 
       
   726 	CheckMessageDetailsL(aId, PreSendState(), ETrue, ETrue);
       
   727 	}
       
   728 
       
   729 void CTestScheduleSendBase::CheckSentMessageL(TMsvId aId)
       
   730 	{
       
   731 	// Need to check the following on the supplied message - 
       
   732 	// 1. Correct sending state - ask derived class (noramlly KMsvSendStateSent).
       
   733 	// 2. Scheduled flag is not false.
       
   734 	// 3. Pending conditions is not false if the message error code is KErrorActionConditions.
       
   735 	
       
   736 	CheckMessageDetailsL(aId, SentState(), ETrue, ETrue);
       
   737 	}
       
   738 	
       
   739 TInt CTestScheduleSendBase::PreSendState()
       
   740 	{
       
   741 	return KMsvSendStateWaiting;
       
   742 	}
       
   743 	
       
   744 TInt CTestScheduleSendBase::SentState()
       
   745 	{
       
   746 	return KMsvSendStateSent;
       
   747 	}
       
   748 
       
   749 TBool CTestScheduleSendBase::ConditionsMet() const
       
   750 	{
       
   751 	return iConditionsMet;
       
   752 	}
       
   753 
       
   754 // methods from CActive
       
   755 
       
   756 void CTestScheduleSendBase::RunL()
       
   757 	{
       
   758 	User::LeaveIfError(iStatus.Int());
       
   759 	
       
   760 	switch( iState )
       
   761 		{
       
   762 	case EClearFolders:
       
   763 		{
       
   764 		ClearFoldersL();
       
   765 		iState = EUpdateSysAgentConditions;
       
   766 		CompleteSelf();
       
   767 		} break;
       
   768 	case EUpdateSysAgentConditions:
       
   769 		{
       
   770 		UpdateSysAgentConditionsL();
       
   771 		iState = ECreateMessages;
       
   772 		} break;			
       
   773 	case ECreateMessages:
       
   774 		{
       
   775 		CreateMessagesL();
       
   776 		iState = ECheckCreatedMessages;
       
   777 		CompleteSelf();
       
   778 		} break;
       
   779 	case ECheckCreatedMessages:
       
   780 		{
       
   781 		CheckCreatedMessagesL();
       
   782 		iState = EScheduleMessages;
       
   783 		CompleteSelf();
       
   784 		} break;
       
   785 	case EScheduleMessages:
       
   786 		{
       
   787 		ScheduleMessagesL();
       
   788 		iState = ECheckScheduledMessages;
       
   789 		} break;
       
   790 	case ECheckScheduledMessages:
       
   791 		{
       
   792 		CheckScheduledMessagesL();
       
   793 
       
   794 		// Get outbox observer to start observing...
       
   795 		iOutboxObserver->StartObserverL();
       
   796 		iSentFolderObserver->StartObserverL();
       
   797 		
       
   798 		TBool done = NotifyMessagesScheduledL();
       
   799 		
       
   800 		if( done )
       
   801 			{
       
   802 			// No more to do - end the test
       
   803 			TestComplete();
       
   804 			}
       
   805 		else
       
   806 			{
       
   807 			// Waiting for the messages to be scheduled and sent.
       
   808 			iState = EPendingMessagesSent;
       
   809 			}
       
   810 		} break;
       
   811 	case EPendingMessagesSent:
       
   812 		{
       
   813 		// End the test...
       
   814 		TestComplete();
       
   815 		} break;			
       
   816 	default:
       
   817 		User::Invariant();
       
   818 		break;
       
   819 		}
       
   820 	}
       
   821 	
       
   822 void CTestScheduleSendBase::DoCancel()
       
   823 	{
       
   824 	}
       
   825 	
       
   826 TInt CTestScheduleSendBase::RunError(TInt aError)
       
   827 	{
       
   828 	iTestUtils.Printf(_L("!!!RunL leave with error code : %d...\n"), aError);
       
   829 	
       
   830 	User::Invariant();
       
   831 	
       
   832 	return aError;
       
   833 	}
       
   834 	
       
   835 //	methods from MTestFolderObserverCallback	
       
   836 	
       
   837 void CTestScheduleSendBase::UpdatedMessageL(TMsvId aFolderId, TMsvId aMessageId)
       
   838 	{
       
   839 	__ASSERT_DEBUG( iState == EPendingMessagesSent, User::Invariant() );
       
   840 	
       
   841 	if( aFolderId == KMsvGlobalOutBoxIndexEntryId )
       
   842 		{
       
   843 		iTestUtils.Printf(_L("Outbox has been updated...\n"));
       
   844 		
       
   845 		// This message has just been scheduled to be sent - check it has been
       
   846 		// updated correctly..
       
   847 		CheckPreSendMessageL(aMessageId);
       
   848 		}
       
   849 	else if( aFolderId == KMsvSentEntryId )
       
   850 		{
       
   851 		iTestUtils.Printf(_L("Sent folder has been updated...\n"));
       
   852 
       
   853 		// This message has just been sent - check it has been updated correctly.
       
   854 		CheckSentMessageL(aMessageId);
       
   855 		++iMessagesDone;
       
   856 		}
       
   857 		
       
   858 	if( iMessagesDone == iSelection->Count() )
       
   859 		{
       
   860 		// Test is ended as all messges have been sent - complete-self to end.
       
   861 		CompleteSelf();
       
   862 		}
       
   863 	}
       
   864 	
       
   865 CMsvEntry* CTestScheduleSendBase::CreateEntryL(TMsvId aFolderId)
       
   866 	{
       
   867 	return 	Session().GetEntryL(aFolderId);
       
   868 	}
       
   869 
       
   870 /*
       
   871  * CTestSchedule
       
   872  */
       
   873  
       
   874 CTestSchedule* CTestSchedule::NewL(CScheduleSendTestUtils& aTestUtils)
       
   875 	{
       
   876 	CTestSchedule* self = new (ELeave) CTestSchedule(aTestUtils);
       
   877 	CleanupStack::PushL(self);
       
   878 	self->ConstructL();
       
   879 	CleanupStack::Pop(self);
       
   880 	return self;
       
   881 	}
       
   882  
       
   883 CTestSchedule::~CTestSchedule()
       
   884 	{
       
   885 	}	
       
   886 	
       
   887 CTestSchedule::CTestSchedule(CScheduleSendTestUtils& aTestUtils)
       
   888 : CTestScheduleSendBase(aTestUtils)
       
   889 	{
       
   890 	}
       
   891 	
       
   892 //	 methods from CTestScheduleSendBase
       
   893 	
       
   894 void CTestSchedule::CreateMessagesL()
       
   895 	{
       
   896 	// Create two pigeon messages in the inbox.
       
   897 	iSelection->Reset();
       
   898 	iSelection->SetReserveL(2);
       
   899 	
       
   900 	TTime now;
       
   901 	now.HomeTime();
       
   902 	now.RoundUpToNextMinute();
       
   903 	
       
   904 	iSelection->AppendL(CreateMessageL(now, KErrNone));
       
   905 	iSelection->AppendL(CreateMessageL(now, KErrNone));	
       
   906 	}
       
   907 
       
   908 void CTestSchedule::ScheduleMessagesL()
       
   909 	{
       
   910 	iTestUtils.Printf(_L("Scheduling %d messages\n"), iSelection->Count());
       
   911 	TransferCommandL(EScheduleAllL);
       
   912 	}
       
   913 
       
   914 TInt CTestSchedule::ScheduledState()
       
   915 	{
       
   916 	return KMsvSendStateScheduled;
       
   917 	}
       
   918 
       
   919 const TDesC& CTestSchedule::TestName()
       
   920 	{
       
   921 	return KTestScheduleSendScheduleMultiple();
       
   922 	}
       
   923 	
       
   924 /*
       
   925  * CTestReScheduleTime_1
       
   926  */
       
   927  
       
   928 CTestReScheduleTime_1* CTestReScheduleTime_1::NewL(CScheduleSendTestUtils& aTestUtils)
       
   929 	{
       
   930 	CTestReScheduleTime_1* self = new (ELeave) CTestReScheduleTime_1(aTestUtils);
       
   931 	CleanupStack::PushL(self);
       
   932 	self->ConstructL();
       
   933 	CleanupStack::Pop(self);
       
   934 	return self;
       
   935 	}
       
   936  
       
   937 CTestReScheduleTime_1::~CTestReScheduleTime_1()
       
   938 	{
       
   939 	}	
       
   940 	
       
   941 CTestReScheduleTime_1::CTestReScheduleTime_1(CScheduleSendTestUtils& aTestUtils)
       
   942 : CTestScheduleSendBase(aTestUtils)
       
   943 	{
       
   944 	}
       
   945 	
       
   946 //	 methods from CTestScheduleSendBase
       
   947 	
       
   948 void CTestReScheduleTime_1::CreateMessagesL()
       
   949 	{
       
   950 	// Create two pigeon messages in the inbox.
       
   951 	iSelection->Reset();
       
   952 	iSelection->SetReserveL(2);
       
   953 	
       
   954 	TTime now;
       
   955 	now.HomeTime();
       
   956 	
       
   957 	iSelection->AppendL(CreateMessageL(now, KErrorActionImmediately));
       
   958 	iSelection->AppendL(CreateMessageL(now, KErrorActionImmediately));
       
   959 	}
       
   960 
       
   961 void CTestReScheduleTime_1::ScheduleMessagesL()
       
   962 	{
       
   963 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
   964 	TransferCommandL(EReScheduleAllL);
       
   965 	}
       
   966 
       
   967 TInt CTestReScheduleTime_1::ScheduledState()
       
   968 	{
       
   969 	return KMsvSendStateResend;
       
   970 	}
       
   971 
       
   972 const TDesC& CTestReScheduleTime_1::TestName()
       
   973 	{
       
   974 	return KTestScheduleSendReScheduleTime_1();
       
   975 	}
       
   976 	
       
   977 /*
       
   978  * CTestReScheduleTime_2
       
   979  */
       
   980  
       
   981 CTestReScheduleTime_2* CTestReScheduleTime_2::NewL(CScheduleSendTestUtils& aTestUtils)
       
   982 	{
       
   983 	CTestReScheduleTime_2* self = new (ELeave) CTestReScheduleTime_2(aTestUtils);
       
   984 	CleanupStack::PushL(self);
       
   985 	self->ConstructL();
       
   986 	CleanupStack::Pop(self);
       
   987 	return self;
       
   988 	}
       
   989  
       
   990 CTestReScheduleTime_2::~CTestReScheduleTime_2()
       
   991 	{
       
   992 	}	
       
   993 	
       
   994 CTestReScheduleTime_2::CTestReScheduleTime_2(CScheduleSendTestUtils& aTestUtils)
       
   995 : CTestScheduleSendBase(aTestUtils)
       
   996 	{
       
   997 	}
       
   998 	
       
   999 //	 methods from CTestScheduleSendBase
       
  1000 	
       
  1001 void CTestReScheduleTime_2::CreateMessagesL()
       
  1002 	{
       
  1003 	// Create two pigeon messages in the inbox.
       
  1004 	iSelection->Reset();
       
  1005 	iSelection->SetReserveL(2);
       
  1006 	
       
  1007 	TTime now;
       
  1008 	now.HomeTime();
       
  1009 	
       
  1010 	iSelection->AppendL(CreateMessageL(now, KErrorActionImmediately));
       
  1011 	iSelection->AppendL(CreateMessageL(now, KErrorActionLater));
       
  1012 	}
       
  1013 
       
  1014 void CTestReScheduleTime_2::ScheduleMessagesL()
       
  1015 	{
       
  1016 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
  1017 	TransferCommandL(EReScheduleAllL);
       
  1018 	}
       
  1019 
       
  1020 TInt CTestReScheduleTime_2::ScheduledState()
       
  1021 	{
       
  1022 	return KMsvSendStateResend;
       
  1023 	}
       
  1024 
       
  1025 const TDesC& CTestReScheduleTime_2::TestName()
       
  1026 	{
       
  1027 	return KTestScheduleSendReScheduleTime_2();
       
  1028 	}
       
  1029 	
       
  1030 /*
       
  1031  * CTestRescheduleConditions_1
       
  1032  */
       
  1033  
       
  1034 CTestRescheduleConditions_1* CTestRescheduleConditions_1::NewL(CScheduleSendTestUtils& aTestUtils)
       
  1035 	{
       
  1036 	CTestRescheduleConditions_1* self = new (ELeave) CTestRescheduleConditions_1(aTestUtils);
       
  1037 	CleanupStack::PushL(self);
       
  1038 	self->ConstructL();
       
  1039 	CleanupStack::Pop(self);
       
  1040 	return self;
       
  1041 	}	
       
  1042 	
       
  1043 CTestRescheduleConditions_1::~CTestRescheduleConditions_1()
       
  1044 	{
       
  1045 	}
       
  1046 	
       
  1047 CTestRescheduleConditions_1::CTestRescheduleConditions_1(CScheduleSendTestUtils& aTestUtils)
       
  1048 : CTestScheduleSendBase(aTestUtils)
       
  1049 	{
       
  1050 	}
       
  1051 	
       
  1052 // methods from CTestScheduleSendBase
       
  1053 
       
  1054 void CTestRescheduleConditions_1::UpdateSysAgentConditionsL()
       
  1055 	{
       
  1056 	iTestUtils.UpdateSysAgentConditionsL();
       
  1057 	iTestUtils.UpdatePendingConditionsTimeoutL(0);	
       
  1058 	CompleteSelf();
       
  1059 	}
       
  1060 	
       
  1061 TBool CTestRescheduleConditions_1::NotifyMessagesScheduledL()
       
  1062 	{
       
  1063 	// Messages have been scheduled - meet the conditions; SIM ok, network available.
       
  1064 	iTestUtils.NotifySaSimOkL();
       
  1065 	iTestUtils.NotifySaNetworkAvailableL();
       
  1066 	iConditionsMet = ETrue;
       
  1067 	return EFalse;
       
  1068 	}
       
  1069 	
       
  1070 void CTestRescheduleConditions_1::CreateMessagesL()
       
  1071 	{
       
  1072 	// Create two pigeon messages in the inbox.
       
  1073 	iSelection->Reset();
       
  1074 	iSelection->SetReserveL(2);
       
  1075 	
       
  1076 	TTime now;
       
  1077 	now.HomeTime();
       
  1078 	
       
  1079 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));
       
  1080 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));	
       
  1081 	}
       
  1082 	
       
  1083 void CTestRescheduleConditions_1::ScheduleMessagesL()
       
  1084 	{
       
  1085 	// First fail to meet conditions - SIM not present + network unavailable.
       
  1086 	iTestUtils.NotifySaSimNotPresentL();	
       
  1087 	iTestUtils.NotifySaNetworkUnAvailableL();	
       
  1088 	
       
  1089 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
  1090 	TransferCommandL(EReScheduleAllL);
       
  1091 	}
       
  1092 	
       
  1093 TInt CTestRescheduleConditions_1::ScheduledState()
       
  1094 	{
       
  1095 	return KMsvSendStateResend;
       
  1096 	}
       
  1097 
       
  1098 const TDesC& CTestRescheduleConditions_1::TestName()
       
  1099 	{
       
  1100 	return KTestScheduleSendReScheduleConditions_1();
       
  1101 	}
       
  1102 	
       
  1103 /*
       
  1104  * CTestRescheduleConditions_2
       
  1105  */
       
  1106  
       
  1107 CTestRescheduleConditions_2* CTestRescheduleConditions_2::NewL(CScheduleSendTestUtils& aTestUtils)
       
  1108 	{
       
  1109 	CTestRescheduleConditions_2* self = new (ELeave) CTestRescheduleConditions_2(aTestUtils);
       
  1110 	CleanupStack::PushL(self);
       
  1111 	self->ConstructL();
       
  1112 	CleanupStack::Pop(self);
       
  1113 	return self;
       
  1114 	}	
       
  1115 	
       
  1116 CTestRescheduleConditions_2::~CTestRescheduleConditions_2()
       
  1117 	{
       
  1118 	}
       
  1119 	
       
  1120 CTestRescheduleConditions_2::CTestRescheduleConditions_2(CScheduleSendTestUtils& aTestUtils)
       
  1121 : CTestScheduleSendBase(aTestUtils)
       
  1122 	{
       
  1123 	}
       
  1124 	
       
  1125 // methods from CTestScheduleSendBase
       
  1126 
       
  1127 void CTestRescheduleConditions_2::UpdateSysAgentConditionsL()
       
  1128 	{
       
  1129 	iTestUtils.UpdateSysAgentConditionsL();
       
  1130 	iTestUtils.UpdatePendingConditionsTimeoutL(1);
       
  1131 	CompleteSelf();
       
  1132 	}
       
  1133 	
       
  1134 TBool CTestRescheduleConditions_2::NotifyMessagesScheduledL()
       
  1135 	{
       
  1136 	// Messages have been scheduled - meet the conditions; SIM ok, network available.
       
  1137 	iTestUtils.NotifySaSimOkL();
       
  1138 	iTestUtils.NotifySaNetworkAvailableL();
       
  1139 	iConditionsMet = ETrue;
       
  1140 	return EFalse;
       
  1141 	}
       
  1142 	
       
  1143 void CTestRescheduleConditions_2::CreateMessagesL()
       
  1144 	{
       
  1145 	// Create two pigeon messages in the inbox.
       
  1146 	iSelection->Reset();
       
  1147 	iSelection->SetReserveL(2);
       
  1148 	
       
  1149 	TTime now;
       
  1150 	now.HomeTime();
       
  1151 	
       
  1152 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));
       
  1153 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));	
       
  1154 	}
       
  1155 	
       
  1156 void CTestRescheduleConditions_2::ScheduleMessagesL()
       
  1157 	{
       
  1158 	// First fail to meet conditions - SIM not present + network unavailable.
       
  1159 	iTestUtils.NotifySaSimNotPresentL();	
       
  1160 	iTestUtils.NotifySaNetworkUnAvailableL();	
       
  1161 	
       
  1162 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
  1163 	TransferCommandL(EReScheduleAllL);
       
  1164 	}
       
  1165 	
       
  1166 TInt CTestRescheduleConditions_2::ScheduledState()
       
  1167 	{
       
  1168 	return KMsvSendStateResend;
       
  1169 	}
       
  1170 
       
  1171 const TDesC& CTestRescheduleConditions_2::TestName()
       
  1172 	{
       
  1173 	return KTestScheduleSendReScheduleConditions_2();
       
  1174 	}
       
  1175 		
       
  1176 /*
       
  1177  * CTestRescheduleConditions_3
       
  1178  */
       
  1179  
       
  1180 CTestRescheduleConditions_3* CTestRescheduleConditions_3::NewL(CScheduleSendTestUtils& aTestUtils)
       
  1181 	{
       
  1182 	CTestRescheduleConditions_3* self = new (ELeave) CTestRescheduleConditions_3(aTestUtils);
       
  1183 	CleanupStack::PushL(self);
       
  1184 	self->ConstructL();
       
  1185 	CleanupStack::Pop(self);
       
  1186 	return self;
       
  1187 	}	
       
  1188 	
       
  1189 CTestRescheduleConditions_3::~CTestRescheduleConditions_3()
       
  1190 	{
       
  1191 	}
       
  1192 	
       
  1193 CTestRescheduleConditions_3::CTestRescheduleConditions_3(CScheduleSendTestUtils& aTestUtils)
       
  1194 : CTestScheduleSendBase(aTestUtils)
       
  1195 	{
       
  1196 	}
       
  1197 	
       
  1198 // methods from CTestScheduleSendBase
       
  1199 
       
  1200 void CTestRescheduleConditions_3::UpdateSysAgentConditionsL()
       
  1201 	{
       
  1202 	iTestUtils.UpdateSysAgentConditionsL();
       
  1203 	iTestUtils.UpdatePendingConditionsTimeoutL(1);
       
  1204 	CompleteSelf();
       
  1205 	}
       
  1206 		
       
  1207 TBool CTestRescheduleConditions_3::NotifyMessagesScheduledL()
       
  1208 	{
       
  1209 	// Messages have been scheduled - meet only one of the conditions; SIM ok.
       
  1210 	// This should imply that timeout should occur
       
  1211 	iTestUtils.NotifySaSimOkL();
       
  1212 	iConditionsMet = EFalse;
       
  1213 	return EFalse;
       
  1214 	}
       
  1215 
       
  1216 void CTestRescheduleConditions_3::CreateMessagesL()
       
  1217 	{
       
  1218 	// Create two pigeon messages in the inbox.
       
  1219 	iSelection->Reset();
       
  1220 	iSelection->SetReserveL(2);
       
  1221 	
       
  1222 	TTime now;
       
  1223 	now.HomeTime();
       
  1224 	
       
  1225 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));
       
  1226 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));	
       
  1227 	}
       
  1228 	
       
  1229 void CTestRescheduleConditions_3::ScheduleMessagesL()
       
  1230 	{
       
  1231 	// First fail to meet conditions - phone off + network unavailable.
       
  1232 	// NOTE - no need to meet conditions, let timeout happen.	
       
  1233 	iTestUtils.NotifySaSimNotPresentL();	
       
  1234 	iTestUtils.NotifySaNetworkUnAvailableL();	
       
  1235 	
       
  1236 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
  1237 	TransferCommandL(EReScheduleAllL);
       
  1238 	}
       
  1239 	
       
  1240 TInt CTestRescheduleConditions_3::ScheduledState()
       
  1241 	{
       
  1242 	return KMsvSendStateResend;
       
  1243 	}
       
  1244 
       
  1245 const TDesC& CTestRescheduleConditions_3::TestName()
       
  1246 	{
       
  1247 	return KTestScheduleSendReScheduleConditions_3();
       
  1248 	}
       
  1249 	
       
  1250 /*
       
  1251  * CTestRescheduleMixed_1
       
  1252  */
       
  1253  
       
  1254 CTestRescheduleMixed_1* CTestRescheduleMixed_1::NewL(CScheduleSendTestUtils& aTestUtils)
       
  1255 	{
       
  1256 	CTestRescheduleMixed_1* self = new (ELeave) CTestRescheduleMixed_1(aTestUtils);
       
  1257 	CleanupStack::PushL(self);
       
  1258 	self->ConstructL();
       
  1259 	CleanupStack::Pop(self);
       
  1260 	return self;
       
  1261 	}	
       
  1262 	
       
  1263 CTestRescheduleMixed_1::~CTestRescheduleMixed_1()
       
  1264 	{
       
  1265 	}
       
  1266 	
       
  1267 CTestRescheduleMixed_1::CTestRescheduleMixed_1(CScheduleSendTestUtils& aTestUtils)
       
  1268 : CTestScheduleSendBase(aTestUtils)
       
  1269 	{
       
  1270 	}
       
  1271 	
       
  1272 // methods from CTestScheduleSendBase
       
  1273 
       
  1274 void CTestRescheduleMixed_1::UpdateSysAgentConditionsL()
       
  1275 	{
       
  1276 	iTestUtils.UpdateSysAgentConditionsL();
       
  1277 	iTestUtils.UpdatePendingConditionsTimeoutL(1);
       
  1278 	CompleteSelf();
       
  1279 	}
       
  1280 	
       
  1281 TBool CTestRescheduleMixed_1::NotifyMessagesScheduledL()
       
  1282 	{
       
  1283 	// Messages have been scheduled - meet the conditions; SIM ok, network available.
       
  1284 	iTestUtils.NotifySaSimOkL();
       
  1285 	iTestUtils.NotifySaNetworkAvailableL();
       
  1286 	iConditionsMet = ETrue;
       
  1287 	return EFalse;
       
  1288 	}
       
  1289 	
       
  1290 void CTestRescheduleMixed_1::CreateMessagesL()
       
  1291 	{
       
  1292 	// Create two pigeon messages in the inbox.
       
  1293 	iSelection->Reset();
       
  1294 	iSelection->SetReserveL(2);
       
  1295 	
       
  1296 	TTime now;
       
  1297 	now.HomeTime();
       
  1298 	
       
  1299 	iSelection->AppendL(CreateMessageL(now, KErrorActionImmediately));
       
  1300 	iSelection->AppendL(CreateMessageL(now, KErrorActionConditions));	
       
  1301 	}
       
  1302 	
       
  1303 void CTestRescheduleMixed_1::ScheduleMessagesL()
       
  1304 	{
       
  1305 	// First fail to meet conditions - SIM not present + network unavailable.
       
  1306 	iTestUtils.NotifySaSimNotPresentL();	
       
  1307 	iTestUtils.NotifySaNetworkUnAvailableL();	
       
  1308 	
       
  1309 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
  1310 	TransferCommandL(EReScheduleAllL);
       
  1311 	}
       
  1312 	
       
  1313 TInt CTestRescheduleMixed_1::ScheduledState()
       
  1314 	{
       
  1315 	return KMsvSendStateResend;
       
  1316 	}
       
  1317 
       
  1318 const TDesC& CTestRescheduleMixed_1::TestName()
       
  1319 	{
       
  1320 	return KTestScheduleSendReScheduleMixed_1();
       
  1321 	}
       
  1322 	
       
  1323 /*
       
  1324  * CTestFailed_1
       
  1325  */
       
  1326  
       
  1327 CTestFailed_1* CTestFailed_1::NewL(CScheduleSendTestUtils& aTestUtils)
       
  1328 	{
       
  1329 	CTestFailed_1* self = new (ELeave) CTestFailed_1(aTestUtils);
       
  1330 	CleanupStack::PushL(self);
       
  1331 	self->ConstructL();
       
  1332 	CleanupStack::Pop(self);
       
  1333 	return self;
       
  1334 	}	
       
  1335 	
       
  1336 CTestFailed_1::~CTestFailed_1()
       
  1337 	{
       
  1338 	}
       
  1339 	
       
  1340 CTestFailed_1::CTestFailed_1(CScheduleSendTestUtils& aTestUtils)
       
  1341 : CTestScheduleSendBase(aTestUtils)
       
  1342 	{
       
  1343 	}
       
  1344 	
       
  1345 // methods from CTestScheduleSendBase
       
  1346 	
       
  1347 TBool CTestFailed_1::NotifyMessagesScheduledL()
       
  1348 	{
       
  1349 	// Messages are not scheduled - end test.
       
  1350 	return ETrue;
       
  1351 	}
       
  1352 	
       
  1353 void CTestFailed_1::CreateMessagesL()
       
  1354 	{
       
  1355 	// Create two pigeon messages in the inbox.
       
  1356 	iSelection->Reset();
       
  1357 	iSelection->SetReserveL(2);
       
  1358 	
       
  1359 	TTime now;
       
  1360 	now.HomeTime();
       
  1361 	
       
  1362 	iSelection->AppendL(CreateMessageL(now, KErrorActionFail));
       
  1363 	iSelection->AppendL(CreateMessageL(now, KErrorActionFail));	
       
  1364 	}
       
  1365 	
       
  1366 void CTestFailed_1::ScheduleMessagesL()
       
  1367 	{
       
  1368 	iTestUtils.Printf(_L("Rescheduling %d messages\n"), iSelection->Count());
       
  1369 	TransferCommandL(EReScheduleAllL);
       
  1370 	}
       
  1371 	
       
  1372 TInt CTestFailed_1::ScheduledState()
       
  1373 	{
       
  1374 	return  KMsvSendStateResend;
       
  1375 	}
       
  1376 
       
  1377 const TDesC& CTestFailed_1::TestName()
       
  1378 	{
       
  1379 	return KTestScheduleSendFailed_1();
       
  1380 	}
       
  1381 	
       
  1382 /*
       
  1383  * CTestFailed_2
       
  1384  */
       
  1385  
       
  1386 CTestFailed_2* CTestFailed_2::NewL(CScheduleSendTestUtils& aTestUtils)
       
  1387 	{
       
  1388 	CTestFailed_2* self = new (ELeave) CTestFailed_2(aTestUtils);
       
  1389 	CleanupStack::PushL(self);
       
  1390 	self->ConstructL();
       
  1391 	CleanupStack::Pop(self);
       
  1392 	return self;
       
  1393 	}	
       
  1394 	
       
  1395 CTestFailed_2::~CTestFailed_2()
       
  1396 	{
       
  1397 	}
       
  1398 	
       
  1399 CTestFailed_2::CTestFailed_2(CScheduleSendTestUtils& aTestUtils)
       
  1400 : CTestScheduleSendBase(aTestUtils)
       
  1401 	{
       
  1402 	}
       
  1403 	
       
  1404 // methods from CTestScheduleSendBase
       
  1405 	
       
  1406 TBool CTestFailed_2::NotifyMessagesScheduledL()
       
  1407 	{
       
  1408 	// Messages are scheduled.
       
  1409 	return EFalse;
       
  1410 	}
       
  1411 	
       
  1412 void CTestFailed_2::CreateMessagesL()
       
  1413 	{
       
  1414 	// Create two pigeon messages in the inbox.
       
  1415 	iSelection->Reset();
       
  1416 	iSelection->SetReserveL(2);
       
  1417 	
       
  1418 	TTime now;
       
  1419 	now.HomeTime();
       
  1420 	
       
  1421 	iSelection->AppendL(CreateMessageL(now, KErrorActionRetryFail));
       
  1422 	iSelection->AppendL(CreateMessageL(now, KErrorActionRetryFail));	
       
  1423 	}
       
  1424 	
       
  1425 void CTestFailed_2::ScheduleMessagesL()
       
  1426 	{
       
  1427 	iTestUtils.Printf(_L("Rescheduling (for retries) %d messages\n"), iSelection->Count());
       
  1428 	TransferCommandL(EReScheduleRetryAllL);
       
  1429 	}
       
  1430 	
       
  1431 TInt CTestFailed_2::ScheduledState()
       
  1432 	{
       
  1433 	return KMsvSendStateResend;
       
  1434 	}
       
  1435 
       
  1436 TInt CTestFailed_2::SentState()
       
  1437 	{
       
  1438 	return KMsvSendStateWaiting;
       
  1439 	}
       
  1440 
       
  1441 const TDesC& CTestFailed_2::TestName()
       
  1442 	{
       
  1443 	return KTestScheduleSendFailed_2();
       
  1444 	}