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

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

Issue 549153002: MediaStream tests need to call WebHeap::collectGarbage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h" 33 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h"
34 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandler.h" 34 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandler.h"
35 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" 35 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h"
36 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" 36 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h"
37 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h " 37 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h "
38 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" 38 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h"
39 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" 39 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h"
40 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h" 40 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h"
41 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" 41 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h"
42 #include "third_party/WebKit/public/platform/WebURL.h" 42 #include "third_party/WebKit/public/platform/WebURL.h"
43 #include "third_party/WebKit/public/web/WebHeap.h"
43 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h " 44 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h "
44 45
45 static const char kDummySdp[] = "dummy sdp"; 46 static const char kDummySdp[] = "dummy sdp";
46 static const char kDummySdpType[] = "dummy type"; 47 static const char kDummySdpType[] = "dummy type";
47 48
48 using blink::WebRTCPeerConnectionHandlerClient; 49 using blink::WebRTCPeerConnectionHandlerClient;
49 using testing::NiceMock; 50 using testing::NiceMock;
50 using testing::_; 51 using testing::_;
51 using testing::Ref; 52 using testing::Ref;
52 53
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 mock_tracker_.reset(new NiceMock<MockPeerConnectionTracker>()); 213 mock_tracker_.reset(new NiceMock<MockPeerConnectionTracker>());
213 blink::WebRTCConfiguration config; 214 blink::WebRTCConfiguration config;
214 blink::WebMediaConstraints constraints; 215 blink::WebMediaConstraints constraints;
215 EXPECT_TRUE(pc_handler_->InitializeForTest(config, constraints, 216 EXPECT_TRUE(pc_handler_->InitializeForTest(config, constraints,
216 mock_tracker_.get())); 217 mock_tracker_.get()));
217 218
218 mock_peer_connection_ = pc_handler_->native_peer_connection(); 219 mock_peer_connection_ = pc_handler_->native_peer_connection();
219 ASSERT_TRUE(mock_peer_connection_); 220 ASSERT_TRUE(mock_peer_connection_);
220 } 221 }
221 222
223 virtual void TearDown() {
224 pc_handler_.reset();
225 mock_tracker_.reset();
226 mock_dependency_factory_.reset();
227 mock_client_.reset();
228 blink::WebHeap::collectAllGarbageForTesting();
229 }
230
222 // Creates a WebKit local MediaStream. 231 // Creates a WebKit local MediaStream.
223 blink::WebMediaStream CreateLocalMediaStream( 232 blink::WebMediaStream CreateLocalMediaStream(
224 const std::string& stream_label) { 233 const std::string& stream_label) {
225 std::string video_track_label("video-label"); 234 std::string video_track_label("video-label");
226 std::string audio_track_label("audio-label"); 235 std::string audio_track_label("audio-label");
227 236
228 blink::WebMediaStreamSource audio_source; 237 blink::WebMediaStreamSource audio_source;
229 audio_source.initialize(blink::WebString::fromUTF8(audio_track_label), 238 audio_source.initialize(blink::WebString::fromUTF8(audio_track_label),
230 blink::WebMediaStreamSource::TypeAudio, 239 blink::WebMediaStreamSource::TypeAudio,
231 blink::WebString::fromUTF8("audio_track")); 240 blink::WebString::fromUTF8("audio_track"));
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 scoped_refptr<webrtc::AudioTrackInterface> webrtc_track = 764 scoped_refptr<webrtc::AudioTrackInterface> webrtc_track =
756 remote_stream->GetAudioTracks()[0].get(); 765 remote_stream->GetAudioTracks()[0].get();
757 remote_stream->RemoveTrack(webrtc_track.get()); 766 remote_stream->RemoveTrack(webrtc_track.get());
758 767
759 { 768 {
760 blink::WebVector<blink::WebMediaStreamTrack> modified_audio_tracks1; 769 blink::WebVector<blink::WebMediaStreamTrack> modified_audio_tracks1;
761 webkit_stream.audioTracks(modified_audio_tracks1); 770 webkit_stream.audioTracks(modified_audio_tracks1);
762 EXPECT_EQ(0u, modified_audio_tracks1.size()); 771 EXPECT_EQ(0u, modified_audio_tracks1.size());
763 } 772 }
764 773
774 blink::WebHeap::collectGarbageForTesting();
775
765 // Add the WebRtc audio track again. 776 // Add the WebRtc audio track again.
766 remote_stream->AddTrack(webrtc_track.get()); 777 remote_stream->AddTrack(webrtc_track.get());
767 blink::WebVector<blink::WebMediaStreamTrack> modified_audio_tracks2; 778 blink::WebVector<blink::WebMediaStreamTrack> modified_audio_tracks2;
768 webkit_stream.audioTracks(modified_audio_tracks2); 779 webkit_stream.audioTracks(modified_audio_tracks2);
769 EXPECT_EQ(1u, modified_audio_tracks2.size()); 780 EXPECT_EQ(1u, modified_audio_tracks2.size());
770 } 781 }
771 782
772 TEST_F(RTCPeerConnectionHandlerTest, RemoveAndAddVideoTrackFromRemoteStream) { 783 TEST_F(RTCPeerConnectionHandlerTest, RemoveAndAddVideoTrackFromRemoteStream) {
773 std::string remote_stream_label("remote_stream"); 784 std::string remote_stream_label("remote_stream");
774 scoped_refptr<webrtc::MediaStreamInterface> remote_stream( 785 scoped_refptr<webrtc::MediaStreamInterface> remote_stream(
(...skipping 16 matching lines...) Expand all
791 // Remove the Webrtc video track from the Webrtc MediaStream. 802 // Remove the Webrtc video track from the Webrtc MediaStream.
792 scoped_refptr<webrtc::VideoTrackInterface> webrtc_track = 803 scoped_refptr<webrtc::VideoTrackInterface> webrtc_track =
793 remote_stream->GetVideoTracks()[0].get(); 804 remote_stream->GetVideoTracks()[0].get();
794 remote_stream->RemoveTrack(webrtc_track.get()); 805 remote_stream->RemoveTrack(webrtc_track.get());
795 { 806 {
796 blink::WebVector<blink::WebMediaStreamTrack> modified_video_tracks1; 807 blink::WebVector<blink::WebMediaStreamTrack> modified_video_tracks1;
797 webkit_stream.videoTracks(modified_video_tracks1); 808 webkit_stream.videoTracks(modified_video_tracks1);
798 EXPECT_EQ(0u, modified_video_tracks1.size()); 809 EXPECT_EQ(0u, modified_video_tracks1.size());
799 } 810 }
800 811
812 blink::WebHeap::collectGarbageForTesting();
813
801 // Add the WebRtc video track again. 814 // Add the WebRtc video track again.
802 remote_stream->AddTrack(webrtc_track.get()); 815 remote_stream->AddTrack(webrtc_track.get());
803 blink::WebVector<blink::WebMediaStreamTrack> modified_video_tracks2; 816 blink::WebVector<blink::WebMediaStreamTrack> modified_video_tracks2;
804 webkit_stream.videoTracks(modified_video_tracks2); 817 webkit_stream.videoTracks(modified_video_tracks2);
805 EXPECT_EQ(1u, modified_video_tracks2.size()); 818 EXPECT_EQ(1u, modified_video_tracks2.size());
806 } 819 }
807 820
808 TEST_F(RTCPeerConnectionHandlerTest, OnIceCandidate) { 821 TEST_F(RTCPeerConnectionHandlerTest, OnIceCandidate) {
809 testing::InSequence sequence; 822 testing::InSequence sequence;
810 EXPECT_CALL(*mock_tracker_.get(), 823 EXPECT_CALL(*mock_tracker_.get(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 EXPECT_CALL(*mock_tracker_.get(), 871 EXPECT_CALL(*mock_tracker_.get(),
859 TrackCreateDTMFSender(pc_handler_.get(), 872 TrackCreateDTMFSender(pc_handler_.get(),
860 testing::Ref(tracks[0]))); 873 testing::Ref(tracks[0])));
861 874
862 scoped_ptr<blink::WebRTCDTMFSenderHandler> sender( 875 scoped_ptr<blink::WebRTCDTMFSenderHandler> sender(
863 pc_handler_->createDTMFSender(tracks[0])); 876 pc_handler_->createDTMFSender(tracks[0]));
864 EXPECT_TRUE(sender.get()); 877 EXPECT_TRUE(sender.get());
865 } 878 }
866 879
867 } // namespace content 880 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698