void CMtfTestActionMoveSelection::RunL()
	{
	TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus);

	delete iOperation;

	User::LeaveIfError(err);
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionForwardSystemTime::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionForwardSystemTime);
	
	//Get the current system time
	TTime utcTime;
	utcTime.UniversalTime();
	
	//Get value from Ini file
    TInt  forwardTimeInMinutes = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0));

	//Forward the system time 
	TTimeIntervalMinutes forwardMinutes(forwardTimeInMinutes);
	User::SetUTCTime(utcTime+forwardMinutes);
	
	TestCase().INFO_PRINTF2(_L("Test Action %S Passed..."), &KTestActionForwardSystemTime);	
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionAddAttachmentAsLink::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionAddAttachmentAsLink);
	TRAPD(err, RunTestL());
	
	if( ActionParameters().Count() < 5 )
		{
		User::LeaveIfError(err);
		}
	else
		{
		StoreParameterL<TInt>(TestCase(),err,ActionParameters().Parameter(4));
		}
	
	TestCase().INFO_PRINTF1(_L("CMtfTestActionAddAttachmentAsLink completed....."));

	TestCase().ActionCompletedL(*this); 
	}
void CMtfTestActionSaveMsvIdParamToFile::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSaveMsvIdParamToFile);
		
	TMsvId messageId = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(0) );										
	HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1));
 
 	
 	RFs fs;
 	User::LeaveIfError( fs.Connect() );
 	CleanupClosePushL( fs );
 	
	TInt err = fs.MkDir( *paramFilePath ); 
	
	if ( ! ( (err == KErrNone ) || ( err == KErrAlreadyExists ) ) )
	{	
		User::LeaveIfError( err );
	}
	// else dir created successfully or already created.
	
	RFileWriteStream rf;
	err = rf.Open( fs , *paramFilePath , EFileWrite );
	if ( err == KErrNotFound )
	{
		err = rf.Create( fs, *paramFilePath , EFileWrite );
	}	
	User::LeaveIfError(err);
	
	rf.PushL();
		// Writes may leave.
		
	rf << messageId; 

	rf.CommitL();
	rf.Pop();
	rf.Release();
			
 	CleanupStack::PopAndDestroy(); // fs

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSaveMsvIdParamToFile);
	TestCase().ActionCompletedL(*this);	
	
	
	}
void CMtfTestActionAddFileAttachmentByHandle::RunL()
	{
	User::LeaveIfError(iStatus.Int());
	iStore->CommitL();
	
	delete iStore;
	iStore = NULL;
	delete iEntry;
	iEntry = NULL;
	
	StoreParameterL<TMsvAttachmentId>(TestCase(),iAttachmentId,ActionParameters().Parameter(4));
	if(ActionParameters().Count() == 6)
		{
		TInt err = KErrNone;
		StoreParameterL<TInt>(TestCase(),err,ActionParameters().Parameter(5));
		}
		
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionSmtpRemoveEntryAttachmentById::RunTestL()
	{
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
	TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2));

	CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
	CleanupStack::PushL(entry);
	
	CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry);
	CleanupStack::PushL(emailMsg);
	
	MMsvAttachmentManager& manager = emailMsg->AttachmentManager();
	
	CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachId);
	CleanupStack::PushL(attachInfo);
	
	// First ensure that the attachment is a file attachment
	if( attachInfo->Type() != CMsvAttachment::EMsvMessageEntry )
		{
		User::Leave(KErrGeneral);
		}
		
	// Get the linked file
	TMsvId msgId = attachInfo->EntryAttachmentId();
	CleanupStack::PopAndDestroy(attachInfo);
		
	// Remove the attachment
	CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
	CleanupStack::PushL(waiter);
	manager.RemoveAttachmentL(attachId, waiter->iStatus);
	waiter->StartAndWait();
	User::LeaveIfError(waiter->Result());
	CleanupStack::PopAndDestroy(waiter);	
	
	CleanupStack::PopAndDestroy(2, entry); // email msg, entry

	// Ensure that the message entry still exists
	CMsvEntry* checkEntry = paramSession->GetEntryL(msgId);
	delete checkEntry;
	checkEntry = NULL;
	}
/**
  ExecuteActionL
	Get the array of account names from the available account list
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionSendAsGetAccountNames::ExecuteActionL()
	{
	if((TestCase().TestStepResult()) == EPass)
		{
		TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsGetAccountNames);
	
		// Get test action input parameters
		CSendAsAccounts* paramAvailableAccounts	= ObtainParameterReferenceL<CSendAsAccounts>(TestCase(),
																		ActionParameters().Parameter(0));
		
		// Get the count of account names
		TInt accountsCount = paramAvailableAccounts->AccountNames().MdcaCount();
		
		// Provide the array of account names as test action output
		StoreParameterL<TInt>(TestCase(), accountsCount, ActionParameters().Parameter(1));

		TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsGetAccountNames);
		}
		TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionVerifyBodyText::RunTestL()
	{
	
	CMsvEntry* paramEntry = ObtainParameterReferenceL<CMsvEntry>(TestCase(),
									ActionParameters().Parameter(0));
									
	CMtfConfigurationType::TMtfConfigurationType paramConfigurationType = ObtainValueParameterL<CMtfConfigurationType::TMtfConfigurationType>(TestCase(),
												ActionParameters().Parameter(1));
	
	TInt paramIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));


	TPtrC fileName = TestCase().GetConfigurationFileL(paramConfigurationType,paramIndex);
	
	// Call the utils function to verify the body text contents
	User::LeaveIfError(CMtfTestActionUtilsMessage::	VerifyBodyTextContentsL(*paramEntry,fileName.AllocLC()));

	CleanupStack::PopAndDestroy();
	
	}
/**
  Function : RunL
  Description	: Handles the asynchronous request completion event. Informs the completion 
				  of the Test Action to the Test Case
  @internalTechnology
  @param		: none
  @return		: void
  @pre none
  @post: none
*/
void CMtfTestActionSchedulePigeonMessage::RunL()
	{
	TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus);
	
	delete iOperation;
	iOperation = NULL;
	
	User::LeaveIfError(err);

	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionSendEMsvDeleteAttachment::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvDeleteAttachment);
	// input params
	TMsvId entryId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0) );
	HBufC* fileName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1) );
	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2) );


	RProxyServerSession RPSS;
	
	// Will auto start the server if not started.
	TInt error = RPSS.Connect();
	CleanupClosePushL(RPSS);
	
	if (error!=KErrNone)
		{
		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvDeleteAttachment :: Unable to start proxy server. !"));
		TestCase().SetTestStepResult(EFail);
		}
	else
		{
		TInt32 serverCaps;
		RPSS.GetServerCapabilities(serverCaps);
		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
				
		error = 0;
				
		TPtr pFileName = fileName->Des();
		
		error=RPSS.SendReceive(EMsvDeleteAttachment , TIpcArgs(entryId, &pFileName));

		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass );
		}
	
	CleanupStack::Check(&RPSS);
	CleanupStack::PopAndDestroy(); // RPSS
		
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvDeleteAttachment);
	TestCase().ActionCompletedL(*this);
	}
/**
  Function : ExecuteActionL
  Description : Entry point for the this test action in the test framework
  @internalTechnology
  @param : none
  @return : void
  @pre none 
  @post none
*/
void CMtfTestActionSendEMsvStopService::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvStopService);
	// for this test action we need a pending operation on the MTM
	// we will create a spurious imap4 disconnect operation
	TMsvId serviceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
	CImap4ClientMtm* paramMtm = ObtainParameterReferenceL<CImap4ClientMtm>(TestCase(),ActionParameters().Parameter(1));
	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2) );
	
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
	CleanupStack::PushL( selection );
	selection->AppendL( serviceId );
	TBuf8<1> param;

	CMsvOperation* operation = paramMtm->InvokeAsyncFunctionL(KIMAP4MTMDisconnect,*selection,param,iStatus);
	CleanupStack::PushL( operation );

	RProxyServerSession RPSS;
	
	TInt error = RPSS.Connect();
		
	if (error!=KErrNone)
		{
		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvStopService :: Unable to start proxy server. !"));
		TestCase().SetTestStepResult(EFail);
		}
	else
		{
		TInt32 serverCaps;
		RPSS.GetServerCapabilities(serverCaps);
		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
				
		error = 0;			
		error=RPSS.SendReceive(EMsvStopService , TIpcArgs( serviceId ) );
		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass );
		}

	CleanupStack::PopAndDestroy( 2, selection );	
	TestCase().INFO_PRINTF2(_L(" (<: Test Action %S completed :>) "), &KTestActionSendEMsvStopService );
	TestCase().ActionCompletedL(*this);
	}
/**
  Function : ExecuteActionL
  Description : Issues command to Pigeon Server MTM to schedule/reschedule the messages
  @internalTechnology
  @param  : none
  @return : void
  @pre  
  @post none
*/
void CMtfTestActionSchedulePigeonMessage::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSchedulePigeonMessage);
	// Obtain input parameters
	CMsvSession* paramSession	= ObtainParameterReferenceL<CMsvSession>(TestCase(),
														ActionParameters().Parameter(0));
	TMsvId paramParentId		= ObtainValueParameterL<TMsvId>(TestCase(),
														ActionParameters().Parameter(1));
	TInt paramCommand			= ObtainValueParameterL<TInt>(TestCase(),
														ActionParameters().Parameter(2));
	
	//Error Handling Just in case one of the above inputs fail.
	if(TestCase().TestStepResult() == EPass)
		{
		CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering());

		// Get the selection of Pigeon Messages
		iSelection = entry->ChildrenWithMtmL(KUidMsgTypePigeon);
		
		// Initiate asynchronous operation, passing the schedule/reschedule the message in the selection
		// Dummy aParameter value passed as Pigeon MTM does not make use of it.
		iOperation = paramSession->TransferCommandL(*iSelection,paramCommand, _L8("aaaa"), iStatus);
		
		CActiveScheduler::Add(this);
		SetActive();
		}
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSchedulePigeonMessage);
	}
void CMtfTestActionDeleteEntry::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteEntry);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId paramEntryId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));

	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramEntryId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(paramEntryId);
	entry->SetEntryL(entry->Entry().Parent());

	if (entry->OwningService() == KMsvLocalServiceIndexEntryId)
		{
		entry->DeleteL(paramEntryId);
		DeleteParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
		TestCase().ActionCompletedL(*this);
		}
	else
		{
		iOperation = entry->DeleteL(paramEntryId,iStatus);
		SetActive();
		}
	CleanupStack::PopAndDestroy(entry);
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteEntry);
	}
void CMtfTestActionSetUserResponse::ExecuteActionL()
	{	
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetUserResponse);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession> (TestCase(),ActionParameters().Parameter(0));	
	TInt paramUserResponse = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1),EFalse);
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*paramSession, KMsvDraftEntryId, 
						TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	TestCase().INFO_PRINTF2(_L("Count of Draft Folder's selection is %d"),selection->Count());
	
	if (selection->Count() == 0)
	{	
	User::Leave(KErrNotFound);
	}
	
	cEntry->SetEntryL((*selection)[0]);

	if (!paramUserResponse)
	{	
	TMsvEntry entry = cEntry->Entry();
	entry.iError = KErrCancel;
	cEntry->ChangeL(entry);
	}
	
	CleanupStack::PopAndDestroy(2);
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetUserResponse);
	TestCase().ActionCompletedL(*this);
	}
/**
  ExecuteActionL
  Obtain the input parameters
	1.	CMsvStore
	2.	paramConfigurationType
	3.	paramIndex
	Check if the store contains any streams using CMsvStore::IsNullL () function.  If store is empty, leave with appropriate error
	Call CMtfTestCase::GetConfigurationFileL(configurationType, Index) passing the configuration type and the index to the file name
	Call User::LeaveIfError( CMtfTestActionUtilsMessage::VerifyBodyTextContentsL()), passing CMsvStore and the file name to the VerifyBodyTextContentsL() function.

  
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionVerifyBodyText::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionVerifyBodyText);
	if( ActionParameters().Count() < 4 )
		{
		TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Insufficient Action Parameters") , &KTestActionVerifyBodyText);
		}
	else
		{
		TRAPD(err, RunTestL());
	
		TInt paramExpectedResult = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3));
		
		if(err != paramExpectedResult)
			{
			TestCase().ERR_PRINTF3(_L("%S :: FAIL :: Verify Body Text Failed with error = %d") , &KTestActionVerifyBodyText, err);
			}
		else
			{
			TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionVerifyBodyText);
			}
		}
		
	TestCase().ActionCompletedL(*this); 
	}
/**
  ExecuteActionL
  Obtains the parameters for the test action. 
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionSendAsCloseAndSendMessage::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsCloseAndSendMessage);
	RSendAsMessage	paramRSendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(),ActionParameters().Parameter(0));
	TInt paramCloseAndSendMessageConfirmed = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1), EFalse);
	
	TInt err = KErrNone;
	
	if (paramCloseAndSendMessageConfirmed)
		{
		TRAP(err,paramRSendAsMessage.SendMessageConfirmedAndCloseL());
		}
	else
		{
		TRAP(err,paramRSendAsMessage.SendMessageAndCloseL());
		}

	if( ActionParameters().Count() > 2 )
		{
		StoreParameterL<TInt>(TestCase(),err,ActionParameters().Parameter(2));
		}
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsCloseAndSendMessage);
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionAddEntryAttachment::RunTestL()
{
    CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
    TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
    TMsvId attachmentMessageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2));

    CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
    CleanupStack::PushL(entry);

    CMsvStore* store = entry->EditStoreL();
    CleanupStack::PushL(store);

    CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
    CleanupStack::PushL(waiter);

    CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvMessageEntry);
    CleanupStack::PushL(attachment);

    TMsvEntry attachmentEntry;
    TMsvId attachmentServiceEntry;
    User::LeaveIfError(paramSession->GetEntry(attachmentMessageEntry, attachmentServiceEntry, attachmentEntry));
    attachment->SetSize(attachmentEntry.iSize);

    MMsvAttachmentManager& manager = store->AttachmentManagerL();

    manager.AddEntryAsAttachmentL(attachmentMessageEntry, attachment, waiter->iStatus);
    CleanupStack::Pop(attachment); // ownership passed to manager
    waiter->StartAndWait();
    User::LeaveIfError(waiter->Result());
    CleanupStack::PopAndDestroy(waiter);

    TMsvAttachmentId attachmentId = attachment->Id();

    store->CommitL();

    CleanupStack::PopAndDestroy(2, entry); // store, entry

    StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(3));
}
void CMtfTestActionDeleteFileStore::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteFileStore);
	// Obtain the input parameters
	TMsvId paramEntryId  = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));

	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	
	RMsvServerSession serverSession;
	serverSession.Connect(fs);
	CleanupClosePushL(serverSession);

	serverSession.DeleteFileStoreL(paramEntryId);

	CleanupStack::PopAndDestroy(2,&fs);
	
	TestCase().ActionCompletedL(*this);
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteFileStore);
	}
void CMtfTestActionSendEMsvDriveContainsStore::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvDriveContainsStore);
	// input params
	TInt drive = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0) ); 
	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1) );

	RProxyServerSession RPSS;
	
	// Will auto start the server if not started.
	TInt error = RPSS.Connect();
	CleanupClosePushL(RPSS);
	
	if (error!=KErrNone)
		{
		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvDriveContainsStore :: Unable to start proxy server. !"));
		TestCase().SetTestStepResult(EFail);
		}
	else
		{
		TInt32 serverCaps;
		RPSS.GetServerCapabilities(serverCaps);
		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
				
		error = 0;
		TDriveUnit driveUnit(drive);
		
		error=RPSS.SendReceive(EMsvDriveContainsStore, TIpcArgs(driveUnit));
		if (error >= 0)
		{
			// we're just interested in being able to make the call, so whether the
			// store is on the drive or not is beside the point
			error = KErrNone;
		}
		
		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass );
		}
	
	CleanupStack::Check(&RPSS);
	CleanupStack::PopAndDestroy(); // RPSS
		
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvDriveContainsStore);
	TestCase().ActionCompletedL(*this);
	}
/**
  Function : ExecuteActionL
  Description		: Launches the schsendexe.exe and verifies the result of process 
					  completion with that of the expected result.
  @internalTechnology
  @param			: none
  @return			: void
  @pre	 
  @post	: none
*/
void CMtfTestActionLaunchSchSendExe::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionLaunchSchSendExe);
	// Expected result
	TInt expectedResult  = KErrPermissionDenied;
	
	TBuf<20> cmdString;
	
	// Return KErrNotSupported in case of Wins
	TInt returnValue = KErrNotSupported;
	
	TRequestStatus status = KRequestPending;

	RProcess process;					
	User::LeaveIfError(process.Create(KMsvSchSendExe, cmdString, TUidType(KNullUid, KNullUid, KMsvSchSendExeUid)));
	TestCase().INFO_PRINTF2(_L("RProcess::Create() is successful %S "), &KTestActionLaunchSchSendExe);

	// Make the process eligible for execution
	process.Logon(status);
	process.Resume();

	// Wait for the process completion
	User::WaitForRequest(status);
				
	// Check the exit reason of the process.If Panic occurs the return value is set to KErrGeneral as the 
	// focus of test action is to check if KErrPermissionDenied is returned.
	returnValue = (process.ExitType() == EExitPanic)? KErrGeneral: status.Int();

	process.Close();

	TestCase().INFO_PRINTF4(_L("Test Action %S completed with %d, while expected %d "), &KTestActionLaunchSchSendExe,returnValue, expectedResult );
	
	if(returnValue != expectedResult )
		{
		TestCase().SetTestStepResult(EFail);
		}
		
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionMoveSelection::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionMoveSelection);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	CMsvEntrySelection* paramSelection = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(1));
	TMsvId paramTargetId      = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2));

	TInt count = paramSelection->Count();
	if (count == 0)
		User::Leave(KErrArgument);

	TMsvId entryId = (*paramSelection)[0];

	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,entryId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(entryId);
	entry->SetEntryL(entry->Entry().Parent());
	iOperation = entry->MoveL(*paramSelection,paramTargetId,iStatus);
	CleanupStack::PopAndDestroy(entry);
	CActiveScheduler::Add(this);
	SetActive();
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionMoveSelection);
	}
void CMtfTestActionSendEMsvReleaseStore::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvReleaseStore);
	// input params
	TMsvId ownerId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0) );
	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1) );

	RProxyServerSession RPSS;
	
	// Will auto start the server if not started.
	TInt error = RPSS.Connect();
	CleanupClosePushL(RPSS);
	
	if (error!=KErrNone)
		{
		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvReleaseStore :: Unable to start proxy server. !"));
		TestCase().SetTestStepResult(EFail);
		}
	else
		{
		TInt32 serverCaps;
		RPSS.GetServerCapabilities(serverCaps);
		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
				
		error = 0;
		
		// First we need to lock the store (or we get a panic in the server when we try to release it)
		error=RPSS.SendReceive(EMsvLockStore , TIpcArgs(ownerId));		
		
		// Release the store
		error=RPSS.SendReceive(EMsvReleaseStore , TIpcArgs(ownerId));

		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass );
		}
	
	CleanupStack::Check(&RPSS);
	CleanupStack::PopAndDestroy(); // RPSS
		
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvReleaseStore);
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionSmtpGetAttachmentFileFromId::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpGetAttachmentFileFromId);
	TInt expectedError = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(4), KErrNone);

	if( expectedError != KErrNone )
		{
		// error checking is requested
		TRAPD(err, RunTestActionL());
		if( expectedError != err )
			{
			// not the expected error code
			User::Leave(KErrGeneral);
			}
		}
	else
		{
		// no error expected
		RunTestActionL();
		}

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpGetAttachmentFileFromId);
	TestCase().ActionCompletedL(*this);
	}
/**
  ExecuteActionL
  Sets the values for TImImap4GetMailInfo memeber variables and then store it
  as an output parameter of the Test Action.
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionSetImap4FullDownloadLimits::ExecuteActionL()
	{	
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetImap4FullDownloadLimits);
	// Obtain Test Action input parameters
	TInt  paramTotalSizeLimit	  = ObtainValueParameterL<TInt>(TestCase(),
										ActionParameters().Parameter(0),KMaxTInt);

	TImap4GetMailOptions  paramMailOptions	 = ObtainValueParameterL<TImap4GetMailOptions>
												(TestCase(),ActionParameters().Parameter(1),
												EGetImap4EmailHeaders);

 	TMsvId	paramDestinationFolder  = ObtainValueParameterL<TMsvId>
										(TestCase(),ActionParameters().Parameter(2));
										
	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(3));

	// Store the full donwload limits values 
	TImImap4GetMailInfo  imap4GetMailInfo;
		
	imap4GetMailInfo.iMaxEmailSize      = paramTotalSizeLimit;
	imap4GetMailInfo.iGetMailBodyParts  = paramMailOptions;
	imap4GetMailInfo.iDestinationFolder = paramDestinationFolder;
	
	// Load the Imap account settings and save the download limits
	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();	
	CImImap4Settings* imapSettings =  new(ELeave) CImImap4Settings();
	CleanupStack::PushL(imapSettings);

	TImapAccount imapAccount;
	emailAccounts->GetImapAccountL(paramServiceId, imapAccount);
	emailAccounts->LoadImapSettingsL(imapAccount, *imapSettings);
		
	imapSettings->SetMaxEmailSize( imap4GetMailInfo.iMaxEmailSize );
	imapSettings->SetGetMailOptions( imap4GetMailInfo.iGetMailBodyParts );
	
	emailAccounts->SaveImapSettingsL(imapAccount, *imapSettings);
	CleanupStack::PopAndDestroy( 2, emailAccounts ); // imapSettings, emailSettings
	

	// Store the full download limits as the ouput parameter of the Test Action		
	StoreParameterL<TImImap4GetMailInfo>(TestCase(),imap4GetMailInfo,
											ActionParameters().Parameter(4));

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetImap4FullDownloadLimits );
	TestCase().ActionCompletedL(*this);
	}
Пример #25
0
    TestCase makeTestCase(  ITestCase* _testCase,
                            std::string const& _className,
                            std::string const& _name,
                            std::string const& _descOrTags,
                            SourceLineInfo const& _lineInfo )
    {
        std::string desc = _descOrTags;
        bool isHidden( startsWith( _name, "./" ) ); // Legacy support
        std::set<std::string> tags;
        TagExtracter( tags ).parse( desc );
        if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() )
            isHidden = true;

        TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo );
        return TestCase( _testCase, info );
    }
void CMtfTestActionSmtpModifyAttachmentInfo::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpModifyAttachmentInfo);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
	TMsvAttachmentId attachmentId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2));

	CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
	CleanupStack::PushL(entry);
	
	CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry);
	CleanupStack::PushL(emailMsg);

	MMsvAttachmentManager& manager = emailMsg->AttachmentManager();
	
	CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
	CleanupStack::PushL(mimeHeaders);

	mimeHeaders->SetContentDescriptionL(KTxtContentDescription());
	mimeHeaders->SetContentBaseL(KTxtContentBase());
	mimeHeaders->SetContentLocationL(KTxtContentLocation());
	mimeHeaders->SetContentIdL(KTxtContentId());
	mimeHeaders->SetContentTypeL(KTxtContentType());
	mimeHeaders->SetContentSubTypeL(KTxtContentSubType());
	mimeHeaders->SetContentDispositionL(KTxtContentDisposition());
	mimeHeaders->ContentTypeParams().AppendL(KTxtParam1());
	mimeHeaders->ContentTypeParams().AppendL(KTxtParam2());
	mimeHeaders->ContentTypeParams().AppendL(KTxtParam3());
	mimeHeaders->ContentDispositionParams().AppendL(KTxtParam4());
	mimeHeaders->ContentDispositionParams().AppendL(KTxtParam5());
	mimeHeaders->ContentDispositionParams().AppendL(KTxtParam6());
	mimeHeaders->XTypeParams().AppendL(KTxtParam7());
	mimeHeaders->XTypeParams().AppendL(KTxtParam8());
	mimeHeaders->XTypeParams().AppendL(KTxtParam9());

	CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
	CleanupStack::PushL(waiter);
	CMsvAttachment* attachment = manager.GetAttachmentInfoL(attachmentId);
	CleanupStack::PushL(attachment);
	mimeHeaders->StoreL(*attachment);
	manager.ModifyAttachmentInfoL(attachment, waiter->iStatus);
	CleanupStack::Pop(attachment);
	waiter->StartAndWait();
	User::LeaveIfError(waiter->Result());

	CleanupStack::PopAndDestroy(2, mimeHeaders); // waiter, mimeHeaders
	
	CompareMimeHeadersL(*emailMsg, attachmentId);
	
	CleanupStack::PopAndDestroy(2, entry);//emailMsg, entry

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpModifyAttachmentInfo);
	TestCase().ActionCompletedL(*this);
	}
/**
  Function : ExecuteActionL
  Description : Entry point for the this test action in the test framework
  @internalTechnology
  @param : none
  @return : void
  @pre none 
  @post none
*/
void CMtfTestActionCompareLastSegmentReport::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareLastSegmentReport);
	CSmsSettings* smsSettingsOrg = ObtainParameterReferenceL<CSmsSettings>(TestCase(),ActionParameters().Parameter(0) );
	CSmsSettings* smsSettingsRef = ObtainParameterReferenceL<CSmsSettings>(TestCase(),ActionParameters().Parameter(1) );

	if(	smsSettingsOrg->LastSegmentDeliveryReport() !=	smsSettingsRef->LastSegmentDeliveryReport())
		{
		// failed
		TestCase().ERR_PRINTF1(_L("SMS Settings for the last segment report request do not match !"));
		TestCase().SetTestStepResult(EFail);
		}
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareLastSegmentReport);
	TestCase().ActionCompletedL(*this);
	}
Пример #28
0
int main( int argc, char *argv[] )
{
#ifdef __SW_BW
    FILE *my_stdout;
    my_stdout = freopen( "tmp.log", "a", stdout );
    if( my_stdout == NULL ) {
        fprintf( stderr, "Unable to redirect stdout\n" );
        exit( -1 );
    }
#endif
    /*** Initialize ***/
    strcpy( ProgramName, strlwr( argv[0] ) );   /* store filename */

    /*** Test various functions ***/
    TestCompare();                              /* compare stuff */
    TestMove();                                 /* moving data about */
    TestCase();                                 /* upper/lowercase stuff */
    TestSearch();                               /* searching stuff */
    TestSubstring();                            /* substring stuff */
    TestToken();                                /* tokenizing stuff */
    TestLocale();                               /* locale stuff */
    TestError();                                /* error string stuff */
    TestFormatted();                            /* formatted I/O stuff */
    TestBounded();                              /* bounded string stuff */
#ifdef __X86__
    TestCompareF();
    TestMoveF();
    TestCaseF();
    TestSearchF();
    TestSubstringF();
    TestTokenF();
#endif

    /*** Print a pass/fail message and quit ***/
    if( NumErrors != 0 ) {
        printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors );
        return( EXIT_FAILURE );
    }
    printf( "Tests completed (%s).\n", strlwr( argv[0] ) );
#ifdef __SW_BW
    fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) );
    fclose( my_stdout );
    _dwShutDown();
#endif
    return( 0 );
}
/**
  Function : ExecuteActionL
  Description : Entry point for the this test action in the test framework
  @internalTechnology
  @param : none
  @return : void
  @pre none 
  @post none
*/
void CMtfTestActionComparePopAccountId::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionComparePopAccountId);
	TPopAccount accountId1 = ObtainValueParameterL<TPopAccount>(TestCase(), ActionParameters().Parameter(0));
	TPopAccount accountId2 = ObtainValueParameterL<TPopAccount>(TestCase(), ActionParameters().Parameter(1));
	
	if (accountId1.iPopAccountId != accountId2.iPopAccountId)
		{
		// failed
		TestCase().ERR_PRINTF1(_L("POP accounts do not match !"));
		TestCase().SetTestStepResult(EFail);
		}
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionComparePopAccountId);
	TestCase().ActionCompletedL(*this);
	}
void CMtfTestActionSendEMsvGetAndClearIndexCorruptFlag::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvGetAndClearIndexCorruptFlag);
	// input params
	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0) );

	RProxyServerSession RPSS;
	
	// Will auto start the server if not started.
	TInt error = RPSS.Connect();
	CleanupClosePushL(RPSS);
	
	if (error!=KErrNone)
		{
		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvGetAndClearIndexCorruptFlag :: Unable to start proxy server. !"));
		TestCase().SetTestStepResult(EFail);
		}
	else
		{
		TInt32 serverCaps;
		RPSS.GetServerCapabilities(serverCaps);
		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
		
		error = 0;
				
		error=RPSS.SendReceive(EMsvGetAndClearIndexCorruptFlag);
		if (error >= 0)
		{
			// command succeeded, so set return code to KErrNone
			error = KErrNone;
		}
		
		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass );
		}
	
	CleanupStack::Check(&RPSS);
	CleanupStack::PopAndDestroy(); // RPSS
		
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvGetAndClearIndexCorruptFlag);
	TestCase().ActionCompletedL(*this);
	}