コード例 #1
0
TVerdict CMultipleClientsStep::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.
 */
	{
    StandardPrepareL();
    InitPsySettingsL(3, 
        KExtGpsPsy1, 1, 
        KIntGpsPsy1, 1,  
        KNetworkPsy2, 1);
        
    TRequestStatus status;
    TPositionInfo posInfo;
    TPositionUpdateOptions options;
    
    TRequestStatus status2;
    TPositionInfo posInfo2;
    TPositionUpdateOptions options2;

    RPositioner positioner2;
    User::LeaveIfError(positioner2.Open(iServer));
    CleanupClosePushL(positioner2);
    User::LeaveIfError(positioner2.SetRequestor(
            CRequestor::ERequestorService,
            CRequestor::EFormatApplication,
            KTdDefProxyTestName));

    //1. Make location request from both PSYs. All should succeed from ExtGpsPsy1
    positioner2.NotifyPositionUpdate(posInfo2,status2);
    PositionRequestWithCheck(posInfo, KErrNone, KExtGpsPsy1);
    User::WaitForRequest(status2);
    CheckExpectedResult(status2.Int(), KErrNone, KWrongRequestResult);                
    CheckExpectedResult(posInfo2.ModuleId(), KExtGpsPsy1, KWrongModuleIdReturned);    \
    
    //2. When all PSYs returns error code, both PSYs shall 
    //get error code from the first PSY
    ConfigPsyL(KExtGpsPsy1, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );

    ConfigPsyL(KIntGpsPsy1, 1,
        KConfigLRErrGeneral1s           //KErrGeneral 1s
        );
    
    ConfigPsyL(KNetworkPsy2, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );
        
    ConfigPsyL(positioner2, KExtGpsPsy1, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );

    ConfigPsyL(positioner2, KIntGpsPsy1, 1,
        KConfigLRErrGeneral1s           //KErrGeneral 1s
        );
    
    ConfigPsyL(positioner2, KNetworkPsy2, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );

    InitPsyListInDefaultProxyL();
    
    iPositioner.NotifyPositionUpdate(posInfo, status);
    positioner2.NotifyPositionUpdate(posInfo2, status2);
    User::WaitForRequest(status);
    CheckExpectedResult(status.Int(), KErrNoMemory, KWrongRequestResult);                
    User::WaitForRequest(status2);
    CheckExpectedResult(status2.Int(), KErrNoMemory, KWrongRequestResult);                
    
    //3. When PSY1 returns error code to to client 1. Location request 
    //from PSY2 shall fallback imediately
    ConfigPsyL(KExtGpsPsy1, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );

    ConfigPsyL(KIntGpsPsy1, 1,
        KConfigLRErrGeneral1s           //KErrGeneral 1s
        );
    
    ConfigPsyL(KNetworkPsy2, 1,
        KConfigLRNoError1s            //No error 1s
        );
        
    ConfigPsyL(positioner2, KExtGpsPsy1, 1,
        KConfigLRNoError10s            //No error in 10s
        );

    ConfigPsyL(positioner2, KIntGpsPsy1, 1,
        KConfigLRNoError10s           //KErrGeneral 1s
        );
    
    ConfigPsyL(positioner2, KNetworkPsy2, 1,
        KConfigLRNoError1s            //KErrNoMemory 1s
        );
    
    InitPsyListInDefaultProxyL();
    User::After(KSecond * 7); //Delay after configuration
    SET_TIME
    PositionRequestWithCheck(posInfo, KErrNone, KNetworkPsy2);
    INFO_PRINTF1(_L("1 3"));
    CHECK_TIME(3)
    
    //LR from second PSY
    positioner2.NotifyPositionUpdate(posInfo2, status2);
    User::WaitForRequest(status2);
    INFO_PRINTF1(_L("2 1"));
    CHECK_TIME(1) //PSY1 and PSY2 fallback imediately, LR completed from PSY3 in 1s
    CheckExpectedResult(status2.Int(), KErrNone, KWrongRequestResult);                
    CheckExpectedResult(posInfo2.ModuleId(), KNetworkPsy2, KWrongModuleIdReturned);
    
    //4. PSY state change beause of LR for client1 shall affect LR for client2 as well
    //
    ConfigPsyL(KExtGpsPsy1, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );

    ConfigPsyL(positioner2, KExtGpsPsy1, 1,
        KConfigLRNoError10s            //No error in 10s
        );
        
    InitPsyListInDefaultProxyL();
    User::After(KSecond * 7); //Delay after configuration

    SET_TIME
    positioner2.NotifyPositionUpdate(posInfo2, status2);
    PositionRequestWithCheck(posInfo, KErrNone, KIntGpsPsy1);
    INFO_PRINTF1(_L("3 1"));
    CHECK_TIME(1);
    User::WaitForRequest(status2);
    CheckExpectedResult(status2.Int(), KErrNone, KWrongRequestResult);                
    CheckExpectedResult(posInfo2.ModuleId(), KIntGpsPsy1, KWrongModuleIdReturned);  
    INFO_PRINTF1(_L("4 0"));
    CHECK_TIME(0);
    
    //5. Dynamic list change caused by PSY1 shall not affect PSY list orders of client2
    //if location request is already made.
    ConfigPsyL(KExtGpsPsy1, 1,
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );
    
    ConfigPsyL(KIntGpsPsy1, 2,
        KConfigLRNoError1s,             //No error in 10s
        KConfigLRErrNoMemory            //KErrNoMemory 1s
        );
        
    ConfigPsyL(positioner2, KIntGpsPsy1, 2,
        KConfigLRNoError1s,           //No error in 10s
        KConfigLRNoError20s            //No error in 10s
        );

    ConfigPsyL(positioner2, KExtGpsPsy1, 1,
        KConfigLRNoError45s            //No error in 45s
        );

    InitPsyListInDefaultProxyL();
    User::After(KSecond * 7); //Delay after configuration

    PositionRequestWithCheck(posInfo, KErrNone, KIntGpsPsy1);
    
    //Location request from client 2 shall be completed imediatelly, since 
    //IntGpsPsy shall be the first on the dynamic list
    SET_TIME
    positioner2.NotifyPositionUpdate(posInfo2, status2);
    User::WaitForRequest(status2);
    CheckExpectedResult(status2.Int(), KErrNone, KWrongRequestResult);                
    CheckExpectedResult(posInfo2.ModuleId(), KIntGpsPsy1, KWrongModuleIdReturned);  
    INFO_PRINTF1(_L("5 1"));
    CHECK_TIME(1);
    
    //Make location request from client 2
    positioner2.NotifyPositionUpdate(posInfo2, status2);
    SET_TIME
    PositionRequestWithCheck(posInfo, KErrNone, KExtGpsPsy1);
    INFO_PRINTF1(_L("6 1"));
    CHECK_TIME(1)
    User::WaitForRequest(status2);
    CheckExpectedResult(status2.Int(), KErrNone, KWrongRequestResult);                
    CheckExpectedResult(posInfo2.ModuleId(), KNetworkPsy2, KWrongModuleIdReturned);  
    INFO_PRINTF1(_L("7 0"));
    CHECK_TIME(0)
    

    CleanupStack::PopAndDestroy(&positioner2);
    //Cleanup
    StandardCleanup();
    return TestStepResult();
	}
コード例 #2
0
TVerdict CBigSendRecvRtp::doTestStepL()
/**
 * @return - TVerdict code
 */
	{
	SetTestStepResult(EFail);
	if(KErrNone == InitSocketsL())
		{
		iIpAddrDest1.SetPort(9000);
		RBuf8 sendBuf;
		sendBuf.CreateMax(KBufferSize1);
		sendBuf.CleanupClosePushL();
		RBuf8 recvBuf;
		recvBuf.CreateMax(KBufferSize1);
		recvBuf.CleanupClosePushL();
		
		/* Fill the buffer with given character upto its length */
		sendBuf.Fill('Q');
		TRequestStatus status;
		/* do a Send of the data */
		iRtpSocket.SendTo(sendBuf, iIpAddrDest1, NULL, status);
		User::WaitForRequest(status);
		User::LeaveIfError(status.Int());
		/* Now do a Receive */
		recvBuf.FillZ();
		iRtpSocket.RecvFrom(recvBuf,iIpAddrDest1,NULL,status);
		User::WaitForRequest(status);
		User::LeaveIfError(status.Int());
		
		/* Obtain a TPtr of the data excluding the RTP header */
		TPtr8 sendBufPtr = sendBuf.MidTPtr(KRtpHeaderSize);
		TPtr8 recvBufPtr = recvBuf.MidTPtr(KRtpHeaderSize);
		/* Check if the data received is the same as the data sent */
		TInt ret = sendBufPtr.Compare(recvBufPtr);
		if(ret == 0)
			{
			/* Increase the buffer size and fill it up with given data */
			sendBuf.ReAlloc(KBufferSize2);
			recvBuf.ReAlloc(KBufferSize2);
			sendBuf.Fill('Q', KBufferSize2);
			
			/* Send the larger data */
			iRtpSocket.SendTo(sendBuf, iIpAddrDest1, NULL, status);
			User::WaitForRequest(status);
			User::LeaveIfError(status.Int());
			/* Now do a Receive */
			recvBuf.FillZ(KBufferSize2);
			iRtpSocket.RecvFrom(recvBuf,iIpAddrDest1,NULL,status);
			User::WaitForRequest(status);
			User::LeaveIfError(status.Int());
			/* Get pointer to data and compare both of them */
			TPtr8 sendBufPtr = sendBuf.MidTPtr(KRtpHeaderSize);
			TPtr8 recvBufPtr = recvBuf.MidTPtr(KRtpHeaderSize);
			TInt ret = sendBufPtr.Compare(recvBufPtr);
			if(ret == 0)
				{
				SetTestStepResult(EPass);
				}
			}
		CleanupStack::PopAndDestroy(2);
		}
	return TestStepResult();
	}
コード例 #3
0
enum TVerdict CEsockTest29_11::easyTestStepL( void )
	{
	TVerdict verdict = EFail;
	TInt ret;
	
	Logger().WriteFormat(_L("Send/ Recv on PDummy3 socket but no avail MBuf Memory, mBuf becomes avail after send"));
	RSocketServ ss;
	ret = ss.Connect();
	TESTL(KErrNone == ret);	
	CleanupClosePushL(ss);
    
    // open dummy prot 3
	Logger().WriteFormat(_L("Openning Dummy Protocol 3"));             
	RSocket sock;                                                  
	ret = sock.Open(ss,_L("Dummy Protocol 3"));
	TESTL(KErrNone == ret);
	
	// connecti socket
	TSockAddr addr;
	TRequestStatus stat;
	sock.Connect(addr, stat);
	User::WaitForRequest(stat);
	TESTL(KErrNone == stat.Int());	
	
	// drain MBuf Pool
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);
	
	// send data and wait for 1/10 seconds
	Logger().WriteFormat(_L("Sending Data"));     
	_LIT8( sendData, "bla bla bla bla");        
	sock.Send(sendData,0,stat);
	const TUint KTenMilliSecs = 10000; 
	User::After(KTenMilliSecs);
	
	// free all mbufs
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetFreeMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetFreeMBufs, 0, 0);
	TESTL(ret == KErrNone);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);

	// wait for send to return
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Send has returned %d"), stat.Int());
	if(stat.Int() != KErrNone)
		{
		verdict = EFail;
		}
	
	// recieve data and verify that it is the same as send data
	TBuf8<20> recvBuf;
	TRequestStatus recvStatus;
	sock.Recv(recvBuf, 0, recvStatus);
	User::WaitForRequest(recvStatus);
	Logger().WriteFormat(_L("recieving data on PDummy3 has returned %d"), recvStatus.Int());
	if(recvStatus.Int() != KErrNone)
		{
		verdict = EFail;
		}
	Logger().WriteFormat(_L("Comparing Recieved data and Sent data"), recvStatus.Int());		
	if(recvBuf.Compare(sendData) == 0)
		{
		verdict = EPass; 
		}
	
	sock.Close();
	CleanupStack::PopAndDestroy(&ss);
    SetTestStepResult(verdict);
	return verdict;

	}
コード例 #4
0
/**
@SYMTestCaseID BA-CTSY-ALLS-MGAL-0001
@SYMComponent  telephony_ctsy
@SYMTestCaseDesc Test support in CTSY for RMobilePhone::GetALSLine
@SYMTestPriority High
@SYMTestActions Invokes RMobilePhone::GetALSLine
@SYMTestExpectedResults Pass
@SYMTestType CT
*/
void CCTsyAlternateLineServiceFU::TestGetALSLine0001L()
	{

	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RBuf8 data;
	CleanupClosePushL(data);
	
	TInt ret(KErrGeneral);
	
	TRequestStatus requestStatus;
	
	// dont change the tests order in order to preserve the environment state
	// at the beginig of every test
 	//-------------------------------------------------------------------------
	// TEST E: Unsolicited completion of RMobilePhone::GetALSLine
	// from LTSY.
 	//-------------------------------------------------------------------------

	// create centRep to change repository 
	CRepository* centRep = CRepository::NewL( KCRUidCtsyMEAlsLine );
	CleanupStack::PushL(centRep);

	// setting environment (set KCtsyMEAlsSupported in repository to EFalse)
	ret = centRep->Set( KCtsyMEAlsSupported, EFalse );
	ASSERT_EQUALS(KErrNone, ret);

	// Unsolicited completion with new value EAlternateLineAuxiliary that is not yet cached in CTSY
	iMockLTSY.NotifyTerminated(requestStatus);	    
	RMobilePhone::TMobilePhoneALSLine alsLine(RMobilePhone::EAlternateLineAuxiliary);
	TMockLtsyData1<RMobilePhone::TMobilePhoneALSLine> alsLineData(alsLine);
	alsLineData.SerialiseL(data);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);
	User::WaitForRequest(requestStatus);
	AssertMockLtsyStatusL();
	ASSERT_EQUALS(KErrNone, requestStatus.Int());

    // Unsolicited completion with the same value EAlternateLineAuxiliary that is cached in CTSY
	iMockLTSY.NotifyTerminated(requestStatus);	
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();
	
 	//-------------------------------------------------------------------------
	// TEST C: Successful completion request of
	// RMobilePhone::GetALSLine when result is not cached.
 	//-------------------------------------------------------------------------

	// test setting and execute
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	AssertMockLtsyStatusL();
		
	//-------------------------------------------------------------------------
	// TESTs for coverage increasing with different values of alsLine and 
	// of KCtsyMEAlsSupported from repository
 	//-------------------------------------------------------------------------
 	// setting environment (set alsLine to EAlternateLineUnknown)
	iMockLTSY.NotifyTerminated(requestStatus);
	alsLine = RMobilePhone::EAlternateLineUnknown;
	data.Close();
	alsLineData.SerialiseL(data);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// test setting and execute
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	AssertMockLtsyStatusL();

	// setting environment (set KCtsyMEAlsSupported in repository to ETrue)
	ret = centRep->Set( KCtsyMEAlsSupported, ETrue );
	ASSERT_EQUALS(KErrNone, ret);
    
	// test setting and execute
	alsLine = RMobilePhone::EAlternateLinePrimary;
	data.Close();
	alsLineData.SerialiseL(data);
	iMockLTSY.ExpectL(EMobilePhoneGetALSLine, KErrNone);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);

	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLinePrimary);
	AssertMockLtsyStatusL();

 	//-------------------------------------------------------------------------
	// TEST D: RMobilePhone::GetALSLine again, this time CTSY
	// will get result from the cache.
 	//-------------------------------------------------------------------------
	
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLinePrimary);
	AssertMockLtsyStatusL();

	//-------------------------------------------------------------------------
	// TEST B: failure on completion of pending request from LTSY->CTSY
 	//-------------------------------------------------------------------------

	// change alsLine to EAlternateLineUnknown again
	iMockLTSY.NotifyTerminated(requestStatus);
	alsLine = RMobilePhone::EAlternateLineUnknown;
	data.Close();
	alsLineData.SerialiseL(data);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// test setting and execute
	iMockLTSY.ExpectL(EMobilePhoneGetALSLine, KErrNone);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrGeneral, data);

	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrGeneral, ret);
	AssertMockLtsyStatusL();

 	//-------------------------------------------------------------------------
	// TEST A: failure to dispatch request to LTSY
 	//-------------------------------------------------------------------------
	
	//change alsLine to EAlternateLineUnknown again
	iMockLTSY.NotifyTerminated(requestStatus);	
	alsLine = RMobilePhone::EAlternateLineUnknown;
	data.Close();
	alsLineData.SerialiseL(data);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// test setting and execute
	iMockLTSY.ExpectL(EMobilePhoneGetALSLine, KErrNotSupported);
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNotSupported, ret);
	AssertMockLtsyStatusL();

	//Done!
	// return repository KCtsyMEAlsSupported to EFalse (initial state)
	ret = centRep->Set( KCtsyMEAlsSupported, EFalse );
	ASSERT_EQUALS(KErrNone, ret);

	AssertMockLtsyStatusL();
	CleanupStack::PopAndDestroy(1); // iCentRep
	CleanupStack::PopAndDestroy(2, this); // data, this
	
	}
コード例 #5
0
void CCTsyPrivacyFU::DoNotifyPrivacyConfirmationL(const TDesC& aLineName)
	{
	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RLine line;
	RMobileCall mobileCall;

	TInt err = line.Open(iPhone, aLineName);
	ASSERT_EQUALS(KErrNone, err)
	CleanupClosePushL(line);
	
	err = mobileCall.OpenNewCall(line);
	ASSERT_EQUALS(KErrNone, err)
	CleanupClosePushL(mobileCall);

 	//-------------------------------------------------------------------------
	// TEST C: Successful completion request of
	// RMobileCall::NotifyPrivacyConfirmation when result is not cached.
 	//-------------------------------------------------------------------------

	// invoke RMobilePhone::NotifyPrivacyConfirmation
	TRequestStatus notifyStatus;

	// initialize the variable to be set by CTSY with the value other than passed to MockLTSY
	RMobilePhone::TMobilePhonePrivacy privacy = RMobilePhone::EPrivacyOn;
	mobileCall.NotifyPrivacyConfirmation(notifyStatus,privacy);

	// prepare the data to be returned from MockLTSY
	RMobilePhone::TMobilePhonePrivacy privacySetting = RMobilePhone::EPrivacyUnspecified;
	TMockLtsyCallData1<RMobilePhone::TMobilePhonePrivacy> privacySettingData(privacySetting);

	RBuf8 data;
	CleanupClosePushL(data);
	privacySettingData.SerialiseL(data);

	// trigger EMobileCallNotifyPrivacyConfirmation completion via MockLTSY 
	TRequestStatus mockLtsyStatus;
	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
	iMockLTSY.CompleteL(EMobileCallNotifyPrivacyConfirmation, KErrNone,data);
	User::WaitForRequest(mockLtsyStatus);
	ASSERT_EQUALS(KErrNone,mockLtsyStatus.Int());

	// wait for RMobilePhone::NotifyPrivacyConfirmation completion
	User::WaitForRequest(notifyStatus);

	ASSERT_EQUALS(KErrNone,notifyStatus.Int());
	ASSERT_EQUALS(RMobilePhone::EPrivacyUnspecified, privacy);
	AssertMockLtsyStatusL();
	
 	//-------------------------------------------------------------------------
	// TEST E: Unsolicited completion of RMobileCall::NotifyPrivacyConfirmation
	// from LTSY.
 	//-------------------------------------------------------------------------

	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
	iMockLTSY.CompleteL(EMobileCallNotifyPrivacyConfirmation, KErrNone,data);
	User::WaitForRequest(mockLtsyStatus);
	ASSERT_EQUALS(KErrNone,mockLtsyStatus.Int());
	AssertMockLtsyStatusL();

	CleanupStack::PopAndDestroy(4, this); // data, mobileCall, line, this
	}
コード例 #6
0
ファイル: t_frqchg.cpp プロジェクト: kuailexs/symbiandump-os1
TBool CTimesliceTestThread::Finished()
	{
	return (KRequestPending!=iExitStatus.Int());
	}
コード例 #7
0
/**
@SYMTestCaseID BA-CTSY-ALLS-MSL-0001
@SYMComponent  telephony_ctsy
@SYMTestCaseDesc Test support in CTSY for RMobilePhone::SetALSLine
@SYMTestPriority High
@SYMTestActions Invokes RMobilePhone::SetALSLine
@SYMTestExpectedResults Pass
@SYMTestType CT
*/
void CCTsyAlternateLineServiceFU::TestSetALSLine0001L()
	{

	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RBuf8 data;
	CleanupClosePushL(data);

	TInt ret(-1);
	TRequestStatus requestStatus;

	//-------------------------------------------------------------------------
	// TEST B: failure on completion of pending request from LTSY->CTSY
 	//-------------------------------------------------------------------------

	// create centRep to change repository 
	CRepository* centRep = CRepository::NewL( KCRUidCtsyMEAlsLine );
	CleanupStack::PushL(centRep);

	// setting environment (set KCtsyMEAlsSupported in repository to ETrue)
	ret = centRep->Set( KCtsyMEAlsSupported, ETrue );
	ASSERT_EQUALS(KErrNone, ret);

	// test setting and execute
	RMobilePhone::TMobilePhoneALSLine alsLine(RMobilePhone::EAlternateLinePrimary);
	TMockLtsyData1< RMobilePhone::TMobilePhoneALSLine >
			alsLineData( alsLine );
	alsLineData.SerialiseL(data);
	iMockLTSY.ExpectL(EMobilePhoneSetALSLine, data);
	iMockLTSY.CompleteL(EMobilePhoneSetALSLine, KErrGeneral);

	iPhone.SetALSLine(requestStatus, alsLine);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrGeneral, requestStatus.Int());
	AssertMockLtsyStatusL();

 	//-------------------------------------------------------------------------
	// TEST C: Successful completion request of
	// RMobilePhone::SetALSLine when result is not cached.
	// Case CtsyMEAlsSupported ETrue
 	//-------------------------------------------------------------------------

	iMockLTSY.ExpectL(EMobilePhoneSetALSLine, data);
	iMockLTSY.CompleteL(EMobilePhoneSetALSLine, KErrNone);
	iPhone.SetALSLine(requestStatus, alsLine);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

 	//-------------------------------------------------------------------------
	// TEST C: Successful completion request of
	// RMobilePhone::SetALSLine when result is not cached.
	// Case ÑtsyMEAlsSupported EFalse
 	//-------------------------------------------------------------------------

	// setting environment (set KCtsyMEAlsSupported in repository to EFalse)
	ret = centRep->Set( KCtsyMEAlsSupported, EFalse );
	ASSERT_EQUALS(KErrNone, ret);

	// test setting and execute
	alsLine = RMobilePhone::EAlternateLinePrimary;
	iPhone.SetALSLine(requestStatus, alsLine);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// check test results
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLinePrimary); //check
	AssertMockLtsyStatusL();

	//-------------------------------------------------------------------------
	// TESTs for coverage increasing with different values of alsLine
 	//-------------------------------------------------------------------------

	// test execute
	alsLine = RMobilePhone::EAlternateLineAuxiliary;
	iPhone.SetALSLine(requestStatus, alsLine);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// check test results
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLineAuxiliary); //check
	AssertMockLtsyStatusL();

	// test execute
	alsLine = RMobilePhone::EAlternateLineUnknown;
	iPhone.SetALSLine(requestStatus, alsLine);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// check test results
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLineUnknown); //check
	AssertMockLtsyStatusL();

	// test execute
	alsLine = RMobilePhone::EAlternateLineNotAvailable;
	iPhone.SetALSLine(requestStatus, alsLine);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

	// check test results
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrNone, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLineNotAvailable); //check
	AssertMockLtsyStatusL();

 	//-------------------------------------------------------------------------
	// TEST E: Unsolicited completion of RMobilePhone::SetALSLine
	// from LTSY.
 	//-------------------------------------------------------------------------

	iMockLTSY.NotifyTerminated(requestStatus);	
	iMockLTSY.CompleteL(EMobilePhoneSetALSLine, KErrNone);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();

 	//-------------------------------------------------------------------------
	// TEST A: failure to dispatch request to LTSY
 	//-------------------------------------------------------------------------

	// setting environment (set KCtsyMEAlsSupported in repository to ETrue)
	ret = centRep->Set( KCtsyMEAlsSupported, ETrue );
	ASSERT_EQUALS(KErrNone, ret);

	// test setting and execute
	data.Close();
	alsLineData.SerialiseL(data); // serialise data here because alsLine variable is changed
	iMockLTSY.ExpectL(EMobilePhoneSetALSLine, data, KErrNotSupported);
	iPhone.SetALSLine(requestStatus, alsLine);

	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNotSupported, requestStatus.Int());
	AssertMockLtsyStatusL();

	// Done !
	// return repository KCtsyMEAlsSupported to EFalse (initial state)
	ret = centRep->Set( KCtsyMEAlsSupported, EFalse );
	ASSERT_EQUALS(KErrNone, ret);

	AssertMockLtsyStatusL();
	CleanupStack::PopAndDestroy(1); // iCentRep
	CleanupStack::PopAndDestroy(2, this); // data, this
	
	}
コード例 #8
0
//
// Performes the test by connecting to MLFW  
// (and makes a number of Location requests if aFullTest is true
//
void DoTestL(TBool aFullTest, TInt aNumberOfRuns, TInt *aResult)
    {
    RPositionServer	posServer;
	TInt errorCode = errorCode = posServer.Connect();

    if (errorCode != KErrNone)
        {
        *aResult = KErrCouldNotConnect;
        return;
        }
    CleanupClosePushL(posServer);

    RPositioner positioner;


    // Full test means requesting position updates
    if (aFullTest)
        {
        TPositionInfo positionInfo = TPositionInfo();
        const TInt32 KUidMultiPsy = 0x01010176;
        TUid uidMultiPsy;
        uidMultiPsy.iUid = KUidMultiPsy;
        errorCode = positioner.Open(posServer, uidMultiPsy);
        
        if (errorCode != KErrNone) 
        {
            *aResult = errorCode;
            return;
        }
        CleanupClosePushL(positioner);
        
        _LIT(KService ,"Service");
        errorCode = positioner.SetRequestor(CRequestor::ERequestorService,
            CRequestor::EFormatApplication, KService);
        
        if (errorCode != KErrNone)
        {
            *aResult = 1001;
            return;
        }
        
        TRequestStatus status;
        TLocality loca(TCoordinate(0,0,0),0);
        TPosition pos(loca, TTime(0));

        for (TInt i = 0; i < aNumberOfRuns; i++)
        {
            positionInfo.SetPosition(pos);
            positioner.NotifyPositionUpdate(positionInfo, status);
            User::WaitForRequest(status);
            TInt err = status.Int();
            if (err != KErrNone)
            {
                *aResult = err;
            }
            TPosition result;
            positionInfo.GetPosition(result);
            
            //sanity check
            if (result.Latitude() == pos.Latitude() ||
                result.Longitude() == pos.Longitude() ||
                result.Altitude() == pos.Altitude())
            {
                //_LIT(KErrorPositon, "ERROR:: The postion was not updated");
                errorCode = 1005;
            }   
        }
        positioner.Close();
        CleanupStack::PopAndDestroy(&positioner);
    }
    
    posServer.Close();
    CleanupStack::PopAndDestroy(&posServer);
    }
コード例 #9
0
TVerdict CTestStepSDevSoundClientThreadNoCap::DoTestStepL( void )
{
    INFO_PRINTF1( _L("CTestStepSDevSoundClientThreadNoCap : DevSoundMP"));
    iVerdict = EFail;

    iServerMonitor = CServerMonitor::NewL(this);

    RTestServ server;
    User::LeaveIfError(server.Connect(_L("SDSCapTestServer")));
    CleanupClosePushL(server);

    RTestSession session2;
    User::LeaveIfError(session2.Open(server,_L("SecDevSndTS0036")));
    CleanupClosePushL(session2);
    TRequestStatus status2 = KRequestPending;
    session2.StartProcessing(status2);
    User::WaitForRequest(status2);
    TPckgBuf<TThreadId> serverTid;
    session2.EndProcessingAndReturnResult(serverTid);
    iServerTid = serverTid();

    RTestServ mmddServer;
    User::LeaveIfError(mmddServer.Connect(_L("SDSMMDDTestServer")));
    CleanupClosePushL(mmddServer);
    RTestSession session1;
    User::LeaveIfError(session1.Open(mmddServer,_L("SecDevSndTS0036")));
    CleanupClosePushL(session1);

    TInt err = DoPlaySimpleTone();
    if (err == KErrNone)
    {
        if (iAttemptInitialCI)
        {
            // assume DoPlaySimpleTone() terminated early prior to InitializeL()
            iVerdict = EPass;
        }
        else
        {
            // Start playing simple tone in this thread
            TRequestStatus status = KRequestPending;
            session1.StartProcessing(status);
            iAL->InitialiseActiveListener();
            CActiveScheduler::Start();
            // Simple tone in this thread finished, wait until the
            // simple tone playing in the other thread to finish
            User::WaitForRequest(status);
            iServerResult = status.Int();

            // Verify the results from both threads
            iVerdict = DoVerifyResult();
            TBuf8<256> message;
            session1.EndProcessingAndReturnResult(message);
        }
    }
    else
    {
        iVerdict = EInconclusive;
    }
    CleanupStack::PopAndDestroy(4, &server);	// session1, mmddServer, session2, server
    return iVerdict;
}
コード例 #10
0
ファイル: t_fsched.cpp プロジェクト: kuailexs/symbiandump-os1
/** Client dying uncleanly before the operation is finished

*/
void TestClientDies()
{
	TInt r = 0;


	TBuf<20> drive = _L("?:\\");
	TVolumeInfo volInfo;
	drive[0]=(TText)(gDrive+'A');
	
	r = TheFs.CheckDisk(drive);
	TEST(r == KErrNone || r == KErrNotSupported);

	// Sync test
	TBuf<20> buf = _L("Big Write V");
	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
	TEST(r == KErrNone);
	
	TRequestStatus status;
	gBig.Logon(status);
	gBig.Resume();
	gSync.Wait();

	// Kill the writing thread and wait for it to die.
	
    if(status.Int() == KRequestPending)
		{// the people who wrote this test did not consider the case when the file write finishes before they try to kill the thread.
		gBig.Kill(KErrGeneral);
		User::WaitForRequest(status);
		TEST(gBig.ExitReason() == KErrGeneral);
		TEST(gBig.ExitType() == EExitKill);
		}

    
    // Make sure the thread is destroyed and the handles it owned and IPCs
    // it executed are closed/cancelled.
    CLOSE_AND_WAIT(gBig);


	r = TheFs.Volume(volInfo, gDrive);
	TESTERROR(r);

	r = TheFs.CheckDisk(drive);
	TEST(r == KErrNone || r == KErrNotSupported);

	r = TheFs.ScanDrive(drive);
	TEST(r == KErrNone || r == KErrNotSupported);

	test.Printf(_L("Sync operation stopped\n"));
	
	// Async test 
	buf = _L("Big Write VI");
	r = gSmall.Create(buf, WriteBigFileAsync, KDefaultStackSize * 2, KHeapSize, KMaxHeapSize, NULL);
	TEST(r == KErrNone);
	
	gSmall.Logon(status);
	gSmall.Resume();
	gSync.Wait();
	
    
    if(status.Int() == KRequestPending)
		{
		// Kill the writing thread and wait for it to die.
		gSmall.Kill(KErrGeneral);
		User::WaitForRequest(status);
		TEST(gSmall.ExitReason() == KErrGeneral);
		TEST(gSmall.ExitType() == EExitKill);
		}


    // Make sure the thread is destroyed and the handles it owned and IPCs
    // it executed are closed/cancelled.
    CLOSE_AND_WAIT(gSmall);

	r = TheFs.CheckDisk(drive);
	TEST(r == KErrNone || r == KErrNotSupported);
	
	r=TheFs.ScanDrive(drive);
	TEST(r == KErrNone || r == KErrNotSupported);
	
	test.Printf(_L("Async operation stopped\n"));
}
コード例 #11
0
TVerdict CPsyVisibleStep::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.
 */
	{
    StandardPrepareL();
    InitPsySettingsL(3, KNetworkPsy1, 1, KIntGpsPsy1, 1, KNetworkPsy2, 1);

    ConfigPsyL(KIntGpsPsy1, 3, 
        KConfigLRNoError5s,        //Step 1. no error in 5s
        KConfigLRErrGeneral1s,     //Step 2. error in 1s
        KConfigLRErrGeneral1s      //Step 3. error in 1s
        );

    User::After(KSecond*7);

    TRequestStatus status;
    TPositionInfo posInfo;
    TPositionUpdateOptions options;
    
    ToggleModuleVisibleL(KNetworkPsy1, EFalse);
    //1. Set PSY1 visible shall not affect location request
    SET_TIME
    iPositioner.NotifyPositionUpdate(posInfo, status);
    User::After(KTinyDelay);
    ToggleModuleVisibleL(KNetworkPsy1, ETrue);
    User::WaitForRequest(status);
    CHECK_TIME(5)
    CheckExpectedResult(status.Int(), KErrNone, KFailedPositionRequest);
    CheckExpectedResult(posInfo.ModuleId(), KIntGpsPsy1, KWrongModuleIdReturned);
    

    ToggleModuleVisibleL(KNetworkPsy2, EFalse);

    
    ConfigPsyL(KNetworkPsy1, 2,
        KConfigLRNoError35s,      //Step2. no error in 35s
        KConfigLRErrNoMemory      //Step 3. error in 1s
        );

    User::After(KSecond*7);

    //2. Set PSY3 visible during fallback shall has no effect 
    SET_TIME
    iPositioner.NotifyPositionUpdate(posInfo, status);
    User::After(KSecond*5);
    ToggleModuleVisibleL(KNetworkPsy2, ETrue);
    User::WaitForRequest(status);
    CHECK_TIME(35)  //PSY1 response time
    CheckExpectedResult(status.Int(), KErrNone, KFailedPositionRequest);
    CheckExpectedResult(posInfo.ModuleId(), KNetworkPsy1, KWrongModuleIdReturned);
    
    //3. PSY3 shall be used in next LR
    SET_TIME
    iPositioner.NotifyPositionUpdate(posInfo, status);
    User::WaitForRequest(status);
    CheckExpectedResult(status.Int(), KErrNone, KFailedPositionRequest);
    CheckExpectedResult(posInfo.ModuleId(), KNetworkPsy2, KWrongModuleIdReturned);
    
    // cleanup
    StandardCleanup();
    return TestStepResult();
	}
コード例 #12
0
TVerdict CAppFwkStartSafeTestStepAppStartAppArcInit::doTestStepL( void )
	{
	
	CStartSafe* startSafe = CStartSafe::NewL();	
	CleanupStack::PushL( startSafe );
	
	CStartupProperties* prop = CStartupProperties::NewL();
	CleanupStack::PushL( prop );
	
	RProcess proc;
	CleanupClosePushL( proc );
	
	prop->SetFileParamsL( KTestAppGood, KNullDesC );
	prop->SetStartupType( EStartApp );
	prop->SetStartMethod( EDeferredWaitForStart );
	

	TRequestStatus startupTRS;
	TRequestStatus apparcSessionTRS;
	
	INFO_PRINTF1(_L("Starting the Test-App process asynchronously"));
	
	startSafe->StartL( *prop, proc, startupTRS );	

	User::WaitForRequest( startupTRS );
	INFO_PRINTF2( _L("Rendezvous completed with %d"), startupTRS.Int() );	
	
	// StartL should have left if it was unsuccessful, 
	// but ensure that the process's name is that of the test-app.
	TPtrC procNamePtr = proc.FileName().Right( KTestAppGood().Length() );
	TInt nameComparison = procNamePtr.Compare( KTestAppGood() );
	
	if( 0 == nameComparison )
		{
		INFO_PRINTF2( _L("Application \"%S\" started correctly"), &procNamePtr );	
		}
	else
		{
		ERR_PRINTF1( _L("Application-start unsuccessful. Test not completed") );
		
		SetTestStepResult( EFail );
		return TestStepResult();
		}
	
	startSafe->InitAppArcServer( apparcSessionTRS ); // try to initiate apparc, to see if that causes any problems
	User::WaitForRequest( apparcSessionTRS );
	

	if ( ( startupTRS == KErrNone) && ( apparcSessionTRS == KErrNone) )
		{
		SetTestStepResult( EPass );
		INFO_PRINTF1( _L("Test passed") );
		// Dispose of the test-app
		proc.Kill( KErrNone );		
		}
	else
		{
		SetTestStepResult( EFail );
		ERR_PRINTF3( _L("Test failed.startupTRS = %d apparcSessionTRS = %d "), startupTRS.Int(), apparcSessionTRS.Int() );				
		}
	
		
	CleanupStack::PopAndDestroy( 3, startSafe );

	return TestStepResult();	
	}
コード例 #13
0
ファイル: smspbear.cpp プロジェクト: cdaffara/symbiandump-os1
/**
 *  Notifies if SMS bearer is set to the TSY. Start setting bearer
 *  process if bearer is not set.
 */
void CSmspSetBearer::NotifyBearerSet(TRequestStatus& aStatus)
	{
	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPSETBEARER_NOTIFYBEARERSET_1, "CSmspSetBearer::NotifyBearerSet, aStatus = %d", aStatus.Int());
	if (!iBearerSet && IsActive())
		{
		Cancel();
		}

	Queue(aStatus);

	if (iBearerSet)
		{
		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPSETBEARER_NOTIFYBEARERSET_2, "CSmspSetBearer::NotifyBearerSet RequestComplete called");
		CSmsuActiveBase::Complete(KErrNone);
		}
	else
		{
		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPSETBEARER_NOTIFYBEARERSET_3, "CSmspSetBearer::NotifyBearerSet started");
		Start();
		}
	} // CSmspSetBearer::NotifyBearerSet
コード例 #14
0
void CAppfwkAmaStarterTestStepCancel::TestCase1L()
	{
	// Launch the appropriate AMAStarter(s) via CAmaStart::StartL()
	
	TRequestStatus myRequestStatus;

	CAmaStart* amaStart = CAmaStart::NewL();
	CleanupStack::PushL(amaStart);
	
	amaStart->Start(TUid::Uid(0x10000017), myRequestStatus);
	TEST(myRequestStatus == KRequestPending);
	User::After(100000); // Wait for a tenth of a second to give the starter a chance to start something - if the cancel is issued without waiting, nothing is started.
	amaStart->CancelStart();	
	User::WaitForRequest(myRequestStatus);
	TEST(myRequestStatus == KErrCancel);
	INFO_PRINTF3(_L("CAmaStart->Start(TUid::Uid(0x10000017), &myRequestStatus) finished with request status '%d' (expected '%d')"), myRequestStatus.Int(), KErrCancel);
	
	//Check that the last item in the DSC didn't run
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	RFileReadStream rs;
	TInt ret = rs.Open(fs, KLogFileName, EFileShareExclusive|EFileRead);
	if (KErrNone != ret)
		{
		ERR_PRINTF2(_L("Could not open log file. Leave code: '%d'"), ret);
		User::LeaveIfError(ret);
		}
	rs.PushL();
	const TInt KMaxCommandLength = 256;
	TBuf<KMaxCommandLength> commandLine;
	rs.ReadL(commandLine,1);
	TEST(commandLine.Compare(_L("9")) != 0);
	INFO_PRINTF2(_L("Checking log result: Expected not '9', Actual '%s'"), &commandLine);
	CleanupStack::PopAndDestroy(); //rs
	
	ret = fs.Delete(KLogFileName);
	if (KErrNone != ret)
		{
		ERR_PRINTF2(_L("Could not delete log file. Leave code: '%d'"), ret);
		User::LeaveIfError(ret);
		}

	// clean-up
	CleanupStack::PopAndDestroy(2,amaStart); // fs, amaStart
	}
コード例 #15
0
TVerdict CTestDevVideoPlayClock::DoTestStepL()
	{
	TVerdict ret = EPass;
	TTimeIntervalMicroSeconds testTime(0);
	TUint timeUint = 0;

	iClockSource = CSystemClockSource::NewL();

	// Construct a new thread to constantly probe the clock - to test that it'll work from multiple threads
	RThread thread;
	
	TInt error = thread.Create(_L("ClockSourceTestThread"), 
								&CTestDevVideoPlayClock::StartThread,
								KDefaultStackSize, 
								&User::Heap(),
								static_cast<TAny*>(this), 
								EOwnerThread);

	if (error)
		{
		ERR_PRINTF1(_L("Error - Couldn't create periodic utility object"));
		delete iClockSource;
		return EInconclusive;
		}

	TRequestStatus stat;
	thread.Logon(stat);
	if (stat!=KRequestPending)
		{
		delete iClockSource;
		ERR_PRINTF2(_L("Error - Couldn't logon to the thread err=%d"), stat.Int());
		thread.LogonCancel(stat);
		User::WaitForRequest(stat);
		return EInconclusive;
		}
	thread.SetPriority(EPriorityLess);

	// wait for system to calm down
	User::After(KTestClock2Seconds);

	// reset the clock
	iClockSource->Reset();

	thread.Resume();

	// wait for 2 seconds and then check the time == 2 seconds
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock2Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock2Seconds);
		ret = EFail;
		}
	else 
		{
		INFO_PRINTF3(_L("Time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock2Seconds);
		}

	// reset the clock back to 2 seconds
	//testTime = KTestClock2Seconds;
	//iClockSource->Reset(testTime);

	// suspend timer for 2 seconds then resume for 2 seconds
	iClockSource->Suspend();
	User::After(KTestClock2Seconds);
	iClockSource->Resume();
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock4Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Suspend() + Resume() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock4Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Suspend() + Resume() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock4Seconds);
		}

	// reset clock to 18 seconds
	testTime = KTestClock18Seconds;
	iClockSource->Reset(testTime);

	// wait for 2 seconds and then check the time == 20 seconds
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock20Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Reset() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock20Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Reset() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock20Seconds);
		}

	// suspend for 2 seconds then resume for 2 seconds
	iClockSource->Suspend();
	User::After(KTestClock2Seconds);
	iClockSource->Resume();
	User::After(KTestClock2Seconds);
	
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock22Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Suspend() + Resume() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock22Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Suspend() + Resume() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock22Seconds);
		}

	// Now test the periodic utility
	TRAPD(perError, iPeriodicUtility = CMMFClockSourcePeriodicUtility::NewL(*iClockSource, *this));
	if (perError)
		{
		ERR_PRINTF1(_L("Error - Couldn't create periodic utility object"));
		ret = EInconclusive;
		}
	else
		{
		iPeriodicUtilityTestVerdict = EPass;
		TTimeIntervalMicroSeconds32 period = KTestClock2Seconds;
		iClockSource->Reset();
		iPeriodicUtility->Start(period);
		CActiveScheduler::Start();
		ret = iPeriodicUtilityTestVerdict;
		}
	delete iPeriodicUtility;
	iPeriodicUtility = NULL;

	// Clean up the thread
	iShutdownSubthread = ETrue;
	User::WaitForRequest(stat);
	thread.Close();

	delete iClockSource;

	return ret;
	}
コード例 #16
0
enum TVerdict CEsockTest10_1::easyTestStepL()
	{
	TESTL(EPass == TestStepResult());
	TPckgBuf<TUint> flags;
	
	// get select state of server socket
	TRequestStatus stat;
	flags() = KSockSelectRead | KSockSelectWrite | KSockSelectExcept;
	iEsockSuite->GetSocketHandle(iSockIndex3).Ioctl(KIOctlSelect, stat, &flags, KSOLSocket);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);
	TESTL(flags()==KSockSelectWrite);
	
	// send data from client to server (2 bytes, 1 urgent)
	TInt ret = iEsockSuite->GetSocketHandle(iSockIndex2).SetOpt(KSoTcpNextSendUrgentData, KSolInetTcp, 1);
	TESTEL(KErrNone == ret, ret);
	iEsockSuite->GetSocketHandle(iSockIndex2).Write(_L8("12"), stat);
	User::WaitForRequest(stat);
	TESTEL(stat==KErrNone, stat.Int());
	
	// delay for 1 second
	User::After(1000000);
	
	// get select state of the server socket
	flags() = KSockSelectRead | KSockSelectWrite | KSockSelectExcept;
	iEsockSuite->GetSocketHandle(iSockIndex3).Ioctl(KIOctlSelect, stat, &flags, KSOLSocket);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);
	TESTL(flags()==(KSockSelectRead | KSockSelectWrite | KSockSelectExcept));
	
	// read data (server)
	TBuf8<20> rbuf2;
	iEsockSuite->GetSocketHandle(iSockIndex3).Read(rbuf2, stat);
	User::WaitForRequest(stat);
	TESTEL(stat==KErrUrgentData, stat.Int());
	
	// get select state of the server socket
	flags() = KSockSelectRead | KSockSelectWrite | KSockSelectExcept;
	iEsockSuite->GetSocketHandle(iSockIndex3).Ioctl(KIOctlSelect, stat, &flags, KSOLSocket);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);
	
	TESTL(flags()==(KSockSelectWrite | KSockSelectExcept));
	
	// read the urgent data byte
	TInt nRet;
	ret = iEsockSuite->GetSocketHandle(iSockIndex3).GetOpt(KSoTcpReadUrgentData, KSolInetTcp, nRet);
	TESTEL(KErrNone == ret, ret);
	TESTL(nRet=='2');
	ret = iEsockSuite->GetSocketHandle(iSockIndex3).GetOpt(KSoTcpReadUrgentData, KSolInetTcp, nRet);
	TESTEL(KErrNotFound == ret, ret);
	
	// get select state of the server socket
	flags() = KSockSelectRead | KSockSelectWrite | KSockSelectExcept;
	iEsockSuite->GetSocketHandle(iSockIndex3).Ioctl(KIOctlSelect, stat, &flags, KSOLSocket);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);
	TESTL(flags()==KSockSelectWrite);
	
	return EPass;
	}
コード例 #17
0
TInt CSenBaseIdentityManager::AuthenticationForL(
                            CSenIdentityProvider& aProvider, 
                            TPckgBuf<TSenAuthentication>& aResponse)
    {
    TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CSenBaseIdentityManager::AuthenticationForL");

    TPtrC8 user = aProvider.AuthzID();
    if (user == KNullDesC8)
        {
        user.Set(aProvider.AdvisoryAuthnID());
        }


    if (!iShowPasswordDialog)
        {
        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"Not allowed to show password dialog");
        HBufC8* pDecodedPassword = SenXmlUtils::DecodeHttpCharactersLC(aProvider.Password());
        TPtrC8 decodedPassword = pDecodedPassword->Des();

        aResponse().iUsername.Append((const TUint8*)user.Ptr(), user.Size());
        aResponse().iPassword.Append((const TUint8*)decodedPassword.Ptr(), 
                                        decodedPassword.Size());
        CleanupStack::PopAndDestroy(); // delete pDecodedPassword
        return KErrNone;
        }


    RNotifier notifier;
    User::LeaveIfError(notifier.Connect());
    CleanupClosePushL(notifier);

    TPckgBuf<TAuthenticationDlgRequest>* request = 
                            new(ELeave)TPckgBuf<TAuthenticationDlgRequest>();
    CleanupStack::PushL(request);

    // convert username to unicode
    HBufC* pUserAsUnicode = SenXmlUtils::ToUnicodeLC(user); // push
    TPtrC username = pUserAsUnicode->Des();

    // decode password
    HBufC8* pDecodedPassword = SenXmlUtils::DecodeHttpCharactersLC(aProvider.Password());
    TPtrC8 decodedPassword = pDecodedPassword->Des();
    // convert decoded password to unicode
    HBufC* pPasswordAsUnicode = 
                SenXmlUtils::ToUnicodeLC(decodedPassword); // push
    TPtrC password = pPasswordAsUnicode->Des();

    // set data to request
    (*request)().SetData(username, password);

    CleanupStack::PopAndDestroy(3); // delete pPasswordAsUnicode, pDecodedPassword, pUserAsUnicode


    TPckgBuf<TAuthenticationDlgResponse>* response = 
                        new(ELeave)TPckgBuf<TAuthenticationDlgResponse>();
    CleanupStack::PushL(response);

    TRequestStatus reqStatus;
    notifier.StartNotifierAndGetResponse(reqStatus, 
                            KSenNotifierPluginUID, *request, *response);

    TBool illegalUsername = EFalse;

    HBufC8* pUsernameUtf8 = NULL;
    HBufC8* pPasswordUtf8 = NULL;
    User::WaitForRequest(reqStatus);

    notifier.Close();

    if(reqStatus.Int() == KErrNone)
        {
        if((*response)().OkButtonPressed())
            {
            TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("User pressed OK Button in Password dialog")));
            pUsernameUtf8 = SenXmlUtils::ToUtf8LC((*response)().Username());
            pPasswordUtf8 = SenXmlUtils::ToUtf8LC((*response)().Password());
            TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("Username: %S"), pUsernameUtf8));
            TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("Password: %S"), pPasswordUtf8 ));
            HBufC8* pEncodedUsername = NULL;
            illegalUsername = 
                SenXmlUtils::EncodeHttpCharactersL(*pUsernameUtf8,
                                                    pEncodedUsername);
            if (illegalUsername) 
                {
                TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("Username included illegal characters.")));
                delete pEncodedUsername;
                pEncodedUsername = NULL;
                }
#ifdef _SENDEBUG
            else
                {
                TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"Username did NOT include illegal characters.");
                }
#endif
       		
       		//Check if iilegal chars are there then return
            if (!illegalUsername)
                {
                
                if(user != *pUsernameUtf8)
                {
                	
	                // User modified the username in the dialog prompt(!)
	                // We have to save it right away, because there is
	                // no in-memory/session based member variables in
	                // components calling identity manager (sec mechs and
	                // in ID-WSF AS client!
	                TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"Username changed. Saving new username.");

	                // Use Advisory only if AuthzID is not available
	                if (aProvider.AuthzID() == KNullDesC8 
	                    && aProvider.AdvisoryAuthnID() != KNullDesC8)
	                    {
	                    aProvider.SetUserInfoL(aProvider.AuthzID(),
	                                            *pUsernameUtf8, 
	                                            aProvider.Password());
	                    }
	                else 
	                    {
	                    // There was at least AuthzID available, and possibly
	                    // also advisory value. Any way, if 

	                    
	                    // We have to NULL advisory value (set it to KNullDesC8), 
	                    // because if both were available, then user was
	                    // prompted to allow modification of AuthzID AND 
	                    // if advisory was changed in service (is no longer
	                    // valid), there would NOT be any way for end-user
	                    // to change (remove) it(!)

	                    CSenElement& element = aProvider.AsElement();
	                    delete element.RemoveElement(KSenIdpAdvisoryAuthnIdLocalname);

	                    aProvider.SetUserInfoL(*pUsernameUtf8, 
	                                            KNullDesC8,
	                                            aProvider.Password());
	                    }
	                // serialize changed username into sensessions.xml database immediately
	                WriteDatabase();
                }
                
	            if (AllowSavePasswordL())
	                {
	                HBufC8* pEncodedPassword = SenXmlUtils::EncodeHttpCharactersLC(*pPasswordUtf8);
#ifdef _SENDEBUG
                if(pEncodedPassword)
                    {
                    TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("Encoded password: %S"), pEncodedPassword));
                    }
#endif
					if(pEncodedPassword)
						{
							aProvider.SetUserInfoL(aProvider.AuthzID(),
	                                        aProvider.AdvisoryAuthnID(),
	                                        *pEncodedPassword);
						}
	                WriteDatabase();
	                CleanupStack::PopAndDestroy(1); // pEncodedPassword
	                }
                
                }

            aResponse().iUsername.Zero();
            aResponse().iPassword.Zero();
            if (!illegalUsername) 
            {
	            aResponse().iUsername.Copy(pUsernameUtf8->Des());
	            aResponse().iPassword.Copy(pPasswordUtf8->Des());
            }

            CleanupStack::PopAndDestroy(2); // pPasswordUtf8, pUsernameUtf8
            }
        else
            {
            TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("User pressed Cancel Button in Password dialog")));
            }
        }
    else if(reqStatus.Int() == KErrNotFound)
        {
        TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("Password dialog plugin notifier impl. was not found")));
        }
    else
        {
        TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8(" Notifier plugin for 'Password' dialog returned an error: %d"), 
                                                        reqStatus.Int()));
        }

    CleanupStack::PopAndDestroy(2); // request, response;
    CleanupStack::Pop(); // notifier

    if (illegalUsername) return KErrArgument;
    return reqStatus.Int();
    }
コード例 #18
0
// ---------------------------------------------------------
// 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();
    }
コード例 #19
0
COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater()
    {
    LOG((" +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater(%d)", iScreenNumber));
    if (iDisplayUpdater)
        {
        TDisplayViewSettings viewSettings;  // DEFAULT
        TBufferInfo bufferInfo; // DEFAULT
        TInt err = KErrNone;

        // Set to default view to release layer
        err = iDisplayUpdater->SetView(KTopMostLayer, viewSettings, bufferInfo);
        if (err != KErrNone)
            {
            LOG((" !!! COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater()ERROR: Display update set view failed %d", err));
            }

        TRequestStatus completedWhenReady = KRequestPending;
        LOG(("\n  +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() FLUSHING *******\n"));
        iDisplayUpdater->Flush(completedWhenReady);
        LOG(("\n  +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() AFTER FLUSHING ******* 2\n"));
        User::WaitForRequest(completedWhenReady);
        LOG(("\n  +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() FLUSHING:REQUEST COMPLETED %d*******\n", completedWhenReady.Int()));

        if (iCurrentSceneStream != SYMBIAN_INVALID_HANDLE && iCurrentReadBuffer != SYMBIAN_INVALID_HANDLE)
            {
            SymbianStreamReleaseReadBuffer(iCurrentSceneStream, iCurrentReadBuffer);
            }
        if (iNextSceneStream != SYMBIAN_INVALID_HANDLE && iNextReadBuffer != SYMBIAN_INVALID_HANDLE)
            {
            SymbianStreamReleaseReadBuffer(iNextSceneStream, iNextReadBuffer);
            }
        }
    delete iDisplayUpdater;
    iSurfaceManager.Close();
    LOG((" --- COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() completed"));    
    }
コード例 #20
0
 // ---------------------------------------------------------
// CPosTp154::PrintParsedDataFromEncoderL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp154::PrintParsedDataFromEncoderL(
    const TDesC& aFile, 
    const TDesC8&  aBuffer, 
    TInt aExpectedStatusCode,
    const TDesC8& aMimeType)
    {
    iLog->Log(_L("===== PrintParsedDataFromEncoderL ======="));
    
    iLandmarkParser = CPosLandmarkParser::NewL(aMimeType);

    if (aFile != KNullDesC)
        {
        TFileName file( aFile );
        iLog->Log(_L("FILE (%S)"), &file );
        TraceL(_L("----->Using FILE<-------"));
        TraceL(file);
        iLandmarkParser->SetInputFileL(file);
        }
    else
        {
        iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() );
        TraceL(_L("----->Using BUFFER<-------"));
        iLandmarkParser->SetInputBuffer(aBuffer);
        }

    iOperation = iLandmarkParser->ParseContentL();
    TRequestStatus status = KPosLmOperationNotComplete;
    TReal32 progress;
    TInt number = 0;

    RArray<TPosLmItemId> array;
    CleanupClosePushL(array);

    while (status == KPosLmOperationNotComplete)
        {
        iLog->Log(_L("--- Parsing ---------------------------"));
        TraceL(_L("------------------------------"));
        iOperation->NextStep(status, progress);

        // Wait for NextStep to complete
        User::WaitForRequest(status);
        if (status != KPosLmOperationNotComplete && status != KErrNone)
            {
            iLog->Log(_L("Parsing Complete"));
            
            HBufC* buffer = HBufC::NewLC( 128);
            TPtr buf = buffer->Des();
            buf.Format(_L("\tStatus %d"), status.Int());
            iLog->Log(buf);
            TraceL(buf);
            
            CleanupStack::PopAndDestroy( buffer );
            buffer = NULL;              
            }
        else
            {
            iLog->Log(_L("Parsing element"));
            if ( iLandmarkParser->NumOfParsedLandmarks() )
                {
                // Get last parsed landmark
                CPosLandmark* lm = iLandmarkParser->LandmarkLC();
                TPtrC lmName;
                TPtrC catName;
                lm->GetLandmarkName(lmName);
                lm->GetCategoriesL(array);
                //iLog->Log(lmName);
                for (TInt i=0;i<array.Count();i++)
                    {
                    CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC( array[i] );
                    category->GetCategoryName( catName );
                     
                    HBufC* buffer = HBufC::NewLC( 128 + catName.Length());
                    TPtr buf = buffer->Des();
                                            
                    if ( category->GlobalCategory()) 
                        {
                        buf.Append(_L("\tGlobal category: "));    
                        }
                    else 
                        {
                        buf.Append(_L("\tLocal category: "));    
                        }                        
                    buf.Append(catName);
                    iLog->Log(buf);
                    TraceL(buf);
                    CleanupStack::PopAndDestroy( buffer );
                    buffer = NULL;
                    CleanupStack::PopAndDestroy(category);
                    }
                    
               	PrintLandmarkFieldsWithDescriptionL(*lm, ETrue);	
               
                
                number++;
                CleanupStack::PopAndDestroy(lm);
                }
            }
        }

    iLog->Log(_L("--- Parsing end ---------------------------"));
    TraceL(_L("------------------------------"));
    CleanupStack::PopAndDestroy(&array);

    if (status.Int() != aExpectedStatusCode)
        {
        HBufC* buffer = HBufC::NewLC( 128 );
        TPtr buf = buffer->Des();
                    
        buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode);
        iLog->Log( buf );
        iErrorsFound++;
        
        CleanupStack::PopAndDestroy( buffer );
        buffer = NULL;        
        }

    TUint32 nr = iLandmarkParser->NumOfParsedLandmarks();
    HBufC* buffer = HBufC::NewLC( 256 );
    TPtr buf = buffer->Des();
    buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number);
    iLog->Log(buf);
    TraceL(buf);

    CleanupStack::PopAndDestroy( buffer );
    buffer = NULL;
    if (nr != (TUint32)number)
        {
        iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!"));
        iErrorsFound++;
        }

    TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId();

    iLog->Log(_L("--- CollectionData ---"));
    TraceL(_L("--- CollectionData ---"));

    if (lmId != EPosLmCollDataNone)
        {
        TPtrC first = iLandmarkParser->CollectionData(lmId);
        HBufC* buffer = HBufC::NewLC( first.Length() + 256 );
        TPtr buf = buffer->Des();
        buf.Zero();
        buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId);
        buf.Append(first);
        iLog->Log(buf);
        TraceL(buf);
        CleanupStack::PopAndDestroy( buffer );
        buffer = NULL;      
        }
    else 
        {
        iLog->Log(_L("\tNo collection data found 1"));    
        }

    while (lmId != EPosLmCollDataNone)
        {
        lmId = iLandmarkParser->NextCollectionDataId(lmId);
        if (lmId != EPosLmCollDataNone)
        {
            TPtrC first = iLandmarkParser->CollectionData(lmId);
            
            HBufC* buffer = HBufC::NewLC( first.Length() + 256 );
            TPtr buf = buffer->Des();         
            buf.Zero();
            buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId);
            buf.Append(first);
            iLog->Log(buf);
            TraceL(buf);
            
            CleanupStack::PopAndDestroy( buffer );
            buffer = NULL;              
            }
        else 
            {
            iLog->Log(_L("\tNo collection data found 2"));   
            }
        }

    iLog->Log(_L("--- CollectionData ---"));
    TraceL(_L("--- CollectionData ---"));

    delete iOperation;
    iOperation = NULL;
    delete iLandmarkParser;
    iLandmarkParser = NULL;
    iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n"));
    }
コード例 #21
0
/**
@SYMTestCaseID BA-CTSY-ALLS-MSL-0004
@SYMComponent  telephony_ctsy
@SYMTestCaseDesc Test support in CTSY for multiple client requests to RMobilePhone::SetALSLine
@SYMTestPriority High
@SYMTestActions Invokes multiple client requests to RMobilePhone::SetALSLine
@SYMTestExpectedResults Pass
@SYMTestType CT
*/
void CCTsyAlternateLineServiceFU::TestSetALSLine0004L()
	{

	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RBuf8 data;
	CleanupClosePushL(data);

	// Open second client
	RTelServer telServer2;
	TInt ret = telServer2.Connect();
	ASSERT_EQUALS(KErrNone, ret);
	CleanupClosePushL(telServer2);

	RMobilePhone phone2;
	ret = phone2.Open(telServer2,KMmTsyPhoneName);
	ASSERT_EQUALS(KErrNone, ret);
	CleanupClosePushL(phone2);

	// create centRep to change repository 
	CRepository* centRep = CRepository::NewL( KCRUidCtsyMEAlsLine );
	CleanupStack::PushL(centRep);

	// setting environment (set KCtsyMEAlsSupported in repository to ETrue)
	ret = centRep->Set( KCtsyMEAlsSupported, ETrue );
	ASSERT_EQUALS(KErrNone, ret);

	TRequestStatus requestStatus;
	TRequestStatus requestStatus2;

	//-------------------------------------------------------------------------
	// Test A: Test multiple clients requesting RMobilePhone::SetALSLine
 	//-------------------------------------------------------------------------

	// setting and execute 1st request
	RMobilePhone::TMobilePhoneALSLine alsLine(RMobilePhone::EAlternateLinePrimary);
	TMockLtsyData1< RMobilePhone::TMobilePhoneALSLine >
			alsLineData( alsLine );
	alsLineData.SerialiseL(data);
	iMockLTSY.ExpectL(EMobilePhoneSetALSLine, data);
	iMockLTSY.CompleteL(EMobilePhoneSetALSLine, KErrNone);
	iPhone.SetALSLine(requestStatus, alsLine);
	
	// setting and execute 2nd request
	RMobilePhone::TMobilePhoneALSLine alsLine2(RMobilePhone::EAlternateLineAuxiliary);
	phone2.SetALSLine(requestStatus2, alsLine2);
	
	// wait for completion and check results
	User::WaitForRequest(requestStatus2);
	ASSERT_EQUALS(KErrServerBusy, requestStatus2.Int());
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());

	AssertMockLtsyStatusL();

	// setting environment (set KCtsyMEAlsSupported in repository to ETrue)
	ret = centRep->Set( KCtsyMEAlsSupported, EFalse );
	ASSERT_EQUALS(KErrNone, ret);

	// setting and execute the test for the case when 
	// KCtsyMEAlsSupported in repository is set to ETrue
	alsLine = RMobilePhone::EAlternateLinePrimary;
	iPhone.SetALSLine(requestStatus, alsLine);
	
	alsLine2 = RMobilePhone::EAlternateLineAuxiliary;
	phone2.SetALSLine(requestStatus2, alsLine2);
	
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	User::WaitForRequest(requestStatus2);
	ASSERT_EQUALS(KErrNone, requestStatus2.Int());

	AssertMockLtsyStatusL();

	//Done!
	CleanupStack::PopAndDestroy(1); // iCentRep
	CleanupStack::PopAndDestroy(4, this); // phone2, telServer2, data, this

	}
コード例 #22
0
TInt CTestDriveRemoteHangupDial::DriveETelApiL()
/**
 * This method contains the real meat of the Client-side "Data Call answer and remote 
 * hang-up closely followed by a dial" test code.  This method sets up to answer a 
 * call and receive a data transfer.  The call is then terminated from the remote end, 
 * and then must quickly respond by dialing the remote end back.  Data is then 
 * transfered and the call is terminated again from the remote end.
 *
 * @return KErrNone.
 */
	{
	_LIT(KMmPhoneName,"GsmPhone1");
	_LIT(KDataLineName,"Data");

	INFO_PRINTF1(_L("Opening Mobile Phone\n"));
	RMobilePhone mmPhone;
	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);

	RLine line;
	INFO_PRINTF1(_L("Opening Data Line\n"));
	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);

	INFO_PRINTF1(_L("Opening New Data Call\n"));
	RCall call;
	TESTL(call.OpenNewCall(line)==KErrNone);

	TRequestStatus reqStatus;
	RMobilePhone::TMMTableSettings tableSettings;
	tableSettings.iLocId=KInternetAccessPoint;
	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
	User::WaitForRequest(reqStatus);
	TESTL(reqStatus == KErrNone);
//
// Initialization complete
//

// Now wait for an incoming call...
	INFO_PRINTF1(_L("Wait to Answer incoming Data Call\n"));
	TESTL(call.AnswerIncomingCall()==KErrNone);

	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
	RCall::TCommPort commPort;
	TESTL(call.LoanDataPort(commPort)==KErrNone);

	RCommServ cs;
	TESTL(cs.Connect()==KErrNone);

	RComm port;
	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);

	// Transfer data
	TRequestStatus stat;
	port.Write(stat,KWriteTestRemoteHangupData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);
    
   //-- a small delay between successive writes to the COM port
    //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
    User::After(500000);		

	port.Write(stat,KWriteTestRemoteHangupData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

	// Remote termination of call should have occurred in scripts, 
	// close port and comm server
	port.Close();
	cs.Close();
	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
	TESTL(call.RecoverDataPort()==KErrNone);

	// Now perform the user specified delay before making outgoing call...
	INFO_PRINTF2(_L("Start the %d sec delay before making outgoing call\n"), iVarDelay);
	User::After( (TTimeIntervalMicroSeconds32)(iVarDelay*1000000L) );
	INFO_PRINTF2(_L("End of the delay before making outgoing call\n"), iVarDelay);

	// Now perform the outgoing call...
	// dial
	_LIT(KDialString,"+1234");
	TESTL(call.Dial(KDialString)==KErrNone);

	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
	TESTL(call.LoanDataPort(commPort)==KErrNone);

	TESTL(cs.Connect()==KErrNone);

	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);

	// Transfer data
	port.Write(stat,KWriteTestRemoteHangupData2);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

    //-- a small delay between successive writes to the COM port
    //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
    User::After(500000);		

	port.Write(stat,KWriteTestRemoteHangupData2);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

	// Remote termination of call should have occurred in scripts, 
	// close port and comm server
	port.Close();
	cs.Close();
	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
	TESTL(call.RecoverDataPort()==KErrNone);

	TInt32 ss;
	TInt8 bar=0;
	mmPhone.GetSignalStrength(stat,ss,bar);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);

	// close iPhone, line and call
	mmPhone.Close();
	line.Close();
	call.Close();
	return KErrNone;
	}
コード例 #23
0
void CCTsyPrivacyFU::DoMultiNotifyPrivacyConfirmationL(const TDesC& aLineName)
	{
	//-------------------------------------------------------------------------
	// Test A: Test multiple clients requesting RMobileCall::NotifyPrivacyConfirmation
 	//-------------------------------------------------------------------------

	// Open first client					
	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RLine line1;
	TInt err = line1.Open(iPhone, aLineName);
	ASSERT_EQUALS(KErrNone, err)
    CleanupClosePushL(line1);
	
	RMobileCall mobileCall1;
	err = mobileCall1.OpenNewCall(line1);
	ASSERT_EQUALS(KErrNone, err)
    CleanupClosePushL(mobileCall1);

	// Open second client
	RTelServer telServer2;
	TInt ret = telServer2.Connect();
	ASSERT_EQUALS(KErrNone, ret);
	CleanupClosePushL(telServer2);

	RMobilePhone phone2;
	ret = phone2.Open(telServer2,KMmTsyPhoneName);
	ASSERT_EQUALS(KErrNone, ret);
	CleanupClosePushL(phone2);

	RLine line2;
	err = line2.Open(phone2, aLineName);
	ASSERT_EQUALS(KErrNone, err)
    CleanupClosePushL(line2);
	
	RMobileCall mobileCall2;
	err = mobileCall2.OpenNewCall(line2);
	ASSERT_EQUALS(KErrNone, err)
    CleanupClosePushL(mobileCall2);

	// initialize variables with values other than passed to MockLTSY
	RMobilePhone::TMobilePhonePrivacy privacy1 = RMobilePhone::EPrivacyOn;
	RMobilePhone::TMobilePhonePrivacy privacy2 = RMobilePhone::EPrivacyOff;

	// request notifications
	TRequestStatus notifyStatus1;
	TRequestStatus notifyStatus2;

	mobileCall1.NotifyPrivacyConfirmation(notifyStatus1,privacy1);
	mobileCall2.NotifyPrivacyConfirmation(notifyStatus2,privacy2);

	// trigger EMobileCallNotifyPrivacyConfirmation completion via MockLTSY 
	RMobilePhone::TMobilePhonePrivacy privacySetting = RMobilePhone::EPrivacyUnspecified;
	TMockLtsyCallData1<RMobilePhone::TMobilePhonePrivacy> privacySettingData(privacySetting);

	RBuf8 data;
	CleanupClosePushL(data);
	privacySettingData.SerialiseL(data);

	TRequestStatus mockLtsyStatus;
	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
	iMockLTSY.CompleteL(EMobileCallNotifyPrivacyConfirmation, KErrNone,data);
	User::WaitForRequest(mockLtsyStatus);
	CleanupStack::PopAndDestroy(1,&data); // data
	ASSERT_EQUALS(KErrNone,mockLtsyStatus.Int());

	
	// wait for both notifications
	User::WaitForRequest(notifyStatus1);
	ASSERT_EQUALS(KErrNone,notifyStatus1.Int());
    ASSERT_EQUALS(RMobilePhone::EPrivacyUnspecified, privacy1);

	User::WaitForRequest(notifyStatus2);
	ASSERT_EQUALS(KErrNone,notifyStatus2.Int());
    ASSERT_EQUALS(RMobilePhone::EPrivacyUnspecified, privacy2);

	// cleanup second client
	CleanupStack::PopAndDestroy(4,&telServer2); // mobileCall2, line2, phone2, telServer2

	AssertMockLtsyStatusL();
	
	// cleanup first client
	CleanupStack::PopAndDestroy(3, this); // mobileCall1, line1, this
	}
コード例 #24
0
TVerdict CPsyDisabledStep::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.
 */
	{
    StandardPrepareL();
    InitPsySettingsL(3, KNetworkPsy1, 1, KIntGpsPsy1, 1, KNetworkPsy2, 1);

    ConfigPsyL(KNetworkPsy1, 1,
        KConfigLRNoError10s      //Step1. no error in 10s
        );
        
    ConfigPsyL(KIntGpsPsy1, 2, 
        KConfigLRNoError,       //Step 1. no error
        KConfigLRNoError10s     //Step 2. no error in 10s
        );

    ConfigPsyL(KNetworkPsy2, 1,
        KConfigLRNoError         //Step2. no error
        );
    
    User::After(KSecond*7);

    TRequestStatus status;
    TPositionInfo posInfo;
    TPositionUpdateOptions options;
    
    //1. Disable PSY1 while location request is on going. LR shall 
    //fallback to PSY2 and then fix from PSY2 is used.
    iPositioner.NotifyPositionUpdate(posInfo, status);
    User::After(KTinyDelay);
    SET_TIME
    ToggleModuleL(KNetworkPsy1, EFalse);
    User::WaitForRequest(status);
    //CHECK_TIME(1)
    CheckExpectedResult(status.Int(), KErrNone, KFailedPositionRequest);
    CheckExpectedResult(posInfo.ModuleId(), KIntGpsPsy1, KWrongModuleIdReturned);
    
    ToggleModuleL(KNetworkPsy1, ETrue);
    //Config PSY1 again since it was unloaded when it was disabled.
    ConfigPsyL(KNetworkPsy1, 1,
        KConfigLRNoError20s      //Step2. no error in 20s
        );

    User::After(KSecond*7);
    
    //2. Disable PSY2 while location request ongoing, the request shall
    //fallbck to PSY3
    SET_TIME
    iPositioner.NotifyPositionUpdate(posInfo, status);
    User::After(KSecond*15); //after 15s disable PSY2
    ToggleModuleL(KIntGpsPsy1, EFalse);
    User::WaitForRequest(status);
    CHECK_TIME(16) //After PSY2 is disabled in 15 seconds, PSY3 is used. 
    CheckExpectedResult(status.Int(), KErrNone, KFailedPositionRequest);
    CheckExpectedResult(posInfo.ModuleId(), KNetworkPsy2, KWrongModuleIdReturned);
    
    
    // cleanup
    StandardCleanup();
    return TestStepResult();
	}
コード例 #25
0
ファイル: test.cpp プロジェクト: cdaffara/symbiandump-os1
enum TVerdict CZCDriverTestStep::doTestStepL()
	{
	CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler;
	CleanupStack::PushL(activeScheduler);
	CActiveScheduler::Install(activeScheduler);

	SetTestStepResult(EFail);

	// Start of testing
	INFO_PRINTF1(_L("Load Physical Device"));
	TInt r;
	r=User::LoadPhysicalDevice(KZeroCopyLoopbackPddFileName);
	TEST_VERDICT(r==KErrNone || r==KErrAlreadyExists);

	INFO_PRINTF1(_L("Load Logical Device"));
	r=User::LoadLogicalDevice(KZeroCopyLoopbackLddFileName);
	TEST_VERDICT(r==KErrNone || r==KErrAlreadyExists);

    // Initialize a commsbuf pond
    RCommsBufPondOp commsBufPond;
    RArray<TCommsBufPoolCreateInfo> createInfos;
    TCommsBufPoolCreateInfo poolInfoForLargeBufs;
    poolInfoForLargeBufs.iBufSize = KMBuf_MBufSizeBig;
    poolInfoForLargeBufs.iInitialBufs = KMBuf_InitialAllocation;
    poolInfoForLargeBufs.iGrowByBufs = KMBuf_MinGrowth;
    poolInfoForLargeBufs.iMinFreeBufs = KMBuf_GrowthThreshold;
    poolInfoForLargeBufs.iCeiling = (KMBuf_MaxAvail/2) / KMBuf_MBufSize;    
    createInfos.AppendL(poolInfoForLargeBufs);
    TCommsBufPoolCreateInfo poolInfoForSmallBufs;
    poolInfoForSmallBufs.iBufSize = KMBuf_MBufSize;
    poolInfoForSmallBufs.iInitialBufs = KMBuf_InitialAllocation;
    poolInfoForSmallBufs.iGrowByBufs = KMBuf_MinGrowth;
    poolInfoForSmallBufs.iMinFreeBufs = KMBuf_GrowthThreshold;
    poolInfoForSmallBufs.iCeiling = (KMBuf_MaxAvail/2) / KMBuf_MBufSize;
    createInfos.AppendL(poolInfoForSmallBufs);
	User::LeaveIfError(commsBufPond.Open(createInfos));
	createInfos.Close();
	
	__KHEAP_MARK;

	INFO_PRINTF1(_L("Open Device"));
	RDevice device;
	r=device.Open(RZeroCopyLoopbackDriver::Name());
	TEST_VERDICT(r==KErrNone);

	INFO_PRINTF1(_L("Get Device Capabilities"));
	RZeroCopyLoopbackDriver::TCaps caps;
	TPckg<RZeroCopyLoopbackDriver::TCaps>capsPckg(caps);
	capsPckg.FillZ(); // Zero 'caps' so we can tell if GetCaps has really filled it
	device.GetCaps(capsPckg);
	TVersion expectedVer(RZeroCopyLoopbackDriver::VersionRequired());
	TEST_VERDICT(caps.iVersion.iMajor==expectedVer.iMajor);
	TEST_VERDICT(caps.iVersion.iMinor==expectedVer.iMinor);
	TEST_VERDICT(caps.iVersion.iBuild==expectedVer.iBuild);

	INFO_PRINTF1(_L("Close Device"));
	device.Close();

	INFO_PRINTF1(_L("Open Logical Channel"));
	RZeroCopyLoopbackDriver ldd;
	r=ldd.Open();
	TEST_VERDICT(r==KErrNone);

	INFO_PRINTF1(_L("GetConfig"));
	RZeroCopyLoopbackDriver::TConfigBuf configBuf;
	configBuf.FillZ();   // Zero 'config' so we can tell if GetConfig has really filled it
	r=ldd.GetConfig(configBuf);
	TEST_VERDICT(r==KErrNone);

	RZeroCopyLoopbackDriver::TConfig& config=configBuf();
	TEST_VERDICT(config.iPddBufferSize!=0);
	TEST_VERDICT(config.iMaxSendDataSize!=0);
	TEST_VERDICT(config.iMaxReceiveDataSize!=0);

	INFO_PRINTF1(_L("SetConfig"));
	TInt speed = configBuf().iSpeed+1;
	configBuf().iSpeed = speed;
	r=ldd.SetConfig(configBuf); // Use SetConfig to change speed
	TEST_VERDICT(r==KErrNone);

	configBuf.FillZ();
	r=ldd.GetConfig(configBuf);
	TEST_VERDICT(r==KErrNone);
	TEST_VERDICT(configBuf().iSpeed==speed);
	TRequestStatus status;

	INFO_PRINTF1(_L("Check access by wrong client"));
	RZeroCopyLoopbackDriver ldd2=ldd;
	r=ldd2.Duplicate(RThread(),EOwnerProcess);
	TEST_VERDICT(r==KErrAccessDenied);

	INFO_PRINTF1(_L("Check handle duplication"));
	ldd2=ldd;
	r=ldd2.Duplicate(RThread(),EOwnerThread);
	TEST_VERDICT(r==KErrNone);
	ldd2.Close();

	INFO_PRINTF1(_L("Load pond"));
	r = ldd.LoadPond(commsBufPond);
	TEST_VERDICT(r == KErrNone);

	INFO_PRINTF1(_L("Unload pond"));
	r = ldd.UnloadPond();
	TEST_VERDICT(r == KErrNone);
	
	INFO_PRINTF1(_L("Reload pond"));
	r = ldd.LoadPond(commsBufPond);
	TEST_VERDICT(r == KErrNone);

	INFO_PRINTF1(_L("SendData"));
	TCommsBufAllocator allocator = commsBufPond.Allocator();
	RCommsBuf* buf = RCommsBuf::Alloc(KTestSendData().Length(), allocator);
	TEST_VERDICT(buf != NULL);
	buf->Reset();
	buf->Append(KTestSendData);
	ldd.SendData(status, *buf);
	User::WaitForRequest(status);
	r = status.Int();
	TEST_VERDICT(r == KErrNone);
	buf = NULL;

	INFO_PRINTF1(_L("SendData"));
	buf = RCommsBuf::Alloc(KTestSendData().Length(), allocator);
	TEST_VERDICT(buf != NULL);
	buf->Reset();
	buf->Append(KTestSendData);
	ldd.SendData(status, *buf);
	User::WaitForRequest(status);
	r=status.Int();
	TEST_VERDICT(r == KErrNone);
	buf = NULL;

	INFO_PRINTF1(_L("ReceiveData"));
	RCommsBuf* rxbuf;
	ldd.ReceiveData(status);
	User::WaitForRequest(status);
	r=status.Int();
	TEST_VERDICT(r > 0);
	rxbuf = commsBufPond.FromHandle(r);
	TEST_VERDICT(rxbuf != 0);
	TEST_VERDICT(rxbuf->Length() == KTestSendData().Size());
	TEST_VERDICT(rxbuf->DesC8() == KTestSendData);
	TBuf8<256> bufdata;
	rxbuf->Read(bufdata);
	TEST_VERDICT(bufdata == KTestSendData);
	rxbuf->Free();
	rxbuf = NULL;

	INFO_PRINTF1(_L("ReceiveData"));
	ldd.ReceiveData(status);
	User::WaitForRequest(status);
	r=status.Int();
	TEST_VERDICT(r > 0);
	rxbuf = commsBufPond.FromHandle(r);
	TEST_VERDICT(rxbuf != 0);
	TEST_VERDICT(rxbuf->Length() == KTestSendData().Size());
	TEST_VERDICT(rxbuf->DesC8() == KTestSendData);
	rxbuf->Read(bufdata);
	TEST_VERDICT(bufdata == KTestSendData);
	rxbuf->Free();
	rxbuf = NULL;

	INFO_PRINTF1(_L("ReceiveDataCancel"));
	ldd.ReceiveData(status);
	User::After(KOneSecond);
	ldd.ReceiveDataCancel();
	User::WaitForRequest(status);
	r=status.Int();
	TEST_VERDICT(r == KErrCancel);

#if 0
	INFO_PRINTF1(_L("SendDataCancel"));
	ldd.SendDataCancel();
	User::WaitForRequest(status);
	r=status.Int();
	TEST_VERDICT(r == KErrNone);
	buf = NULL;
#endif
	
	INFO_PRINTF1(_L("Unload pond"));
	r = ldd.UnloadPond();
	TEST_VERDICT(r == KErrNone);
	
	INFO_PRINTF1(_L("Close Logical Channel"));
	ldd.Close();

	__KHEAP_MARKEND;

	INFO_PRINTF1(_L("Unload Logical Device"));
	r=User::FreeLogicalDevice(RZeroCopyLoopbackDriver::Name());
	TEST_VERDICT(r==KErrNone);

	INFO_PRINTF1(_L("Unload Physical Device"));
	TName pddName(RZeroCopyLoopbackDriver::Name());
	_LIT(KVariantExtension,".template");
	pddName.Append(KVariantExtension);
	r=User::FreePhysicalDevice(pddName);
	TEST_VERDICT(r==KErrNone);

	// Close the pond
	commsBufPond.Close();
	
	// End of testing
	CleanupStack::PopAndDestroy(activeScheduler);
	
	SetTestStepResult(EPass);
	return TestStepResult();
	}
コード例 #26
0
TInt CNcmCommunicationInterface::WriteInterruptData(TInt aEndPoint,
        TDesC8& aDes,
        TInt aLength)

{
    OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_ENTRY, this );

    TInt ret;
    RTimer timer;
    ret = timer.CreateLocal();
    if ( ret )
    {
        OstTrace1( TRACE_FATAL, CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA, "\ttimer.CreateLocal = %d- returning", ret);
        OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT, this );
        return ret;
    }
    TRequestStatus status;
    TRequestStatus timerStatus;

    TEndpointBuffer epBuffer;
    ret = iPort.OpenEndpoint(epBuffer, aEndPoint);
    if (ret != KErrNone)
    {
        timer.Close();
        OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP1, this );
        return ret;
    }

    TAny *buf;
    TUint size;
    ret = epBuffer.GetInBufferRange(buf, size);
    if (ret != KErrNone)
    {
        timer.Close();
        OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP2, this );
        return ret;
    }
    else if (size < aLength)
    {
        timer.Close();
        OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP3, this );
        return KErrArgument;
    }

    TPtr8 writeBuf((TUint8 *)buf, size);
    writeBuf.Copy(aDes.Ptr(), aLength);
    ret = epBuffer.WriteBuffer(buf, writeBuf.Size(), ETrue, status);
    if (ret != KErrNone)
    {
        timer.Close();
        OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP4, this );
        return ret;
    }

    const TInt KWriteDataTimeout = 1000000;
    timer.After(timerStatus, KWriteDataTimeout);
    User::WaitForRequest(status, timerStatus);
    if ( timerStatus != KRequestPending )
    {
        // Timeout occurred, silently ignore error condition.
        // Assuming that the line has been disconnected
        OstTrace0( TRACE_ERROR, CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA1, "CNcmCommunicationInterface::WriteInterruptData() - Timeout occurred");
        iPort.WriteCancel(epBuffer.BufferNumber());
        User::WaitForRequest(status);
        ret = timerStatus.Int();
    }
    else
    {
        OstTrace0( TRACE_ERROR, CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA2, "CNcmCommunicationInterface::WriteInterruptData() - Write completed");
        timer.Cancel();
        User::WaitForRequest(timerStatus);
        ret = status.Int();
    }

    epBuffer.Close();
    timer.Close();
    OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP5, this );
    return ret;
}
コード例 #27
0
enum TVerdict CEsockTest29_10::easyTestStepL( void )
	{
	SetTestStepResult(EFail);
	TInt ret;
	const TUint KOneSecond = 1000000;
	
	Logger().WriteFormat(_L("Send/ Recv on PDummy3 socket but no avail MBuf Memory, mBuf becomes avail after send"));
	RSocketServ ss;
	ret = ss.Connect();
	TESTL(KErrNone == ret);	
    
    // open dummy prot 3
	Logger().WriteFormat(_L("Openning Dummy Protocol 3"));             
	RSocket sock;                                                  
	ret = sock.Open(ss,_L("Dummy Protocol 3"));
	TESTL(KErrNone == ret);
	
	// connect socket
	TSockAddr addr;
	TRequestStatus connStat;
	sock.Connect(addr, connStat);
	User::WaitForRequest(connStat);
	TESTL(KErrNone == connStat.Int());
	
	// send packet 1
	TRequestStatus stat;
	Logger().WriteFormat(_L("Attempting to create a packet to receive later"));	
	_LIT8(sendDataOne, "First Send");
	sock.Send(sendDataOne,0,stat);
	User::WaitForRequest(stat);
	TESTL(KErrNone == stat.Int());	
	// wait for packets to go through esock
	User::After(KOneSecond * 2);
	// gobble mBufs
	TInt nFree = 0;
	sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
	while (nFree > 0)
		{
		ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
		sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
		}
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
	
	// we are running in high priority and allocating in a loop.
	// so kernel may not be able to enlarge the pools.
	// wait for kernel to enlarge the pool
	// We have to come out from the loop as well.
    User::After(KOneSecond * 2);
	
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }

	
	// send packet 2
	User::After(KOneSecond);
	TRequestStatus stat2;
	_LIT8(sendDataTwo, "Second Send");
	Logger().WriteFormat(_L("Sending Data - Should never complete"));             
	sock.Send(sendDataTwo,0,stat2);

	User::After(KOneSecond);
	Logger().WriteFormat(_L("Now cancel the Send"));     
	sock.CancelSend();
	User::WaitForRequest(stat2);
	TESTL(stat2 == KErrCancel);
	
	Logger().WriteFormat(_L("Receiving Data -- expected to pick up sendDataOne"));
	TBuf8<100> buf;          
	TRequestStatus stat3;
	sock.Recv(buf, 0, stat3);
	User::After(KOneSecond);
	User::WaitForRequest(stat3);
	TESTL(buf.Compare(sendDataOne) == 0);
		
	// send packet 3
	_LIT8(sendDataThree, "Third Send");
	Logger().WriteFormat(_L("Sending Data ... again"));             
	TRequestStatus stat4;
	sock.Send(sendDataThree,0,stat4);
	User::After(1000);
			
	// free memory
	Logger().WriteFormat(_L("Now free memory - should get send and receive completion"));	
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetFreeMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetFreeMBufs, 0, 0);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);
	TESTL(KErrNone == ret);	

	Logger().WriteFormat(_L("Sending Data - Should now complete"));             
	User::WaitForRequest(stat4);
	TESTL(stat4.Int() == KErrNone);

	// recieve data and compare contents to sent data
	Logger().WriteFormat(_L("Receiving Data"));
	sock.Recv(buf, 0, stat);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Recv has returned %d"), stat.Int());
	TBuf<100> buf16;
	buf16.Copy(buf);
	if(buf.Compare(sendDataThree) == 0)
		{
		SetTestStepResult(EPass);
		}
		
	Logger().WriteFormat(_L("Data Recv'ed is '%S'"), &buf16);
	sock.Close();
	ss.Close();
	return TestStepResult();
	}
コード例 #28
0
// ---------------------------------------------------------------------------
// CTestStartupListUpdater::RemoveL()
// ---------------------------------------------------------------------------
//
TInt CTestStartupListUpdater::RemoveL( CStifItemParser& aItem )
    {
    _LIT( KTestName, "Remove" );
    Print( 0, KTestStartFormat, &KTestName );
    TInt testResult = KErrNone;

    RSoftwareComponentRegistry registry;
    User::LeaveIfError( registry.Connect() );
    CleanupClosePushL( registry );

    // Get installed application TComponentIds and TUids
    RArray<TUid> uidList;
    CleanupClosePushL( uidList );
    RArray<TComponentId> componentIdList;
    CleanupClosePushL( componentIdList );

    registry.GetComponentIdsL( componentIdList );
    for( TInt i = 0; i < componentIdList.Count(); ++i ) {
        TComponentId compId = componentIdList[ i ];
        CComponentEntry *compEntry = CComponentEntry::NewLC();
        if( registry.GetComponentL( compId, *compEntry ) ) {
            if( compEntry->IsRemovable() && compEntry->SoftwareType() == KSoftwareTypeNative )
                {
                _LIT(KCompUid, "CompUid");
                CPropertyEntry *property = registry.GetComponentPropertyL( compId, KCompUid );
                CleanupStack::PushL( property );
                CIntPropertyEntry* intProperty = dynamic_cast<CIntPropertyEntry*>( property );
                uidList.AppendL( TUid::Uid( intProperty->IntValue() ) );
                CleanupStack::PopAndDestroy( property );
            } else {
                uidList.AppendL( KNullUid );
            }

        }
        CleanupStack::PopAndDestroy( compEntry );
    }
    if( uidList.Count() != componentIdList.Count() )
        {
        _LIT( KFailedToGetIds, "Failed to get IDs" );
        Print( 0, KTestStartFormat, &KFailedToGetIds );
        testResult = KErrGeneral;
        }

    // Uninstall TUid apps listed in parameters
    TPtrC param;
    while( aItem.GetNextString ( param ) == KErrNone && testResult == KErrNone )
        {
        const TUint KMaxLimit = 0xFFFFFFFF;
        TLex lex( param );
        TUint32 intVal = 0;

        _LIT( KHexPrefix, "0x" );
        if( param.Left( KHexPrefix().Length() ) == KHexPrefix )
            {
            lex.Inc( KHexPrefix().Length() );
            testResult = lex.BoundedVal( intVal, EHex, KMaxLimit );
            }
        else
            {
            testResult = lex.BoundedVal( intVal, EDecimal, KMaxLimit );
            }

        if( testResult == KErrNone )
            {
            TUid uid( TUid::Uid( intVal ) );
            if( uid != KNullUid )
                {
                TInt index = uidList.Find( uid );
                if( index >= 0 && index < componentIdList.Count() )
                    {
                    TComponentId componentId = componentIdList[ index ];

                    RSoftwareInstall installer;
                    User::LeaveIfError( installer.Connect() );
                    CleanupClosePushL( installer );

                    TRequestStatus status;
                    installer.Uninstall( componentId, status );
                    User::WaitForRequest( status );
                    testResult = status.Int();

                    CleanupStack::PopAndDestroy( &installer );
                    }
                else
                    {
                    testResult = KErrNotFound;
                    }
                }
            else
                {
                testResult = KErrUnknown;
                }
            }
        Print( 1, KTestParamFormatArg, &KTestName, &param, testResult );
        }

    CleanupStack::PopAndDestroy( 3, &registry );    // componentIdList, uidList, registry
    Print( 0, KTestDoneFormat, &KTestName );
    return testResult;
    }
コード例 #29
0
TVerdict CEsockTest29::easyTestStepL()
	{

	// Open Sockets, one to manipulate mBufPool and one to send/revieve with tcp or udp
	TESTL( OpenSockets() == KErrNone );

	// Bind Test Socket To local Address
	TInetAddr local;
	SetPort( local, KPort, KLocal );
	iTestSocket.Bind( local );
	
	// Connect Test Socket to LoopBack Address
	TInetAddr loopBack;
	SetPort( loopBack, KPort, KLoopback );
	ConnectSocketL( iTestSocket, loopBack );
	
	// Gobble all the Buf's in the MBuf Pool return the number of mBufs in Use
	TInt totalUsedBufs = iDummySocket.SetOpt( KDummyOptionSetGobbleMBufs, 0, 0 );
	TInt bufsToBeFreed = 0;
	
	// Data to be used during socket Send
	GetIntFromConfig(KSection29, KBufSize, iBufSize);
	TBool keepSending = ETrue;
	TBuf8<4500> recvBuf;
	TBuf8<4500> sendData;
	sendData.Fill(TChar('z'), iBufSize );
	TRequestStatus sendStatus;
	TRequestStatus recvStatus;
	const TInt KOneSecond = 1000000;
	
	
	
	for( TInt freeBufCounter = 0; freeBufCounter < totalUsedBufs && keepSending; freeBufCounter += bufsToBeFreed )
	// OOB loop that will gradually release more MBufs
		{
		
		// release some mBufs and send
		iDummySocket.SetOpt( KDummyOptionSetFreeSomeMBufs, bufsToBeFreed , 0);
		iTestSocket.Send( sendData, 0, sendStatus );
		
		// Wait for a second to allow time for server/protocol to send
		User::After( KOneSecond );
		
		// Cancel the send and start to recv
		iTestSocket.CancelSend();
		User::WaitForRequest(sendStatus);
		
		iTestSocket.Recv(recvBuf, 0, recvStatus);
		
		// Wait for a second to allow time for server/protocol to recieve
		User::After( KOneSecond );
		iTestSocket.CancelRecv();
		User::WaitForRequest( recvStatus );
		
		if( freeBufCounter % 5 == 0 )
			{
			INFO_PRINTF2( _L("freeBufs now >= %d "),  freeBufCounter );
			}
		
		if( recvBuf.Compare(sendData) == 0 )
		// if we have recieved data then exit the loop
			{
			keepSending = EFalse;
			}
			
		bufsToBeFreed = 2;
		
		}
	
	// Now do a regular send for good measure to make sure everything is ok
	sendData.Fill(TChar('c'), iBufSize );
	INFO_PRINTF1( _L("End of Loop, Now sending....") );
	iTestSocket.Send( sendData, 0, sendStatus );
	User::WaitForRequest( sendStatus );
	INFO_PRINTF2( _L("Send Returned %d, now recieving...."), sendStatus.Int() );
	iTestSocket.Recv( recvBuf, 0, recvStatus );
	User::After( KOneSecond ); 
	iTestSocket.CancelRecv();
	User::WaitForRequest( recvStatus );
	
	INFO_PRINTF2( _L("Recieve returned %d ") , recvStatus.Int() );
	if( recvBuf.Compare(sendData) != 0 )
		{
		return EFail;
		}
	
	return EPass;
	
	}
コード例 #30
0
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void MenuStatesTest::HsUninstallItemState_getApplicationsNames()
{
#ifdef UT_MEMORY_CHECK
    __UHEAP_MARK;
#endif//UT_MEMORY_CHECK
    {

        static const char javaUid[] = "270437153";   //in DS_Snow

        Usif::RSoftwareInstall sif;
        CleanupClosePushL( sif );
        User::LeaveIfError( sif.Connect() );

        // Install the component
        _LIT16( KDsSnowJadPath, "c:\\testing\\data\\t_hsmenuworkerstateplugin\\installs\\DS_Snow.jad" );
        Usif::COpaqueNamedParams* arguments = NULL;
        Usif::COpaqueNamedParams* results = NULL;
        arguments = Usif::COpaqueNamedParams::NewLC();
        results = Usif::COpaqueNamedParams::NewLC();
        arguments->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
        TRequestStatus status;
        sif.Install( KDsSnowJadPath, *arguments, *results, status, EFalse );
        User::WaitForRequest( status );
        User::LeaveIfError( status.Int() );

        CleanupStack::PopAndDestroy( results );
        CleanupStack::PopAndDestroy( arguments );

        // Disconnect from the SIF server
        CleanupStack::PopAndDestroy( &sif );


        QSharedPointer<CaService> service = CaService::instance();
        CaQuery query;
        query.setAttribute(Hs::applicationUidEntryKey, javaUid);
        QList< QSharedPointer<CaEntry> > entries = service->getEntries(query);
        QCOMPARE(entries.length(), 1);
        QSharedPointer<CaEntry> entry = entries[0];

        HsUninstallItemState state;

        QVariantMap params;
        params.insert(Hs::itemIdKey, entry->id());

        QEvent *e = new HsMenuEvent(HsMenuEvent::UninstallApplication, params);
        state.onEntry( e );

        QCOMPARE(state.mEntry->id(), entry->id());


        QString componentName;
        QStringList appNames;
        QString confirmationMessage;

        bool result = state.getApplicationsNames(componentName,
            appNames, confirmationMessage);
        QVERIFY(result);
        QCOMPARE(componentName, QString("DS_Snow"));
        QCOMPARE(appNames.length(), 0); //in DS_Snow

        const QString remove("remove");
        service->executeCommand(entry->id(), remove);

        state.cleanUp();
        QVERIFY(state.mEntry.isNull());
    }
#ifdef UT_MEMORY_CHECK
    __UHEAP_MARKEND;
#endif//UT_MEMORY_CHECK
}