コード例 #1
0
/**
 Overload of the CCoeAppUi virtual method.
 The method in the base class merely returns ETrue. Overloads would normally just return EFalse.
 In this case however, we do some jiggery-pokery in order to invoke the StartSafe retry mechanism.
 ie we return EFalse on each of several invocations but don't do the Rendezvous, then 
 eventually ETrue, so the Framework Rendezvous for us. our final invocation therefore being successful.
 
 The count file is written from the test-step, and 
 if successful, deleted here.
 
 The code is nearly all parenthesised within a TRAP harness in order to preserve the integrity 
 of this function, which is called by the framework.

*/
TBool CTestAppUi::FrameworkCallsRendezvous() const
	{
	
	TBool frameworkRendezvous = EFalse;

	TRAPD( err,
		{			
		RFs fs;
		RFileReadStream readStream;
		RFileWriteStream writeStream;
						
		CleanupClosePushL( fs );
		CleanupClosePushL( readStream );
		CleanupClosePushL( writeStream );
		
			
		if( KErrNone != fs.Connect()
		 || KErrNone != readStream.Open(fs, KDontRvCountFile, EFileRead) )
			{
			User::Leave( KErrCouldNotConnect );	
			}
		

		TInt failCount = readStream.ReadInt8L();
		readStream.Close();	
		

		if( 0 == failCount )
			{
			fs.Delete( KDontRvCountFile );
			
			// We've decided to be good this time. Let the framework do it for us.
			frameworkRendezvous = ETrue;
			}
		else
			{
			// StartSafe will timeout while waiting for a Rendezvous()
			User::LeaveIfError( writeStream.Open(fs, KDontRvCountFile, EFileWrite) );
	
			writeStream.WriteInt8L( --failCount );
			writeStream.CommitL();
			writeStream.Close();
			}
			
		CleanupStack::PopAndDestroy( 3, &fs );
		} );
コード例 #2
0
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);	
	
	
	}