LOCAL_C TInt SendSerialData(RBusDevComm& aSerial,const TDesC8& aData) { TRequestStatus serStat; TRequestStatus timStat; RTimer timer; TInt error=timer.CreateLocal(); if (!error) { timer.After(timStat,KSerialLogTransmitTimeout); aSerial.Write(serStat,aData); User::WaitForRequest(serStat,timStat); if (timStat.Int()==KErrNone) { aSerial.WriteCancel(); error=KErrTimedOut; } else if (serStat.Int()!=KErrNone) { timer.Cancel(); error=serStat.Int(); } else timer.Cancel(); timer.Close(); } return(error); }
// 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 }
/** 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(); }
/** * 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; }
// 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; }
MsgQueueConnection::EReceiveStatus MsgQueueConnection::Receive() { TRequestStatus dataStatus; GetInQueue().NotifyDataAvailable(dataStatus); TRequestStatus timerStatus; RTimer timer; timer.CreateLocal(); timer.After(timerStatus, 1000000); User::WaitForRequest(dataStatus, timerStatus); if (dataStatus == KRequestPending) { GetInQueue().CancelDataAvailable(); User::WaitForRequest(dataStatus); timer.Close(); return RS_TIME_OUT; } else { timer.Cancel(); User::WaitForRequest(timerStatus); timer.Close(); } if (KErrNone == GetInQueue().Receive(*(reinterpret_cast<message_buf*>(&m_cBuffer)))) { return RS_OK; } else return RS_ERROR; }
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(); } } }
void CPjTimerEntry::DoCancel() { /* It's possible that _timer_id is -1, see schedule(). In this case, * the entry has not been added to the timer heap, so don't remove * it. */ if (entry_ && entry_->_timer_id != -1) remove_entry(timer_heap_, this); rtimer_.Cancel(); }
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(); }
/** 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(); }
/** 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(); }
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(); }
/** * 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() ; }
/** 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); }
void Clog_cellidImpl::DoCancel() { CALLSTACKITEM_N(_CL("Clog_cellidImpl"), _CL("DoCancel")); #ifndef __WINS__ # ifdef BASICGSM # ifndef __S60V2__ Phone().NotifyChangeOfCurrentNetworkCancel(); # else // The Cancel hangs on v2 :-( //Phone().NotifyChangeOfCurrentNetworkCancelNS(); TRequestStatus* s=&iStatus; User::RequestComplete(s, KErrCancel); # endif # endif #ifdef ETEL3RDPARTY if (i3rdpartyState==NOTIFYONCHANGE) Telephony().CancelAsync(CTelephony::ECurrentNetworkInfoChangeCancel); else Telephony().CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel); #endif #ifdef MOBINFO switch(iInfoState) { case GETTING_CELL: iMobInfo->CancelCellIdChangeNotification(); break; case GETTING_FIRST_CELL: iMobInfo->CancelGetCellId(); break; case GETTING_FIRST_MCC: case GETTING_NEW_MCC: iMobInfo->CancelGetCurrentNetwork(); break; }; #endif #else timer.Cancel(); #endif }
// Wait for either a hit stroke or timeout. void CConsolePrint::WaitForUserAck() { TRequestStatus timerStatus, consoleStatus; RTimer timer; timer.CreateLocal(); TTimeIntervalMicroSeconds32 interval = KTimeToWait; iConsole->Read(consoleStatus); timer.After(timerStatus, interval); User::WaitForRequest(consoleStatus, timerStatus); if (consoleStatus == KRequestPending) { iConsole->ReadCancel(); } else { timer.Cancel(); User::WaitForRequest(timerStatus); } }
enum TVerdict CTS_Delay::doTestStepL(void) { TInt aDelay = 0; RTimer aTimer; aTimer.CreateLocal(); GetIntFromConfig(KDelay, KDelayInMs, aDelay); TTimeIntervalMicroSeconds32 aInterval = aDelay * 1000; TRequestStatus aStatus; aTimer.After(aStatus, aInterval); User::WaitForRequest(aStatus); aTimer.Cancel(); aTimer.Close(); return EPass; }
LOCAL_C void ReadConsole(CConsoleBase* aConsole) { aConsole->Printf(KTxtPressAnyKey); TRequestStatus keyStatus; // Gets a keystroke from the console window, asynchronously aConsole->Read(keyStatus); RTimer timer; test_KErrNone(timer.CreateLocal()); TRequestStatus timerStatus; timer.After(timerStatus,2*1000000); User::WaitForRequest(timerStatus,keyStatus); if(keyStatus!=KRequestPending) { TKeyCode keyCode = aConsole->KeyCode(); aConsole->Printf(_L("Keycode %d\n"),keyCode); } timer.Cancel(); // Cancels any outstanding request aConsole->ReadCancel(); User::WaitForAnyRequest(); }
void CPhBkAndPacketTestsTestStepBase::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds) /** * Timeout function */ { 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() ; }
/** * Acts exactly like User::WaitForRequest, except aTimeOut is a timeout period * to give up waiting after. * * @return If the request times out, returns KErrTimedOut, otherwise * returns KErrNone and aRequestStatus is completed as usual. * */ TInt CSender::GetRequestOrTimeOut( TRequestStatus& aRequestStatus, TTimeIntervalMicroSeconds32 aTimeOut) { RTimer timer; TRequestStatus timerRequest; timer.CreateLocal(); timer.After(timerRequest, aTimeOut); // Wait for the requestto complete or until we time out User::WaitForRequest(timerRequest, aRequestStatus); // If timer is no longer pending => we have timed out if (timerRequest != KRequestPending) { RDEBUGPRINTLOGGER1(_L("RPS: GetRequestOrTimeOut *** Timed out ***")); return KErrTimedOut; } timer.Cancel(); User::WaitForRequest(timerRequest); return KErrNone; }
TInt GetNumberEntry ( const TInt aMaxDigits, // max numbers of digits const TInt aMin, // min value allowed const TInt aMax, // max value allowed const TInt aInputWait, // (s) how long to wait for each user key entry const TInt aDefaultVal, // default value if timed out const TDesC &aPrompt // string prompt ) /** * This method gets numeric user entry from the console. It checks that the key entered * is between 0 to 9 inclusive. This method exits by user hitting the * Enter key or timing out. * * @param aMaxNumbers integer for max numbers of digits * @param aMin integer for min value allowed * @param aMax integer for max value allowed * @param aInputWait integer for number of seconds to wait for each user key entry * @param aDefaultVal integer for default value if time-out occurs without * @param aPrompt string prompt * @return KErrNone. */ { TInt keyFolded; // actual digit entered, not TKeyCode TRequestStatus stat1,stat2; RTimer timer; TBool bCorrectEntry = EFalse; TInt userNum = -1; TInt limit; TKeyCode key; TTimeIntervalMicroSeconds32 anInterval = aInputWait * 1000000; CConsoleBase *pConsole = test.Console(); timer.CreateLocal(); while (!bCorrectEntry) { userNum = -1; limit = aMaxDigits; key = EKeyNull; INFO_PRINTF1(aPrompt); // print prompt INFO_PRINTF1(_L(" (range %d-%d) or <CR> for default of %d: "), aMin, aMax, aDefaultVal); // exits loop when Enter keyed or limit reached (by decrement to 0) while ((key != EKeyEnter) && limit) { pConsole->Read(stat1); // set read timer.After(stat2, anInterval); // set wait for this period User::WaitForRequest(stat1,stat2); // whatever comes first if(stat1 == KErrNone) // user entered key { timer.Cancel(); User::WaitForRequest(stat2); key = pConsole->KeyCode(); if((key >= '0') && (key <= '9')) { // valid digit keyFolded = (TKeyCode)(key - '0'); // convert to digit INFO_PRINTF1(_L("%d"), keyFolded); // echo limit--; // tracks number of digits // "append" to number if (-1 == userNum) // ie first char entered { userNum = keyFolded; } else // next char entered { userNum = userNum * 10 + keyFolded; // shift } } } else // timer went off, use default unless valid key entered before timer expired { pConsole->ReadCancel(); User::WaitForRequest(stat1); if (-1 == userNum) { // no value entered before timer went off userNum = aDefaultVal; } break; } } // endwhile test.Printf (_L("\n")); if ((userNum >= aMin) && (userNum <= aMax)) { bCorrectEntry = ETrue; // exit loop } else // return to loop { if (userNum == -1) { // <CR> was entered before any numbers, so use default userNum = aDefaultVal; break; } INFO_PRINTF1(_L("Try again, Entry out of limit. Must be between %d and %d inclusive.\n\n"), aMin, aMax); } } // endwhile return (userNum); }
TVerdict CShutdownApp::doTestStepL() { TInt uidValue; _LIT(KUidKey, "uid"); if (!GetHexFromConfig(ConfigSection(), KUidKey, uidValue)) { ERR_PRINTF1(_L("Missing uid")); SetTestStepResult(EFail); return EFail; } TInt connectErr = KErrNotFound; #ifndef SWI_TEXTSHELL_ROM TUid appUid; appUid.iUid = uidValue; TInt wgId=0; RWsSession wsSession; connectErr = wsSession.Connect(); if (connectErr != KErrNotFound) { User::LeaveIfError(connectErr); CleanupClosePushL(wsSession); CApaWindowGroupName* wgName = CApaWindowGroupName::NewL(wsSession); CleanupStack::PushL(wgName); CApaWindowGroupName::FindByAppUid(appUid, wsSession, wgId); if (wgId == KErrNotFound) { ERR_PRINTF2(_L("Running app with UID 0x%x not found."), appUid.iUid); User::Leave(KErrNotFound); } wgName->ConstructFromWgIdL(wgId); if(wgName->RespondsToShutdownEvent()) { TApaTask task(wsSession); task.SetWgId(wgId); RThread thread; TInt err=thread.Open(task.ThreadId()); CleanupClosePushL(thread); if (!err) { RProcess process; thread.Process(process); CleanupClosePushL(process); TRequestStatus processStatus; process.Rendezvous(processStatus); task.SendSystemEvent(EApaSystemEventShutdown); RTimer timer; CleanupClosePushL(timer); TRequestStatus timerStatus; User::LeaveIfError(timer.CreateLocal()); timer.After(timerStatus, KAppShutdownTimeout); User::WaitForRequest(processStatus,timerStatus); if (processStatus==KRequestPending) { // timer completed so give up process.RendezvousCancel(processStatus); User::WaitForRequest(processStatus); ERR_PRINTF2(_L("App with UID 0x%x timed out on shutdown."), appUid.iUid); User::Leave(KErrTimedOut); } else if (timerStatus==KRequestPending) { // Rendezvous completed so cancel timer timer.Cancel(); User::WaitForRequest(timerStatus); } else { // Both have completed, so prevent stray request User::WaitForRequest(processStatus,timerStatus); } CleanupStack::PopAndDestroy(2, &process); INFO_PRINTF2(_L("App with UID 0x%x shut down."), appUid.iUid); SetTestStepResult(EPass); } CleanupStack::PopAndDestroy(&thread); } else { ERR_PRINTF2(_L("App with UID %x does not handle shutdown events."), appUid.iUid); SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(2, &wsSession); } #endif if (connectErr == KErrNotFound) { // emulator tests running in textshell or in textshell ROM (#def SWI_TEXTSHELL_ROM) ERR_PRINTF1(_L("Ignoring shutdown checks in Textshell Rom")); } return TestStepResult(); }
/** @SYMTestCaseID SYSLIB-ECOM-CT-0658 @SYMTestCaseDesc Tests for REComSession::NotifyOnChange() function @SYMTestPriority High @SYMTestActions Tests for changing the implementation dll(timestamp change) and checks for the notify status @SYMTestExpectedResults The test must not fail. @SYMREQ REQ0000 */ void TestNotifyL() { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0658 TestNotifyL ")); // Set up for heap leak checking __UHEAP_MARK; // and leaking thread handles TInt startProcessHandleCount; TInt startThreadHandleCount; TInt endProcessHandleCount; TInt endThreadHandleCount; // Test Starts... RThread thisThread; thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount); //----- REComSession& ecomSession = REComSession::OpenL(); CleanupClosePushL(ecomSession); RTimer timer; CleanupClosePushL(timer); User::LeaveIfError(timer.CreateLocal()); TRequestStatus timerStatus; TRequestStatus notifyStatus; // 1st disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 2nd disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 3rd disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 4th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 5th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 6th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 7th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 8th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 9th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 10th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulateDiskChangeL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); // 11th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulatePluginDeleteBaflL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); //Copy back the deleted plugin for the next test CopyTestPlugin(); // 12th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change, but no regigstry data changed SimulatePluginCopyBaflL(); User::WaitForAnyRequest(); //since the file copied is same as before, no notify will be send TEST(notifyStatus==KRequestPending); TEST(timerStatus==KRequestPending); timer.Cancel(); // 13th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulatePluginDeleteFileManL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); //Copy back the deleted plugin for the next test CopyTestPlugin(); // 14th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulatePluginCopyFileManL(); User::WaitForAnyRequest(); //since the file copied is same as before, no notify will be send TEST(notifyStatus==KRequestPending); TEST(timerStatus==KRequestPending); timer.Cancel(); // 15th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulatePluginDeleteRFsL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); //Copy back the deleted plugin for the next test CopyTestPlugin(); // 16th disk change // Issue the requests timer.After(timerStatus, KWaitDuration); ecomSession.NotifyOnChange(notifyStatus); // simulate a disk change SimulatePluginReplaceRFsL(); User::WaitForAnyRequest(); TEST(notifyStatus==KErrNone); TEST(timerStatus==KRequestPending); timer.Cancel(); //Replace back the deleted plugin. TRAPD(err, EComTestUtils::FileManCopyFileL(KExample5TmpRscOnC, KExample5RscOnC)); TEST2(err, KErrNone); CleanupStack::PopAndDestroy(&timer); CleanupStack::PopAndDestroy(&ecomSession); //----- // Test Ends... REComSession::FinalClose(); // Check for open handles thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount); TEST(startThreadHandleCount == endThreadHandleCount); __UHEAP_MARKEND; }
void CPollTimeoutTimer::DoCancel() { rtimer_.Cancel(); }
TBool CT_LbsMolrResetAssistance::SendResetAssistanceDataL() { // First make sure that no reset of assistance data has been received by the GPS module RProperty resetAssistanceDataReceivedProperty; User::LeaveIfError(resetAssistanceDataReceivedProperty.Attach(KUidSystemCategory, ELbsTestAGpsModuleResetAssistanceDataFlag)); TInt resetReceivedStatus; TInt err = resetAssistanceDataReceivedProperty.Get(resetReceivedStatus); TESTL(err == KErrNone || err == KErrNotFound); if(err == KErrNone) { TESTL(resetReceivedStatus == ELbsTestAGpsResetAssistanceDataNotReceived); } // << ProcessAssistanceData(KPositionAssistanceDataReset) RLbsAssistanceDataBuilderSet assistanceData; CleanupClosePushL(assistanceData); assistanceData.OpenL(); TInt reason = KPositionAssistanceDataReset; INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData(KPositionAssistanceDataReset)")); iProxy->CallL(ENetMsgProcessAssistanceData, &iResetMask, &assistanceData, &reason); CleanupStack::PopAndDestroy(&assistanceData); // Now check the the module receives and verifies the ResetAssistanceData err = resetAssistanceDataReceivedProperty.Get(resetReceivedStatus); TESTL(err == KErrNone || err == KErrNotFound); if(err == KErrNotFound || resetReceivedStatus != ELbsTestAGpsResetAssistanceDataReceived) { RTimer timeout; timeout.CreateLocal(); CleanupClosePushL(timeout); TRequestStatus statTime = KRequestPending, statProp = KRequestPending; timeout.After(statTime, KTimeoutWaitingForResetAssistanceData); resetAssistanceDataReceivedProperty.Subscribe(statProp); User::WaitForRequest(statProp, statTime); if(KRequestPending == statProp.Int()) { resetAssistanceDataReceivedProperty.Cancel(); err = KErrTimedOut; } else { err = KErrNone; timeout.Cancel(); } User::WaitForRequest(statProp, statTime); // Coz the one that didn't signal earlier has // just been completed with KErrCancel, and // we want to avoid the otherwise inevitable // stray signal in any (nested) schedulers. if(err == KErrNone) { err = resetAssistanceDataReceivedProperty.Get(resetReceivedStatus); } CleanupStack::PopAndDestroy(&timeout); TESTL(err == KErrNone && resetReceivedStatus == ELbsTestAGpsResetAssistanceDataReceived); } // Reset the status on the property err = resetAssistanceDataReceivedProperty.Set(ELbsTestAGpsResetAssistanceDataNotReceived); TESTL(err == KErrNone); if((iResetMask & EAssistanceDataReferenceTime) != 0) { return ETrue; } else { return EFalse; } }
/* SearchForEvent Searches for an event returns whether the event has been found */ TVerdict CTestStepActrl::SearchForEvent( TMMFEvent& aEvent ) { 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 ; TInt err = myTimer.CreateLocal(); if (err != KErrNone) { ERR_PRINTF2(_L("CreateLocal failed, error code %d"), err); return EFail; } //[ 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 break out timer to escape ] myTimer.After( timerStatus, KDelay ); //StartTheTimer( 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(); // [ due to problems with rtimer as member variable ] myTimer.Cancel(); //CancelTheTimer(); //[ set status to pass since we have found the event ] result = EPass; break; } else { // [ We rx'd an event other than expected ] // [ due to problems with RTimer as mv] myTimer.Cancel(); //CancelTheTimer(); } } return result; }
void DoCancel() { rtimer_.Cancel(); }
/** @SYMTestCaseID SYSLIB-ECOM-CT-1808 @SYMTestCaseDesc Tests the uninstallation of an active plugin @SYMTestPriority High @SYMTestActions Creates a plugin implementation and then uninstalls the plugin's files from the C: Drive and waits for an ECOM notification completion, upon which it deletes the plugin. @SYMTestExpectedResults The test must not fail. @SYMREQ REQ0000 */ void TestUninstallL() { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1808 TestUninstallL ")); // Set up for heap leak checking and leaking thread handles __UHEAP_MARK; TInt startProcessHandleCount; TInt startThreadHandleCount; TInt endProcessHandleCount; TInt endThreadHandleCount; RThread thisThread; thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount); // Step 1: Setup the session to ECOM TInt err = KErrNone; REComSession& ecomSession = REComSession::OpenL(); CleanupClosePushL(ecomSession); // Step 2: Register for ECOM Server notification. TRequestStatus notifyStatus; ecomSession.NotifyOnChange(notifyStatus); TEST2(notifyStatus.Int(), KRequestPending); // Step 3. Create the plugin implementation we will uninstall TheTest.Printf(_L("CHeapTestInterface::NewL()\n")); CHeapTestInterface* implPtr = 0; TRAP(err, implPtr = CHeapTestInterface::NewL()); TEST2(err, KErrNone); // Step 4. Simulate the uninstall of the plugin files TheTest.Printf(_L("Deleting HTI plugin - attempt 1, wait 5s...\n")); //TRAP(err, EComTestUtils::FileManDeleteFileL(KHTI_PluginInstalledOnC)); TRAP(err, EComTestUtils::RLoaderDeleteFileL(KHTI_PluginInstalledOnC)); #if defined(__WINS__) || defined (__WINSCW__) TEST2(err, KErrAccessDenied); // DLL File locked under Windows emulator due to it being demand paged TheTest.Printf(_L("Error -21 (KErrAccessDenied) expected due to Windows keeping the DLL mapped in the emulator process adress space due to Windows demand paging/virtual memory system\n")); #elif defined(__EPOC32__) TEST2(err, KErrNone); // DLL File not locked on target hardware under SOS //#else Do no test at all as its an unexpected platform. #endif TRAP(err, EComTestUtils::FileManDeleteFileL(KHTIr_PluginInstalledOnC)); TEST2(err, KErrNone); // Step 5. Wait for ECOM Server notification to arrive, with precautionary hang timer. RTimer timer; CleanupClosePushL(timer); User::LeaveIfError(timer.CreateLocal()); TRequestStatus timerStatus; timer.After(timerStatus, KWaitDuration); TEST2(timerStatus.Int(), KRequestPending); TheTest.Printf(_L("Before calling WaitForAnyRequest(): Timer Status: %d; ECOM Notif Status: %d\n"), timerStatus.Int(), notifyStatus.Int()); TheTest.Printf(_L("Checking notification recieved for ECOM Server...\n")); User::WaitForRequest(timerStatus, notifyStatus); TEST2(timerStatus.Int(), KRequestPending); TEST2(notifyStatus.Int(), KErrNone); timer.Cancel(); // Step 6. Destroy the plugin TheTest.Printf(_L("DELETE implPtr\n")); delete implPtr; //CleanupStack::PopAndDestroy(&timer); TheTest.Printf(_L("Test over, cleanup...\n")); CleanupStack::PopAndDestroy(&timer); CleanupStack::PopAndDestroy(&ecomSession); REComSession::FinalClose(); // Check for open handles thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount); TEST(startThreadHandleCount == endThreadHandleCount); // Test Ends... __UHEAP_MARKEND; }