コード例 #1
0
/**
 @fn void WriteIniFileL()
 Open the ini file and store the values
 */
LOCAL_C void WriteIniFileL()
	{
	RFs fileSession;
	User::LeaveIfError(fileSession.Connect());
	CleanupClosePushL(fileSession);
	
	// create folder path
	fileSession.MkDirAll(IniFileName);
	
	RFileWriteStream fileWriteStream;
	User::LeaveIfError(fileWriteStream.Create(fileSession, IniFileName ,EFileWrite));
	CleanupClosePushL(fileWriteStream);
	
	//write the KEComUid to the stream
	fileWriteStream.WriteInt32L(KEComUid);
	
	//write the KSsaUid to the stream
	fileWriteStream.WriteInt32L(KSsaUid);
	
	//write the SSA value to the stream
	fileWriteStream.WriteInt8L(KSsaDisabled);
	
	//commit changes to the stream
	fileWriteStream.CommitL();

	// close: fileSession, fileWriteStream
	CleanupStack::PopAndDestroy(2);
	}
コード例 #2
0
/**
 ssmtestapprvafterretry.exe is eventually invoked successfully. SsmStartSafe is configured to
 make 1 + retries attempts to start the recalcitrant app. The app is configured to start
 after retries attempts
*/
void CSsTestStepAppStart::DoTestAppStartWithRetriesL()
{
    INFO_PRINTF1( _L("\nStart recalcitrant app with retries") );

    //
    // Write the retry number to a file to be read, updated
    // and eventually deleted by the test-app.
    RFs fs;
    CleanupClosePushL( fs );

    RFileWriteStream writeStream;
    CleanupClosePushL( writeStream );

    if( KErrNone != fs.Connect()
            || KErrNone != writeStream.Replace(fs, KDontRvCountFile, EFileWrite) )
    {
        User::Leave( KErrCouldNotConnect );
    }
    const TInt KSsTestDontRvCount = 4;
    writeStream.WriteInt8L( KSsTestDontRvCount );
    writeStream.CommitL();

    CleanupStack::PopAndDestroy( 2, &fs );
    //


    const TInt KRetries = KSsTestDontRvCount + 1;
    CSsmStartupProperties* startupProperties_0 = CSsmStartupProperties::NewL();
    CleanupStack::PushL( startupProperties_0 );

    startupProperties_0->SetFileParamsL( KTestAppRvAfterRetry, KNullDesC );
    startupProperties_0->SetCommandTypeL( ESsmCmdStartApp );
    startupProperties_0->SetExecutionBehaviour( ESsmWaitForSignal );
    startupProperties_0->SetRetries( KRetries );
    // For each retry KTestAppRvAfterRetry takes 2secs
    startupProperties_0->SetTimeout( KSsTestAppStartTimeout*1.5 );

    RProcess process;
    TInt id_0 = 0;

    CStartAcknowledge* ack_0 = new(ELeave) CStartAcknowledge( this );
    CleanupStack::PushL( ack_0 );

    CSsmStartSafe* ss  = CSsmStartSafe::NewLC();
    ss->Start(*startupProperties_0, process, ack_0->iStatus, id_0);


    CAsPauseStopper* pauseStopper = new(ELeave) CAsPauseStopper( KSsAsStopperNominalTimeout * 10 );
    CleanupStack::PushL( pauseStopper );
    CActiveScheduler::Start();
    process.Close();

    TEST( ack_0->iStatus == KErrNone );

    CleanupStack::PopAndDestroy( 4, startupProperties_0 );

    TEST( 1 == FindAndKill(KTestAppRvAfterRetry) );
}
コード例 #3
0
/**
 Start a test application synchronously using Wait-for-Signal with timeout
 more than the time required for the application to start and which starts after the no. of retries given.
*/
void CSsTestStepAppTimeout::DoTestWaitForSignalWithMoreTimeOutAndWithRetriesL()
	{	
	INFO_PRINTF1(_L("Performing Wait-for-Signal test with timeout and retries"));

	// Write the retry number to a file to be read, updated 
	// and eventually deleted by the test-app.
	RFs fs;	
	CleanupClosePushL( fs );
	
	RFileWriteStream writeStream;
	CleanupClosePushL( writeStream );

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(writeStream.Replace(fs, KFileForFAndF, EFileWrite));

	const TInt KSsTestRequiredDelay = 0;
	const TInt KSsTestFailCount = 1;
	const TInt KSsTestRetryCount = 0;
	writeStream.WriteInt8L(KSsTestRetryCount);
	writeStream.WriteInt8L(KSsTestFailCount);
	writeStream.WriteInt8L(KSsTestRequiredDelay);
	writeStream.CommitL();
	writeStream.Close();
	
	const TInt KRetries = KSsTestFailCount + 1;
	TInt completionCode = DoTestAndStopperL(KRetries, KWaitTimeForTestAppForFAndF * 3, KTestAppForFAndF);
	TEST(completionCode == 0);
	
	INFO_PRINTF2( _L("Anticipated completion code 0. Supplied completion code %d"),completionCode);
	RFileReadStream readStream;
	CleanupClosePushL(readStream);

	User::LeaveIfError(readStream.Open(fs, KFileForFAndF, EFileRead));
	TInt retryCount = readStream.ReadInt8L();
	readStream.Close();	
	fs.Delete(KFileForFAndF);

	CleanupStack::PopAndDestroy(3, &fs);

	TEST(1 == FindAndKill(KTestAppForFAndF));
	TEST(retryCount == 1);

	INFO_PRINTF3( _L("ssmtestappsucessfulafterretry.exe is started after %d retries. anticipated retries value %d"),retryCount, 1);
	}
コード例 #4
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 );
		} );