Index: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
diff --git a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
index 12f41fb1430fbb236354308394a367a8c02bc193..2fb9f8df130f7b982e9e56793f9fe0be633091f4 100644 |
--- a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
+++ b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
@@ -15,12 +15,23 @@ |
#include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
#include "content/common/media/media_stream_messages.h" |
#include "content/common/media/media_stream_options.h" |
+#include "content/public/browser/media_device_id.h" |
#include "content/public/test/mock_resource_context.h" |
#include "content/public/test/test_browser_thread_bundle.h" |
#include "content/test/test_content_browser_client.h" |
#include "content/test/test_content_client.h" |
#include "ipc/ipc_message_macros.h" |
#include "media/audio/audio_manager.h" |
+#include "media/audio/audio_manager_base.h" |
+#if defined(OS_ANDROID) |
+#include "media/audio/android/audio_manager_android.h" |
+#elif defined(OS_LINUX) || defined(OS_OPENBSD) |
+#include "media/audio/linux/audio_manager_linux.h" |
+#elif defined(OS_MACOSX) |
+#include "media/audio/mac/audio_manager_mac.h" |
+#elif defined(OS_WIN) |
+#include "media/audio/win/audio_manager_win.h" |
+#endif |
#include "media/video/capture/fake_video_capture_device.h" |
#include "net/url_request/url_request_context.h" |
#include "testing/gmock/include/gmock/gmock.h" |
@@ -38,6 +49,37 @@ const int kPageRequestId = 7; |
namespace content { |
+#if defined(OS_LINUX) || defined(OS_OPENBSD) |
+typedef media::AudioManagerLinux AudioManagerPlatform; |
+#elif defined(OS_MACOSX) |
+typedef media::AudioManagerMac AudioManagerPlatform; |
+#elif defined(OS_WIN) |
+typedef media::AudioManagerWin AudioManagerPlatform; |
+#elif defined(OS_ANDROID) |
+typedef media::AudioManagerAndroid AudioManagerPlatform; |
+#endif |
+ |
+// This class mocks the audio manager and overrides the |
+// GetAudioInputDeviceNames() method to ensure that we can run our tests on |
+// the buildbots. media::AudioManagerBase |
+class MockAudioManager : public AudioManagerPlatform { |
+ public: |
+ MockAudioManager() {} |
+ virtual ~MockAudioManager() {} |
+ |
+ virtual void GetAudioInputDeviceNames( |
+ media::AudioDeviceNames* device_names) OVERRIDE { |
+ DCHECK(device_names->empty()); |
+ device_names->push_back(media::AudioDeviceName("fake_device_name_1", |
+ "fake_device_id_1")); |
+ device_names->push_back(media::AudioDeviceName("fake_device_name_2", |
+ "fake_device_id_2")); |
+ } |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
+}; |
+ |
+ |
class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, |
public TestContentBrowserClient { |
public: |
@@ -61,10 +103,11 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, |
void OnGenerateStream(int render_view_id, |
int page_request_id, |
const StreamOptions& components, |
+ const GURL& security_origin, |
const base::Closure& quit_closure) { |
quit_closures_.push(quit_closure); |
MediaStreamDispatcherHost::OnGenerateStream( |
- render_view_id, page_request_id, components, GURL()); |
+ render_view_id, page_request_id, components, security_origin); |
} |
void OnStopStreamDevice(int render_view_id, |
@@ -76,25 +119,28 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, |
int page_request_id, |
const std::string& device_id, |
MediaStreamType type, |
+ const GURL& security_origin, |
const base::Closure& quit_closure) { |
quit_closures_.push(quit_closure); |
MediaStreamDispatcherHost::OnOpenDevice( |
- render_view_id, page_request_id, device_id, type, GURL()); |
+ render_view_id, page_request_id, device_id, type, security_origin); |
} |
- bool FindExistingRequestedDeviceInfo(const std::string& device_id, |
- MediaStreamRequestType request_type, |
- StreamDeviceInfo* device_info) { |
- MediaRequestState request_state; |
- return media_stream_manager_->FindExistingRequestedDeviceInfo( |
- kProcessId, kRenderId, request_type, device_id, device_info, |
- &request_state); |
+ void OnEnumerateDevices(int render_view_id, |
+ int page_request_id, |
+ MediaStreamType type, |
+ const GURL& security_origin, |
+ const base::Closure& quit_closure) { |
+ quit_closures_.push(quit_closure); |
+ MediaStreamDispatcherHost::OnEnumerateDevices( |
+ render_view_id, page_request_id, type, security_origin); |
} |
std::string label_; |
StreamDeviceInfoArray audio_devices_; |
StreamDeviceInfoArray video_devices_; |
StreamDeviceInfo opened_device_; |
+ StreamDeviceInfoArray enumerated_devices_; |
private: |
virtual ~MockMediaStreamDispatcherHost() {} |
@@ -115,6 +161,8 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, |
IPC_MESSAGE_HANDLER(MediaStreamMsg_StopGeneratedStream, |
OnStopGeneratedStreamFromBrowser) |
IPC_MESSAGE_HANDLER(MediaStreamMsg_DeviceOpened, OnDeviceOpened) |
+ IPC_MESSAGE_HANDLER(MediaStreamMsg_DevicesEnumerated, |
+ OnDevicesEnumerated) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
EXPECT_TRUE(handled); |
@@ -176,6 +224,17 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, |
opened_device_ = device; |
} |
+ void OnDevicesEnumerated(const IPC::Message& msg, |
+ int request_id, |
+ const std::string& label, |
+ const StreamDeviceInfoArray& devices) { |
+ base::Closure quit_closure = quit_closures_.front(); |
+ quit_closures_.pop(); |
+ message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); |
+ label_ = label; |
+ enumerated_devices_ = devices; |
+ } |
+ |
scoped_refptr<base::MessageLoopProxy> message_loop_; |
std::queue<base::Closure> quit_closures_; |
@@ -190,9 +249,10 @@ class MediaStreamDispatcherHostTest : public testing::Test { |
public: |
MediaStreamDispatcherHostTest() |
: old_browser_client_(NULL), |
- thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { |
+ thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
+ origin_("https://test.com") { |
// Create our own MediaStreamManager. |
- audio_manager_.reset(media::AudioManager::Create()); |
+ audio_manager_.reset(new MockAudioManager()); |
media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
// Make sure we use fake devices to avoid long delays. |
media_stream_manager_->UseFakeDevice(); |
@@ -207,10 +267,14 @@ class MediaStreamDispatcherHostTest : public testing::Test { |
} |
virtual ~MediaStreamDispatcherHostTest() { |
- // Recover the old browser client and content client. |
- SetBrowserClientForTesting(old_browser_client_); |
- content_client_.reset(); |
- media_stream_manager_->WillDestroyCurrentMessageLoop(); |
+ } |
+ |
+ virtual void SetUp() OVERRIDE { |
+ media::FakeVideoCaptureDevice::GetDeviceNames(&physical_video_devices_); |
+ ASSERT_GT(physical_video_devices_.size(), 0u); |
+ |
+ audio_manager_->GetAudioInputDeviceNames(&physical_audio_devices_); |
+ ASSERT_GT(physical_audio_devices_.size(), 0u); |
} |
virtual void TearDown() OVERRIDE { |
@@ -231,9 +295,28 @@ class MediaStreamDispatcherHostTest : public testing::Test { |
int page_request_id, |
const StreamOptions& options) { |
base::RunLoop run_loop; |
- host_->OnGenerateStream(render_view_id, page_request_id, options, |
+ EXPECT_CALL(*host_.get(), OnStreamGenerated( |
+ render_view_id, page_request_id, |
+ options.audio_type != MEDIA_NO_SERVICE ? 1 : 0, |
+ options.video_type != MEDIA_NO_SERVICE ? 1 : 0)); |
+ host_->OnGenerateStream(render_view_id, page_request_id, options, origin_, |
run_loop.QuitClosure()); |
run_loop.Run(); |
+ EXPECT_FALSE(DoesContainRawIds(host_->audio_devices_)); |
+ EXPECT_FALSE(DoesContainRawIds(host_->video_devices_)); |
+ EXPECT_TRUE(DoesEveryDeviceMapToRawId(host_->audio_devices_, origin_)); |
+ EXPECT_TRUE(DoesEveryDeviceMapToRawId(host_->video_devices_, origin_)); |
+ } |
+ |
+ void GenerateStreamAndWaitForFailure(int render_view_id, |
+ int page_request_id, |
+ const StreamOptions& options) { |
+ base::RunLoop run_loop; |
+ EXPECT_CALL(*host_.get(), |
+ OnStreamGenerationFailed(render_view_id, page_request_id)); |
+ host_->OnGenerateStream(render_view_id, page_request_id, options, origin_, |
+ run_loop.QuitClosure()); |
+ run_loop.Run(); |
} |
void OpenVideoDeviceAndWaitForResult(int render_view_id, |
@@ -241,9 +324,92 @@ class MediaStreamDispatcherHostTest : public testing::Test { |
const std::string& device_id) { |
base::RunLoop run_loop; |
host_->OnOpenDevice(render_view_id, page_request_id, device_id, |
- MEDIA_DEVICE_VIDEO_CAPTURE, |
+ MEDIA_DEVICE_VIDEO_CAPTURE, origin_, |
run_loop.QuitClosure()); |
run_loop.Run(); |
+ EXPECT_FALSE(DoesContainRawIds(host_->video_devices_)); |
+ EXPECT_TRUE(DoesEveryDeviceMapToRawId(host_->video_devices_, origin_)); |
+ } |
+ |
+ void StopStreamDeviceAndWait(const std::string& device_id) { |
+ EXPECT_TRUE(FindRequestedDeviceInfo(device_id, MEDIA_GENERATE_STREAM, |
+ NULL)); |
+ host_->OnStopStreamDevice(kRenderId, device_id); |
+ base::RunLoop().RunUntilIdle(); |
+ EXPECT_FALSE(FindRequestedDeviceInfo(device_id, MEDIA_GENERATE_STREAM, |
+ NULL)); |
+ } |
+ |
+ void EnumerateDevicesAndWaitForResult(int render_view_id, |
+ int page_request_id, |
+ MediaStreamType type) { |
+ base::RunLoop run_loop; |
+ host_->OnEnumerateDevices(render_view_id, page_request_id, type, origin_, |
+ run_loop.QuitClosure()); |
+ run_loop.Run(); |
+ ASSERT_FALSE(host_->enumerated_devices_.empty()); |
+ EXPECT_FALSE(DoesContainRawIds(host_->enumerated_devices_)); |
+ EXPECT_TRUE(DoesEveryDeviceMapToRawId(host_->enumerated_devices_, origin_)); |
+ } |
+ |
+ bool FindRequestedDeviceInfo(const std::string& device_id, |
+ MediaStreamRequestType request_type, |
+ StreamDeviceInfo* device_info) { |
+ return media_stream_manager_->FindRequestedDeviceInfo(device_id, |
+ kProcessId, |
+ kRenderId, |
+ request_type, |
+ device_info); |
+ } |
+ |
+ bool DoesContainRawIds(const StreamDeviceInfoArray& devices) { |
+ for (size_t i = 0; i < devices.size(); i++) { |
tommi (sloooow) - chröme
2013/10/28 13:48:23
nit: change i++ to ++i (elsewhere as well)
perkj_chrome
2013/10/29 08:52:17
Done.
|
+ media::AudioDeviceNames::const_iterator audio_it = |
+ physical_audio_devices_.begin(); |
+ for (; audio_it != physical_audio_devices_.end(); ++audio_it) { |
+ if (audio_it->unique_id == devices[i].device.id) |
+ return true; |
+ } |
+ media::VideoCaptureDevice::Names::const_iterator video_it = |
+ physical_video_devices_.begin(); |
+ for (; video_it != physical_video_devices_.end(); ++video_it) { |
+ if (video_it->id() == devices[i].device.id) |
+ return true; |
+ } |
+ } |
+ return false; |
+ } |
+ |
+ bool DoesEveryDeviceMapToRawId(const StreamDeviceInfoArray& devices, |
+ const GURL& origin) { |
+ for (size_t i = 0; i < devices.size(); i++) { |
+ bool found_match = false; |
+ media::AudioDeviceNames::const_iterator audio_it = |
+ physical_audio_devices_.begin(); |
+ for (; audio_it != physical_audio_devices_.end(); ++audio_it) { |
+ if (content::DoesMediaDeviceIDMatchHMAC( |
+ origin, |
+ devices[i].device.id, |
+ audio_it->unique_id)) { |
+ EXPECT_FALSE(found_match); |
+ found_match = true; |
+ } |
+ } |
+ media::VideoCaptureDevice::Names::const_iterator video_it = |
+ physical_video_devices_.begin(); |
+ for (; video_it != physical_video_devices_.end(); ++video_it) { |
+ if (content::DoesMediaDeviceIDMatchHMAC( |
+ origin, |
+ devices[i].device.id, |
+ video_it->id())) { |
+ EXPECT_FALSE(found_match); |
+ found_match = true; |
+ } |
+ } |
+ if (!found_match) |
+ return false; |
+ } |
+ return true; |
} |
scoped_refptr<MockMediaStreamDispatcherHost> host_; |
@@ -252,19 +418,31 @@ class MediaStreamDispatcherHostTest : public testing::Test { |
ContentBrowserClient* old_browser_client_; |
scoped_ptr<ContentClient> content_client_; |
content::TestBrowserThreadBundle thread_bundle_; |
+ media::AudioDeviceNames physical_audio_devices_; |
+ media::VideoCaptureDevice::Names physical_video_devices_; |
+ GURL origin_; |
}; |
TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithVideoOnly) { |
StreamOptions options(MEDIA_NO_SERVICE, MEDIA_DEVICE_VIDEO_CAPTURE); |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
EXPECT_EQ(host_->audio_devices_.size(), 0u); |
EXPECT_EQ(host_->video_devices_.size(), 1u); |
} |
+TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithAudioOnly) { |
+ StreamOptions options(MEDIA_DEVICE_AUDIO_CAPTURE, MEDIA_NO_SERVICE); |
+ |
+ SetupFakeUI(true); |
+ GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
+ |
+ EXPECT_EQ(host_->audio_devices_.size(), 1u); |
+ EXPECT_EQ(host_->video_devices_.size(), 0u); |
+} |
+ |
// This test generates two streams with video only using the same render view |
// id. The same capture device with the same device and session id is expected |
// to be used. |
@@ -273,7 +451,6 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsFromSameRenderId) { |
// Generate first stream. |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
// Check the latest generated stream. |
@@ -285,8 +462,6 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsFromSameRenderId) { |
// Generate second stream. |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), |
- OnStreamGenerated(kRenderId, kPageRequestId + 1, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId + 1, options); |
// Check the latest generated stream. |
@@ -306,7 +481,6 @@ TEST_F(MediaStreamDispatcherHostTest, |
// Generate first stream. |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
EXPECT_EQ(host_->audio_devices_.size(), 0u); |
@@ -335,7 +509,6 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsDifferentRenderId) { |
// Generate first stream. |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
// Check the latest generated stream. |
@@ -347,8 +520,6 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsDifferentRenderId) { |
// Generate second stream from another render view. |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), |
- OnStreamGenerated(kRenderId+1, kPageRequestId + 1, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId+1, kPageRequestId + 1, options); |
// Check the latest generated stream. |
@@ -378,41 +549,93 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsWithoutWaiting) { |
base::RunLoop run_loop1; |
base::RunLoop run_loop2; |
- host_->OnGenerateStream(kRenderId, kPageRequestId, options, |
+ host_->OnGenerateStream(kRenderId, kPageRequestId, options, origin_, |
run_loop1.QuitClosure()); |
- host_->OnGenerateStream(kRenderId, kPageRequestId + 1, options, |
+ host_->OnGenerateStream(kRenderId, kPageRequestId + 1, options, origin_, |
run_loop2.QuitClosure()); |
run_loop1.Run(); |
run_loop2.Run(); |
} |
+// Test that we can generate streams where a sourceId is specified in the |
+// request. |
+TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsWithSourceId) { |
+ ASSERT_GE(physical_audio_devices_.size(), 1u); |
+ ASSERT_GE(physical_video_devices_.size(), 1u); |
+ |
+ media::AudioDeviceNames::const_iterator audio_it = |
+ physical_audio_devices_.begin(); |
+ for (; audio_it != physical_audio_devices_.end(); ++audio_it) { |
+ StreamOptions options(MEDIA_DEVICE_AUDIO_CAPTURE, |
+ MEDIA_DEVICE_VIDEO_CAPTURE); |
+ options.audio_device_id = content::GetHMACForMediaDeviceID( |
+ origin_, |
+ audio_it->unique_id); |
+ ASSERT_FALSE(options.audio_device_id.empty()); |
+ |
+ // Generate first stream. |
+ SetupFakeUI(true); |
+ GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
+ EXPECT_EQ(host_->audio_devices_[0].device.id, options.audio_device_id); |
+ } |
+ |
+ media::VideoCaptureDevice::Names::const_iterator video_it = |
+ physical_video_devices_.begin(); |
+ for (; video_it != physical_video_devices_.end(); ++video_it) { |
+ StreamOptions options(MEDIA_DEVICE_AUDIO_CAPTURE, |
+ MEDIA_DEVICE_VIDEO_CAPTURE); |
+ options.video_device_id = content::GetHMACForMediaDeviceID( |
+ origin_, |
+ video_it->id()); |
+ ASSERT_FALSE(options.video_device_id.empty()); |
+ |
+ // Generate first stream. |
+ SetupFakeUI(true); |
+ GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
+ EXPECT_EQ(host_->video_devices_[0].device.id, options.video_device_id); |
+ } |
+} |
+ |
+// Test that generating a stream with an invalid video source id fail. |
+TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsWithInvalidVideoSourceId) { |
+ StreamOptions options(MEDIA_DEVICE_AUDIO_CAPTURE, |
+ MEDIA_DEVICE_VIDEO_CAPTURE); |
+ std::string invalid_source_id = "invalid source id"; |
+ options.video_device_id = invalid_source_id; |
+ |
+ GenerateStreamAndWaitForFailure(kRenderId, kRenderId, options); |
+} |
+ |
+// Test that generating a stream with an invalid audio source id fail. |
+TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsWithInvalidAudioSourceId) { |
+ StreamOptions options(MEDIA_DEVICE_AUDIO_CAPTURE, |
+ MEDIA_DEVICE_VIDEO_CAPTURE); |
+ std::string invalid_source_id = "invalid source id"; |
+ options.audio_device_id = invalid_source_id; |
+ |
+ GenerateStreamAndWaitForFailure(kRenderId, kRenderId, options); |
+} |
+ |
TEST_F(MediaStreamDispatcherHostTest, StopDeviceInStream) { |
StreamOptions options(MEDIA_NO_SERVICE, MEDIA_DEVICE_VIDEO_CAPTURE); |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
const std::string device_id = host_->video_devices_.front().device.id; |
const int session_id = host_->video_devices_.front().session_id; |
StreamDeviceInfo video_device_info; |
- EXPECT_TRUE(host_->FindExistingRequestedDeviceInfo(device_id, |
- MEDIA_GENERATE_STREAM, |
- &video_device_info)); |
+ EXPECT_TRUE(FindRequestedDeviceInfo(device_id, MEDIA_GENERATE_STREAM, |
+ &video_device_info)); |
EXPECT_EQ(video_device_info.device.id, device_id); |
EXPECT_EQ(video_device_info.session_id, session_id); |
OpenVideoDeviceAndWaitForResult(kRenderId, kPageRequestId, device_id); |
- host_->OnStopStreamDevice(kRenderId, device_id); |
+ StopStreamDeviceAndWait(device_id); |
- EXPECT_FALSE(host_->FindExistingRequestedDeviceInfo(device_id, |
- MEDIA_GENERATE_STREAM, |
- &video_device_info)); |
- EXPECT_TRUE(host_->FindExistingRequestedDeviceInfo(device_id, |
- MEDIA_OPEN_DEVICE, |
- &video_device_info)); |
+ EXPECT_TRUE(FindRequestedDeviceInfo(device_id, MEDIA_OPEN_DEVICE, NULL)); |
} |
TEST_F(MediaStreamDispatcherHostTest, CancelPendingStreamsOnChannelClosing) { |
@@ -423,7 +646,7 @@ TEST_F(MediaStreamDispatcherHostTest, CancelPendingStreamsOnChannelClosing) { |
// Create multiple GenerateStream requests. |
size_t streams = 5; |
for (size_t i = 1; i <= streams; ++i) { |
- host_->OnGenerateStream(kRenderId, kPageRequestId + i, options, |
+ host_->OnGenerateStream(kRenderId, kPageRequestId + i, options, origin_, |
run_loop.QuitClosure()); |
} |
@@ -439,8 +662,6 @@ TEST_F(MediaStreamDispatcherHostTest, StopGeneratedStreamsOnChannelClosing) { |
size_t generated_streams = 3; |
for (size_t i = 0; i < generated_streams; ++i) { |
SetupFakeUI(true); |
- EXPECT_CALL(*host_.get(), |
- OnStreamGenerated(kRenderId, kPageRequestId + i, 0, 1)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId + i, options); |
} |
@@ -458,9 +679,8 @@ TEST_F(MediaStreamDispatcherHostTest, CloseFromUI) { |
.WillOnce(SaveArg<0>(&close_callback)); |
media_stream_manager_->UseFakeUI(stream_ui.PassAs<FakeMediaStreamUIProxy>()); |
- EXPECT_CALL(*host_.get(), OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
- EXPECT_CALL(*host_.get(), OnStopGeneratedStreamFromBrowser(kRenderId)); |
GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, options); |
+ EXPECT_CALL(*host_.get(), OnStopGeneratedStreamFromBrowser(kRenderId)); |
EXPECT_EQ(host_->audio_devices_.size(), 0u); |
EXPECT_EQ(host_->video_devices_.size(), 1u); |
@@ -470,4 +690,15 @@ TEST_F(MediaStreamDispatcherHostTest, CloseFromUI) { |
base::RunLoop().RunUntilIdle(); |
} |
+TEST_F(MediaStreamDispatcherHostTest, EnumerateAudioDevices) { |
+ EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
+ MEDIA_DEVICE_AUDIO_CAPTURE); |
+} |
+ |
+TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevices) { |
+ EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
+ MEDIA_DEVICE_VIDEO_CAPTURE); |
+} |
+ |
+ |
}; // namespace content |