Chromium Code Reviews| Index: talk/app/webrtc/webrtcsession_unittest.cc |
| diff --git a/talk/app/webrtc/webrtcsession_unittest.cc b/talk/app/webrtc/webrtcsession_unittest.cc |
| index 2853ca43a7301b5e28b202f60041f35784342bb2..62ee7b2f2e503031d7b2adff4934252469d0b1d9 100644 |
| --- a/talk/app/webrtc/webrtcsession_unittest.cc |
| +++ b/talk/app/webrtc/webrtcsession_unittest.cc |
| @@ -68,7 +68,6 @@ |
| return; \ |
| } |
| -using cricket::BaseSession; |
| using cricket::DF_PLAY; |
| using cricket::DF_SEND; |
| using cricket::FakeVoiceMediaChannel; |
| @@ -88,6 +87,7 @@ using webrtc::JsepSessionDescription; |
| using webrtc::PeerConnectionFactoryInterface; |
| using webrtc::PeerConnectionInterface; |
| using webrtc::SessionDescriptionInterface; |
| +using webrtc::SessionStats; |
| using webrtc::StreamCollection; |
| using webrtc::WebRtcSession; |
| using webrtc::kBundleWithoutRtcpMux; |
| @@ -758,7 +758,7 @@ class WebRtcSessionTest |
| session_->MaybeStartGathering(); |
| } |
| void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, |
| - BaseSession::State expected_state) { |
| + WebRtcSession::State expected_state) { |
| SetLocalDescriptionWithoutError(desc); |
| EXPECT_EQ(expected_state, session_->state()); |
| } |
| @@ -786,7 +786,7 @@ class WebRtcSessionTest |
| EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); |
| } |
| void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, |
| - BaseSession::State expected_state) { |
| + WebRtcSession::State expected_state) { |
| SetRemoteDescriptionWithoutError(desc); |
| EXPECT_EQ(expected_state, session_->state()); |
| } |
| @@ -1834,8 +1834,8 @@ TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { |
| SessionDescriptionInterface* offer = CreateOffer(); |
| SetLocalDescriptionWithoutError(offer); |
| offer = CreateOffer(); |
| - SetRemoteDescriptionOfferExpectError( |
| - "Called in wrong state: STATE_SENTINITIATE", offer); |
| + SetRemoteDescriptionOfferExpectError("Called in wrong state: STATE_SENTOFFER", |
| + offer); |
| } |
| TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { |
| @@ -1845,44 +1845,44 @@ TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { |
| SetRemoteDescriptionWithoutError(offer); |
| offer = CreateOffer(); |
| SetLocalDescriptionOfferExpectError( |
| - "Called in wrong state: STATE_RECEIVEDINITIATE", offer); |
| + "Called in wrong state: STATE_RECEIVEDOFFER", offer); |
| } |
| TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { |
| Init(); |
| mediastream_signaling_.SendNothing(); |
| SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| - SetRemoteDescriptionExpectState(offer, BaseSession::STATE_RECEIVEDINITIATE); |
| + SetRemoteDescriptionExpectState(offer, WebRtcSession::STATE_RECEIVEDOFFER); |
| JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( |
| CreateAnswer(NULL)); |
| pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| - SetLocalDescriptionExpectState(pranswer, BaseSession::STATE_SENTPRACCEPT); |
| + SetLocalDescriptionExpectState(pranswer, WebRtcSession::STATE_SENTPRANSWER); |
| mediastream_signaling_.SendAudioVideoStream1(); |
| JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( |
| CreateAnswer(NULL)); |
| pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| - SetLocalDescriptionExpectState(pranswer2, BaseSession::STATE_SENTPRACCEPT); |
| + SetLocalDescriptionExpectState(pranswer2, WebRtcSession::STATE_SENTPRANSWER); |
| mediastream_signaling_.SendAudioVideoStream2(); |
| SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| - SetLocalDescriptionExpectState(answer, BaseSession::STATE_SENTACCEPT); |
| + SetLocalDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); |
| } |
| TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { |
| Init(); |
| mediastream_signaling_.SendNothing(); |
| SessionDescriptionInterface* offer = CreateOffer(); |
| - SetLocalDescriptionExpectState(offer, BaseSession::STATE_SENTINITIATE); |
| + SetLocalDescriptionExpectState(offer, WebRtcSession::STATE_SENTOFFER); |
| JsepSessionDescription* pranswer = |
| CreateRemoteAnswer(session_->local_description()); |
| pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| SetRemoteDescriptionExpectState(pranswer, |
| - BaseSession::STATE_RECEIVEDPRACCEPT); |
| + WebRtcSession::STATE_RECEIVEDPRANSWER); |
| mediastream_signaling_.SendAudioVideoStream1(); |
| JsepSessionDescription* pranswer2 = |
| @@ -1890,12 +1890,12 @@ TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { |
| pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| SetRemoteDescriptionExpectState(pranswer2, |
| - BaseSession::STATE_RECEIVEDPRACCEPT); |
| + WebRtcSession::STATE_RECEIVEDPRANSWER); |
| mediastream_signaling_.SendAudioVideoStream2(); |
| SessionDescriptionInterface* answer = |
| CreateRemoteAnswer(session_->local_description()); |
| - SetRemoteDescriptionExpectState(answer, BaseSession::STATE_RECEIVEDACCEPT); |
| + SetRemoteDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); |
| } |
| TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { |
| @@ -1928,21 +1928,24 @@ TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { |
| candidate.set_component(1); |
| JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); |
| - // Fail since we have not set a offer description. |
| + // Fail since we have not set a remote description. |
| EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); |
| SessionDescriptionInterface* offer = CreateOffer(); |
| SetLocalDescriptionWithoutError(offer); |
| - // Candidate should be allowed to add before remote description. |
|
Taylor Brandstetter
2015/10/09 23:02:07
It's odd that this test says "candidate can be add
pthatcher1
2015/10/10 00:07:27
It's weird that we explicitly expected this behavi
Taylor Brandstetter
2015/10/10 00:30:15
Email sent; CC'd you.
|
| - EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| - candidate.set_component(2); |
| - JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); |
| - EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| + |
| + // Fail since we have not set a remote description. |
| + EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); |
| SessionDescriptionInterface* answer = CreateRemoteAnswer( |
| session_->local_description()); |
| SetRemoteDescriptionWithoutError(answer); |
| + EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| + candidate.set_component(2); |
| + JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); |
| + EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| + |
| // Verifying the candidates are copied properly from internal vector. |
| const SessionDescriptionInterface* remote_desc = |
| session_->remote_description(); |
| @@ -2119,8 +2122,9 @@ TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| // CreateOffer creates session description with the content names "audio" and |
| - // "video". Goal is to modify these content names and verify transport channel |
| - // proxy in the BaseSession, as proxies are created with the content names |
| + // "video". Goal is to modify these content names and verify transport |
| + // channels |
| + // in the WebRtcSession, as channels are created with the content names |
| // present in SDP. |
| std::string sdp; |
| EXPECT_TRUE(offer->ToString(&sdp)); |
| @@ -2700,7 +2704,7 @@ TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithIceRestart) { |
| } |
| // Test that candidates sent to the "video" transport do not get pushed down to |
| -// the "audio" transport channel when bundling using TransportProxy. |
| +// the "audio" transport channel when bundling. |
| TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| @@ -2725,7 +2729,7 @@ TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| // Checks if one of the transport channels contains a connection using a given |
| // port. |
| auto connection_with_remote_port = [this, voice_channel](int port) { |
| - cricket::SessionStats stats; |
| + SessionStats stats; |
| session_->GetChannelTransportStats(voice_channel, &stats); |
| for (auto& kv : stats.transport_stats) { |
| for (auto& chan_stat : kv.second.channel_stats) { |
| @@ -3245,29 +3249,30 @@ TEST_F(WebRtcSessionTest, InsertDtmf) { |
| expected_duration, expected_flags)); |
| } |
| -// This test verifies the |initiator| flag when session initiates the call. |
| +// This test verifies the |initial_offerer| flag when session initiates the |
| +// call. |
| TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { |
| Init(); |
| - EXPECT_FALSE(session_->initiator()); |
| + EXPECT_FALSE(session_->initial_offerer()); |
| SessionDescriptionInterface* offer = CreateOffer(); |
| SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| SetLocalDescriptionWithoutError(offer); |
| - EXPECT_TRUE(session_->initiator()); |
| + EXPECT_TRUE(session_->initial_offerer()); |
| SetRemoteDescriptionWithoutError(answer); |
| - EXPECT_TRUE(session_->initiator()); |
| + EXPECT_TRUE(session_->initial_offerer()); |
| } |
| -// This test verifies the |initiator| flag when session receives the call. |
| +// This test verifies the |initial_offerer| flag when session receives the call. |
| TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { |
| Init(); |
| - EXPECT_FALSE(session_->initiator()); |
| + EXPECT_FALSE(session_->initial_offerer()); |
| SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| SetRemoteDescriptionWithoutError(offer); |
| SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| - EXPECT_FALSE(session_->initiator()); |
| + EXPECT_FALSE(session_->initial_offerer()); |
| SetLocalDescriptionWithoutError(answer); |
| - EXPECT_FALSE(session_->initiator()); |
| + EXPECT_FALSE(session_->initial_offerer()); |
| } |
| // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
| @@ -3479,10 +3484,17 @@ TEST_F(WebRtcSessionTest, TestSessionContentError) { |
| video_channel_ = media_engine_->GetVideoChannel(0); |
| video_channel_->set_fail_set_send_codecs(true); |
| - mediastream_signaling_.SendAudioVideoStream2(); |
| SessionDescriptionInterface* answer = |
| CreateRemoteAnswer(session_->local_description()); |
| SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); |
| + |
| + // Test that after a content error, setting any description will |
| + // result in an error. |
| + video_channel_->set_fail_set_send_codecs(false); |
| + answer = CreateRemoteAnswer(session_->local_description()); |
| + SetRemoteDescriptionExpectError("", "ERROR_CONTENT", answer); |
| + offer = CreateRemoteOffer(); |
| + SetLocalDescriptionExpectError("", "ERROR_CONTENT", offer); |
| } |
| // Runs the loopback call test with BUNDLE and STUN disabled. |
| @@ -3516,28 +3528,6 @@ TEST_F(WebRtcSessionTest, TestIceStatesBundle) { |
| TestLoopbackCall(); |
| } |
| -TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) { |
| - Init(); |
| - cricket::MediaSessionOptions options; |
| - options.recv_video = true; |
| - |
| - cricket::BaseSession::Error error_code = cricket::BaseSession::ERROR_CONTENT; |
| - std::string error_code_str = "ERROR_CONTENT"; |
| - std::string error_desc = "Fake session error description."; |
| - session_->SetError(error_code, error_desc); |
| - |
| - SessionDescriptionInterface* offer = CreateRemoteOffer(options); |
| - SessionDescriptionInterface* answer = |
| - CreateRemoteAnswer(offer, options); |
| - |
| - std::string action; |
| - std::ostringstream session_error_msg; |
| - session_error_msg << kSessionError << error_code_str << ". "; |
| - session_error_msg << kSessionErrorDesc << error_desc << "."; |
| - SetRemoteDescriptionExpectError(action, session_error_msg.str(), offer); |
| - SetLocalDescriptionExpectError(action, session_error_msg.str(), answer); |
| -} |
| - |
| TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
| constraints_.reset(new FakeConstraints()); |
| constraints_->AddOptional( |