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

Side by Side Diff: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc

Issue 11146008: remove VideoDeviceError and AudioDeviceError for media stream. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" 10 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 MediaStreamManager* manager) 44 MediaStreamManager* manager)
45 : MediaStreamDispatcherHost(kProcessId), 45 : MediaStreamDispatcherHost(kProcessId),
46 message_loop_(message_loop), 46 message_loop_(message_loop),
47 manager_(manager) {} 47 manager_(manager) {}
48 48
49 // A list of mock methods. 49 // A list of mock methods.
50 MOCK_METHOD4(OnStreamGenerated, 50 MOCK_METHOD4(OnStreamGenerated,
51 void(int routing_id, int request_id, int audio_array_size, 51 void(int routing_id, int request_id, int audio_array_size,
52 int video_array_size)); 52 int video_array_size));
53 MOCK_METHOD2(OnStreamGenerationFailed, void(int routing_id, int request_id)); 53 MOCK_METHOD2(OnStreamGenerationFailed, void(int routing_id, int request_id));
54 MOCK_METHOD2(OnAudioDeviceFailed, void(int routing_id, int index));
55 MOCK_METHOD2(OnVideoDeviceFailed, void(int routing_id, int index));
56 MOCK_METHOD0(GetMediaObserver, content::MediaObserver*()); 54 MOCK_METHOD0(GetMediaObserver, content::MediaObserver*());
57 55
58 // Accessor to private functions. 56 // Accessor to private functions.
59 void OnGenerateStream(int page_request_id, const StreamOptions& components) { 57 void OnGenerateStream(int page_request_id, const StreamOptions& components) {
60 MediaStreamDispatcherHost::OnGenerateStream(kRenderId, 58 MediaStreamDispatcherHost::OnGenerateStream(kRenderId,
61 page_request_id, 59 page_request_id,
62 components, 60 components,
63 GURL()); 61 GURL());
64 } 62 }
65 void OnGenerateStreamForDevice(int page_request_id, 63 void OnGenerateStreamForDevice(int page_request_id,
(...skipping 27 matching lines...) Expand all
93 virtual bool Send(IPC::Message* message) OVERRIDE { 91 virtual bool Send(IPC::Message* message) OVERRIDE {
94 CHECK(message); 92 CHECK(message);
95 93
96 // In this method we dispatch the messages to the according handlers as if 94 // In this method we dispatch the messages to the according handlers as if
97 // we are the renderer. 95 // we are the renderer.
98 bool handled = true; 96 bool handled = true;
99 IPC_BEGIN_MESSAGE_MAP(MockMediaStreamDispatcherHost, *message) 97 IPC_BEGIN_MESSAGE_MAP(MockMediaStreamDispatcherHost, *message)
100 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, OnStreamGenerated) 98 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, OnStreamGenerated)
101 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerationFailed, 99 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerationFailed,
102 OnStreamGenerationFailed) 100 OnStreamGenerationFailed)
103 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_VideoDeviceFailed,
104 OnVideoDeviceFailed)
105 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_AudioDeviceFailed,
106 OnAudioDeviceFailed)
107 IPC_MESSAGE_UNHANDLED(handled = false) 101 IPC_MESSAGE_UNHANDLED(handled = false)
108 IPC_END_MESSAGE_MAP() 102 IPC_END_MESSAGE_MAP()
109 EXPECT_TRUE(handled); 103 EXPECT_TRUE(handled);
110 104
111 delete message; 105 delete message;
112 return true; 106 return true;
113 } 107 }
114 108
115 // Use our own MediaStreamManager. 109 // Use our own MediaStreamManager.
116 virtual MediaStreamManager* GetManager() OVERRIDE { 110 virtual MediaStreamManager* GetManager() OVERRIDE {
(...skipping 15 matching lines...) Expand all
132 audio_devices_ = audio_device_list; 126 audio_devices_ = audio_device_list;
133 video_devices_ = video_device_list; 127 video_devices_ = video_device_list;
134 } 128 }
135 129
136 void OnStreamGenerationFailed(const IPC::Message& msg, int request_id) { 130 void OnStreamGenerationFailed(const IPC::Message& msg, int request_id) {
137 OnStreamGenerationFailed(msg.routing_id(), request_id); 131 OnStreamGenerationFailed(msg.routing_id(), request_id);
138 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 132 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
139 label_= ""; 133 label_= "";
140 } 134 }
141 135
142 void OnAudioDeviceFailed(const IPC::Message& msg,
143 std::string label,
144 int index) {
145 OnAudioDeviceFailed(msg.routing_id(), index);
146 audio_devices_.erase(audio_devices_.begin() + index);
147 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
148 }
149
150 void OnVideoDeviceFailed(const IPC::Message& msg,
151 std::string label,
152 int index) {
153 OnVideoDeviceFailed(msg.routing_id(), index);
154 video_devices_.erase(video_devices_.begin() + index);
155 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
156 }
157
158 MessageLoop* message_loop_; 136 MessageLoop* message_loop_;
159 MediaStreamManager* manager_; 137 MediaStreamManager* manager_;
160 }; 138 };
161 139
162 class MediaStreamDispatcherHostTest : public testing::Test { 140 class MediaStreamDispatcherHostTest : public testing::Test {
163 public: 141 public:
164 MediaStreamDispatcherHostTest() : old_client_(NULL), 142 MediaStreamDispatcherHostTest() : old_client_(NULL),
165 old_browser_client_(NULL) {} 143 old_browser_client_(NULL) {}
166 virtual ~MediaStreamDispatcherHostTest() {} 144 virtual ~MediaStreamDispatcherHostTest() {}
167 145
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Calling OnChannelClosing() to cancel all the pending/generated streams. 374 // Calling OnChannelClosing() to cancel all the pending/generated streams.
397 EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesClosed(_, _, _)) 375 EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesClosed(_, _, _))
398 .Times(3); 376 .Times(3);
399 host_->OnChannelClosing(); 377 host_->OnChannelClosing();
400 378
401 // Streams should have been cleaned up. 379 // Streams should have been cleaned up.
402 EXPECT_EQ(host_->NumberOfStreams(), 0u); 380 EXPECT_EQ(host_->NumberOfStreams(), 0u);
403 } 381 }
404 382
405 }; // namespace media_stream 383 }; // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698