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

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

Issue 10947030: Removed the use of WebFrame::frameForCurrentContext() in MediaStreamCenter::didStopLocalMediaStream (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressing code review comments found by Tommi. Created 8 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
« no previous file with comments | « content/renderer/media/media_stream_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "content/renderer/media/media_stream_extra_data.h" 8 #include "content/renderer/media/media_stream_extra_data.h"
9 #include "content/renderer/media/media_stream_impl.h" 9 #include "content/renderer/media/media_stream_impl.h"
10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h"
11 #include "content/renderer/media/mock_media_stream_dispatcher.h" 11 #include "content/renderer/media/mock_media_stream_dispatcher.h"
12 #include "content/renderer/media/video_capture_impl_manager.h" 12 #include "content/renderer/media/video_capture_impl_manager.h"
13 #include "media/base/video_decoder.h" 13 #include "media/base/video_decoder.h"
14 #include "media/base/message_loop_factory.h" 14 #include "media/base/message_loop_factory.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
20 21
21 class MediaStreamImplUnderTest : public MediaStreamImpl { 22 class MediaStreamImplUnderTest : public MediaStreamImpl {
22 public: 23 public:
23 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, 24 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher,
24 VideoCaptureImplManager* vc_manager, 25 VideoCaptureImplManager* vc_manager,
25 MediaStreamDependencyFactory* dependency_factory) 26 MediaStreamDependencyFactory* dependency_factory)
26 : MediaStreamImpl(NULL, media_stream_dispatcher, vc_manager, 27 : MediaStreamImpl(NULL, media_stream_dispatcher, vc_manager,
27 dependency_factory) { 28 dependency_factory) {
28 } 29 }
29 30
30 virtual void CompleteGetUserMediaRequest( 31 virtual void CompleteGetUserMediaRequest(
31 const WebKit::WebMediaStreamDescriptor& stream, 32 const WebKit::WebMediaStreamDescriptor& stream,
32 WebKit::WebUserMediaRequest* request) { 33 WebKit::WebUserMediaRequest* request) {
33 last_generated_stream_ = stream; 34 last_generated_stream_ = stream;
34 } 35 }
35 36
36 virtual WebKit::WebMediaStreamDescriptor GetMediaStream(const GURL& url) { 37 virtual WebKit::WebMediaStreamDescriptor GetMediaStream(const GURL& url) {
37 return last_generated_stream_; 38 return last_generated_stream_;
38 } 39 }
39 40
40 const WebKit::WebMediaStreamDescriptor& last_generated_stream() { 41 const WebKit::WebMediaStreamDescriptor& last_generated_stream() {
41 return last_generated_stream_; 42 return last_generated_stream_;
42 } 43 }
43 44
45 using MediaStreamImpl::OnLocalMediaStreamStop;
46
44 private: 47 private:
45 WebKit::WebMediaStreamDescriptor last_generated_stream_; 48 WebKit::WebMediaStreamDescriptor last_generated_stream_;
46 }; 49 };
47 50
48 class MediaStreamImplTest : public ::testing::Test { 51 class MediaStreamImplTest : public ::testing::Test {
49 public: 52 public:
50 void SetUp() { 53 void SetUp() {
51 // Create our test object. 54 // Create our test object.
52 ms_dispatcher_.reset(new MockMediaStreamDispatcher()); 55 ms_dispatcher_.reset(new MockMediaStreamDispatcher());
53 scoped_refptr<VideoCaptureImplManager> vc_manager( 56 scoped_refptr<VideoCaptureImplManager> vc_manager(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_TRUE(audio_decoder.get() == NULL); 120 EXPECT_TRUE(audio_decoder.get() == NULL);
118 121
119 // Test a stream with video only. 122 // Test a stream with video only.
120 WebKit::WebMediaStreamDescriptor video_desc = RequestLocalMediaStream(false, 123 WebKit::WebMediaStreamDescriptor video_desc = RequestLocalMediaStream(false,
121 true); 124 true);
122 scoped_refptr<media::VideoDecoder> video_decoder( 125 scoped_refptr<media::VideoDecoder> video_decoder(
123 ms_impl_->GetVideoDecoder(GURL(), message_loop_factory.get())); 126 ms_impl_->GetVideoDecoder(GURL(), message_loop_factory.get()));
124 EXPECT_TRUE(video_decoder.get() != NULL); 127 EXPECT_TRUE(video_decoder.get() != NULL);
125 128
126 // Stop generated local streams. 129 // Stop generated local streams.
127 ms_impl_->StopLocalMediaStream(mixed_desc); 130 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8());
128 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); 131 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter());
129 ms_impl_->StopLocalMediaStream(audio_desc); 132 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8());
130 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); 133 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter());
131 134
132 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. 135 // Test that the MediaStreams are deleted if the owning WebFrame is deleted.
133 // In the unit test the owning frame is NULL. 136 // In the unit test the owning frame is NULL.
134 ms_impl_->FrameWillClose(NULL); 137 ms_impl_->FrameWillClose(NULL);
135 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); 138 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter());
136 } 139 }
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698