OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/renderer_host/media/media_stream_ui_proxy.h" | 5 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "content/browser/renderer_host/render_view_host_delegate.h" | 8 #include "content/browser/renderer_host/render_view_host_delegate.h" |
9 #include "content/public/common/renderer_preferences.h" | 9 #include "content/public/common/renderer_preferences.h" |
10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 expected.tab_capture_device_id == arg.tab_capture_device_id && | 85 expected.tab_capture_device_id == arg.tab_capture_device_id && |
86 expected.security_origin == arg.security_origin && | 86 expected.security_origin == arg.security_origin && |
87 expected.request_type == arg.request_type && | 87 expected.request_type == arg.request_type && |
88 expected.requested_audio_device_id == arg.requested_audio_device_id && | 88 expected.requested_audio_device_id == arg.requested_audio_device_id && |
89 expected.requested_video_device_id == arg.requested_video_device_id && | 89 expected.requested_video_device_id == arg.requested_video_device_id && |
90 expected.audio_type == arg.audio_type && | 90 expected.audio_type == arg.audio_type && |
91 expected.video_type == arg.video_type; | 91 expected.video_type == arg.video_type; |
92 } | 92 } |
93 | 93 |
94 TEST_F(MediaStreamUIProxyTest, Deny) { | 94 TEST_F(MediaStreamUIProxyTest, Deny) { |
95 MediaStreamRequest request(0, 0, 0, std::string(), GURL("http://origin/"), | 95 MediaStreamRequest request(0, 0, 0, GURL("http://origin/"), |
96 MEDIA_GENERATE_STREAM, std::string(), | 96 MEDIA_GENERATE_STREAM, std::string(), |
97 std::string(), | 97 std::string(), |
98 MEDIA_DEVICE_AUDIO_CAPTURE, | 98 MEDIA_DEVICE_AUDIO_CAPTURE, |
99 MEDIA_DEVICE_VIDEO_CAPTURE); | 99 MEDIA_DEVICE_VIDEO_CAPTURE); |
100 proxy_->RequestAccess( | 100 proxy_->RequestAccess( |
101 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, | 101 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, |
102 base::Unretained(&response_callback_))); | 102 base::Unretained(&response_callback_))); |
103 MediaResponseCallback callback; | 103 MediaResponseCallback callback; |
104 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) | 104 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) |
105 .WillOnce(SaveArg<1>(&callback)); | 105 .WillOnce(SaveArg<1>(&callback)); |
106 message_loop_.RunUntilIdle(); | 106 message_loop_.RunUntilIdle(); |
107 ASSERT_FALSE(callback.is_null()); | 107 ASSERT_FALSE(callback.is_null()); |
108 | 108 |
109 MediaStreamDevices devices; | 109 MediaStreamDevices devices; |
110 callback.Run(devices, scoped_ptr<MediaStreamUI>()); | 110 callback.Run(devices, scoped_ptr<MediaStreamUI>()); |
111 | 111 |
112 MediaStreamDevices response; | 112 MediaStreamDevices response; |
113 EXPECT_CALL(response_callback_, OnAccessRequestResponse(_)) | 113 EXPECT_CALL(response_callback_, OnAccessRequestResponse(_)) |
114 .WillOnce(SaveArg<0>(&response)); | 114 .WillOnce(SaveArg<0>(&response)); |
115 message_loop_.RunUntilIdle(); | 115 message_loop_.RunUntilIdle(); |
116 | 116 |
117 EXPECT_TRUE(response.empty()); | 117 EXPECT_TRUE(response.empty()); |
118 } | 118 } |
119 | 119 |
120 TEST_F(MediaStreamUIProxyTest, AcceptAndStart) { | 120 TEST_F(MediaStreamUIProxyTest, AcceptAndStart) { |
121 MediaStreamRequest request(0, 0, 0, std::string(), GURL("http://origin/"), | 121 MediaStreamRequest request(0, 0, 0, GURL("http://origin/"), |
122 MEDIA_GENERATE_STREAM, std::string(), | 122 MEDIA_GENERATE_STREAM, std::string(), |
123 std::string(), | 123 std::string(), |
124 MEDIA_DEVICE_AUDIO_CAPTURE, | 124 MEDIA_DEVICE_AUDIO_CAPTURE, |
125 MEDIA_DEVICE_VIDEO_CAPTURE); | 125 MEDIA_DEVICE_VIDEO_CAPTURE); |
126 proxy_->RequestAccess( | 126 proxy_->RequestAccess( |
127 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, | 127 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, |
128 base::Unretained(&response_callback_))); | 128 base::Unretained(&response_callback_))); |
129 MediaResponseCallback callback; | 129 MediaResponseCallback callback; |
130 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) | 130 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) |
131 .WillOnce(SaveArg<1>(&callback)); | 131 .WillOnce(SaveArg<1>(&callback)); |
(...skipping 13 matching lines...) Expand all Loading... |
145 message_loop_.RunUntilIdle(); | 145 message_loop_.RunUntilIdle(); |
146 | 146 |
147 EXPECT_FALSE(response.empty()); | 147 EXPECT_FALSE(response.empty()); |
148 | 148 |
149 proxy_->OnStarted(base::Closure()); | 149 proxy_->OnStarted(base::Closure()); |
150 message_loop_.RunUntilIdle(); | 150 message_loop_.RunUntilIdle(); |
151 } | 151 } |
152 | 152 |
153 // Verify that the proxy can be deleted before the request is processed. | 153 // Verify that the proxy can be deleted before the request is processed. |
154 TEST_F(MediaStreamUIProxyTest, DeleteBeforeAccepted) { | 154 TEST_F(MediaStreamUIProxyTest, DeleteBeforeAccepted) { |
155 MediaStreamRequest request(0, 0, 0, std::string(), GURL("http://origin/"), | 155 MediaStreamRequest request(0, 0, 0, GURL("http://origin/"), |
156 MEDIA_GENERATE_STREAM, std::string(), | 156 MEDIA_GENERATE_STREAM, std::string(), |
157 std::string(), | 157 std::string(), |
158 MEDIA_DEVICE_AUDIO_CAPTURE, | 158 MEDIA_DEVICE_AUDIO_CAPTURE, |
159 MEDIA_DEVICE_VIDEO_CAPTURE); | 159 MEDIA_DEVICE_VIDEO_CAPTURE); |
160 proxy_->RequestAccess( | 160 proxy_->RequestAccess( |
161 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, | 161 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, |
162 base::Unretained(&response_callback_))); | 162 base::Unretained(&response_callback_))); |
163 MediaResponseCallback callback; | 163 MediaResponseCallback callback; |
164 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) | 164 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) |
165 .WillOnce(SaveArg<1>(&callback)); | 165 .WillOnce(SaveArg<1>(&callback)); |
166 message_loop_.RunUntilIdle(); | 166 message_loop_.RunUntilIdle(); |
167 ASSERT_FALSE(callback.is_null()); | 167 ASSERT_FALSE(callback.is_null()); |
168 | 168 |
169 proxy_.reset(); | 169 proxy_.reset(); |
170 | 170 |
171 MediaStreamDevices devices; | 171 MediaStreamDevices devices; |
172 scoped_ptr<MediaStreamUI> ui; | 172 scoped_ptr<MediaStreamUI> ui; |
173 callback.Run(devices, ui.Pass()); | 173 callback.Run(devices, ui.Pass()); |
174 } | 174 } |
175 | 175 |
176 TEST_F(MediaStreamUIProxyTest, StopFromUI) { | 176 TEST_F(MediaStreamUIProxyTest, StopFromUI) { |
177 MediaStreamRequest request(0, 0, 0, std::string(), GURL("http://origin/"), | 177 MediaStreamRequest request(0, 0, 0, GURL("http://origin/"), |
178 MEDIA_GENERATE_STREAM, std::string(), | 178 MEDIA_GENERATE_STREAM, std::string(), |
179 std::string(), | 179 std::string(), |
180 MEDIA_DEVICE_AUDIO_CAPTURE, | 180 MEDIA_DEVICE_AUDIO_CAPTURE, |
181 MEDIA_DEVICE_VIDEO_CAPTURE); | 181 MEDIA_DEVICE_VIDEO_CAPTURE); |
182 proxy_->RequestAccess( | 182 proxy_->RequestAccess( |
183 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, | 183 request, base::Bind(&MockResponseCallback::OnAccessRequestResponse, |
184 base::Unretained(&response_callback_))); | 184 base::Unretained(&response_callback_))); |
185 MediaResponseCallback callback; | 185 MediaResponseCallback callback; |
186 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) | 186 EXPECT_CALL(delegate_, RequestMediaAccessPermission(SameRequest(request), _)) |
187 .WillOnce(SaveArg<1>(&callback)); | 187 .WillOnce(SaveArg<1>(&callback)); |
(...skipping 22 matching lines...) Expand all Loading... |
210 base::Unretained(&stop_handler))); | 210 base::Unretained(&stop_handler))); |
211 message_loop_.RunUntilIdle(); | 211 message_loop_.RunUntilIdle(); |
212 | 212 |
213 ASSERT_FALSE(stop_callback.is_null()); | 213 ASSERT_FALSE(stop_callback.is_null()); |
214 EXPECT_CALL(stop_handler, OnStop()); | 214 EXPECT_CALL(stop_handler, OnStop()); |
215 stop_callback.Run(); | 215 stop_callback.Run(); |
216 message_loop_.RunUntilIdle(); | 216 message_loop_.RunUntilIdle(); |
217 } | 217 } |
218 | 218 |
219 } // content | 219 } // content |
OLD | NEW |