Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <queue> | 6 #include <queue> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 223 |
| 224 void set_mic_access(bool allow_access) { | 224 void set_mic_access(bool allow_access) { |
| 225 mic_access_ = allow_access; | 225 mic_access_ = allow_access; |
| 226 } | 226 } |
| 227 | 227 |
| 228 void set_camera_access(bool allow_access) { | 228 void set_camera_access(bool allow_access) { |
| 229 camera_access_ = allow_access; | 229 camera_access_ = allow_access; |
| 230 } | 230 } |
| 231 | 231 |
| 232 private: | 232 private: |
| 233 /* | |
|
perkj_chrome
2014/09/15 12:06:25
fix
Henrik Grunell
2014/09/15 13:45:17
Oh right, forgot to say that this test isn't done
| |
| 233 virtual bool CheckMediaAccessPermissionOnUIThread( | 234 virtual bool CheckMediaAccessPermissionOnUIThread( |
| 234 int render_process_id, | 235 int render_process_id, |
| 235 const GURL& security_origin, | 236 const GURL& security_origin, |
| 236 MediaStreamType type) OVERRIDE { | 237 MediaStreamType type) OVERRIDE { |
| 237 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) | 238 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) |
| 238 return mic_access_; | 239 return mic_access_; |
| 239 else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) | 240 else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) |
| 240 return camera_access_; | 241 return camera_access_; |
| 241 return false; | 242 return false; |
| 242 } | 243 } |
| 244 */ | |
| 243 | 245 |
| 244 bool mic_access_; | 246 bool mic_access_; |
| 245 bool camera_access_; | 247 bool camera_access_; |
| 246 }; | 248 }; |
| 247 | 249 |
| 248 class MediaStreamDispatcherHostTest : public testing::Test { | 250 class MediaStreamDispatcherHostTest : public testing::Test { |
| 249 public: | 251 public: |
| 250 MediaStreamDispatcherHostTest() | 252 MediaStreamDispatcherHostTest() |
| 251 : old_browser_client_(NULL), | 253 : old_browser_client_(NULL), |
| 252 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 254 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 &physical_audio_devices_); | 293 &physical_audio_devices_); |
| 292 ASSERT_GT(physical_audio_devices_.size(), 0u); | 294 ASSERT_GT(physical_audio_devices_.size(), 0u); |
| 293 } | 295 } |
| 294 | 296 |
| 295 virtual void TearDown() OVERRIDE { | 297 virtual void TearDown() OVERRIDE { |
| 296 host_->OnChannelClosing(); | 298 host_->OnChannelClosing(); |
| 297 } | 299 } |
| 298 | 300 |
| 299 protected: | 301 protected: |
| 300 virtual void SetupFakeUI(bool expect_started) { | 302 virtual void SetupFakeUI(bool expect_started) { |
| 301 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy()); | 303 stream_ui_ = new MockMediaStreamUIProxy(); |
| 304 scoped_ptr<MockMediaStreamUIProxy> stream_ui(stream_ui_); | |
| 302 if (expect_started) { | 305 if (expect_started) { |
| 303 EXPECT_CALL(*stream_ui, OnStarted(_, _)); | 306 EXPECT_CALL(*stream_ui_, OnStarted(_, _)); |
| 304 } | 307 } |
| 305 media_stream_manager_->UseFakeUI( | 308 media_stream_manager_->UseFakeUI( |
| 306 stream_ui.PassAs<FakeMediaStreamUIProxy>()); | 309 // static_cast<FakeMediaStreamUIProxy*>(stream_ui_)); |
|
perkj_chrome
2014/09/15 12:06:25
fix
Henrik Grunell
2014/09/15 13:45:17
Same here.
| |
| 310 stream_ui.PassAs<FakeMediaStreamUIProxy>()); | |
| 307 } | 311 } |
| 308 | 312 |
| 309 void GenerateStreamAndWaitForResult(int render_frame_id, | 313 void GenerateStreamAndWaitForResult(int render_frame_id, |
| 310 int page_request_id, | 314 int page_request_id, |
| 311 const StreamOptions& options) { | 315 const StreamOptions& options) { |
| 312 base::RunLoop run_loop; | 316 base::RunLoop run_loop; |
| 313 int expected_audio_array_size = | 317 int expected_audio_array_size = |
| 314 (options.audio_requested && | 318 (options.audio_requested && |
| 315 physical_audio_devices_.size() > 0) ? 1 : 0; | 319 physical_audio_devices_.size() > 0) ? 1 : 0; |
| 316 int expected_video_array_size = | 320 int expected_video_array_size = |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 | 444 |
| 441 void AddSourceIdConstraint(const std::string& source_id, | 445 void AddSourceIdConstraint(const std::string& source_id, |
| 442 StreamOptions::Constraints* constraints) { | 446 StreamOptions::Constraints* constraints) { |
| 443 constraints->push_back(StreamOptions::Constraint(kMediaStreamSourceInfoId, | 447 constraints->push_back(StreamOptions::Constraint(kMediaStreamSourceInfoId, |
| 444 source_id)); | 448 source_id)); |
| 445 } | 449 } |
| 446 | 450 |
| 447 scoped_refptr<MockMediaStreamDispatcherHost> host_; | 451 scoped_refptr<MockMediaStreamDispatcherHost> host_; |
| 448 scoped_ptr<media::AudioManager> audio_manager_; | 452 scoped_ptr<media::AudioManager> audio_manager_; |
| 449 scoped_ptr<MediaStreamManagerForTest> media_stream_manager_; | 453 scoped_ptr<MediaStreamManagerForTest> media_stream_manager_; |
| 454 MockMediaStreamUIProxy* stream_ui_; | |
| 450 ContentBrowserClient* old_browser_client_; | 455 ContentBrowserClient* old_browser_client_; |
| 451 scoped_ptr<ContentClient> content_client_; | 456 scoped_ptr<ContentClient> content_client_; |
| 452 content::TestBrowserThreadBundle thread_bundle_; | 457 content::TestBrowserThreadBundle thread_bundle_; |
| 453 content::TestBrowserContext browser_context_; | 458 content::TestBrowserContext browser_context_; |
| 454 media::AudioDeviceNames physical_audio_devices_; | 459 media::AudioDeviceNames physical_audio_devices_; |
| 455 media::VideoCaptureDevice::Names physical_video_devices_; | 460 media::VideoCaptureDevice::Names physical_video_devices_; |
| 456 GURL origin_; | 461 GURL origin_; |
| 457 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; | 462 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; |
| 458 }; | 463 }; |
| 459 | 464 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 } | 922 } |
| 918 | 923 |
| 919 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevices) { | 924 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevices) { |
| 920 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, | 925 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
| 921 MEDIA_DEVICE_VIDEO_CAPTURE); | 926 MEDIA_DEVICE_VIDEO_CAPTURE); |
| 922 EXPECT_TRUE(DoesContainLabels(host_->enumerated_devices_)); | 927 EXPECT_TRUE(DoesContainLabels(host_->enumerated_devices_)); |
| 923 } | 928 } |
| 924 | 929 |
| 925 TEST_F(MediaStreamDispatcherHostTest, EnumerateAudioDevicesNoAccess) { | 930 TEST_F(MediaStreamDispatcherHostTest, EnumerateAudioDevicesNoAccess) { |
| 926 media_stream_manager_->set_mic_access(false); | 931 media_stream_manager_->set_mic_access(false); |
| 932 stream_ui_->SetMicAccess(true); | |
| 927 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, | 933 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
| 928 MEDIA_DEVICE_AUDIO_CAPTURE); | 934 MEDIA_DEVICE_AUDIO_CAPTURE); |
| 929 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); | 935 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); |
| 930 } | 936 } |
| 931 | 937 |
| 932 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { | 938 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { |
| 933 media_stream_manager_->set_camera_access(false); | 939 media_stream_manager_->set_camera_access(false); |
| 940 stream_ui_->SetCameraAccess(true); | |
| 934 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, | 941 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
| 935 MEDIA_DEVICE_VIDEO_CAPTURE); | 942 MEDIA_DEVICE_VIDEO_CAPTURE); |
| 936 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); | 943 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); |
| 937 } | 944 } |
| 938 | 945 |
| 939 }; // namespace content | 946 }; // namespace content |
| OLD | NEW |