void CPlPerformanceAPI::CreateContactsBatchL(TInt aSize) { test.Next(_L("->... Create")); RDebug::Print(_L("CreateContactsTestL(TInt aSize)")); TBool testFlag = EFalse; testFlag = iCntTestImpl.DefaultContactDatabaseExistsL(); test.Printf(_L("CreateContactsBatchL_1, DefaultContactDatabaseExistsL:%d \n"),testFlag); TTime startTime; startTime.UniversalTime(); for (int ii = 0; ii < aSize; ii+=nsPlPerformance::KBatchSize) { CreateContactsTestL(aSize<nsPlPerformance::KBatchSize ? aSize:nsPlPerformance::KBatchSize); if (ii >= nsPlPerformance::KBatchSize - 1) { iCntTestImpl.CompactL(); } } TTime finishTime; finishTime.UniversalTime(); // Temporary required for ARMv5, adress of Int64() is taken in // parameter to Format method otherwise. TReal lapsed = (TReal) finishTime.MicroSecondsFrom(startTime).Int64(); TBuf8<64> row; // _LIT8 gives an error - illegal implicit conversion from long row.Format(_L8("Create,%d,%.4f\r\n"), aSize, lapsed/1000000); iCsvWriter->WriteNextLineL(row); // API Tests testFlag = iCntTestImpl.CompressRequired(); test.Printf(_L("CreateContactsBatchL, CompressRequired:%d \n"),testFlag); testFlag = iCntTestImpl.IsDamaged(); test.Printf(_L("CreateContactsBatchL, IsDamaged:%d \n"),testFlag); testFlag = iCntTestImpl.DefaultContactDatabaseExistsL(); test.Printf(_L("CreateContactsBatchL, DefaultContactDatabaseExistsL:%d \n"),testFlag); testFlag = iCntTestImpl.ContactDatabaseExistsL(KTestContactFileName); test.Printf(_L("CreateContactsBatchL, ContactDatabaseExistsL:%d \n"),testFlag); TInt theCount; theCount = iCntTestImpl.FileSize(); test.Printf(_L("CreateContactsBatchL, FileSize:%d \n"),theCount); theCount = iCntTestImpl.WastedSpaceInBytes(); test.Printf(_L("CreateContactsBatchL, WastedSpaceInBytes:%d \n"),theCount); TBuf<190> defaultName; iCntTestImpl.GetDefaultNameL(defaultName); test.Printf(_L("CreateContactsBatchL, GetDefaultNameL: %s \n"),defaultName.PtrZ()); defaultName.Delete(0,defaultName.Size()); TDriveUnit driveUnit; iCntTestImpl.DatabaseDrive(driveUnit); TBuf<190> driveName = driveUnit.Name(); test.Printf(_L("CreateContactsBatchL, DatabaseDrive: %s \n"),driveName.PtrZ()); }
void eap_am_type_securid_symbian_c::store_authentication_timeL() { EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL("eap_am_type_securid_symbian_c::store_authentication_timeL: EAP-tunneling type=0xfe%06x%08x\n"), m_tunneling_type.get_vendor_id(), m_tunneling_type.get_vendor_type())); HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); // Query all the relevant parameters _LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); if (m_eap_type == eap_type_generic_token_card) { sqlStatement.Format( KSQLQuery, &KGTCLastFullAuthTime, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } else { // Secure ID is not supported at the moment. // Leave with error. CleanupStack::PopAndDestroy(buf); // Delete buf. User::Leave(KErrNotSupported); } RDbView view; // Evaluate view User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); // Get the first (and only) row for updation. view.FirstL(); view.UpdateL(); // Get column set so we get the correct column numbers CDbColSet* colSet = view.ColSetL(); CleanupStack::PushL(colSet); // Get the current universal time. TTime currentTime; currentTime.UniversalTime(); #if defined(_DEBUG) || defined(DEBUG) TDateTime currentDateTime = currentTime.DateTime(); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(), currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); #endif TInt64 fullAuthTime = currentTime.Int64(); view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), fullAuthTime); view.PutL(); CleanupStack::PopAndDestroy(colSet); // Delete colSet. CleanupStack::PopAndDestroy(&view); // Close view. CleanupStack::PopAndDestroy(buf); // Delete buf. EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); }
EXPORT_C void CHuiFxEffect::AdvanceTime(TReal32 aElapsedTime) { #ifdef HUIFX_TRACE RDebug::Printf("CHuiFxEffect::AdvanceTime 0x%x, aElapsed time: %f, Total elapsed time: %f, Frames drawn: %d, iFlags: 0x%x, iGroup %d, iHandle: %d", this, aElapsedTime, iElapsedTime, iFramesDrawn, iFlags, iGroupId, iHandle); #endif // KHuiFxDelayRunUntilFirstFrameHasBeenDrawn flag is for giving effect chance to run // its whole timeline by starting the time only when first frame has been drawn. if (iFlags & KHuiFxDelayRunUntilFirstFrameHasBeenDrawn) { // Sometimes the effect does not get any frames. Force the time to start, because // otherwise will jam itself and possible the group, where the effect is. if (iElapsedTime > 0.2 && iFramesDrawn == 0) { iFramesDrawn = 1; #ifdef HUIFX_TRACE RDebug::Printf("CHuiFxEffect::AdvanceTime - Not drawn, but cannot wait. release 0x%x in time %f", this, iElapsedTime); #endif } if (iFramesDrawn) { if (iFlags & KHuiFxReadyAndWaitingGroupToStartSyncronized) { // this has drawn atleast once, but all the effect in this group have not drawn. Must hang on little more. return; } if (iFlags & KHuiFxWaitGroupToStartSyncronized) { // Group has been started, waiting the others in the group to be drawn ClearEffectFlag(KHuiFxWaitGroupToStartSyncronized); SetEffectFlag(KHuiFxReadyAndWaitingGroupToStartSyncronized); // NotifyEffectReady will clear KHuiFxReadyAndWaitingGroupToStartSyncronized flag // if all items in the group are ready. iEngine->NotifyEffectReady(iGroupId); SetEffectFlag(KHuiReadyToDrawNotified); return; } if (iFramesDrawn == 1) { #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF // This is about the time when first frame from the effect is on screen TTime endTime; endTime.UniversalTime(); AMT_ADD_TIME(iHandle, endTime.Int64(), ETrue); #endif aElapsedTime = 0; iFramesDrawn++; } iRoot->AdvanceTime(aElapsedTime); } } else { #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF if (iFramesDrawn == 1) { // This is about the time when first frame from the effect is on screen TTime endTime; endTime.UniversalTime(); AMT_ADD_TIME(iHandle, endTime.Int64(), ETrue); } #endif iRoot->AdvanceTime(aElapsedTime); } iElapsedTime += aElapsedTime; }
EXPORT_C void CEventLogger::LogDataAddEvent(TInt aRConnectionStatusId, const TDesC& aRemote, TInt aLogDir, const TDesC& aTelNum, TUid aDataEventType) { LOGSTRING2("GenConn:\tCEventLogger LogDataAddEvent aRConnectionStatusId:%d", aRConnectionStatusId); //It is possible to add a new logevent with a new log id for the same connection (reconnect case) // assuming that all the next updates will be for the new event and not the old one. // [NeilMa 140403]: This method cannot leave and has no return value, but // performs memory allocations if the event cannot be logged immediately. // Therefore, if the memory alloc fails for any reason, the event is // currently discarded with no record. This method should be replaced by // one which can Leave or returns an error code. See Typhoon DEF022946. TTime time; time.UniversalTime(); if (!IsActive() && (iLogEventQueue->Count() ==0)) { iCurrentLogEvent->SetId(KGenconnLogWaitingForLogId); iCurrentLogEvent->SetTime(time); TBuf<KLogMaxStatusLength > logStatusBuf; iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok iCurrentLogEvent->SetStatus(logStatusBuf); iCurrentLogEvent->SetRemoteParty(aRemote); TBuf<KLogMaxDirectionLength> logDirBuf; iLogWrap->Log().GetString(logDirBuf, aLogDir); // Ignore error - string blank on error which is ok iCurrentLogEvent->SetDirection(logDirBuf); iCurrentLogEvent->SetNumber(aTelNum); iCurrentLogEvent->SetEventType(aDataEventType); iCurrentLogEvent->SetDurationType(KLogDurationValid); iStatus=KRequestPending; iLogWrap->Log().AddEvent(*iCurrentLogEvent, iStatus); SetActive(); } else { // add the request to the queue, it will be processed asap CLogEvent* eventUpdate = 0; TRAPD(error, eventUpdate = CLogEvent::NewL()); if (KErrNone != error) { return; // event is discarded! } eventUpdate->SetId(KGenconnLogWaitingForLogId); eventUpdate->SetTime(time); TBuf<KLogMaxStatusLength > logStatusBuf; iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok eventUpdate->SetStatus(logStatusBuf); eventUpdate->SetRemoteParty(aRemote); TBuf<KLogMaxDirectionLength> logDirBuf; iLogWrap->Log().GetString(logDirBuf, aLogDir); // Ignore error - string blank on error which is ok eventUpdate->SetDirection(logDirBuf); eventUpdate->SetNumber(aTelNum); eventUpdate->SetEventType(aDataEventType); eventUpdate->SetDurationType(KLogDurationValid); // add to the queue TRAP(error, iLogEventQueue->AppendL(eventUpdate)); if (KErrNone != error) { delete eventUpdate; // event is discarded! return; } } }
// --------------------------------------------------------- // CT_LbsClientPosTp178::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp178::StartL() { _LIT(KServiceAccept, "SAAA"); SetupPsyL(iUidTestPsy3); RPositioner positioner; TPositionInfo info = TPositionInfo(); ConnectL(); User::LeaveIfError(positioner.Open(iPosServer,iUidTestPsy3)); CleanupClosePushL(positioner); TInt Err = positioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, KServiceAccept); TPositionUpdateOptions updateOptionsLong, updateOptionsShort; TTimeIntervalMicroSeconds longInterval(7000000); updateOptionsLong.SetUpdateTimeOut(longInterval); Err = positioner.SetUpdateOptions(updateOptionsLong); TTimeIntervalMicroSeconds shortInterval(2000000); updateOptionsShort.SetUpdateTimeOut(shortInterval); TPositionUpdateOptions theUpdateOptions; Err = positioner.GetUpdateOptions(theUpdateOptions); if (theUpdateOptions.UpdateTimeOut() != updateOptionsLong.UpdateTimeOut() || updateOptionsLong.UpdateTimeOut() != longInterval) { _LIT(KUpdateOptions, "The update option was not set correctly"); LogErrorAndLeaveL(KUpdateOptions); } _LIT(KDelayMsg, "The successfull requests was completed within %d microsecs."); _LIT(KCancelMsg, "The canceled requests was completed within %d microsecs."); TRequestStatus status; for (TInt i = 0; i < 10; i++) // makes 10 test inorder to get some statistic { positioner.SetUpdateOptions(updateOptionsLong); TTime requestStartTime; requestStartTime.UniversalTime(); positioner.NotifyPositionUpdate(info, status); User::WaitForRequest(status); TTime requestStopTime; requestStopTime.UniversalTime(); TTimeIntervalMicroSeconds durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); TInt duration = durationMicro.Int64(); TBuf<100> timeMsg; timeMsg.Format(KDelayMsg, duration); INFO_PRINTF1(timeMsg); //check error status if (status != KErrNone) { _LIT(KErrPositionRequest, "error code returned from NotifyPositionUpdate, error code = %d"); TBuf<100> buf; buf.Format(KErrPositionRequest, status.Int()); LogErrorAndLeaveL(buf); } TTimeIntervalMicroSeconds shortInterval(2000000); updateOptionsShort.SetUpdateTimeOut(shortInterval); positioner.SetUpdateOptions(updateOptionsShort); requestStartTime.UniversalTime(); positioner.NotifyPositionUpdate(info, status); User::WaitForRequest(status); requestStopTime.UniversalTime(); durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); duration = durationMicro.Int64(); #ifdef __WINS__ TTimeIntervalMicroSeconds winsFail(100000); durationMicro = TTimeIntervalMicroSeconds(durationMicro.Int64()+winsFail.Int64()); #endif timeMsg.Format(KCancelMsg, duration); INFO_PRINTF1(timeMsg); if (status != KErrTimedOut) { _LIT(KErrPositionRequest, "Request did not returned KErrTimedOut, status code = %d."); TBuf<100> buf; buf.Format(KErrPositionRequest, status.Int()); LogErrorAndLeaveL(buf); } //Check that the request was not aborted before the Interval //Remove this condition if a lot of data is needed in test log. if (durationMicro < shortInterval) { _LIT(KErrInterval, " The request was aborted before the set timed out "); LogErrorAndLeaveL(KErrInterval); } } // end for loop CleanupStack::PopAndDestroy(1); //positioner Disconnect(); // Do timeout test TestTimeoutL(); // Do cancel test TestCancelL(); // ESLI-5QRA7U just check that it is not possible to set a timeout that is less than // the update interval TestOptionL(); }
static void GenerateTestRecIds() { TTime now; now.UniversalTime(); TInt64 seed = now.Int64(); TInt i; //Update multi for(i=0;i<KUpdateRecCnt;) { TInt id = Math::Rand(seed) % KInsertRecCnt; if(id > 0 && !IdIn(id, TheUpdateRecIds, i)) { TheUpdateRecIds[i++] = id; } } //Delete multi for(i=0;i<KDeleteRecCnt;) { TInt id = Math::Rand(seed) % KInsertRecCnt; if(id > 0 && !IdIn(id, TheDeleteRecIds, i) && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt)) { TheDeleteRecIds[i++] = id; } } //Select multi for(i=0;i<KSelectRecCnt;) { TInt id = Math::Rand(seed) % KInsertRecCnt; if(id > 0 && !IdIn(id, TheSelectRecIds, i) && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) && !IdIn(id, TheDeleteRecIds, KDeleteRecCnt)) { TheSelectRecIds[i++] = id; } } //Insert one TheInsertRecId = KInsertRecCnt + 1; //Update one for(;;) { TInt id = Math::Rand(seed) % KInsertRecCnt; if(id > 0 && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) && !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) && !IdIn(id, TheSelectRecIds, KSelectRecCnt)) { TheUpdateRecId = id; break; } } //Delete one for(;;) { TInt id = Math::Rand(seed) % KInsertRecCnt; if(id > 0 && id != TheUpdateRecId && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) && !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) && !IdIn(id, TheSelectRecIds, KSelectRecCnt)) { TheDeleteRecId = id; break; } } //Select one for(;;) { TInt id = Math::Rand(seed) % KInsertRecCnt; if(id > 0 && id != TheUpdateRecId && id != TheDeleteRecId && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) && !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) && !IdIn(id, TheSelectRecIds, KSelectRecCnt)) { TheSelectRecId = id; break; } } }
//-------------------------------------------------------------------- //-------------------------------------------------------------------- // void CPosLmNameIndex::SaveL( TChar aDrive ) { RDbTable table; TInt err = table.Open( iDatabase, KPosLmIndexTable, RDbRowSet::EUpdatable ); if ( err == KErrNotFound ) { PosLmDatabaseManager::CreateIndexTableL( iDatabase ); err = table.Open( iDatabase, KPosLmIndexTable, RDbRowSet::EUpdatable ); } User::LeaveIfError( err ); CleanupClosePushL( table ); TInt currentSize = 0; table.FirstL(); if ( table.AtEnd() ) { table.InsertL(); } else { table.GetL(); currentSize = table.ColSize( EPosLmIncIndexDataCol ); table.UpdateL(); } if ( currentSize < DataSize() ) { // check disk size CPosLmDiskUtilities* diskUtilities = CPosLmDiskUtilities::NewL(); CleanupStack::PushL( diskUtilities ); TInt bytesToWrite = DataSize() - currentSize; diskUtilities->DiskSpaceBelowCriticalLevelL( bytesToWrite, aDrive ); CleanupStack::PopAndDestroy( diskUtilities ); } // current language table.SetColL( EPosLmIncLanguageCol, User::Language() ); // index data RDbColWriteStream writeStream; writeStream.OpenL( table, EPosLmIncIndexDataCol ); CleanupClosePushL( writeStream ); ExternalizeL( writeStream ); CleanupStack::PopAndDestroy( &writeStream ); // index timestamp TTime now; now.UniversalTime(); table.SetColL( EPosLmIncTimestampCol, now ); #ifdef _DEBUG TBuf<64> mtime; now.FormatL( mtime, KPosLmTimeFormat ); LOG1( "NameIndex: Saving index timestamp %S", &mtime); #endif table.PutL(); CleanupStack::PopAndDestroy ( &table ); iTimeStamp = now; }
/** @SYMTestCaseID SYSLIB-LOGENG-CT-1008 @SYMTestCaseDesc Tests for writing different events to a store @SYMTestPriority High @SYMTestActions Calls up TestStoreL() function @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void TestEventL() { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1008 ")); CLogEvent* event1 = CLogEvent::NewL(); CleanupStack::PushL(event1); // Event Id TEST(event1->Id() == KLogNullId); TestStoreL(*event1); event1->SetId(0x12345678); TEST(event1->Id() == 0x12345678); TestStoreL(*event1); event1->SetId(KMaxTInt32); TEST(event1->Id() == KMaxTInt32); TestStoreL(*event1); event1->SetId(0); TEST(event1->Id() == 0); TestStoreL(*event1); // Event type event1->SetEventType(TUid::Null()); TestStoreL(*event1); event1->SetEventType(TUid::Uid(0x12345678)); TEST(event1->EventType() == TUid::Uid(0x12345678)); TestStoreL(*event1); event1->SetEventType(TUid::Uid(KMaxTInt32)); TEST(event1->EventType() == TUid::Uid(KMaxTInt32)); TestStoreL(*event1); event1->SetEventType(TUid::Null()); TEST(event1->EventType() == TUid::Null()); TestStoreL(*event1); // Remote Party TEST(event1->RemoteParty() == KNullDesC); TestStoreL(*event1); HBufC* buf = TestUtils::CreateBufLC(KLogMaxRemotePartyLength / 2); event1->SetRemoteParty(buf->Des()); TEST(event1->RemoteParty() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxRemotePartyLength); event1->SetRemoteParty(buf->Des()); TEST(event1->RemoteParty() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxRemotePartyLength * 2); event1->SetRemoteParty(buf->Des()); TEST(event1->RemoteParty() == buf->Des().Left(KLogMaxRemotePartyLength)); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); event1->SetRemoteParty(KNullDesC); TEST(event1->RemoteParty() == KNullDesC); TestStoreL(*event1); // Direction TEST(event1->Direction() == KNullDesC); TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxDirectionLength / 2); event1->SetDirection(buf->Des()); TEST(event1->Direction() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxDirectionLength); event1->SetDirection(buf->Des()); TEST(event1->Direction() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxDirectionLength * 2); event1->SetDirection(buf->Des()); TEST(event1->Direction() == buf->Des().Left(KLogMaxDirectionLength)); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); event1->SetDirection(KNullDesC); TEST(event1->Direction() == KNullDesC); TestStoreL(*event1); // Time TTime time; time.UniversalTime(); event1->SetTime(time); TEST(event1->Time() == time); TestStoreL(*event1); time.HomeTime(); event1->SetTime(time); TEST(event1->Time() == time); TestStoreL(*event1); // Duration Type TEST(event1->DurationType() == KLogNullDurationType); event1->SetDurationType(0xf); TEST(event1->DurationType() == 0xf); TestStoreL(*event1); event1->SetDurationType(KMaxTInt8); TEST(event1->DurationType() == KMaxTInt8); TestStoreL(*event1); event1->SetDurationType(KLogNullDurationType); TEST(event1->DurationType() == KLogNullDurationType); TestStoreL(*event1); // Duration TEST(event1->Duration() == KLogNullDuration); event1->SetDuration(0x12345678); TEST(event1->Duration() == 0x12345678); TestStoreL(*event1); event1->SetDuration(KMaxTUint32); TEST(event1->Duration() == KMaxTUint32); TestStoreL(*event1); event1->SetDuration(KLogNullDuration); TEST(event1->Duration() == KLogNullDuration); TestStoreL(*event1); // Status TEST(event1->Status() == KNullDesC); buf = TestUtils::CreateBufLC(KLogMaxStatusLength / 2); event1->SetStatus(buf->Des()); TEST(event1->Status() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxStatusLength); event1->SetStatus(buf->Des()); TEST(event1->Status() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxStatusLength * 2); event1->SetStatus(buf->Des()); TEST(event1->Status() == buf->Des().Left(KLogMaxStatusLength)); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); event1->SetStatus(KNullDesC); TEST(event1->Status() == KNullDesC); TestStoreL(*event1); // Subject TEST(event1->Subject() == KNullDesC); buf = TestUtils::CreateBufLC(KLogMaxSubjectLength / 2); event1->SetSubject(buf->Des()); TEST(event1->Subject() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxSubjectLength); event1->SetSubject(buf->Des()); TEST(event1->Subject() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxSubjectLength * 2); event1->SetSubject(buf->Des()); TEST(event1->Subject() == buf->Des().Left(KLogMaxSubjectLength)); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); event1->SetSubject(KNullDesC); TEST(event1->Subject() == KNullDesC); TestStoreL(*event1); // Number TEST(event1->Number() == KNullDesC); buf = TestUtils::CreateBufLC(KLogMaxNumberLength / 2); event1->SetNumber(buf->Des()); TEST(event1->Number() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxNumberLength); event1->SetNumber(buf->Des()); TEST(event1->Number() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxNumberLength * 2); event1->SetNumber(buf->Des()); TEST(event1->Number() == buf->Des().Left(KLogMaxNumberLength)); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); event1->SetNumber(KNullDesC); TEST(event1->Number() == KNullDesC); TestStoreL(*event1); // Contact TEST(event1->Contact() == KLogNullContactId); event1->SetContact(0x12345678); TEST(event1->Contact() == 0x12345678); TestStoreL(*event1); event1->SetContact(KMaxTInt32); TEST(event1->Contact() == KMaxTInt32); TestStoreL(*event1); event1->SetContact(KLogNullContactId); TEST(event1->Contact() == KLogNullContactId); TestStoreL(*event1); event1->SetContact(KMinTInt32); TEST(event1->Contact() == KMinTInt32); TestStoreL(*event1); // Link TEST(event1->Link() == KLogNullLink); event1->SetLink(0x12345678); TEST(event1->Link() == 0x12345678); TestStoreL(*event1); event1->SetLink(KMaxTUint32); TEST(event1->Link() == KMaxTUint32); TestStoreL(*event1); event1->SetLink(KLogNullLink); TEST(event1->Link() == KLogNullLink); // Description TEST(event1->Description() == KNullDesC); buf = TestUtils::CreateBufLC(KLogMaxDescriptionLength / 2); event1->SetDescription(buf->Des()); TEST(event1->Description() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxDescriptionLength); event1->SetDescription(buf->Des()); TEST(event1->Description() == buf->Des()); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); buf = TestUtils::CreateBufLC(KLogMaxDescriptionLength * 2); event1->SetDescription(buf->Des()); TEST(event1->Description() == buf->Des().Left(KLogMaxDescriptionLength)); CleanupStack::PopAndDestroy(); // buf TestStoreL(*event1); event1->SetDescription(KNullDesC); TEST(event1->Description() == KNullDesC); // Flags TEST(event1->Flags() == KLogNullFlags); event1->SetFlags(1); TEST(event1->Flags() == 1); TestStoreL(*event1); event1->SetFlags(2); TEST(event1->Flags() == 3); event1->SetFlags(4); TEST(event1->Flags() == 7); event1->SetFlags(8); TEST(event1->Flags() == KLogFlagsMask); event1->ClearFlags(8); TEST(event1->Flags() == 7); event1->ClearFlags(4); TEST(event1->Flags() == 3); event1->ClearFlags(2); TEST(event1->Flags() == 1); event1->ClearFlags(1); TEST(event1->Flags() == KLogNullFlags); event1->SetFlags(1); TEST(event1->Flags() == 1); event1->SetFlags(3); TEST(event1->Flags() == 3); event1->SetFlags(7); TEST(event1->Flags() == 7); event1->SetFlags(15); event1->SetFlags(KLogFlagsMask); TEST(event1->Flags() == KLogFlagsMask); event1->ClearFlags(KLogFlagsMask); TEST(event1->Flags() == KLogNullFlags); event1->SetFlags(0x5); TEST(event1->Flags() == 0x5); event1->SetFlags(0xA); TEST(event1->Flags() == KLogFlagsMask); event1->ClearFlags(0x5); TEST(event1->Flags() == 0xA); event1->ClearFlags(0xA); TEST(event1->Flags() == KLogNullFlags); // Data TEST(event1->Data() == KNullDesC8); HBufC8* buf8; buf8 = TestUtils::CreateBuf8LC(100); event1->SetDataL(buf8->Des()); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); TestStoreL(*event1); buf8 = TestUtils::CreateBuf8LC(200); event1->SetDataL(buf8->Des()); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); TestStoreL(*event1); buf8 = TestUtils::CreateBuf8LC(400); event1->SetDataL(buf8->Des()); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); TestStoreL(*event1); event1->SetDataL(KNullDesC8); TEST(event1->Data() == KNullDesC8); // streaming TFileName storename = _L("c:\\T_LOGEVENT_DATA"); TUid uid={0x12345678}; // create a store theFs.Delete(storename); CDictionaryFileStore* store = CDictionaryFileStore::OpenLC(theFs, storename, uid); RDictionaryWriteStream write; RDictionaryReadStream read; event1->SetDataL(KNullDesC8); uid.iUid++; write.AssignL(*store, uid); write << event1->Data(); write.CommitL(); write.Close(); read.OpenL(*store, uid); event1->SetDataL(read, 0); read.Close(); TEST(event1->Data() == KNullDesC8); buf8 = TestUtils::CreateBuf8LC(100); event1->SetDataL(buf8->Des()); uid.iUid++; write.AssignL(*store, uid); write.WriteL(event1->Data()); write.CommitL(); write.Close(); read.OpenL(*store, uid); event1->SetDataL(read, 100); read.Close(); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); // buf8 buf8 = TestUtils::CreateBuf8LC(200); event1->SetDataL(buf8->Des()); uid.iUid++; write.AssignL(*store, uid); write.WriteL(event1->Data()); write.CommitL(); write.Close(); read.OpenL(*store, uid); event1->SetDataL(read, 200); read.Close(); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); // buf8 buf8 = TestUtils::CreateBuf8LC(400); event1->SetDataL(buf8->Des()); uid.iUid++; write.AssignL(*store, uid); write.WriteL(event1->Data()); write.CommitL(); write.Close(); read.OpenL(*store, uid); event1->SetDataL(read, 400); read.Close(); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(2); // buf8, store // Copying event1->SetId(0x12345678); event1->SetEventType(TUid::Uid(0x12345678)); buf = TestUtils::CreateBufLC(KLogMaxRemotePartyLength / 2); event1->SetRemoteParty(buf->Des()); TEST(event1->RemoteParty() == buf->Des()); CleanupStack::PopAndDestroy(); // buf buf = TestUtils::CreateBufLC(KLogMaxDirectionLength / 2); event1->SetDirection(buf->Des()); TEST(event1->Direction() == buf->Des()); CleanupStack::PopAndDestroy(); // buf event1->SetDurationType(0xf); TEST(event1->DurationType() == 0xf); event1->SetDuration(0x12345678); TEST(event1->Duration() == 0x12345678); buf = TestUtils::CreateBufLC(KLogMaxStatusLength / 2); event1->SetStatus(buf->Des()); TEST(event1->Status() == buf->Des()); CleanupStack::PopAndDestroy(); // buf buf = TestUtils::CreateBufLC(KLogMaxSubjectLength / 2); event1->SetSubject(buf->Des()); TEST(event1->Subject() == buf->Des()); CleanupStack::PopAndDestroy(); // buf buf = TestUtils::CreateBufLC(KLogMaxNumberLength / 2); event1->SetNumber(buf->Des()); TEST(event1->Number() == buf->Des()); CleanupStack::PopAndDestroy(); // buf event1->SetContact(0x12345678); TEST(event1->Contact() == 0x12345678); event1->SetLink(0x12345678); TEST(event1->Link() == 0x12345678); buf = TestUtils::CreateBufLC(KLogMaxDescriptionLength / 2); event1->SetDescription(buf->Des()); TEST(event1->Description() == buf->Des()); CleanupStack::PopAndDestroy(); // buf buf8 = TestUtils::CreateBuf8LC(200); event1->SetDataL(buf8->Des()); TEST(event1->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); CLogEvent* event2 = CLogEvent::NewL(); CleanupStack::PushL(event2); TEST(!TestUtils::EventsEqual(*event1, *event2)); event2->CopyL(*event1); TEST(TestUtils::EventsEqual(*event1, *event2)); CleanupStack::PopAndDestroy(); // event2; event2 = CLogEvent::NewL(); CleanupStack::PushL(event2); TEST(!TestUtils::EventsEqual(*event1, *event2)); event1->CopyL(*event2); TEST(TestUtils::EventsEqual(*event1, *event2)); CleanupStack::PopAndDestroy(2); // event1, event2; ::DeleteDataFile(storename); }
TVerdict ClbsinternalapiTest7Step::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { if (TestStepResult()==EPass) { // // Test the GPS Measurement Updates interface // RLbsGpsMeasurementUpdates::InitializeL(); RLbsGpsMeasurementUpdates gpsMeasurements; gpsMeasurements.OpenL(); CleanupClosePushL(gpsMeasurements); // Generate some GPS measurement data TPositionGpsMeasurementData gpsData; gpsData.SetSatelliteId(3); gpsData.SetCarrierNoiseRatio(0x14); gpsData.SetDoppler(0x09); gpsData.SetWholeGpsChips(0x124); gpsData.SetFractionalGpsChips(0x03); gpsData.SetMultiPathIndicator(TPositionGpsMeasurementData::EMultiPathHigh); gpsData.SetPseudoRangeRmsError(1); TPositionGpsMeasurementInfo gpsInfo; gpsInfo.SetGpsTimeOfWeek(3); gpsInfo.SetPositionMode(TPositionModuleInfo::ETechnologyTerminal); gpsInfo.SetPositionModeReason(KErrNone); gpsInfo.SetUpdateType(EPositionUpdateGeneral); gpsInfo.SetModuleId(TUid::Uid(0x10281D6A)); gpsInfo.AppendMeasurementData(gpsData); TESTL(gpsInfo.NumMeasurements() == 1); // // Test setting measurement data // TTime timeNow; timeNow.UniversalTime(); TInt err = gpsMeasurements.SetGpsMeasurementInfo(KErrNone, &gpsInfo, sizeof(gpsInfo), timeNow); TESTL(err == KErrNone); // // Test getting measurement data // TTime timeGot; TPositionGpsMeasurementInfo gpsInfo2; err = gpsMeasurements.GetGpsMeasurementInfo(&gpsInfo2, sizeof(gpsInfo2), timeGot); TESTL(err == KErrNone); TESTL(gpsInfo2.NumMeasurements() == gpsInfo.NumMeasurements()); TESTL(gpsInfo2.GpsTimeOfWeek() == gpsInfo.GpsTimeOfWeek()); TESTL(gpsInfo2.PositionMode() == gpsInfo.PositionMode()); TESTL(gpsInfo2.PositionModeReason() == gpsInfo.PositionModeReason()); TESTL(gpsInfo2.UpdateType() == gpsInfo.UpdateType()); TESTL(gpsInfo2.ModuleId() == gpsInfo.ModuleId()); TESTL(timeGot == timeNow); // // Test notification of updates // TRequestStatus status; gpsMeasurements.NotifyGpsMeasurementUpdate(status); timeNow.UniversalTime(); err = gpsMeasurements.SetGpsMeasurementInfo(KErrNone, &gpsInfo, sizeof(gpsInfo), timeNow); TESTL(err == KErrNone); User::WaitForRequest(status); TESTL(status.Int() == KErrNone); err = gpsMeasurements.GetGpsMeasurementInfo(&gpsInfo2, sizeof(gpsInfo2), timeGot); TESTL(err == KErrNone); TESTL(timeGot == timeNow); // // Test errors are passed along // err = gpsMeasurements.SetGpsMeasurementInfo(KErrNotReady, &gpsInfo, sizeof(gpsInfo), timeNow); TESTL(err == KErrNone); err = gpsMeasurements.GetGpsMeasurementInfo(&gpsInfo2, sizeof(gpsInfo2), timeGot); TESTL(err == KErrNotReady); // End of tests CleanupStack::PopAndDestroy(&gpsMeasurements); RLbsGpsMeasurementUpdates::ShutDownL(); } return TestStepResult(); }
/** @SYMTestCaseID SYSLIB-LOGENG-CT-0119 @SYMTestCaseDesc Tests AddEvent, GetEvent, ChangeEvent and DeleteEvent. @SYMTestPriority High @SYMTestActions See the description and expected results. @SYMTestExpectedResults 1. a client with sufficient capability succeed in all cases would expect the following... AddEvent - KErrNone GetEvent - KErrNone ChangeEvent - KErrNone DeleteEvent - KErrNone 2. a client with insufficient capability would expect the following results... AddEvent - KErrPermissionDenied GetEvent - KErrNone ChangeEvent - KErrPermissionDenied DeleteEvent - KErrPermissionDenied @SYMREQ REQ3431 */ LOCAL_C void TestBasicL(CLogClient& aClient) { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0119 ")); CTestActive* active = new(ELeave)CTestActive(); CleanupStack::PushL(active); CLogEvent* event = CLogEvent::NewL(); CleanupStack::PushL(event); TTime now; now.UniversalTime(); event->SetEventType(KLogCallEventTypeUid); active->StartL(); aClient.AddEvent(*event, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); if(!TheHiCapability) { TInt eventId = TestUtils::AddEventL(); TEST(eventId >= 0); event->SetId(eventId); } TEST(event->EventType() == KLogCallEventTypeUid); now = event->Time(); TLogId id = event->Id(); event->SetRemoteParty(KTestRemoteParty1); event->SetDirection(KTestDirection1); event->SetDurationType(KTestDurationType1); event->SetDuration(KTestDuration1); event->SetStatus(KTestStatus1); event->SetSubject(KTestSubject1); event->SetNumber(KTestNumber1); event->SetContact(KTestContact1); event->SetLink(KTestLink1); event->SetDataL(KTestData1); active->StartL(); aClient.ChangeEvent(*event, active->iStatus); CActiveScheduler::Start(); TheTest.Printf(_L("TestBasicL(), TheHiCapability=%d, event id=%d\r\n"), TheHiCapability, id); TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); TEST(event->Id() == id ); TEST(event->EventType() == KLogCallEventTypeUid); if(TheHiCapability) { TEST(event->Description().Length() > 0); TEST(event->Time() == now); TEST(event->RemoteParty() == KTestRemoteParty1); TEST(event->Direction() == KTestDirection1); TEST(event->DurationType() == KTestDurationType1); TEST(event->Duration() == KTestDuration1); TEST(event->Status() == KTestStatus1); TEST(event->Subject() == KTestSubject1); TEST(event->Number() == KTestNumber1); TEST(event->Contact() == KTestContact1); TEST(event->Link() == KTestLink1); TEST(event->Data() == KTestData1); } CleanupStack::PopAndDestroy(); // event; event = CLogEvent::NewL(); CleanupStack::PushL(event); event->SetId(id); active->StartL(); aClient.GetEvent(*event, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); if(TheHiCapability) { TEST(event->Id() == id); TEST(event->EventType() == KLogCallEventTypeUid); TEST(event->Description().Length() > 0); TEST(event->Time() == now); TEST(event->RemoteParty() == KTestRemoteParty1); TEST(event->Direction() == KTestDirection1); TEST(event->DurationType() == KTestDurationType1); TEST(event->Duration() == KTestDuration1); TEST(event->Status() == KTestStatus1); TEST(event->Subject() == KTestSubject1); TEST(event->Number() == KTestNumber1); TEST(event->Contact() == KTestContact1); TEST(event->Link() == KTestLink1); TEST(event->Data() == KTestData1); } active->StartL(); aClient.DeleteEvent(id, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); active->StartL(); aClient.GetEvent(*event, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), TheHiCapability ? KErrNotFound : KErrPermissionDenied); // try to delete a non-existent event... active->StartL(); aClient.DeleteEvent(123, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), KErrNotFound); CleanupStack::PopAndDestroy(2); // event, active }
/** @SYMTestCaseID SYSLIB-LOGENG-CT-1009 @SYMTestCaseDesc Tests for CLogEvent::NewL(),SetDataL() functions @SYMTestPriority High @SYMTestActions Tests for creation of log event on heap and test for setting event specific data from the specified stream and try to read the data back. Check for memory errors @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void TestEventWithHeapFailL() { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1009 ")); #ifdef _DEBUG TInt failCount = 0; #endif TInt error; TBool finished = EFalse; CLogEvent* event = NULL; while(!finished) { __UHEAP_FAILNEXT(failCount++); TRAP(error, event = CLogEvent::NewL()); __UHEAP_RESET; if (error == KErrNone) { finished = ETrue; CleanupStack::PushL(event); } else TEST2(error, KErrNoMemory); } _LIT8(KDataTest1, "01234567890123456789"); _LIT8(KDataTest2, "012345678901234567890123456789"); finished = EFalse; #ifdef _DEBUG failCount = 0; #endif event->SetDataL(KNullDesC8); while(!finished) { __UHEAP_FAILNEXT(failCount++); TRAP(error, event->SetDataL(KDataTest1)); __UHEAP_RESET; if (error == KErrNone) { finished = ETrue; TEST(event->Data() == KDataTest1); } else { TEST2(error, KErrNoMemory); TEST(event->Data() == KNullDesC8); } } finished = EFalse; #ifdef _DEBUG failCount = 0; #endif event->SetDataL(KNullDesC8); while(!finished) { __UHEAP_FAILNEXT(failCount++); TRAP(error, event->SetDataL(KDataTest2)); __UHEAP_RESET; if (error == KErrNone) { finished = ETrue; TEST(event->Data() == KDataTest2); } else { TEST2(error, KErrNoMemory); TEST(event->Data() == KNullDesC8); } } finished = EFalse; #ifdef _DEBUG failCount = 0; #endif event->SetDataL(KNullDesC8); // Check we don't get any more failures __UHEAP_FAILNEXT(0); event->SetDataL(KDataTest2); TEST(event->Data() == KDataTest2); event->SetDataL(KDataTest1); TEST(event->Data() == KDataTest1); event->SetDataL(KNullDesC8); TEST(event->Data() == KNullDesC8); __UHEAP_RESET; // streaming TFileName storename = _L("c:\\T_BASIC_DATA"); TUid uid={0x12345678}; // create a store theFs.Delete(storename); CDictionaryFileStore* store = CDictionaryFileStore::OpenLC(theFs, storename, uid); RDictionaryWriteStream write; RDictionaryReadStream read; uid.iUid++; write.AssignL(*store, uid); write << KNullDesC8; write.CommitL(); write.Close(); read.OpenL(*store, uid); #ifdef _DEBUG failCount = 0; #endif finished = EFalse; __UHEAP_FAILNEXT(0); event->SetDataL(read, 0); __UHEAP_RESET; read.Close(); TEST(event->Data() == KNullDesC8); HBufC8* buf8 = TestUtils::CreateBuf8LC(100); uid.iUid++; write.AssignL(*store, uid); write.WriteL(buf8->Des()); write.CommitL(); write.Close(); read.OpenL(*store, uid); while(!finished) { __UHEAP_FAILNEXT(failCount++); TRAP(error, event->SetDataL(read, 100)); __UHEAP_RESET; if (error == KErrNone) { TEST(event->Data() == buf8->Des()); read.Close(); finished = ETrue; } else { TEST2(error, KErrNoMemory); TEST(event->Data() == KNullDesC8); } } event->SetId(0x12345678); event->SetEventType(TUid::Uid(0x12345678)); HBufC* buf = TestUtils::CreateBufLC(KLogMaxRemotePartyLength / 2); event->SetRemoteParty(buf->Des()); CleanupStack::PopAndDestroy(); // buf buf = TestUtils::CreateBufLC(KLogMaxDirectionLength / 2); event->SetDirection(buf->Des()); CleanupStack::PopAndDestroy(); // buf TTime time; time.UniversalTime(); event->SetTime(time); TEST(event->Time() == time); event->SetDurationType(0xf); event->SetDuration(0x12345678); buf = TestUtils::CreateBufLC(KLogMaxStatusLength / 2); event->SetStatus(buf->Des()); CleanupStack::PopAndDestroy(); // buf buf = TestUtils::CreateBufLC(KLogMaxSubjectLength / 2); event->SetSubject(buf->Des()); CleanupStack::PopAndDestroy(); // buf buf = TestUtils::CreateBufLC(KLogMaxNumberLength / 2); event->SetNumber(buf->Des()); CleanupStack::PopAndDestroy(); // buf event->SetContact(0x12345678); event->SetLink(0x12345678); buf = TestUtils::CreateBufLC(KLogMaxDescriptionLength / 2); event->SetDescription(buf->Des()); CleanupStack::PopAndDestroy(); // buf event->SetFlags(0xA); buf8 = TestUtils::CreateBuf8LC(100); event->SetDataL(buf8->Des()); TEST(event->Data() == buf8->Des()); CleanupStack::PopAndDestroy(); // buf8 CLogEvent* event1 = CLogEvent::NewL(); CleanupStack::PushL(event1); CLogEvent* event2 = CLogEvent::NewL(); CleanupStack::PushL(event2); TEST(TestUtils::EventsEqual(*event1, *event2)); finished = EFalse; #ifdef _DEBUG failCount = 0; #endif while(!finished) { __UHEAP_FAILNEXT(failCount++); TRAP(error, event1->CopyL(*event)); __UHEAP_RESET; if (error == KErrNone) { TEST(!TestUtils::EventsEqual(*event1, *event2)); TEST(TestUtils::EventsEqual(*event1, *event)); finished = ETrue; } else { TEST2(error, KErrNoMemory); TEST(TestUtils::EventsEqual(*event1, *event2)); TEST(!TestUtils::EventsEqual(*event1, *event)); } } CleanupStack::PopAndDestroy(5); // buf8, store, event, event1, event2 ::DeleteDataFile(storename); }
/* @file @SYMTestCaseID SYSLIB-SCHSVR-CIT-0279 @SYMTestCaseDesc Persistant schedule - UTC & Hometime @SYMTestPriority High @SYMTestActions For time and condition based test schedule task and check it fires @SYMTestExpectedResults The test must not fail. @SYMPREQ PREQ234 */ TVerdict Cpersist_mixedStep::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { SetTestStepResult(EFail); _LIT(KTestName1, "Persistant Mixed - Hometime"); _LIT(KTaskData1, "This is some really exciting task data (number 1)"); _LIT(KTestName2, "Persistant Mixed - UTC"); _LIT(KTaskData2, "This is some really exciting task data (number 2)"); // Tests with timezone set to Europe, London RTz tz; tz.Connect(); CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London CleanupStack::PushL(tzId); tz.SetTimeZoneL(*tzId); // Set the time to a known value, since this makes testing much easier (and more // repeatable). SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am // Prepare schedules describing when we want the tasks to run (10:00 am & 10.00) // Creates a hometime based daily persistant schedule TSchedulerItemRef ref1; // This is the time when we want the Hometime time-based schedule to fire TDateTime datetime1(2000, EJanuary, 1, 11, 0, 0, 0); TTsTime startTimeForSchedule1(datetime1, EFalse); // 11:00 am { CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); CleanupStack::PushL(entryList); TScheduleEntryInfo2 entry1 (startTimeForSchedule1, EDaily, 1, 30); entryList->AppendL(entry1); TInt res = TheScheduler.CreatePersistentSchedule(ref1, *entryList); TESTL(res==KErrNone); CleanupStack::PopAndDestroy(); // entryList } // Disable the schedule whilst we set it up User::LeaveIfError(TheScheduler.DisableSchedule(ref1.iHandle)); // Creates a UTC based daily persistant schedule TSchedulerItemRef ref2; // This is the time when we want the UTC time-based schedule to fire TDateTime datetime2(2000, EJanuary, 1, 10, 0, 0, 0); TTsTime startTimeForSchedule2(datetime2, ETrue); // 10:00 am { CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); CleanupStack::PushL(entryList); TScheduleEntryInfo2 entry1 (startTimeForSchedule2, EDaily, 1, 30); entryList->AppendL(entry1); TInt res = TheScheduler.CreatePersistentSchedule(ref2, *entryList); TESTL(res==KErrNone); CleanupStack::PopAndDestroy(); // entryList } // Disable the schedule whilst we set it up User::LeaveIfError(TheScheduler.DisableSchedule(ref2.iHandle)); // Kill the server to check if persisted schedules have been stored // Need to turn off JIT dubugging as we are panicking server and we // want test to keep running. TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); TheScheduler.__FaultServer(); // Change UTC Offset whilst server is down // Set UTC offset to +1Hr by moving to Europe, Paris tzId = CTzId::NewL(2656); //set the timezone to Europe/Paris tz.SetTimeZoneL(*tzId); User::After(1000000); // Turn on JIT again. User::SetJustInTime(jit); // Connect to the server again TInt res = TheScheduler.Connect(); TESTL(res==KErrNone); // Re-register TESTL(SchSvrHelpers::RegisterClientL(TheScheduler)==KErrNone); // Associate a task with the time-based schedule TTaskInfo taskInfo1; taskInfo1.iName = KTestName1; taskInfo1.iPriority = 2; taskInfo1.iRepeat = 0; // Create some data associated with this task HBufC* taskData1 = KTaskData1().AllocLC(); User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref1.iHandle)); CleanupStack::PopAndDestroy(); // taskData1 // Associate a task with the condition-based schedule TTaskInfo taskInfo2; taskInfo2.iName = KTestName2; taskInfo2.iPriority = 2; taskInfo2.iRepeat = 0; // Create some data associated with this task HBufC* taskData2 = KTaskData2().AllocLC(); User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref2.iHandle)); CleanupStack::PopAndDestroy(); // taskData2 // Set the UTC time such that both schedules fire at the same time SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 59, 50, 0))); // 9:59.50 am User::LeaveIfError(TheScheduler.EnableSchedule(ref1.iHandle)); User::LeaveIfError(TheScheduler.EnableSchedule(ref2.iHandle)); // Now wait for the time-based schedule to fire TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); // Now wait for the condition-based schedule to fire TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); TTime timeNow; timeNow.HomeTime(); TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), startTimeForSchedule1)); timeNow.UniversalTime(); TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, ETrue), startTimeForSchedule2)); CleanupStack::PopAndDestroy(); // timezone ID CleanupHelpers::KillProcess(KMinimalTaskHandler); SetTestStepResult(EPass); return TestStepResult(); }
void CMacBasicDataStep::doTestL() { INFO_PRINTF1(_L("*** Mac - Basic Data ***")); INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells()); TVariantPtrC algorithmUid; TPtrC sourcePath; TPtrC expectedMac; TPtrC encryptKey; TVariantPtrC keyType; //Extract the Test Case ID parameter from the specified INI file if (!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) || !GetStringFromConfig(ConfigSection(),KConfigSourcePath,sourcePath) || !GetStringFromConfig(ConfigSection(),KConfigExMacValue,expectedMac)|| !GetStringFromConfig(ConfigSection(),KConfigEncryptKey,encryptKey) || !GetStringFromConfig(ConfigSection(),KConfigEncryptKeyType,keyType)) { ERR_PRINTF1(_L("** Error: Failed to Load Configuration Parameters **")); return; } //Create a pointer for the Mac Implementation Object CMac* macImpl = NULL; //Convert encryption key to an 8 Bit Descriptor HBufC8* keyStr = HBufC8::NewLC(encryptKey.Length()); TPtr8 keyStrPtr = keyStr->Des(); keyStrPtr.Copy(encryptKey); //Create an new CryptoParams object to encapsulate the key type and secret key string CCryptoParams* keyParams = CCryptoParams::NewL(); CleanupStack::PushL(keyParams); keyParams->AddL(*keyStr,keyType); //Create Key Object TKeyProperty keyProperty; CKey* key=CKey::NewL(keyProperty,*keyParams); CleanupStack::PushL(key); //Retrieve a Mac Factory Object TRAPD(err, CMacFactory::CreateMacL(macImpl, algorithmUid, *key, NULL)); if (err != KErrNone) { CleanupStack::PopAndDestroy(3, keyStr); // keyStr, keyParams, key delete macImpl; ERR_PRINTF2(_L("*** FAIL: Failed to Create Mac Object - %d ***"), err); User::Leave(err); } //Push the Mac Implementation Object onto the Cleanup Stack CleanupStack::PushL(macImpl); RFs fsSession; User::LeaveIfError(fsSession.Connect()); CleanupClosePushL(fsSession); RFile sourceFile; //Open the specified source file User::LeaveIfError(sourceFile.Open(fsSession,sourcePath, EFileRead)); CleanupClosePushL(sourceFile); TInt sourceLength = 0; User::LeaveIfError(sourceFile.Size(sourceLength)); //Create a heap based descriptor to store the data HBufC8* sourceData = HBufC8::NewL(sourceLength); CleanupStack::PushL(sourceData); TPtr8 sourcePtr = sourceData->Des(); sourceFile.Read(sourcePtr); if(sourcePtr.Length() != sourceLength) { ERR_PRINTF1(_L("*** Error: Reading Source File ***")); } else { //Create a NULL TCharacteristics pointer const TCharacteristics* charsPtr(NULL); //Retrieve the characteristics for the Mac implementation object TRAP_LOG(err, macImpl->GetCharacteristicsL(charsPtr)); //Static cast the characteristics to type TMacCharacteristics const TMacCharacteristics* macCharsPtr = static_cast<const TMacCharacteristics*>(charsPtr); //The mac output size is returned in Bits, divide by 8 to get the Byte size TInt macSize = macCharsPtr->iHashAlgorithmChar->iOutputSize/8; //Retrieve the final 8bit mac value and convert to 16bit HBufC* macData = HBufC::NewLC(macSize); TPtr macPtr = macData->Des(); // This is just a simple performance measurement on generating // the Mac TTime startTime; startTime.UniversalTime(); macPtr.Copy(macImpl->MacL(*sourceData)); TTime endTime; endTime.UniversalTime(); TTimeIntervalMicroSeconds time = endTime.MicroSecondsFrom(startTime); //Take the 16bit descriptor and convert the string to hexadecimal TVariantPtrC convertMac; convertMac.Set(macPtr); HBufC* macResult = convertMac.HexStringLC(); INFO_PRINTF2(_L("*** Mac: %S ***"), &*macResult); INFO_PRINTF2(_L("*** Expected Mac: %S ***"), &expectedMac); //If the returned mac value matches the expected mac, Pass the test if(*macResult == expectedMac) { INFO_PRINTF2(_L("*** Mac - Basic Data generated after setup in %d micro sec.: PASS ***"), time.Int64()); SetTestStepResult(EPass); } else { ERR_PRINTF1(_L("*** FAIL: Generated Mac and Expected Mac Mismatch ***")); } CleanupStack::PopAndDestroy(2, macData); // macData, macResult } CleanupStack::PopAndDestroy(7, keyStr); // keyStr, keyParams, key, macImpl, &fsSession, &sourceFile, sourceData INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells()); }
/** @SYMTestCaseID SYSLIB-LOGENG-CT-1022 @SYMTestCaseDesc Tests for operations on log database @SYMTestPriority High @SYMTestActions Check by add new event,change the event,and get event and check for integrity of data @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void TestEventViewL(CLogClient& aClient) { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1022 ")); CTestActive* active = new(ELeave)CTestActive(); CleanupStack::PushL(active); CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); changeObs->SetActive(); CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); CleanupStack::PushL(view); CLogEvent* event; TLogId id; TTime now; now.UniversalTime(); TInt count; for(count = 0; count < KTestEventNum; count++) { event = CLogEvent::NewL(); CleanupStack::PushL(event); event->SetEventType(KLogCallEventTypeUid); //User::After(Math::Random() % 100000); User::After(1000000); active->StartL(); aClient.AddEvent(*event, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), KErrNone); TEST(event->EventType() == KLogCallEventTypeUid); TEST(event->Description().Length() > 0); TEST(event->Time() >= now); now = event->Time(); id = event->Id(); event->SetRemoteParty(KTestRemoteParty1); event->SetDirection(KTestDirection1); event->SetDurationType(KTestDurationType1); event->SetDuration(KTestDuration1); event->SetStatus(KTestStatus1); event->SetSubject(KTestSubject1); event->SetNumber(KTestNumber1); event->SetLink(KTestLink1); event->SetDataL(KTestData1); event->SetFlags(KTestFlags1); event->SetContact((TLogContactItemId) count+1); User::After(Math::Random() % 100000); active->StartL(); aClient.ChangeEvent(*event, active->iStatus); CActiveScheduler::Start(); //If the test fails on the next line with -1 or -12 error, it is possible that the contacts database is missing: //c:\private\10003a73\SQLite__Contacts.cdb. Copy it to the specified location and rerun the test. TEST2(active->iStatus.Int(), KErrNone); TEST(event->EventType() == KLogCallEventTypeUid); TEST(event->RemoteParty() == KTestRemoteParty1); TEST(event->Direction() == KTestDirection1); TEST(event->DurationType() == KTestDurationType1); TEST(event->Duration() == KTestDuration1); TEST(event->Status() == KTestStatus1); TEST(event->Subject() == KTestSubject1); TEST(event->Number() == KTestNumber1); TEST(event->Link() == KTestLink1); TEST(event->Data() == KTestData1); TLogFlags eventFlags; if(TheMatchingIsEnabled) { eventFlags=KTestFlags1|KLogEventContactSearched; } else { eventFlags=KTestFlags1; } //If the test fails on the next line, it is quite possible that there is a //z:\private\10202be9a\101f401d.txt file that sets the contacts match count to 0. //Delete the file and run the test again. TEST(event->Flags() == eventFlags); TEST(event->Contact()==(TLogContactItemId) count+1); CleanupStack::PopAndDestroy(); // event; event = CLogEvent::NewL(); CleanupStack::PushL(event); event->SetId(id); active->StartL(); aClient.GetEvent(*event, active->iStatus); CActiveScheduler::Start(); TEST2(active->iStatus.Int(), KErrNone); TEST(event->EventType() == KLogCallEventTypeUid); TEST(event->RemoteParty() == KTestRemoteParty1); TEST(event->Direction() == KTestDirection1); TEST(event->DurationType() == KTestDurationType1); TEST(event->Duration() == KTestDuration1); TEST(event->Status() == KTestStatus1); TEST(event->Subject() == KTestSubject1); TEST(event->Number() == KTestNumber1); TEST(event->Link() == KTestLink1); TEST(event->Data() == KTestData1); TEST(event->Flags() == eventFlags); TEST(event->Contact()==(TLogContactItemId) count+1); CleanupStack::PopAndDestroy(); // event; } CleanupStack::PopAndDestroy(3, active); // Delete view, changeObs, active }
/** Return a CCntDbManager for an existing Contacts database. Creates a CCntDbManager if no session has the file open. The Contacts database must exist. @param aCntFile Contacts database filename. @param aMode Indicates whether Contacts database is to be opened, created or replaced. @return CCntDbManager instance. */ CCntDbManager* CCntDbManagerController::GetDbManagerL(TDes& aCntFile, TCntFileMode aMode) { #ifdef __PROFILE__ TTime now; now.UniversalTime(); #endif // If a Backup or Restore is in progress disallow creation of manager and // hence any access to database. This is replicated behaviour from Contacts // Model 1. if (iBackupRestoreAgent->RestoreInProgress() || iBackupRestoreAgent->BackupInProgress()) { User::Leave(KErrLocked); } // Deal with default Contacts database file (indicated by empty descriptor). if(aCntFile.Length() == 0) { DefaultDatabaseL(aCntFile); } // Free it up for a replace/create operation if // permanent data is only thing holding it open. if (iPermanentData && (aMode == ECntFileReplace)) { CCntDbManager* manager = DbManagerL(aCntFile); if (manager && iPermanentData->IsOnlyClientOfDbManager(manager)) { iPermanentData->ReleaseDbManagerL(manager); } } CCntDbManager* theManager = DbManagerL(aCntFile); if (theManager != NULL) // Existing DbManager is found. { // If creating the file, leave because it is already exists. if (aMode == ECntFileCreate) { User::Leave(KErrAlreadyExists); } // If replacing the file, leave because it is currently in use. if (aMode == ECntFileReplace) { User::Leave(KErrInUse); } } else // The file is not opened and DbManager doesn't exist. { // Create new CCntDbManager. theManager = CCntDbManager::NewLC(iFs, aCntFile, aMode, *iBackupRestoreAgent, *iIniFileManager); // Add to the list of managers. iManagers.AppendL(theManager); CleanupStack::Pop(theManager); } // Increase the session count. theManager->AddSession(); #ifdef __PROFILE__ TTime now2; now2.UniversalTime(); RDebug::Print(_L("[CNTMODEL] Spend %d microseconds in CCntDbManagerController::GetDbManagerL \n"), now2.MicroSecondsFrom(now).Int64()); #endif return theManager; }
//--------------------------------------------------------------------- // //--------------------------------------------------------------------- TUint32 CDebugLogger::TimeMs() { TTime now; now.UniversalTime(); return (TUint32)(now.Int64()/1000); }
void CSmilTranslatorTestUtils::RunTestL() { TRequestStatus *s = &iStatus; // used to generate a leave if an out of memory error was encountered, specifically // during the memory test loop in E32Main(). This is necessary because leaves in // the .dll Active Object RunL() functions do not return to this application, so // have to be Trapped in the Active objects and translated into an error code. TBool memoryError = EFalse; switch(iState) { case KInit: { // Utility class for file manipulation iFileFinder = new TFindFile(iSession); TPtrC errorFileName(KErrorFileName); // create err dir if doesn't exist - this api ignores the file name (ignores everything after final '/') fileSystem.MkDirAll(KErrorFileName); // overwrite any existing file of this name iErr = iErrorFile.Replace(iSession, errorFileName, EFileWrite | EFileStreamText); if(iErr == KErrNone) { TBuf<1> bom; bom.Append(CEditableText::EByteOrderMark); iErrorFile.Write(DES_AS_8_BIT(bom)); // will search multiple directories, but halt after completing current directory // if at least one match is made. Remembers which directories have been searched // in order to continue search using .FindWild() function later iErr = iFileFinder->FindWildByPath(KWildName, &KInputPathList, iFileList); iIndex = 0; } if(iErr == KErrNone) { iState = KParseFile; } else { iState = KEnd; } User::RequestComplete(s, KErrNone); SetActive(); } break; case KParseFile: { ++iFilesProcessed; iErr = KErrNone; TParse fullEntry; fullEntry.Set((*iFileList)[iIndex++].iName,& iFileFinder->File(),NULL); iInputFileName = fullEntry.FullName(); // extract individual path + name from list SetOutputFileName(); // output name is based on input one iOutputMsg = KStartFile; iOutputMsg.Append(iInputFileName); // display full path test.Start(iOutputMsg); // print to console // test console automatically places output on a new line, for output // to error file we need to add white space ready for next line iOutputMsg.Append(KOutputNewLine); iErrorFile.Write(DES_AS_8_BIT(iOutputMsg)); // print to error file // schedule Parser active object for call to it's RunL function if (testConfig->DataMode() == CTestConfig::EBufferData) { // We're testing the buffering API... // Create a data supplier object and pass it in to the parser delete iDataSupplier; iDataSupplier = NULL; iDataSupplier = CTestDataSupplier::NewL(iSession, iInputFileName); iParser->ParseSource(iDataSupplier); } else { if( iUseFileHandle ) { RFile file; User::LeaveIfError(file.Open(iSession, iInputFileName, EFileRead | EFileShareReadersOnly)); // No function declaration of ParseFile() that take RFile Object parameter // iParser->ParseFile(file); iParser->ParseFile(iSession, iInputFileName); } else { // We're testing the file mode so parse the file. iParser->ParseFile(iSession, iInputFileName); } } iState = KCheckResults; iStatus = KRequestPending; SetActive(); } break; case KCheckResults: { // when execution begins again one parse followed by a compose would have // completed for the current file, handle any error messages generated here iErr = iParser->Error(); TInt severity = iParser->ErrorSeverity(); if(iErr != KErrNone) { iOutputMsg = KParseError; AppendErrorStr(iErr, iOutputMsg); AppendSeverityStr(severity, iOutputMsg); iOutputMsg.Append(KOutputNewLine); // IF there are no more errors for this file bung in an // extra line to make output more prominent if(iComposer->Error() == KErrNone) { iOutputMsg.Append(KOutputNewLine); } test.Printf(iOutputMsg); // print to console iErrorFile.Write(DES_AS_8_BIT(iOutputMsg)); // print to error file if(iErr == KErrNoMemory) { memoryError = ETrue; } } iErr = iComposer->Error(); severity = iComposer->ErrorSeverity(); if(iErr != KErrNone) { iOutputMsg = KComposeError; AppendErrorStr(iErr, iOutputMsg); AppendSeverityStr(severity, iOutputMsg); iOutputMsg.Append(KOutputNewLine); iOutputMsg.Append(KOutputNewLine); test.Printf(iOutputMsg); iErrorFile.Write(DES_AS_8_BIT(iOutputMsg)); if(iErr == KErrNoMemory) { memoryError = ETrue; } } test.End(); // if the OOM condition occured during Parsing or Composing if(memoryError) { User::Leave(KErrNoMemory); } iState = KParseFile; if(iIndex >= iFileList->Count()) { // fileList must be deleted after each loop prior to being passed // back to fileFinder (unnecessary after KErrNotFound) delete iFileList; iFileList = 0; // Just in case it doesn't get set in the FindWild // continue wildcard search for next directory in list iErr = iFileFinder->FindWild(iFileList); iIndex = 0; if(iErr != KErrNone) iState = KEnd; } SetActive(); User::RequestComplete(s, KErrNone); } break; default: case KEnd: { TTime endTime; TTimeIntervalSeconds interval; endTime.UniversalTime(); endTime.SecondsFrom(iStartTime, interval); TBuf<100> time; _LIT(KComposeTime, "Total time for composing: %d microseconds\n"); time.Format(KComposeTime, iComposeTime); iErrorFile.Write(DES_AS_8_BIT(time)); _LIT(KTimeTaken, "Total time for tests: %d seconds"); time.Format(KTimeTaken, interval.Int()); iErrorFile.Write(DES_AS_8_BIT(time)); delete iFileFinder; delete iDataSupplier; CActiveScheduler::Stop(); } break; } }
LOCAL_C void DoTests() // // single thread // { TInt r=KErrNone; test.Next(_L("Start continuous file Write/Read/Verify operation")); RThread t[KMaxNumberThreads]; TRequestStatus tStat[KMaxNumberThreads]; TInt i=0; TName threadName; TRequestStatus kStat=KRequestPending; test.Console()->Read(kStat); ThreadTestInfo[i].iCycles=0; ThreadTestInfo[i].iErrors=0; ThreadTestInfo[i].iSizeArrayPos=(i%KMaxSizeArray); ThreadTestInfo[i].iErrorInfo=0; if (i<(KMaxNumberThreads-1)) { threadName.Format(_L("MakeAndDeleteFiles%d"),i); r=t[i].Create(threadName,MakeAndDeleteFilesThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); } else { // Last thread fills/empties disk threadName.Format(_L("FillAndEmptyDisk%d"),i); r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); } if (r!=KErrNone) test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i); test(r==KErrNone); t[i].Logon(tStat[i]); t[i].Resume(); CurrentlyFillingDisk=ETrue; FillDiskCount=0; TInt totalTime=0; TTime startTime; TTime time; startTime.UniversalTime(); TInt ypos=test.Console()->WhereY(); FOREVER { User::WaitForAnyRequest(); if (kStat!=KRequestPending) { t[i].LogonCancel(tStat[i]); User::WaitForRequest(tStat[i]); break; } else { TBool threadFinished=EFalse; if (tStat[i]!=KRequestPending && !threadFinished) { t[i].Close(); (ThreadTestInfo[i].iCycles)++; if (tStat[i]!=KErrNone) (ThreadTestInfo[i].iErrors)++; threadFinished=ETrue; // Launch another thread TInt threadNameId=((ThreadTestInfo[i].iCycles)%2)?(i+KMaxNumberThreads):i; // Alternate thread name threadName.Format(_L("FillAndEmptyDisk%d"),threadNameId); r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); if (r!=KErrNone) test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i); test(r==KErrNone); t[i].Logon(tStat[i]); t[i].Resume(); } test.Console()->SetPos(0,(ypos+i)); test.Printf(_L("Thread(%d): % 4d errors in % 4d cycles (%d)\r\n"),i,ThreadTestInfo[i].iErrors,ThreadTestInfo[i].iCycles,ThreadTestInfo[i].iErrorInfo); if (!threadFinished) { test.Printf(_L("Semaphore death")); break; } TVolumeInfo v; r=TheFs.Volume(v,gDriveNumber); test(r==KErrNone); test.Console()->SetPos(0,(ypos+KMaxNumberThreads)); test.Printf(_L("Free space on disk: %u K(of %u K)\r\n"),(v.iFree/1024).Low(),(v.iSize/1024).Low()); TTimeIntervalSeconds timeTaken; time.UniversalTime(); r=time.SecondsFrom(startTime,timeTaken); test(r==KErrNone); totalTime=timeTaken.Int(); TInt seconds = totalTime % 60; TInt minutes = (totalTime / 60) % 60; TInt hours = (totalTime / 3600) % 24; TInt days = totalTime / (60 * 60 * 24); test.Printf(_L("Elapsed Time: %d d %02d:%02d:%02d\r\n"), days, hours, minutes, seconds); } } }
/** Second phase constructor @internalComponent */ void CVideoRenderer::ConstructL() { User::LeaveIfError(iSurfaceManager.Open()); User::LeaveIfError(iWsSession.Connect()); CResourceFileReader* reader = CResourceFileReader::NewLC(KResourceFileName); reader->ReadSupportedFormatL(iSupportedFormat); if (iTimed) { // Create a high priority thread for timed mode // get timer info for timed mode TInt64 defaultDelay; TInt64 maxDelay; reader->ReadTimerInfoL(defaultDelay, maxDelay); //Get a reference to this thread's heap RHeap& thisHeap = User::Heap(); //Parameters to send to the sub thread TThreadRelayParam param; param.iObserver = &iObserver; param.iThreadRelay = &iRendererRelay; // return pointer to allow direct calls //Get the id of this thread RThread thisThread; TThreadId thisThreadId = thisThread.Id(); param.iMainThreadId = thisThreadId; //Get a request to signal for setup completion TRequestStatus setupComplete = KRequestPending; param.iSetupComplete = &setupComplete; //current time and the "this" pointer for a unique key _LIT(KFormatString,"%S.%020Lu.%08X"); TName threadName; TTime now; now.UniversalTime(); threadName.Format(KFormatString, &KVideoRendererThreadName, now.Int64(), reinterpret_cast<TUint>(this)); //Create a new thread using the same heap as this thread TInt result = iRendererThread.Create(threadName, ThreadCreateFunction, KSubThreadStackSize, &thisHeap, ¶m); User::LeaveIfError(result); //Run the thread under high priority iRendererThread.SetPriority(KSubThreadPriority); //Wait for thread startup to complete TRequestStatus threadStatus = KRequestPending; iRendererThread.Logon(threadStatus); //Start the thread iRendererThread.Resume(); User::WaitForRequest(threadStatus, setupComplete); if(threadStatus != KRequestPending) { //Thread creation failed TInt reason = iRendererThread.ExitReason(); DEBUGPRINT3(_L("Renderer thread died with type=%d, reason=%d"), iRendererThread.ExitType(), reason); User::Leave(reason); } // Thread creation was successfull TInt error = iRendererThread.LogonCancel(threadStatus); User::LeaveIfError(error); // There is no outstanding request User::WaitForRequest(threadStatus); // Consume the signal __ASSERT_DEBUG(iRendererRelay != NULL, User::Panic(_L("CVR::ConstructL"), KErrCorrupt)); iRendererRelay->SetRendererThread(&iRendererThread); iRendererRelay->SetTimerInfo(defaultDelay, maxDelay); iThreadCreated = ETrue; User::LeaveIfError(setupComplete.Int()); //Create a listener that will monitor the thread iRendererThreadUndertaker = CThreadUndertaker::NewL(iRendererThread); } else { iRendererRelay = CRendererRelay::NewL(iObserver); } CleanupStack::PopAndDestroy(reader); }
LOCAL_C void DoTests() // // multiple threads // { TInt r=KErrNone; test.Next(_L("Start continuous file Write/Read/Verify operation")); RThread t[KMaxNumberThreads]; TRequestStatus tStat[KMaxNumberThreads]; TInt i=0; TName threadName; TRequestStatus kStat=KRequestPending; test.Console()->Read(kStat); for (i=0;i<KMaxNumberThreads;i++) { ThreadTestInfo[i].iCycles=0; ThreadTestInfo[i].iErrors=0; ThreadTestInfo[i].iSizeArrayPos=(i%KMaxSizeArray); ThreadTestInfo[i].iErrorInfo=0; if (i<(KMaxNumberThreads-1)) { threadName.Format(_L("MakeAndDeleteFiles%d"),i); r=t[i].Create(threadName,MakeAndDeleteFilesThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); } else { // Last thread fills/empties disk threadName.Format(_L("FillAndEmptyDisk%d"),i); r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); } if (r!=KErrNone) test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i); test(r==KErrNone); t[i].Logon(tStat[i]); t[i].Resume(); } CurrentlyFillingDisk=ETrue; FillDiskCount=0; TInt totalTime = 0; TTime cycleTime; TTime startTime; TTime time; startTime.UniversalTime(); cycleTime.UniversalTime(); TVolumeInfo v; r=TheFs.Volume(v,gDriveNumber); test(r==KErrNone); // TInt initialFreeSpace = I64LOW(v.iFree / 1024); #ifdef __LIMIT_EXECUTION_TIME__ RTimer timer; timer.CreateLocal(); TRequestStatus reqStat; timer.After(reqStat,60000000); // After 60 secs #endif #ifdef REUSE_THREAD RTimer displayTimer; displayTimer.CreateLocal(); TRequestStatus displayStat; displayTimer.After(displayStat, KNotificationInterval); // after 10 secs #endif TInt ypos=test.Console()->WhereY(); FOREVER { User::WaitForAnyRequest(); if (kStat!=KRequestPending) { // user requested to end - let threads die #ifdef REUSE_THREAD gRequestEnd = ETrue; #endif for (i=0;i<KMaxNumberThreads;i++) { User::WaitForRequest(tStat[i]); } break; } #ifdef __LIMIT_EXECUTION_TIME__ else if (reqStat != KRequestPending) { // max execution exceeded - wait for threads to die TInt totalCycles = 0; for (i=0;i<KMaxNumberThreads;i++) { totalCycles+= ThreadTestInfo[i].iCycles; } test.Printf(_L("Total cycles = %d\r\n"), totalCycles); test.Printf(_L("Waiting for thread death...\r\n")); for (i=0;i<KMaxNumberThreads;i++) { User::WaitForRequest(tStat[i]); } break; } #endif else { // other notification TBool threadFinished=EFalse; for (i=0;i<KMaxNumberThreads;i++) { if (tStat[i]!=KRequestPending && !threadFinished) { t[i].Close(); (ThreadTestInfo[i].iCycles)++; if (tStat[i]!=KErrNone) (ThreadTestInfo[i].iErrors)++; threadFinished=ETrue; // Launch another thread TInt threadNameId=((ThreadTestInfo[i].iCycles)%2)?(i+KMaxNumberThreads):i; // Alternate thread name if (i<(KMaxNumberThreads-1)) { threadName.Format(_L("MakeAndDeleteFiles%d"),threadNameId); r=t[i].Create(threadName,MakeAndDeleteFilesThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); } else { // Last thread fills/empties disk threadName.Format(_L("FillAndEmptyDisk%d"),threadNameId); r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i); } if (r!=KErrNone) test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i); test(r==KErrNone); t[i].Logon(tStat[i]); t[i].Resume(); } test.Console()->SetPos(0,(ypos+i)); test.Printf(_L("Thread(%d): % 4d errors in % 4d cycles (%d)\r\n"),i,ThreadTestInfo[i].iErrors,ThreadTestInfo[i].iCycles,ThreadTestInfo[i].iErrorInfo); } #ifdef REUSE_THREAD if(displayStat != KRequestPending) { // re-request notification displayTimer.After(displayStat, KNotificationInterval); } else if (!threadFinished) { test.Printf(_L("Semaphore death")); break; } #else if (!threadFinished) { test.Printf(_L("Semaphore death")); break; } #endif r=TheFs.Volume(v,gDriveNumber); test(r==KErrNone); test.Console()->SetPos(0,(ypos+KMaxNumberThreads)); TInt freeSpace; TInt8 freeSpaceUnit; TInt totalSpace; TInt8 totalSpaceUnit; // switch t if(v.iFree > KDiskUnitThreshold) { // display in MB freeSpace = I64LOW(v.iFree / (1024 * 1024)); freeSpaceUnit = 'M'; } else { // display in KB freeSpace = I64LOW(v.iFree/1024); freeSpaceUnit = 'K'; } if(v.iSize > KDiskUnitThreshold) { // display in MB totalSpace = I64LOW(v.iSize / (1024 * 1024)); totalSpaceUnit = 'M'; } else { // display in KB totalSpace = I64LOW(v.iSize/1024); totalSpaceUnit = 'K'; } test.Printf(_L("Free space on disk: %u %cB (of %u %cB)\r\n"), freeSpace, freeSpaceUnit, totalSpace, totalSpaceUnit); TTimeIntervalSeconds timeTaken; time.UniversalTime(); r=time.SecondsFrom(startTime,timeTaken); test(r==KErrNone); totalTime=timeTaken.Int(); TInt seconds = totalTime % 60; TInt minutes = (totalTime / 60) % 60; TInt hours = (totalTime / 3600) % 24; TInt days = totalTime / (60 * 60 * 24); test.Printf(_L("Elapsed Time (%d): %d d %02d:%02d:%02d\r\n"), FillDiskCycle, days, hours, minutes, seconds); if(CurrentlyFillingDisk) { // work out ETA to full disk r = time.SecondsFrom(cycleTime, timeTaken); if((r == KErrNone) && (v.iSize > v.iFree)) { totalTime = (TInt) ((v.iFree/1024 * (TInt64) timeTaken.Int()) / (v.iSize/1024 - v.iFree/1024)); seconds = totalTime % 60; minutes = (totalTime / 60) % 60; hours = (totalTime / 3600) % 24; days = totalTime / (60 * 60 * 24); test.Printf(_L("ETA to full disk: %d d %02d:%02d:%02d\r\n"), days, hours, minutes, seconds); } } else { // currently emptying disk, update time metrics cycleTime.UniversalTime(); } } test.Printf(_L("\n")); } }
TInt CTestHistoryLog::DoStreamingL( CStifItemParser& /*aItem*/ ) { CSyncMLHistoryPushMsg * entry = CSyncMLHistoryPushMsg::NewL(); CleanupStack::PushL(entry); entry->SetMsgDigest(KMsgDigest); entry->SetResultCode(KErrorEleven); entry->IncReceivedCount(); RPointerArray<CSmlAlertInfo> alertInfoArray; CleanupClosePushL( alertInfoArray ); CSmlAlertInfo* info = CSmlAlertInfo::NewLC(); info->TaskIds().Append(1); info->TaskIds().Append(KTwo); info->TaskSyncTypes().Append( (TSmlSyncType)0); info->TaskSyncTypes().Append( (TSmlSyncType)1); info->SetConfirmation(ETrue); info->SetConnectionId(KUidNSmlMediumTypeInternet.iUid); info->SetErrorCode(KErrorEleven); info->SetJobControl(CSmlAlertInfo::ECreateJob); info->SetProfileId(1); info->SetProtocolType(ESmlDataSync); info->SetSessionId(KTwo); info->SetTransportId(KUidNSmlMediumTypeInternet.iUid); info->SetVendorSpecificInfoL(KVendorInfo); info->SetUimode(KTwelve); alertInfoArray.AppendL(info); entry->AddAlertsL(alertInfoArray); iHistoryArray->AppendEntryL(entry); CleanupStack::Pop(info); //Given KOne constant in the below line just to pop one item //and not given 'alertInfoArray' as PushL doesnot take that CleanupStack::PopAndDestroy(KOne); //alertInfoArray CleanupStack::Pop(entry); TInt profileId(1); RArray<TInt> tasks; tasks.Append(KTaskId1); tasks.Append(KTaskId2); CSyncMLHistoryJob * entryJob = CSyncMLHistoryJob::NewL(profileId, tasks ); CleanupStack::PushL(entryJob); tasks.Reset(); tasks.Close(); TTime lastsync = 0; TTime now; now.UniversalTime(); entryJob->SetResult(now, KErrorFive); entryJob->SetLastSyncResult(lastsync); CSyncMLHistoryJob::TTaskInfo& taskInfo = entryJob->TaskById(KTaskId1); taskInfo.iError = KErrorOne; taskInfo.iItemsAdded = KFive; taskInfo.iItemsChanged = KFour; taskInfo.iItemsDeleted = KThree; taskInfo.iItemsFailed = KTwo; taskInfo.iItemsMoved = KOne; taskInfo.iServerItemsAdded = KOne; taskInfo.iServerItemsChanged = KTwo; taskInfo.iServerItemsDeleted = KThree; taskInfo.iServerItemsFailed = KFour; taskInfo.iServerItemsMoved = KFive; iHistoryArray->AppendEntryL(entryJob); if (iOwnerShip) { CleanupStack::Pop(entryJob); } else { CleanupStack::PopAndDestroy(entryJob); } CBufBase* buffer = CBufFlat::NewL(KMaxBufSize); CleanupStack::PushL(buffer); RBufWriteStream writeStream(*buffer); writeStream.PushL(); iHistoryArray->ExternalizeL(writeStream); //Given KOne constant in the below line just to pop one item //and not given 'alertInfoArray' as PushL doesnot take that CleanupStack::PopAndDestroy(KOne); //writeStream RBufReadStream readStream(*buffer); readStream.PushL(); iHistoryArray->InternalizeL(readStream); //Given KOne constant in the below line just to pop one item //and not given 'alertInfoArray' as PushL doesnot take that CleanupStack::PopAndDestroy(KOne); //readStream CleanupStack::PopAndDestroy(buffer); //Assinging CSyncMLHistoryEntry to CSyncMLHistoryPushMsg and verifies the values CSyncMLHistoryEntry& hEntry = iHistoryArray->Entry(0); CSyncMLHistoryPushMsg * pushEntry = CSyncMLHistoryPushMsg::DynamicCast(&hEntry); //Just verifying the EntryId TL(hEntry.EntryId() == 0); TL(pushEntry->MsgDigest() == KMsgDigest ); TL(pushEntry->ResultCode() == KErrorEleven ); TL(pushEntry->ReceivedCount() == 1 ); TL(pushEntry->AlertCount() == 1 ); TL(pushEntry->Profile() == 1 ); const CSmlAlertInfo& alertInfo = pushEntry->Alert(0); TL(alertInfo.TaskIds().Count() == KTwo); const RArray<TInt>& streamedTasks = alertInfo.TaskIds(); const RArray<TSmlSyncType>& streamedSyncTypes = alertInfo.TaskSyncTypes(); if( streamedTasks.Count() == KTwo ) { TL(streamedTasks[0] == 1); TL(streamedTasks[1] == KTwo); } if( streamedSyncTypes.Count() == KTwo ) { TL(streamedSyncTypes[0] == 0); TL(streamedSyncTypes[1] == 1); } TL(alertInfo.ErrorCode() == KErrorEleven); TL(alertInfo.JobControl() == CSmlAlertInfo::ECreateJob); TL(alertInfo.CreateSession()); TL(alertInfo.Profile() == 1); TL(alertInfo.Protocol() == ESmlDataSync); TL(alertInfo.SessionId() == KTwo); TL(alertInfo.Transport() == KUidNSmlMediumTypeInternet.iUid); TL(alertInfo.VendorSpecificInfo() == KVendorInfo); //end push msg //Assinging CSyncMLHistoryEntry to CSyncMLHistoryJob and verifies the values CSyncMLHistoryEntry& scEntry = iHistoryArray->Entry(1); CSyncMLHistoryJob * jobEntry = CSyncMLHistoryJob::DynamicCast(&scEntry); //Just verifying the EntryId TL(hEntry.EntryId() == 0); TL(jobEntry->FinishTime() == now); TL(jobEntry->ResultCode() == KErrorFive); TL(jobEntry->LastSuccessSyncTime() == lastsync); TL(jobEntry->Profile() == 1) TL(jobEntry->TaskCount() == KTwo); const CSyncMLHistoryJob::TTaskInfo& taskInfo2 = jobEntry->TaskAt(0); TL(taskInfo2.iError == KErrorOne); TL(taskInfo2.iItemsAdded == KFive); TL(taskInfo2.iItemsChanged == KFour); TL(taskInfo2.iItemsDeleted == KThree); TL(taskInfo2.iItemsFailed == KTwo); TL(taskInfo2.iItemsMoved == KOne); TL(taskInfo2.iServerItemsAdded == KOne); TL(taskInfo2.iServerItemsChanged == KTwo); TL(taskInfo2.iServerItemsDeleted == KThree); TL(taskInfo2.iServerItemsFailed == KFour); TL(taskInfo2.iServerItemsMoved == KFive); //----------------------Just verifying the ------------------- CSyncMLHistoryEntry *copyObj = CSyncMLHistoryEntry::NewL(scEntry); CSyncMLHistoryJob * copyJobEntry = CSyncMLHistoryJob::DynamicCast(copyObj); //Comparing the value of EntryType from copyObj and scEntry TL(jobEntry->EntryType() == copyJobEntry->EntryType()); return KErrNone; }
void CWsfKeepalive::TimerExpired( TInt aError ) { OstTraceFunctionEntry0( CWSFKEEPALIVE_TIMEREXPIRED_ENTRY ); TBool restartTimer = ETrue; // Should we restart timer or not? if ( aError == KErrNone ) { // Timer successfully completed, handle it if ( NoRealClients( iConnectionId ) ) { TTime now; now.UniversalTime(); // Check whether we are moving from EActiveWithClients to // EActiveNoClients if ( iState == EActiveWithClients ) { OstTrace0( TRACE_NORMAL, CWSFKEEPALIVE_TIMEREXPIRED_RESET, "CWsfKeepalive::TimerExpired Keepalive time reset" ); // Connection had clients, but doesn't anymore. Keepalive // inactivity time starts now iKeepaliveStart = now; } // Check whether keepalive time has been reached else if ( iKeepaliveStart + TTimeIntervalSeconds( KKeepaliveInactivityInterval ) <= now ) { OstTrace0( TRACE_NORMAL, CWSFKEEPALIVE_TIMEREXPIRED_DONE, "CWsfKeepalive::TimerExpired Keepalive time expired" ); // Keepalive time limit expired, connection should be stopped iEsock->Disconnect(); iConnMonDisc->Disconnect( iConnectionId ); restartTimer = EFalse; } // There are now no real clients for the connection SetState( EActiveNoClients ); } else { // One or more real clients are using the connection SetState( EActiveWithClients ); } } else { // Timer not successful, probably because we stopped it restartTimer = EFalse; } if ( restartTimer ) { TTimeIntervalMicroSeconds32 interval( KKeepalivePollInterval ); iTimer->After( interval ); } OstTraceFunctionExit0( CWSFKEEPALIVE_TIMEREXPIRED_EXIT ); }
// --------------------------------------------------------- // CT_LbsClientPosTp178::TestTimeout // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp178::TestTimeoutL() { _LIT(KSTART, "TestTimeout()"); _LIT(KEND, "TestTimeout() passed"); _LIT(KTIME, "Request took %d us"); // Setup verification stuff INFO_PRINTF1(KSTART); //TPrivDlgDiagnostics tmpdiag; TTime requestStartTime; TTime requestStopTime; TTimeIntervalMicroSeconds durationMicro; TBuf<100> buf; _LIT(KService, "SAAA"); TPositionUpdateOptions updateOptions; TTimeIntervalMicroSeconds longInterval(7000000); ConnectL(); SetupPsyL(iUidTestPsy3); OpenPositionerByName(iUidTestPsy3); updateOptions.SetUpdateTimeOut(longInterval); // Access protected member (iPositioner) here iPositioner.SetUpdateOptions(updateOptions); _LIT(KONE, "Perform first request, should NOT time out"); INFO_PRINTF1(KONE); requestStartTime.UniversalTime(); //Make one request to verify psy PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication); CheckRequestResultL(KErrNone); requestStopTime.UniversalTime(); durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); TInt duration = durationMicro.Int64(); buf.Format(KTIME, duration); INFO_PRINTF1(buf); ClosePositioner(); OpenPositionerByName(iUidTestPsy3); // ECancelButton means that the Automatised class should wait for a cancel call // before returning result updateOptions.SetUpdateTimeOut(longInterval); // Access protected (iPositioner) member here iPositioner.SetUpdateOptions(updateOptions); _LIT(KTWO, "Perform second request, should not time out"); INFO_PRINTF1(KTWO); //Make one request to verify psy TPositionInfo info = TPositionInfo(); requestStartTime.UniversalTime(); TInt err = PerformSyncRequest(KService, &info); requestStopTime.UniversalTime(); if (err != KErrNone) { _LIT(KError, "Wrong result from iStatus, should be KErrNone, was %d"); TBuf<100> buf; buf.Format(KError, err); LogErrorAndLeaveL(buf); } durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); duration = durationMicro.Int64(); buf.Format(KTIME, duration); INFO_PRINTF1(buf); ClosePositioner(); Disconnect(); INFO_PRINTF1(KEND); }
TBool CHuiFxEffect::NotifyEffectEndObserver() { if (iFlags & KHuiEffectObserverNotified) { return ETrue; } SetEffectFlag(KHuiEffectObserverNotified); // prevent extra notifier calls calls // fade effect should not have observers if (iFlags & KHuiFadeEffectFlag) { return ETrue; // fade effect does not have observer that would need notification } #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF TTime endTime; endTime.UniversalTime(); // There might be several BeginFullScreen for single effects. We want to calculate // reaction time from the first BeginFullScreen event to this point TInt timeStamps = 0; AMT_GET_TIME_POINT_COUNT(iHandle, timeStamps); TInt64 temp; TBool effects(EFalse); // dummy, 1 if effects were on for this time stamp AMT_GET_TIME(temp, iHandle, 0, effects); TTime startTime(temp); AMT_GET_TIME(temp, iHandle, timeStamps - 1, effects); TTime effectStartTime(temp); TInt64 effectTime = endTime.MicroSecondsFrom(effectStartTime).Int64(); TReal fps = (TReal)iFramesDrawn / ((TReal)effectTime / 1000000.0f) ; TInt64 totalEffectTime = endTime.MicroSecondsFrom(startTime).Int64(); TInt64 reactionTime = effectStartTime.MicroSecondsFrom(startTime).Int64(); RDebug::Printf("CHuiFxEffect::NotifyEffectEndObserver - Reaction time \t0x%x\t%f\tVisible effect time:\t%f\ts. (%f FPS). Total effect time:\t%f", iHandle, (TReal)reactionTime / 1000000.0f, ((TReal)effectTime)/1000000, fps, ((TReal)totalEffectTime)/1000000.0f ); AMT_RESET_TIME(iHandle); #endif if (iEffectEndObserver) { // The callback can be called only once when the effect finishes MAlfGfxEffectObserver* effectEndObserver = iEffectEndObserver; iEffectEndObserver = NULL; // Note: The call below may synchronously delete me (CHuiFxEffect instance) effectEndObserver->AlfGfxEffectEndCallBack( iHandle ); return ETrue; // end observer notified } else { // must be notified without destroying the effect first. gives alf apps chance // to do their own cleanup return EFalse; } }
TVerdict CAppFwkStartSafeTestStepProcMonSysRestart::doTestStepL() { #ifdef __WINSCW__ ASSERT(0); #endif CActiveScheduler* sched = new(ELeave) CActiveScheduler; CleanupStack::PushL(sched); CActiveScheduler::Install(sched); iNotifier = CSaveNotifier::NewL(*this); CStartSafe* startSafe = CStartSafe::NewL(); CleanupStack::PushL( startSafe ); CStartupProperties* prop = CStartupProperties::NewLC(); prop->SetFileParamsL(KTestProcGood, KNullDesC); prop->SetStartMethod(EWaitForStart); prop->SetMonitored(ETrue); prop->SetRecoveryParams(ERestartOS, 0); TInt tried; RProcess proc; CleanupClosePushL(proc); TRAPD(err, startSafe->StartAndMonitorL(*prop, proc, tried)); TEST(KErrNone == err); CleanupStack::Pop(&proc); CleanupStack::PopAndDestroy(prop); CleanupStack::PopAndDestroy(startSafe); INFO_PRINTF1(_L("Process monitoring setup with TRecoveryMethod=ERestartOS")); proc.Kill(KErrNone); proc.Close(); TTime init; init.UniversalTime(); INFO_PRINTF4( _L("Process killed at time %d:%d.%d"), init.DateTime().Minute(), init.DateTime().Second(), init.DateTime().MicroSecond()); INFO_PRINTF1(_L("Starting scheduler (expecting an OS restart)")); CActiveScheduler::Start(); //Wait for MSaveObserver callback //resume here after callback has stopped the scheduler TESTE(iCallbackReceived, iCallbackReceived); if(iCallbackReceived) { const TTimeIntervalMicroSeconds elapsedTime = iShutdownPerformed.MicroSecondsFrom(init); const TDateTime dt = iShutdownPerformed.DateTime(); const TInt64 value = elapsedTime.Int64(); INFO_PRINTF5(_L("Shutdown callback received at time %d:%d.%d (after %d microseconds)"), dt.Minute(), dt.Second(), dt.MicroSecond(), value); TESTE((value >= 0) && (value < 1000000), value); // within 1 second } else { INFO_PRINTF1( _L("Restart didn't take place :-(")); TEST(EFalse); } // Now call CPowerdownClient::QueryServerPowerState() which will in turn call the method 'ServerPowerState()' // to stop the shutdown. This function call will cause the shutdown server in syslibs/pwrcli to cancel power off. INFO_PRINTF1(_L("Aborting shutdown.")); TBool powerOff = EFalse; CPowerdownClient* powerdownclient = CPowerdownClient::NewL(); CleanupStack::PushL(powerdownclient); TEST(KErrNone == powerdownclient->QueryServerPowerState(iNotifier,powerOff)); TEST(powerOff); CleanupStack::PopAndDestroy(powerdownclient); CleanupStack::PopAndDestroy(sched); return TestStepResult(); }
bool eap_am_type_securid_symbian_c::is_session_validL() { EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid(): EAP-tunneling type=0xfe%06x%08x\n"), m_tunneling_type.get_vendor_id(), m_tunneling_type.get_vendor_type())); HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); // Query all the relevant parameters _LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); if (m_eap_type == eap_type_generic_token_card) { sqlStatement.Format( KSQLQuery, &cf_str_EAP_GTC_max_session_validity_time_literal, &KGTCLastFullAuthTime, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } else { // Secure ID is not supported at the moment. // Treat this as session invalid. CleanupStack::PopAndDestroy(buf); // Delete buf. return false; } RDbView view; // Evaluate view User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); // Get the first (and only) row view.FirstL(); view.GetL(); // Get column set so we get the correct column numbers CDbColSet* colSet = view.ColSetL(); CleanupStack::PushL(colSet); TInt64 maxSessionTime = view.ColInt64(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal)); TInt64 fullAuthTime = view.ColInt64(colSet->ColNo(KGTCLastFullAuthTime)); CleanupStack::PopAndDestroy(colSet); // Delete colSet. CleanupStack::PopAndDestroy(&view); // Close view. CleanupStack::PopAndDestroy(buf); // Delete buf. // If the max session time from DB is zero then we use the // one read from configuration file. if( maxSessionTime == 0) { EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL("Session Validity - Using max session validity time from config file\n"))); maxSessionTime = m_max_session_time; // value from configuration file. } // Get the current time. TTime currentTime; currentTime.UniversalTime(); TTime lastFullAuthTime(fullAuthTime); #if defined(_DEBUG) || defined(DEBUG) TDateTime currentDateTime = currentTime.DateTime(); TDateTime fullAuthDateTime = lastFullAuthTime.DateTime(); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Session Validity - Current Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(), currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(), fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond())); #endif TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime); EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_securid_symbian_c::is_session_valid:interval in microseconds:"), &(interval.Int64()), sizeof(interval.Int64()) ) ); EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_securid_symbian_c::is_session_valid:max session time in microseconds:"), &(maxSessionTime), sizeof(maxSessionTime) ) ); #if defined(_DEBUG) || defined(DEBUG) TTimeIntervalMinutes intervalMins; TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins); if(error == KErrNone) { EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_validL()") EAPL("interval in Minutes =%d\n"), intervalMins.Int())); } #endif if( maxSessionTime >= interval.Int64() ) { EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid - Session Valid \n"))); EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); return true; } else { EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid - Session NOT Valid \n"))); EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); return false; } }