telephonyserverplugins/common_tsy/test/component/src/cctsycallcontrolfu.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 17 3f227a47ad75
child 66 07a122eea281
--- a/telephonyserverplugins/common_tsy/test/component/src/cctsycallcontrolfu.cpp	Thu Aug 19 11:03:36 2010 +0300
+++ b/telephonyserverplugins/common_tsy/test/component/src/cctsycallcontrolfu.cpp	Tue Aug 31 16:23:08 2010 +0300
@@ -114,6 +114,12 @@
 	ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateAllCalls0002L);
 	ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateAllCalls0004L);
 	ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateAllCalls0005L);	
+    ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateActiveCalls0001L);
+    ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateActiveCalls0001bL);
+    ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateActiveCalls0001cL);
+    ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateActiveCalls0002L);
+    ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateActiveCalls0004L);
+    ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestTerminateActiveCalls0005L);  
 	ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestSetIncomingCallType0001L);
 	ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestAnswerIncomingCallISV0001L);
 	ADD_TEST_STEP_ISO_CPP(CCTsyCallControlFU, TestAnswerIncomingCallISV0002L);
@@ -2065,6 +2071,11 @@
     callParams0.iInterval = callParams.iInterval;
     callParams0.iWaitForDialTone = callParams.iWaitForDialTone; 
     RCall::TCallParamsPckg   pckgCallParams0(callParams0);
+    // We should expect the appropriate Alpha ID and Icon ID
+    callInfo.iValid |= (RMobileCall::KCallAlphaId | RMobileCall::KCallIconId);    
+    callInfo.iAlphaId.Copy(_L("Alpha Id"));
+    callInfo.iIconId.iQualifier = RMobileCall::ESelfExplanatory;
+    callInfo.iIconId.iIdentifier = 0x0A;
 
     expectData.Close();
     TMockLtsyCallData2< RMobileCall::TMobileCallParamsV7, RMobileCall::TMobileCallInfoV8 >
@@ -9973,7 +9984,7 @@
 	TRequestStatus requestStatus;
     
 	//-----------------------------------------------------------------------
-	// TEST 0: with no active calls (request should not reach the LTSY)
+	// TEST 0: with no active calls 
 	//----------------------------------------------------------------------
 	
 	iPhone.TerminateAllCalls(requestStatus);
@@ -10277,6 +10288,426 @@
 	CleanupStack::PopAndDestroy(4, this); // call, line, expectData, this
 	}
 
+/**
+@SYMTestCaseID BA-CTSY-CCON-MTACTC-0001
+@SYMComponent  telephony_ctsy
+@SYMTestCaseDesc Test support in CTSY for RMobilePhone::TerminateActiveCalls  When the call status is EStatusHold
+@SYMTestPriority High
+@SYMTestActions Invokes RMobilePhone::TerminateActiveCalls
+@SYMTestExpectedResults Pass
+@SYMTestType CT
+*/
+void CCTsyCallControlFU::TestTerminateActiveCalls0001L()
+    {
+    OpenEtelServerL(EUseExtendedError);
+    CleanupStack::PushL(TCleanupItem(Cleanup,this));
+    OpenPhoneL();
+
+    RBuf8 expectData;
+    CleanupClosePushL(expectData); // PUSH
+    
+    TRequestStatus requestStatus;
+    
+    //-----------------------------------------------------------------------
+    // TEST 0: with no active calls 
+    //----------------------------------------------------------------------
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq,KErrNone);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone);
+    iPhone.TerminateActiveCalls(requestStatus);
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrNone, requestStatus.Int());
+    AssertMockLtsyStatusL();
+    
+    //-------------------------------------------------------------------------
+    // TEST A: failure to dispatch request to LTSY
+    //-------------------------------------------------------------------------
+
+    // open new line and call for KMmTsyVoice1LineName
+    RLine line;
+    RCall call;
+    TInt errorCode = OpenNewLineLC(iPhone, line, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    // create new incoming call
+    TName incomingCallName;
+    TInt callId = 1;
+    errorCode = CreateIncomingCallL(line, callId, incomingCallName, 
+            RMobilePhone::EVoiceService, RMobileCall::EStatusHold);   
+    
+    ASSERT_EQUALS(KErrNone, errorCode);
+        
+    CleanupClosePushL(call); // PUSH
+    errorCode = call.OpenExistingCall(line, incomingCallName);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    //-------------------------------------------------------------------------
+
+    TMockLtsyData1<TInt> mockData(callId);
+    mockData.SerialiseL(expectData);
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq, expectData, KErrNotSupported);
+    iPhone.TerminateActiveCalls(requestStatus);
+
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrNotSupported, requestStatus.Int());
+    AssertMockLtsyStatusL();
+
+    
+    
+    //-------------------------------------------------------------------------
+    // TEST B: failure on completion of pending request from LTSY->CTSY
+    //-------------------------------------------------------------------------
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq, expectData);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrGeneral);
+
+    iPhone.TerminateActiveCalls(requestStatus);
+
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrGeneral, requestStatus.Int());
+    AssertMockLtsyStatusL();
+    
+    //-------------------------------------------------------------------------
+    // TEST C: Successful completion request of
+    // RMobilePhone::TerminateActiveCalls.
+    //-------------------------------------------------------------------------
+    
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq, expectData);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone);
+    
+    iPhone.TerminateActiveCalls(requestStatus);
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrNone, requestStatus.Int());
+    AssertMockLtsyStatusL();
+    
+    //-------------------------------------------------------------------------
+    // TEST E: Unsolicited completion of RMobilePhone::TerminateActiveCalls
+    // from LTSY.
+    //-------------------------------------------------------------------------
+
+    TRequestStatus mockLtsyStatus;
+    iMockLTSY.NotifyTerminated(mockLtsyStatus);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone);
+    User::WaitForRequest(mockLtsyStatus);
+    ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
+    AssertMockLtsyStatusL();
+        
+    CleanupStack::PopAndDestroy(4, this); // call, line, expectData, this
+    }
+
+
+/**
+@SYMTestCaseID BA-CTSY-CCON-MTACTC-000B1
+@SYMComponent  telephony_ctsy
+@SYMTestCaseDesc Test support in CTSY for RMobilePhone::TerminateActiveCalls When the call status is EStatusRinging
+@SYMTestPriority High
+@SYMTestActions Invokes RMobilePhone::TerminateActiveCalls
+@SYMTestExpectedResults Pass
+@SYMTestType CT
+*/
+void CCTsyCallControlFU::TestTerminateActiveCalls0001bL()
+    {
+    OpenEtelServerL(EUseExtendedError);
+    CleanupStack::PushL(TCleanupItem(Cleanup,this));
+    OpenPhoneL();
+
+    RBuf8 expectData;
+    CleanupClosePushL(expectData); // PUSH
+        
+    TRequestStatus requestStatus;
+    // open new line and call for KMmTsyVoice1LineName
+    RLine line;
+    RCall call;
+    TInt errorCode = OpenNewLineLC(iPhone, line, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    // create new incoming call
+    TName incomingCallName;
+    TInt callId = 1;
+    errorCode = CreateIncomingCallL(line, callId, incomingCallName, 
+    RMobilePhone::EVoiceService, RMobileCall::EStatusRinging);   
+        
+    ASSERT_EQUALS(KErrNone, errorCode);
+    CleanupClosePushL(call); // PUSH
+    errorCode = call.OpenExistingCall(line, incomingCallName);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq,KErrNone);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone);
+    iPhone.TerminateActiveCalls(requestStatus);
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrNone, requestStatus.Int());
+    AssertMockLtsyStatusL();
+        
+    CleanupStack::PopAndDestroy(4, this); // call, line, expectData, this
+    }
+    
+/**
+@SYMTestCaseID BA-CTSY-CCON-MTACTC-000C1
+@SYMComponent  telephony_ctsy
+@SYMTestCaseDesc Test support in CTSY for RMobilePhone::TerminateActiveCalls When the call status is EStatusConnecting
+@SYMTestPriority High
+@SYMTestActions Invokes RMobilePhone::TerminateActiveCalls
+@SYMTestExpectedResults Pass
+@SYMTestType CT
+*/
+void CCTsyCallControlFU::TestTerminateActiveCalls0001cL()
+    {
+    OpenEtelServerL(EUseExtendedError);
+    CleanupStack::PushL(TCleanupItem(Cleanup,this));
+    OpenPhoneL();
+
+    RBuf8 expectData;
+    CleanupClosePushL(expectData); // PUSH
+        
+    TRequestStatus requestStatus;
+    // open new line and call for KMmTsyVoice1LineName
+    RLine line;    
+    TInt errorCode = OpenNewLineLC(iPhone, line, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    // create new incoming call
+    TName incomingCallName;
+    TInt callId = 1;
+    errorCode = CreateIncomingCallL(line, callId, incomingCallName, 
+                RMobilePhone::EVoiceService, RMobileCall::EStatusConnecting);   
+        
+    ASSERT_EQUALS(KErrNone, errorCode);
+    RCall call;    
+    CleanupClosePushL(call); // PUSH
+    errorCode = call.OpenExistingCall(line, incomingCallName);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq,KErrNone);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone);
+    iPhone.TerminateActiveCalls(requestStatus);
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrNone, requestStatus.Int());
+    AssertMockLtsyStatusL();
+        
+    CleanupStack::PopAndDestroy(4, this); // call, line, expectData, this
+    }
+
+
+
+/**
+@SYMTestCaseID BA-CTSY-CCON-MTACTC-0002
+@SYMComponent  telephony_ctsy
+@SYMTestCaseDesc Test support in CTSY for cancelling RMobilePhone::TerminateActiveCalls
+@SYMTestPriority High
+@SYMTestActions Invokes RMobilePhone::TerminateActiveCalls and cancels it
+@SYMTestExpectedResults Pass
+@SYMTestType CT
+*/
+void CCTsyCallControlFU::TestTerminateActiveCalls0002L()
+    {
+    OpenEtelServerL(EUseExtendedError);
+    CleanupStack::PushL(TCleanupItem(Cleanup,this));
+    OpenPhoneL();
+    
+    RBuf8 expectData;
+    CleanupClosePushL(expectData); // PUSH
+    
+    //-------------------------------------------------------------------------
+    
+    // open new line and call for KMmTsyVoice1LineName
+    RLine line;
+    RCall call;
+    TInt errorCode = OpenNewLineLC(iPhone, line, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    // create new incoming call
+    TName incomingCallName;
+    TInt callId = 1;
+    errorCode = CreateIncomingCallL(line, callId, incomingCallName, 
+            RMobilePhone::EVoiceService, RMobileCall::EStatusHold);   
+    
+    ASSERT_EQUALS(KErrNone, errorCode);
+        
+    CleanupClosePushL(call); // PUSH
+    errorCode = call.OpenExistingCall(line, incomingCallName);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    //-------------------------------------------------------------------------
+    
+    //-------------------------------------------------------------------------
+    // Test A: cancelling of RMobilePhone::TerminateActiveCalls
+    //-------------------------------------------------------------------------
+
+    TMockLtsyData1<TInt> mockData(callId);
+    mockData.SerialiseL(expectData);
+    
+    TRequestStatus mockLtsyStatus;
+    iMockLTSY.NotifyTerminated(mockLtsyStatus);
+        
+    // Expect call down to LTSY for this IPC
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq, expectData);
+
+    // Queue response to be delayed to give time for cancel to come through
+    // There is no interface for cancelling the simple TerminateActiveCalls request once passed to LTSY, 
+    // however this test will still emulate the completion of the request which will finally return from LTSY regardless.
+    
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone, 10);
+
+    TRequestStatus requestStatus;
+    iPhone.TerminateActiveCalls(requestStatus);
+    iPhone.CancelAsyncRequest(EMobilePhoneTerminateActiveCalls);
+    User::WaitForRequest(requestStatus);
+    INFO_PRINTF2(_L("requestStatus.Int() %d"),(requestStatus.Int()));
+    ASSERT_EQUALS(KErrNone, requestStatus.Int());
+    
+    AssertMockLtsyStatusL();
+    
+    User::WaitForRequest(mockLtsyStatus);
+    INFO_PRINTF2(_L("mockLtsyStatus.Int() %d"),(mockLtsyStatus.Int()));
+    
+    AssertMockLtsyStatusL();
+    
+    CleanupStack::PopAndDestroy(4, this); // call, line, expectData, this
+    }
+
+/**
+@SYMTestCaseID BA-CTSY-CCON-MTACTC-0004
+@SYMComponent  telephony_ctsy
+@SYMTestCaseDesc Test support in CTSY for multiple client requests of RMobilePhone::TerminateActiveCalls
+@SYMTestPriority High
+@SYMTestActions Invokes RMobilePhone::TerminateActiveCalls on multiple clients
+@SYMTestExpectedResults Pass
+@SYMTestType CT
+*/
+void CCTsyCallControlFU::TestTerminateActiveCalls0004L()
+    {
+
+    OpenEtelServerL(EUseExtendedError);
+    CleanupStack::PushL(TCleanupItem(Cleanup,this));
+    OpenPhoneL();
+        
+    // Open second client
+    RTelServer telServer2;
+    TInt ret = telServer2.Connect();
+    ASSERT_EQUALS(KErrNone, ret);
+    CleanupClosePushL(telServer2);
+
+    RMobilePhone phone2;
+    ret = phone2.Open(iTelServer,KMmTsyPhoneName);
+    ASSERT_EQUALS(KErrNone, ret);
+    CleanupClosePushL(phone2);
+
+    //
+    // set up line and call for first client
+    
+    RLine line;
+    RCall call;
+    TInt errorCode = OpenNewLineLC(iPhone, line, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    // create new incoming call
+    TName incomingCallName;
+    TInt callId = 1;
+    errorCode = CreateIncomingCallL(line, callId, incomingCallName, 
+            RMobilePhone::EVoiceService, RMobileCall::EStatusHold);   
+    
+    ASSERT_EQUALS(KErrNone, errorCode);
+        
+    CleanupClosePushL(call); // PUSH
+    errorCode = call.OpenExistingCall(line, incomingCallName);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    
+    //
+    // set up call for second client
+    
+    RLine line2;
+    RCall call2;
+    errorCode = OpenNewLineLC(phone2, line2, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    // create new incoming call
+    TName incomingCallName2;
+    TInt callId2 = 2;
+    errorCode = CreateIncomingCallL(line2, callId2, incomingCallName2, 
+            RMobilePhone::EVoiceService, RMobileCall::EStatusHold);   
+    
+    ASSERT_EQUALS(KErrNone, errorCode);
+        
+    CleanupClosePushL(call2); // PUSH
+    errorCode = call2.OpenExistingCall(line2, incomingCallName2);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    
+    // let's start testing...
+    
+    RBuf8 expectData;
+    CleanupClosePushL(expectData); // PUSH
+    TMockLtsyData1<TInt> mockData(callId);
+    mockData.SerialiseL(expectData);
+    
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq, expectData);
+    iMockLTSY.CompleteL(ECtsyPhoneTerminateActiveCallsComp, KErrNone, 20);
+    TRequestStatus requestStatus;
+    TRequestStatus requestStatus2;
+    iPhone.TerminateActiveCalls(requestStatus);
+    phone2.TerminateActiveCalls(requestStatus2);
+    
+    User::WaitForRequest(requestStatus);
+    ASSERT_EQUALS(KErrNone, requestStatus.Int());
+    
+    User::WaitForRequest(requestStatus2);
+    ASSERT_EQUALS(KErrServerBusy, requestStatus2.Int());
+    
+    AssertMockLtsyStatusL();
+    
+    CleanupStack::PopAndDestroy(8, this);   // expectData,
+                                            // call2, line2, call, line,
+                                            // phone2, telServer2, this
+    }
+
+/**
+@SYMTestCaseID BA-CTSY-CCON-MTACTC-0005
+@SYMComponent  telephony_ctsy
+@SYMTestCaseDesc Test support in CTSY for RMobilePhone::TerminateActiveCalls with timeout.
+@SYMTestPriority High
+@SYMTestActions Invokes RMobilePhone::TerminateActiveCalls and tests for timeout.
+@SYMTestExpectedResults Pass
+@SYMTestType CT
+*/
+void CCTsyCallControlFU::TestTerminateActiveCalls0005L()
+    {
+    OpenEtelServerL(EUseExtendedError);
+    CleanupStack::PushL(TCleanupItem(Cleanup,this));
+    OpenPhoneL();
+
+    RBuf8 expectData;
+    CleanupClosePushL(expectData); // PUSH
+   
+    
+    // open new line and call for KMmTsyVoice1LineName
+    RLine line;
+    RCall call;
+    TInt errorCode = OpenNewLineLC(iPhone, line, KMmTsyVoice1LineName); // PUSH
+    ASSERT_EQUALS(KErrNone, errorCode);
+
+    
+    // create new incoming call
+    TName incomingCallName;
+    TInt callId = 1;
+    errorCode = CreateIncomingCallL(line, callId, incomingCallName, 
+            RMobilePhone::EVoiceService, RMobileCall::EStatusHold);   
+    
+    ASSERT_EQUALS(KErrNone, errorCode);
+        
+    CleanupClosePushL(call); // PUSH
+    errorCode = call.OpenExistingCall(line, incomingCallName);
+    ASSERT_EQUALS(KErrNone, errorCode);
+    //-------------------------------------------------------------------------
+
+    TMockLtsyData1<TInt> mockData(callId);
+    mockData.SerialiseL(expectData);    
+    //-------------------------------------------------------------------------
+    // Test A: Test timeout of RMobilePhone::TerminateActiveCalls
+    //-------------------------------------------------------------------------
+    
+    TRequestStatus requestStatus;
+    iMockLTSY.ExpectL(ECtsyPhoneTerminateActiveCallsReq, expectData);
+    iPhone.TerminateActiveCalls(requestStatus);
+    User::WaitForRequest(requestStatus);
+    AssertMockLtsyStatusL();
+    ASSERT_EQUALS(KErrTimedOut, requestStatus.Int());
+
+    CleanupStack::PopAndDestroy(4, this); // call, line, expectData, this
+    }
 
 /**
 @SYMTestCaseID BA-CTSY-CCON-MSICT-0001