Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler_unittest.cc

Issue 2619343003: Track SDP parse errors for SLD in chrome://webrtc-internals (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void(RTCPeerConnectionHandler* pc_handler, 177 void(RTCPeerConnectionHandler* pc_handler,
178 WebRTCPeerConnectionHandlerClient::SignalingState state)); 178 WebRTCPeerConnectionHandlerClient::SignalingState state));
179 MOCK_METHOD2( 179 MOCK_METHOD2(
180 TrackIceConnectionStateChange, 180 TrackIceConnectionStateChange,
181 void(RTCPeerConnectionHandler* pc_handler, 181 void(RTCPeerConnectionHandler* pc_handler,
182 WebRTCPeerConnectionHandlerClient::ICEConnectionState state)); 182 WebRTCPeerConnectionHandlerClient::ICEConnectionState state));
183 MOCK_METHOD2( 183 MOCK_METHOD2(
184 TrackIceGatheringStateChange, 184 TrackIceGatheringStateChange,
185 void(RTCPeerConnectionHandler* pc_handler, 185 void(RTCPeerConnectionHandler* pc_handler,
186 WebRTCPeerConnectionHandlerClient::ICEGatheringState state)); 186 WebRTCPeerConnectionHandlerClient::ICEGatheringState state));
187 MOCK_METHOD4(TrackSessionDescriptionCallback,
188 void(RTCPeerConnectionHandler* pc_handler,
189 Action action,
190 const std::string& type,
191 const std::string& value));
187 MOCK_METHOD1(TrackOnRenegotiationNeeded, 192 MOCK_METHOD1(TrackOnRenegotiationNeeded,
188 void(RTCPeerConnectionHandler* pc_handler)); 193 void(RTCPeerConnectionHandler* pc_handler));
189 MOCK_METHOD2(TrackCreateDTMFSender, 194 MOCK_METHOD2(TrackCreateDTMFSender,
190 void(RTCPeerConnectionHandler* pc_handler, 195 void(RTCPeerConnectionHandler* pc_handler,
191 const blink::WebMediaStreamTrack& track)); 196 const blink::WebMediaStreamTrack& track));
192 }; 197 };
193 198
194 class MockRTCStatsReportCallback : public blink::WebRTCStatsReportCallback { 199 class MockRTCStatsReportCallback : public blink::WebRTCStatsReportCallback {
195 public: 200 public:
196 explicit MockRTCStatsReportCallback( 201 explicit MockRTCStatsReportCallback(
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 pc_handler_->setLocalDescription(request, description); 477 pc_handler_->setLocalDescription(request, description);
473 base::RunLoop().RunUntilIdle(); 478 base::RunLoop().RunUntilIdle();
474 EXPECT_EQ(description.type(), pc_handler_->localDescription().type()); 479 EXPECT_EQ(description.type(), pc_handler_->localDescription().type());
475 EXPECT_EQ(description.sdp(), pc_handler_->localDescription().sdp()); 480 EXPECT_EQ(description.sdp(), pc_handler_->localDescription().sdp());
476 481
477 std::string sdp_string; 482 std::string sdp_string;
478 ASSERT_TRUE(mock_peer_connection_->local_description() != NULL); 483 ASSERT_TRUE(mock_peer_connection_->local_description() != NULL);
479 EXPECT_EQ(kDummySdpType, mock_peer_connection_->local_description()->type()); 484 EXPECT_EQ(kDummySdpType, mock_peer_connection_->local_description()->type());
480 mock_peer_connection_->local_description()->ToString(&sdp_string); 485 mock_peer_connection_->local_description()->ToString(&sdp_string);
481 EXPECT_EQ(kDummySdp, sdp_string); 486 EXPECT_EQ(kDummySdp, sdp_string);
487
488 // TODO(deadbeef): Also mock the "success" callback from the PeerConnection
489 // and ensure that the sucessful result is tracked by PeerConnectionTracker.
490 }
491
492 // Test that setLocalDescription with invalid SDP will result in a failure, and
493 // is tracked as a failure with PeerConnectionTracker.
494 TEST_F(RTCPeerConnectionHandlerTest, setLocalDescriptionParseError) {
495 blink::WebRTCVoidRequest request;
496 blink::WebRTCSessionDescription description;
497 description.initialize(kDummySdpType, kDummySdp);
498 testing::InSequence sequence;
499 // Expect two "Track" calls, one for the start of the attempt and one for the
500 // failure.
501 EXPECT_CALL(
502 *mock_tracker_.get(),
503 TrackSetSessionDescription(pc_handler_.get(), kDummySdp, kDummySdpType,
504 PeerConnectionTracker::SOURCE_LOCAL));
505 EXPECT_CALL(
506 *mock_tracker_.get(),
507 TrackSessionDescriptionCallback(
508 pc_handler_.get(),
509 PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION, "OnFailure", _));
510
511 // Used to simulate a parse failure.
512 mock_dependency_factory_->SetFailToCreateSessionDescription(true);
513 pc_handler_->setLocalDescription(request, description);
514 base::RunLoop().RunUntilIdle();
515 // A description that failed to be applied shouldn't be stored.
516 EXPECT_TRUE(pc_handler_->localDescription().sdp().isEmpty());
482 } 517 }
483 518
484 TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescription) { 519 TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescription) {
485 blink::WebRTCVoidRequest request; 520 blink::WebRTCVoidRequest request;
486 blink::WebRTCSessionDescription description; 521 blink::WebRTCSessionDescription description;
487 description.initialize(kDummySdpType, kDummySdp); 522 description.initialize(kDummySdpType, kDummySdp);
488 523
489 // PeerConnectionTracker::TrackSetSessionDescription is expected to be called 524 // PeerConnectionTracker::TrackSetSessionDescription is expected to be called
490 // before |mock_peer_connection| is called. 525 // before |mock_peer_connection| is called.
491 testing::InSequence sequence; 526 testing::InSequence sequence;
492 EXPECT_CALL(*mock_tracker_.get(), 527 EXPECT_CALL(*mock_tracker_.get(),
493 TrackSetSessionDescription(pc_handler_.get(), kDummySdp, 528 TrackSetSessionDescription(pc_handler_.get(), kDummySdp,
494 kDummySdpType, 529 kDummySdpType,
495 PeerConnectionTracker::SOURCE_REMOTE)); 530 PeerConnectionTracker::SOURCE_REMOTE));
496 EXPECT_CALL(*mock_peer_connection_, SetRemoteDescription(_, _)); 531 EXPECT_CALL(*mock_peer_connection_, SetRemoteDescription(_, _));
497 532
498 pc_handler_->setRemoteDescription(request, description); 533 pc_handler_->setRemoteDescription(request, description);
499 base::RunLoop().RunUntilIdle(); 534 base::RunLoop().RunUntilIdle();
500 EXPECT_EQ(description.type(), pc_handler_->remoteDescription().type()); 535 EXPECT_EQ(description.type(), pc_handler_->remoteDescription().type());
501 EXPECT_EQ(description.sdp(), pc_handler_->remoteDescription().sdp()); 536 EXPECT_EQ(description.sdp(), pc_handler_->remoteDescription().sdp());
502 537
503 std::string sdp_string; 538 std::string sdp_string;
504 ASSERT_TRUE(mock_peer_connection_->remote_description() != NULL); 539 ASSERT_TRUE(mock_peer_connection_->remote_description() != NULL);
505 EXPECT_EQ(kDummySdpType, mock_peer_connection_->remote_description()->type()); 540 EXPECT_EQ(kDummySdpType, mock_peer_connection_->remote_description()->type());
506 mock_peer_connection_->remote_description()->ToString(&sdp_string); 541 mock_peer_connection_->remote_description()->ToString(&sdp_string);
507 EXPECT_EQ(kDummySdp, sdp_string); 542 EXPECT_EQ(kDummySdp, sdp_string);
543
544 // TODO(deadbeef): Also mock the "success" callback from the PeerConnection
545 // and ensure that the sucessful result is tracked by PeerConnectionTracker.
546 }
547
548 // Test that setRemoteDescription with invalid SDP will result in a failure, and
549 // is tracked as a failure with PeerConnectionTracker.
550 TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescriptionParseError) {
551 blink::WebRTCVoidRequest request;
552 blink::WebRTCSessionDescription description;
553 description.initialize(kDummySdpType, kDummySdp);
554 testing::InSequence sequence;
555 // Expect two "Track" calls, one for the start of the attempt and one for the
556 // failure.
557 EXPECT_CALL(
558 *mock_tracker_.get(),
559 TrackSetSessionDescription(pc_handler_.get(), kDummySdp, kDummySdpType,
560 PeerConnectionTracker::SOURCE_REMOTE));
561 EXPECT_CALL(*mock_tracker_.get(),
562 TrackSessionDescriptionCallback(
563 pc_handler_.get(),
564 PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION,
565 "OnFailure", _));
566
567 // Used to simulate a parse failure.
568 mock_dependency_factory_->SetFailToCreateSessionDescription(true);
569 pc_handler_->setRemoteDescription(request, description);
570 base::RunLoop().RunUntilIdle();
571 // A description that failed to be applied shouldn't be stored.
572 EXPECT_TRUE(pc_handler_->remoteDescription().sdp().isEmpty());
508 } 573 }
509 574
510 TEST_F(RTCPeerConnectionHandlerTest, setConfiguration) { 575 TEST_F(RTCPeerConnectionHandlerTest, setConfiguration) {
511 blink::WebRTCConfiguration config; 576 blink::WebRTCConfiguration config;
512 577
513 EXPECT_CALL(*mock_tracker_.get(), 578 EXPECT_CALL(*mock_tracker_.get(),
514 TrackSetConfiguration(pc_handler_.get(), _)); 579 TrackSetConfiguration(pc_handler_.get(), _));
515 // TODO(perkj): Test that the parameters in |config| can be translated when a 580 // TODO(perkj): Test that the parameters in |config| can be translated when a
516 // WebRTCConfiguration can be constructed. It's WebKit class and can't be 581 // WebRTCConfiguration can be constructed. It's WebKit class and can't be
517 // initialized from a test. 582 // initialized from a test.
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 testing::Ref(tracks[0]))); 1282 testing::Ref(tracks[0])));
1218 1283
1219 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender( 1284 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender(
1220 pc_handler_->createDTMFSender(tracks[0])); 1285 pc_handler_->createDTMFSender(tracks[0]));
1221 EXPECT_TRUE(sender.get()); 1286 EXPECT_TRUE(sender.get());
1222 1287
1223 StopAllTracks(local_stream); 1288 StopAllTracks(local_stream);
1224 } 1289 }
1225 1290
1226 } // namespace content 1291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698