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

Side by Side Diff: content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc

Issue 566793002: MediaStream content_unittests need to trigger a GC before tear down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "content/child/child_process.h" 7 #include "content/child/child_process.h"
8 #include "content/renderer/media/media_stream.h" 8 #include "content/renderer/media/media_stream.h"
9 #include "content/renderer/media/media_stream_audio_source.h" 9 #include "content/renderer/media/media_stream_audio_source.h"
10 #include "content/renderer/media/media_stream_video_source.h" 10 #include "content/renderer/media/media_stream_video_source.h"
11 #include "content/renderer/media/media_stream_video_track.h" 11 #include "content/renderer/media/media_stream_video_track.h"
12 #include "content/renderer/media/mock_media_stream_video_source.h" 12 #include "content/renderer/media/mock_media_stream_video_source.h"
13 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h" 13 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h"
14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
15 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" 15 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/public/platform/WebMediaStream.h" 17 #include "third_party/WebKit/public/platform/WebMediaStream.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
20 #include "third_party/WebKit/public/platform/WebVector.h" 20 #include "third_party/WebKit/public/platform/WebVector.h"
21 #include "third_party/WebKit/public/web/WebHeap.h"
21 22
22 namespace content { 23 namespace content {
23 24
24 class WebRtcMediaStreamAdapterTest : public ::testing::Test { 25 class WebRtcMediaStreamAdapterTest : public ::testing::Test {
25 public: 26 public:
26 virtual void SetUp() { 27 virtual void SetUp() {
27 child_process_.reset(new ChildProcess()); 28 child_process_.reset(new ChildProcess());
28 dependency_factory_.reset(new MockPeerConnectionDependencyFactory()); 29 dependency_factory_.reset(new MockPeerConnectionDependencyFactory());
29 } 30 }
30 31
32 virtual void TearDown() OVERRIDE {
33 adapter_.reset();
34 blink::WebHeap::collectAllGarbageForTesting();
35 }
36
31 blink::WebMediaStream CreateBlinkMediaStream(bool audio, bool video) { 37 blink::WebMediaStream CreateBlinkMediaStream(bool audio, bool video) {
32 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector( 38 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector(
33 audio ? static_cast<size_t>(1) : 0); 39 audio ? static_cast<size_t>(1) : 0);
34 if (audio) { 40 if (audio) {
35 blink::WebMediaStreamSource audio_source; 41 blink::WebMediaStreamSource audio_source;
36 audio_source.initialize("audio", 42 audio_source.initialize("audio",
37 blink::WebMediaStreamSource::TypeAudio, 43 blink::WebMediaStreamSource::TypeAudio,
38 "audio"); 44 "audio");
39 audio_source.setExtraData(new MediaStreamAudioSource()); 45 audio_source.setExtraData(new MediaStreamAudioSource());
40 46
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 EXPECT_TRUE(webrtc_stream()->GetVideoTracks().empty()); 152 EXPECT_TRUE(webrtc_stream()->GetVideoTracks().empty());
147 153
148 native_stream->AddTrack(audio_tracks[0]); 154 native_stream->AddTrack(audio_tracks[0]);
149 EXPECT_EQ(1u, webrtc_stream()->GetAudioTracks().size()); 155 EXPECT_EQ(1u, webrtc_stream()->GetAudioTracks().size());
150 156
151 native_stream->AddTrack(video_tracks[0]); 157 native_stream->AddTrack(video_tracks[0]);
152 EXPECT_EQ(1u, webrtc_stream()->GetVideoTracks().size()); 158 EXPECT_EQ(1u, webrtc_stream()->GetVideoTracks().size());
153 } 159 }
154 160
155 } // namespace content 161 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698