Example #1
0
void CPasswordTest::TurnOffAndOn()
	{
/*#if defined(LOG_TESTS)
	TLogMessageText buf;
	_LIT(KSettingTime,"Setting Off Timer");
	buf.Append(KSettingTime);
	Client()->LogMessage(buf);
#endif*/
	RTimer timer;
	timer.CreateLocal();
	TTime time;
	time.HomeTime();
	time+=TTimeIntervalSeconds(7);	// For some reason the O/S won't switch off for less than 6 seconds
	TRequestStatus status;
	timer.At(status,time);
	UserHal::SwitchOff();
	User::WaitForRequest(status);
#if !defined(__WINS__)
	TRawEvent event;
	event.Set(TRawEvent::ESwitchOn);
	UserSvr::AddEvent(event);
#endif
/*#if defined(LOG_TESTS)
	TLogMessageText buf;
	_LIT(KTimerOff,"Timer Gone Off (P=%d,S=%d)");
	buf.AppendFormat(KTimerOff,iState,iPassState);
	Client()->LogMessage(buf);
#endif*/
	}
/**
 * Waits for asynchronous request using aRequestStatus to complete or for
 * a period of time aTimeOut to pass which ever is sooner.
 * 
 * @param aRequestStatus Request status to wait for.
 * @param aTimeOut Timeout for aRequestStatus.
 * 
 * @return KErrNone if aRequestStatus completes or KErrTimedOut if 
 * aRequestStatus did not complete within the aTimeOut period.
 */
TInt CCTSYIntegrationTestSuiteStepBase::WaitForRequestWithTimeOut
		(TEtelRequestBase& aRequestStatus, TTimeDuration aTimeOut)
	{
	RTimer timer;
	TRequestStatus timerRequest;
	timer.CreateLocal();
	timer.After(timerRequest, aTimeOut);

	// Wait for the request to complete or until we time out
	User::WaitForRequest(timerRequest, aRequestStatus);

	// we must cancel the callers request if it is still outstanding
	if (aRequestStatus.Int() == KRequestPending)
		{
		WARN_PRINTF1(_L("WaitForRequestWithTimeOut - cancelling pending request"));
		aRequestStatus.Cancel();
		}

	// If timer is no longer pending => we have timed out
	if (timerRequest != KRequestPending)
		{
		INFO_PRINTF1(_L("WaitForRequestWithTimeOut *** Timed out ***"));
		return KErrTimedOut;
		}

	timer.Cancel();
	User::WaitForRequest(timerRequest);
	
	return KErrNone;
	}
TVerdict CLoopbackTestStep10::doTestStepL()
/**
Test flow control
*/
	{
	TestErrorCodeL( iCommPort1.Open(iCommServer, KPortName1, ECommExclusive, ECommRoleDCE), _L("Opening comm port 1") );
	TestErrorCodeL( iCommPort2.Open(iCommServer, KPortName2, ECommExclusive, ECommRoleDCE), _L("Opening comm port 2") );
	
	TRequestStatus writeStatus1;
	iCommPort1.Write(writeStatus1, KWriteBuf1);
	SetFlowControl(KPortUnitNum1, ETrue);
	SetFlowControl(KPortUnitNum2, ETrue);
	User::WaitForRequest(writeStatus1);
	TestErrorCodeL(writeStatus1.Int(), _L("Writing to comm port 1"));

	TRequestStatus timerStatus, readStatus;
	TBuf8<KRegularBufferSize> readBuf;
	iCommPort2.ReadOneOrMore(readStatus, readBuf);

	RTimer timer;
	timer.CreateLocal();
	timer.After(timerStatus, 3*KConfiguredPortDelayMicroseconds);
	
	User::WaitForRequest(readStatus, timerStatus);
	
	SetFlowControl(KPortUnitNum1, EFalse);
	SetFlowControl(KPortUnitNum2, EFalse);
	TestBooleanTrueL(timerStatus == KErrNone && readStatus != KErrNone, _L("Check that setting flow control causes read to be stopped"));

	User::WaitForRequest(readStatus);
	TestErrorCodeAndDescriptorL(readStatus.Int(), readBuf, KWriteBuf1, _L("Read from comm port 1"));

	return TestStepResult();
	}
Example #4
0
// Member for thread function
TInt CSMPSoakThread::DoSMPStressTimerThread()
	{
	RTest test(_L("SMPStressTimerThread"));
	test.Start(_L("SMPStressTimerThread"));

	PRINT (_L("SMPStressTimerThread\n"));
	RTimer timer;
	test_KErrNone(timer.CreateLocal());
	TRequestStatus s;

	FOREVER
		{
		timer.After(s, iThreadData.delayTime*1000);
		User::WaitForRequest(s);
		test (s == KErrNone);
		PRINT ((_L("*")));
		gSwitchSem.Signal(iThreadData.numThreads);

		if (gAbort)
			break;
		User::After(gPeriod);
		}
	timer.Cancel();
	PRINT((_L("SMPStressTimerThread MyTimer.Cancel() called\n")));
	test.End();
	test.Close();
	return 0x00;
	}
Example #5
0
void CPollTimeoutTimer::ConstructL(int msec)
{
    rtimer_.CreateLocal();
    CActiveScheduler::Add(this);
    rtimer_.After(iStatus, msec*1000);
    SetActive();
}
// Searches for an event
TVerdict RTestStepMmfCtlfrmAudio::SearchForEvent( TMMFEvent& aEvent )
{
#ifdef EVENT_SEARCH_DISABLED
    WARN_PRINTF1(_L("Warning : SearchForEvent disabled"));
    TMMFEvent dummyEvent; // JS
    aEvent = dummyEvent;	// to get rid of compiler warning
    return EPass;
#else

    TVerdict result = EFail;

    // status of events
    TRequestStatus timerStatus;
    TRequestStatus eventStatus;

    // due to problems with the timer as a member variable
    // added a local timer here
    RTimer  myTimer ;
    myTimer.CreateLocal();

    // create an event and initialise with unknown marker

    TMMFEventPckg receivedEvent;

    // for KMaxRetries attempt to find the event
    for( TInt retries = 0; retries < KMaxRetries; retries++ )
    {
        // post receive event to controller
        iController.ReceiveEvents( receivedEvent, eventStatus );
        // start breakout timer to escape
        myTimer.After(timerStatus, KDelay);

        // wait for an event to mature
        User::WaitForRequest( eventStatus, timerStatus );

        // check if the command is the event
        // and that a timeout did not occur
        if( IsTimeOut( eventStatus ))
        {
            // cancel the receive events
            CancelReceivedEvents();
        }
        else if( IsSoughtEvent( aEvent, receivedEvent ) )
        {
            // cancel the outstanding timer
            User::Check();
            myTimer.Cancel();
            // set status to pass since we have found the event
            result = EPass;
            break;
        }
        else
        {
            // We rx'd an event other than expected
            myTimer.Cancel();
        }
    }
    return result;
#endif // EVENT_SEARCH_DISABLED
}
// -----------------------------------------------------------------------------
// CContextEnginePluginTest::CreateContextEngine2L
// -----------------------------------------------------------------------------
//
TInt CContextEnginePluginTest::CreateContextEngine2L( CStifItemParser& /* aItem */ )
    {
    _LIT( KMsg1, "Enter CreateContextEngine" );
    iLog->Log( KMsg1 );  
    RDebug::Print( KMsg1 );
    
    iContextEngine = NULL;
    iContextEngine = CContextEngine::GetInstanceL();
    
    // 4 seconds
    TTimeIntervalMicroSeconds32 timeout(4000000);
    RTimer timer;
    TRequestStatus status;

    timer.CreateLocal();
    timer.After( status,timeout );

    User::WaitForAnyRequest();
    
    timer.Close();
    
    if( !iContextEngine )
        {
        User::Leave( KErrUnknown );
        }
    
    _LIT( KMsg2, "Exit CreateContextEngine" );
    iLog->Log( KMsg2 );  
    RDebug::Print( KMsg2 );
	
    return KErrNone;
    }
LOCAL_C TKeyCode ShortWaitForKey(TInt aDelay, TBool& aKeyPressed)
	{
	TRequestStatus stat1,stat2;
	RTimer timer;
	aKeyPressed=EFalse;
	timer.CreateLocal();
	for(TInt i=0;i<aDelay;i++)
		{
		test.Console()->Read(stat1);
		timer.After(stat2,1000000L);
		User::WaitForRequest(stat1,stat2);
		if(stat1==KErrNone)
			{
			timer.Cancel();
			User::WaitForRequest(stat2);
			aKeyPressed=ETrue;
			break;
			}
		else
			{
			test.Console()->ReadCancel();
			User::WaitForRequest(stat1);
			INFO_PRINTF1(_L("."));
			}
		}
	INFO_PRINTF1(_L("\n"));
	return test.Console()->KeyCode();
	}
GLDEF_C TInt E32Main()
    {
	test.Title();

	test.Start(_L("Test V1 notifier"));
	if(UserSvr::IpcV1Available())
		DoTests(KUidTestTextNotifier1,EFalse);
	else
		test.Printf(_L("IPC V1 not supported"));

	test.Next(_L("Test V2 notifier"));
	DoTests(KUidTestTextNotifier2,EFalse);

	test.Next(_L("Test V1 notifier using MNotifierManager"));
	if(UserSvr::IpcV1Available())
		DoTests(KUidTestTextNotifier1,ETrue);
	else
		test.Printf(_L("IPC V1 not supported"));

	test.Next(_L("Test V2 notifier using MNotifierManager"));
	if(UserSvr::IpcV1Available())
		DoTests(KUidTestTextNotifier2,ETrue);
	else
		test.Printf(_L("FIX ME! - Can't run because IPC V1 not supported\n"));

	
	test.Next(_L("TestNotify"));
	TestNotify();
	
	test.Next(_L("TestNotifyCancel"));
	TestNotifyCancel();

	test.Next(_L("Test removed methods"));
	TestRemovedMethods();

	test.Next(_L("Interactive Tests"));
	test.Printf(_L("  Do you want to test notifiers interactively? y/n\n"));
	test.Printf(_L("  Waiting 10 seconds for answer...\n"));
	TRequestStatus keyStat;
	test.Console()->Read(keyStat);
	RTimer timer;
	test(timer.CreateLocal()==KErrNone);
	TRequestStatus timerStat;
	timer.After(timerStat,10*1000000);
	User::WaitForRequest(timerStat,keyStat);
	TInt key = 0;
	if(keyStat!=KRequestPending)
		key = test.Console()->KeyCode();
	timer.Cancel();
	test.Console()->ReadCancel();
	User::WaitForAnyRequest();
	if(key=='y' || key=='Y')
		DoInteractiveTests();
	else
		test.Printf(_L("  Interactive Tests Not Run\n"));

	test.End();
	return(0);
	}
void CTestCalInterimApiSuiteStepBase::WaitForAgendaServerShutdown()
	{
	// the name of the agenda server process includes its uid like this [10003a5b]
	_LIT(KAgendaServerUIDMatch, "*[10003a5b]*");
	TFindProcess findProcess(KAgendaServerUIDMatch);
	
	TFullName fullName;
	
	TInt findProcessResult(KErrNone);
	findProcessResult = findProcess.Next(fullName);
	
	if (findProcessResult == KErrNone)
		{
		// find the latest agenda server process
		while (findProcessResult == KErrNone)
			{
			findProcessResult = findProcess.Next(fullName);
			}
			
		// The agenda server process is running so wait 
		RProcess process;
		if (process.Open(fullName) == KErrNone)
			{
			TRequestStatus processStatus;
			process.Logon(processStatus); // ask for a callback when the process ends
			
			// Don't wait for the server to close for longer than 7 seconds
			RTimer timeOutTimer;
			timeOutTimer.CreateLocal();
			TRequestStatus timeOutStatus;
			timeOutTimer.After(timeOutStatus, 7000000);
			
			// Wait for either the agenda server to close
			// or the time out timer to time out.
			User::WaitForRequest(processStatus, timeOutStatus);
			
			if (timeOutStatus.Int() == KRequestPending)
				{
				timeOutTimer.Cancel();
				User::WaitForRequest(timeOutStatus);
				}
			else
				{
				if (timeOutStatus.Int() == KErrNone)
					{
					// Agenda server shutdown request has timed out
					ERR_PRINTF1(KErrAgendaServerShutdownTimedOut);
					SetTestStepResult(EFail);
					}
				}

			timeOutTimer.Close();		
			process.LogonCancel(processStatus);	
			process.Close();
			}
		}
	}
Example #11
0
void RTimer_timerFunc(void *arg)
{
    RTimer *tm = (RTimer *) arg;

    if( tm->m_state == 0 ) {
        tm->timer_func(tm->m_arg);
        tm->m_count ++;
    }
}
TVerdict CLoopbackTestStep13::doTestStepL()
/**
Test setting read result
*/
	{
	TRequestStatus readStatus;
	TRequestStatus writeStatus;

	TCommConfig commConfigBuf;
	TCommConfigV01& commConfig = commConfigBuf();
	commConfig.iTerminator[0] = '\t';
	commConfig.iTerminator[1] = '\n';
	commConfig.iTerminatorCount = 2;
	
	TInt err = iCommPort1.Open(iCommServer, KPortName1, ECommExclusive, ECommRoleDCE);
	err = iCommPort1.SetConfig(commConfigBuf);
	TestErrorCodeL(err, _L("Failed loading port"));
		
	err = iCommPort2.Open(iCommServer, KPortName2, ECommExclusive, ECommRoleDCE);
	err = iCommPort2.SetConfig(commConfigBuf);
	TestErrorCodeL(err, _L("Failed loading port"));
	
	// make sure Read works
	iCommPort1.Write(writeStatus, KWriteBufNewlineThenTabTerminator);
	User::WaitForRequest(writeStatus);
	TestErrorCodeL(writeStatus.Int(), _L("Write failed"));

	TBuf8<KRegularBufferSize> readBuf2;
	iCommPort2.Read(readStatus, readBuf2);
	User::WaitForRequest(readStatus);
	TestErrorCodeAndDescriptorL(readStatus.Int(), readBuf2, KWriteBufNewlineTerminator, _L("Read from comm port 1"));
	
	iCommPort2.Read(readStatus, readBuf2);
	User::WaitForRequest(readStatus);
	TestErrorCodeAndDescriptorL(readStatus.Int(), readBuf2, KWriteBufTabTerminator, _L("Read from comm port 1"));
	
	TRequestStatus timerStatus;
	TBuf8<2*KWriteBufSegmentSize> readBuf4;
	iCommPort2.Read(readStatus, readBuf4);

	RTimer timer;
	timer.CreateLocal();
	timer.After(timerStatus, 10*KConfiguredPortDelayMicroseconds);

	User::WaitForRequest(readStatus, timerStatus);
	TestBooleanTrueL(timerStatus == KErrNone && readStatus != KErrNone, _L("Check that read didn't complete"));
	
	iCommPort1.Write(writeStatus, KWriteBuf);
	User::WaitForRequest(writeStatus);
	TestErrorCodeL(writeStatus.Int(), _L("Failed write"));

	User::WaitForRequest(readStatus);
	TestErrorCodeAndDescriptorL(readStatus.Int(), readBuf4, KDoubleWriteBuf, _L("Read from comm port 1"));

	return TestStepResult();
	}
Example #13
0
	void CABDataOwnerCallbackImplementation::WaitForMillisecondsL(TInt aMilliseconds)
		{
		RTimer timer;
		TRequestStatus status;
		
		User::LeaveIfError(timer.CreateLocal());
		
		timer.After(status, aMilliseconds);
		User::WaitForRequest(status);
		}
void TestNotify()
//
// Test Notify by launching a simple notifier. Gets closed
// using timer and simulated keypress.
//
	{
	TInt r;
	test.Start(_L("Connect to notifier server"));
	RNotifier n;
	r = n.Connect();
	test(r==KErrNone);
	TInt button=0;
	TRequestStatus status;
	TRequestStatus timerStatus;
	RTimer timer;
	timer.CreateLocal();

	test.Next(_L("Launching simple notifier"));
	_LIT(KLine1,"Line1 - Select Button2");
	_LIT(KLine2,"Line2 - or press enter");
	_LIT(KButton1,"Button1");
	_LIT(KButton2,"Button2");

	n.Notify(KLine1,KLine2,KButton1,KButton2,button,status);
	timer.After(timerStatus,KTimeOut); // launch timer for getting control back after timeout
	User::WaitForRequest(status, timerStatus);
	if (status==KRequestPending)
		{
		test.Printf(_L("Timeout in waiting for keypress, continuing\n"));

		// make the notifier to disappear
		TRawEvent eventDown;
		eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
		TRawEvent eventUp;
		eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
		UserSvr::AddEvent(eventDown);
		UserSvr::AddEvent(eventUp);
		User::WaitForRequest(status); // wait again
		}
	else
		{
		timer.Cancel();
		}
	
	timer.Close();

	test(status.Int()==KErrNone);

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.End();
	}
Example #15
0
void CPjTimerEntry::ConstructL(const pj_time_val *delay) 
{
    rtimer_.CreateLocal();
    CActiveScheduler::Add(this);
    
    pj_int32_t interval = PJ_TIME_VAL_MSEC(*delay) * 1000;
    if (interval < 0) {
    	interval = 0;
    }
    rtimer_.After(iStatus, interval);
    SetActive();
}
TVerdict CLoopbackTestStep11::doTestStepL()
/**
Test setting read result
*/
	{
	TestErrorCodeL( iCommPort1.Open(iCommServer, KPortName1, ECommExclusive, ECommRoleDCE), _L("Opening comm port 1") );
	TestErrorCodeL( iCommPort2.Open(iCommServer, KPortName2, ECommExclusive, ECommRoleDCE), _L("Opening comm port 2") );
	
	TRequestStatus writeStatus1;
	iCommPort1.Write(writeStatus1, KWriteBuf1);
	User::WaitForRequest(writeStatus1);
	TestErrorCodeL(writeStatus1.Int(), _L("Writing to comm port 1"));

	TRequestStatus readStatus;
	TBuf8<KRegularBufferSize> readBuf;
	iCommPort2.ReadOneOrMore(readStatus, readBuf);

	SetReadResult(KPortUnitNum2, KErrNotFound);

	User::WaitForRequest(readStatus);
	
	// Make sure everything still works
	SetReadResult(KPortUnitNum2, KErrNone);
	TestErrorCodeL(readStatus.Int(), KErrNotFound, _L("Check that SetReadResult causes Read to return error"));

	iCommPort1.Write(writeStatus1, KWriteBuf2);
	User::WaitForRequest(writeStatus1);
	TestErrorCodeL(writeStatus1.Int(), _L("Writing to comm port 1"));

	iCommPort2.ReadOneOrMore(readStatus, readBuf);
	User::WaitForRequest(readStatus);
	TestErrorCodeAndDescriptorL(readStatus.Int(), readBuf, KWriteBuf2, _L("Read from comm port 1"));

	// Now test failing a write
	SetWriteResult(KPortUnitNum2, KErrNotFound);
	iCommPort2.Write(writeStatus1, KWriteBuf3);
	User::WaitForRequest(writeStatus1);
	SetWriteResult(KPortUnitNum2, KErrNone);
	TestErrorCodeL(writeStatus1.Int(), KErrNotFound, _L("Check that SetWriteResult causes Write to return error"));

	// Make sure we can't read this
	TRequestStatus timerStatus;
	RTimer timer;
	timer.CreateLocal();
	iCommPort1.ReadOneOrMore(readStatus, readBuf);
	timer.After(timerStatus, 3*KConfiguredPortDelayMicroseconds);
	
	User::WaitForRequest(readStatus, timerStatus);
	TestBooleanTrueL(timerStatus == KErrNone && readStatus != KErrNone, _L("Write that was configured to fail completed successfully"));
	
	return TestStepResult();
	}
Example #17
0
/**
 Test cancelling asynchronous requests. This function cancels a pending 
 asynchronous receive request.
 
 @pre	TestLoadDriver(), channel opened
 */
void TestExDriver::TestCancelRequests()
	{
	TInt r;
	
	// Cancel Asynchronous Receive Request
 	iTest.Printf(_L("Test Cancelling Asynchronous Receive Request\n"));
 	
 	// Create the iTimer that is relative to the thread 
 	r = iTimer.CreateLocal();
 	iTest(r==KErrNone);
 			
	// Create a buffer that has to be filled and returned by the driver	
 	TBuf8<KTestRxSize> rxBuf;
 	
	// Request status object for receive. This object will be used to read the 
 	// status of asynchronous requests after the notification of request completion 
 	//
 	TRequestStatus rxStatus;
 	 	 	 	
 	// Trigger iTimer expiry after KTimeOutTxRx. The status should be pending
	iTimer.After(iTimeStatus,KTimeOutTxRx);
	iTest(iTimeStatus==KRequestPending);
	 	 
 	// Call ldd interface ReceiveData() API to get data to RxBuf
 	r = iLdd.ReceiveData(rxStatus, rxBuf);
 	iTest(r==KErrNone);
 	
 	// Cancel the Receive Request, This invokes a DoCancel()
 	iLdd.CancelReceive();
 	
 	// Wait till the request is complete on rxStatus. User thread is blocked 
 	// with this call, till it is notified about the request completion.
 	// 	
 	User::WaitForRequest(rxStatus,iTimeStatus); 	 	
    
 	// If receive has occured correctly, the iTimeStatus will not be KErrNone,
 	// else no receive complete has occured and iTimer has expired
 	iTest (iTimeStatus!=KErrNone);
 	
 	// rxStatus holds the request completion. TRequestStatus::Int() returns
 	// the completion code. It should be KErrCancel in case of successful
 	// cancellation of request
 	//
 	r=rxStatus.Int();
    iTest(r==KErrCancel);  	
     	
 	// Cancel the iTimer
 	iTimer.Cancel();
 	
    // Close the handle to the iTimer
 	iTimer.Close();
	}
Example #18
0
/**
 Transmits data over the device
 @pre	TestLoadDriver(), channel opened
 */	
void TestExDriver::TestTransmit()
	{
	TInt r;
	
	// Transmit data to the device (uart)
 	iTest.Printf(_L("Test Transmit Asynchronous Request\n"));
		   	 	
 	// Request status object for transmit. This object will be used to read the 
 	// status of asynchronous requests after the notification of request completion 
 	//
 	TRequestStatus txStatus;
 	
 	// Create the iTimer that is relative to the thread 
 	r = iTimer.CreateLocal();
 	iTest(r==KErrNone);
 	 	 	
 	// Trigger iTimer expiry after KTimeOut. The status should be pending
	iTimer.After(iTimeStatus,KTimeOutTxRx);
	iTest(iTimeStatus==KRequestPending);
 	
  	// Call ldd interface TransmitData() API test data descriptor as parameter
 	r = iLdd.TransmitData(txStatus, KTestTxDataMedium);
 	iTest(r==KErrNone);
 	 	
 	// Wait till the request is complete on txStatus or iTimeStatus. User thread is 
 	// blocked with this call, till it is notified about the request completion or 
 	// iTimer expiry
 	//
 	User::WaitForRequest(txStatus, iTimeStatus);
 	
 	// if transmit has occured correctly, the iTimeStatus will not be KErrNone, else
 	// no transmit complete has occured and iTimer has expired
 	iTest (iTimeStatus!=KErrNone);
 	
 	// Cancel the iTimer request
 	iTimer.Cancel();
 	
 	// txStatus holds the request completion. TRequestStatus::Int() returns the
 	// completion code. It will be KErrNone in case of successful completion
 	//
 	r = txStatus.Int();
 	iTest(r==KErrNone);
 	  	
 	// Cancel the iTimer request
 	iTimer.Cancel();
 	
 	// Close the handle to the iTimer
 	iTimer.Close();  		
	}
Example #19
0
/**
 Test access from a different thread
 @pre	TestLoadDriver() called
 */    
void TestExDriver::TestMultipleThreadAccess()
	{
	TInt r;
	RThread thrd;		    
    TRequestStatus tS;
	_LIT(KTestThreadName,"TestThread");
	
	iTest.Printf(_L("Test multiple thread access\n"));
	
	// Create the iTimer that is relative to the thread 
 	r = iTimer.CreateLocal();
 	iTest(r==KErrNone);
 	
 	// Open the channel 	  
	r=iLdd.Open(KUnit1);
	iTest(r==KErrNone);
	  
	// Create a new thread, where we can test access to the driver
    iTest (thrd.Create(KTestThreadName,&ThreadFunc,KDefaultStackSize,NULL,&iLdd)==KErrNone);
    
    // Logon() will request asynchronous notification on thread termination
    thrd.Logon(tS);
    
    // Trigger iTimer expiry after KTimeOut. The status should be pending
	iTimer.After(iTimeStatus,KTimeOut);
	iTest(iTimeStatus==KRequestPending);
	
	// Resume() schedules the thread created
    thrd.Resume();
    
    // Wait for the thread termination notification
    //User::WaitForRequest(tS,iTimeStatus);
    User::WaitForRequest(tS);
    
    // Incase thread is not scheduled and timeout occurs
    if ((iTimeStatus==KErrNone))
    	{
    	iTest.Printf(_L("Timeout for TestThread schedule and exit\n"));
    	}
    
    // Cancel the timer and close	
    iTimer.Cancel();	
    iTimer.Close();
    
    // Close the thread created	
    thrd.Close(); 
    // Close the channel opened   
    iLdd.Close(); 
	}
//             Called by the UI framework when a command has been issued.
//             In this example, a command can originate through a 
//             hot-key press or by selection of a menu item.
//             The command Ids are defined in the .hrh file
//             and are 'connected' to the hot-key and menu item in the
//             resource file.
//             Note that the EEikCmdExit is defined by the UI
//             framework and is pulled in by including eikon.hrh
//
void CExampleAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		      // Just issue simple info messages to show that
		      // the menu items have been selected
	case EExampleItem0:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0);
		break;

	
	case EExampleItem1:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1);
		break;
	
	case EExampleItem2:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2);
		break;
               // Exit the application. The call is
		       // implemented by the UI framework.

	case EEikCmdExit: 
		TInt timerDuration(KDefaultTimeout);
	    CCommandLineArguments* cmdLine = CCommandLineArguments::NewL();
		TInt argTotal=cmdLine->Count();
		for (TInt loop=1 ; loop < argTotal ; ++loop)
			{
			TPtrC arg(cmdLine->Arg(loop));
			if (arg==KSetShutDownTimeOption && loop++ < (argTotal-1))
				{
				TLex timeoutLex(cmdLine->Arg(loop));
				timeoutLex.Val(timerDuration);
				}
			}
		delete cmdLine;
		if(timerDuration > 0)
			{
			RTimer timer;
			TRequestStatus timerStatus;
			timer.CreateLocal();
			timer.After(timerStatus, timerDuration);
			User::WaitForRequest(timerStatus);
			timer.Close();
			}
		Exit();
		break;
		}
	}
static inline TInt PhoneOpen(RMobilePhone& /*aPhone*/, RTelServer& /*aTelServer*/, TDesC& aPhoneName) 
	{
	TInt err = KErrNone;
	if (selectedPhone != -1)
		{
		User::Panic(KDevInfoSupportPanic, KInvalidTestState);
		}
	if (aPhoneName == KPhoneId1)
		{
		selectedPhone = 0;
		}
	else if (aPhoneName == KPhoneId2)
		{
		selectedPhone = 1;
		}
	else if (aPhoneName == KPhoneId3)
		{
		selectedPhone = 2;
		}
	else if (aPhoneName == KPhoneId4)
		{
		selectedPhone = 3;
		}
	else 
		{
		err = KErrArgument;
		}
	timer.CreateLocal();
	return err;
}
static inline void GetPhoneId(RMobilePhone& /*aPhone*/, TRequestStatus& aReqStatus, RMobilePhone::TMobilePhoneIdentityV1& aMobilePhoneId)
	{
	TInt err = KErrNone;
	switch (selectedPhone)
		{
	case 0:
		aMobilePhoneId.iSerialNumber = KDevId1;
		break;
	case 1:
		aMobilePhoneId.iSerialNumber = KDevId2;
		break;
	case 2:
		aMobilePhoneId.iSerialNumber = KDevId3;
		break;
	case 3:
		aMobilePhoneId.iSerialNumber = KDevId4;
		break;
	default:
		err = KErrArgument;
		break;
		}
	if (err == KErrNone)
		{
		// complete the request after a (relatively long) time interval,
		// to make sure that the client waits for the server to start up.
		TTimeIntervalMicroSeconds32 interval = 1000000; // 1 secs
		timer.After(aReqStatus, interval);
		}
	else
		{
		TRequestStatus* status = &aReqStatus;
		User::RequestComplete(status, err);
		}
	}
Example #23
0
void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
	{
	TTime wakeup;
	wakeup.HomeTime();
	wakeup += TTimeIntervalMicroSeconds(aUs);
	aTimer.At(aStatus, wakeup);
	}
Example #24
0
void CPjTimerEntry::ConstructL(const pj_time_val *delay) 
{
    rtimer_.CreateLocal();
    CActiveScheduler::Add(this);
    
    interval_left_ = PJ_TIME_VAL_MSEC(*delay);
    Schedule();
}
static inline void PhoneClose(RMobilePhone& /*aPhone*/)
	{
	if (selectedPhone != -1)
		{
		timer.Close();
		selectedPhone = -1;
		}
	}
Example #26
0
void HXSymbianEventHandler::DoEvents(int timeoutMs)
{
    TInt err = m_timer.CreateLocal();
    
    if( KErrNone == err )
    {
	m_timer.After(iStatus, timeoutMs * 1000);
	SetActive();	

	m_done = false;

	while(!m_done)
	{
	    User::WaitForAnyRequest();
	    TInt aError;
	    CActiveScheduler::RunIfReady(aError, CActive::EPriorityIdle);
	}
    }
}
void CRunProc::RunTestL()
    {
    TTime theTime;
    theTime.UniversalTime();
    TInt64 randSeed(theTime.Int64());
    TInt random(Math::Rand(randSeed) % (1000 * 1000));
    User::After(random);

    RTimer timer;
    timer.CreateLocal();
    TRequestStatus timerStatus = KRequestPending;
    TTimeIntervalMicroSeconds32 timeout(KTimeOut);
    timer.After(timerStatus, timeout);

    TText ch;
    const TUint8 *bitmap = NULL;
    TSize bitmapsize;
    TOpenFontCharMetrics Metrics;    
    do
        {
        TInt hitcount = 0;
        for (ch = 'A'; ch <= 'z'; ch++)
            {
            if(iFont->GetCharacterData(iSessionHandle, (TInt)ch, Metrics,bitmap))
                {
                //RDebug::Print(_L("%c hit bitmap[0]=%x"),ch,bitmap[0]);
                TUint8 testbyte = bitmap[0];
                testbyte += testbyte;
                __ASSERT_ALWAYS((testbyte & 0x01) == 0, User::Panic(KTCacheDeletionProcess, KErrGeneral));
                hitcount++;
                }
            else 
                {
                //RDebug::Print(_L("%c missed"),ch);
                }
            }
        __ASSERT_ALWAYS(hitcount > 0, User::Panic(KTCacheDeletionProcess, KErrNotFound));
        }
    while (timerStatus == KRequestPending);

    timer.Cancel();
    timer.Close();
    }
void Clog_cellidImpl::ConstructL() 
{
	CALLSTACKITEM_N(_CL("Clog_cellidImpl"), _CL("ConstructL"));

	Mlog_base_impl::ConstructL();

	CActiveScheduler::Add(this); // add to scheduler
	iTimeOut=CTimeOut::NewL(*this);
#ifndef __WINS__

#ifdef BASICGSM
	TInt err=Phone().GetCurrentNetworkInfo(async_info);
	TRequestStatus *s=&iStatus;
	User::RequestComplete(s, err);
#endif

#ifdef ETEL3RDPARTY
	Telephony().GetCurrentNetworkInfo(iStatus, async_infop);
	i3rdpartyState=GETTING_INFO;
#endif

#ifdef MOBINFO
	iMobInfo=CMobileNetworkInfo::NewL();
	iInfoState=GETTING_FIRST_MCC;
	iMobInfo->GetCurrentNetwork(iNetworkInfo, iStatus);
	//iMobInfo->GetCellId(async_infop, iStatus);
#endif

	SetActive();

#else
	iOpMap->AddRef();
	timer.CreateLocal();
	//TTimeIntervalMicroSeconds32 w(5*1000*1000);
	TTimeIntervalMicroSeconds32 w(1*1000*1000);
	timer.After(iStatus, w);
	SetActive();
#endif

#ifdef BASICGSM
	//post_new_value(get_value());
#endif
}
Example #29
0
/**
 * Timeout function
 */
void CTestMmfAclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
	{
	TRequestStatus timerStatus;
	RTimer timer ;
	timer.CreateLocal() ;
	timer.After(timerStatus,aNumberOfMicroSeconds);

	User::WaitForRequest(aStatus, timerStatus);
	if (timerStatus == KRequestPending)
		{
		timer.Cancel();
		User::WaitForRequest(timerStatus);
		}
	else
		{
		INFO_PRINTF1(_L("Time is over!!!")) ;
		}
	timer.Close() ;
	}
Example #30
0
/**
Wait for apparc server to complete initial population of its app list. If list 
population doesn't complete within @c KAppArcAppListInitialCompletionTimeout, 
this function will leave with KErrTimedOut.

@panic If Apsexe.exe isn't started.
@leave KErrTimedOut if apparc doesn't complete the initial list population within KAppArcAppListInitialCompletionTimeout.
@leave With system-wide error-codes for generic errors.
*/
void CApaAppStart::WaitForApparcToInitialiseL()
	{
	// Make sure we have a usable session...
	if (iApaLsSession.Handle()==KNullHandle)
		{
		const TInt err = iApaLsSession.Connect(); 
		if(err != KErrNone)
			{
			Panic(EApsexeNotRunning);
			}
		}
	
	//...and a timer
	RTimer timer;
	User::LeaveIfError(timer.CreateLocal());
	CleanupClosePushL(timer); 
	
	// Request apparc to notify us when the initial list population is complete
	TRequestStatus apparcStatus;
	iApaLsSession.RegisterListPopulationCompleteObserver(apparcStatus);

	// Request a timeout.
	TRequestStatus timerStatus;
	timer.After(timerStatus, TTimeIntervalMicroSeconds32(KAppArcAppListInitialCompletionTimeout));
	
	// As soon as either request completes, cancel the other
	User::WaitForRequest(timerStatus, apparcStatus);
	if (timerStatus == KRequestPending)
		{
		timer.Cancel();
		User::WaitForRequest(timerStatus);
		}
	else
		{
		// Timeout
		User::LeaveIfError(iApaLsSession.CancelListPopulationCompleteObserver());
		User::WaitForRequest(apparcStatus);
		User::Leave(KErrTimedOut);
		}
		
	CleanupStack::PopAndDestroy(&timer);
	}