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 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
11 #include "content/browser/renderer_host/media/media_stream_manager.h" | 11 #include "content/browser/renderer_host/media/media_stream_manager.h" |
12 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 12 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
13 #include "content/common/media/media_stream_options.h" | 13 #include "content/common/media/media_stream_options.h" |
14 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "media/audio/audio_manager_base.h" | 15 #include "media/audio/audio_manager_base.h" |
16 #include "media/audio/fake_audio_log_factory.h" | 16 #include "media/audio/fake_audio_log_factory.h" |
| 17 #include "media/video/capture/fake_video_capture_device_factory.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 #if defined(USE_ALSA) | 21 #if defined(USE_ALSA) |
21 #include "media/audio/alsa/audio_manager_alsa.h" | 22 #include "media/audio/alsa/audio_manager_alsa.h" |
22 #elif defined(OS_ANDROID) | 23 #elif defined(OS_ANDROID) |
23 #include "media/audio/android/audio_manager_android.h" | 24 #include "media/audio/android/audio_manager_android.h" |
24 #elif defined(OS_MACOSX) | 25 #elif defined(OS_MACOSX) |
25 #include "media/audio/mac/audio_manager_mac.h" | 26 #include "media/audio/mac/audio_manager_mac.h" |
26 #elif defined(OS_WIN) | 27 #elif defined(OS_WIN) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class MediaStreamManagerTest : public ::testing::Test { | 74 class MediaStreamManagerTest : public ::testing::Test { |
74 public: | 75 public: |
75 MediaStreamManagerTest() | 76 MediaStreamManagerTest() |
76 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 77 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
77 message_loop_(base::MessageLoopProxy::current()) { | 78 message_loop_(base::MessageLoopProxy::current()) { |
78 // Create our own MediaStreamManager. | 79 // Create our own MediaStreamManager. |
79 audio_manager_.reset(new MockAudioManager()); | 80 audio_manager_.reset(new MockAudioManager()); |
80 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 81 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
81 | 82 |
82 // Use fake devices in order to run on the bots. | 83 // Use fake devices in order to run on the bots. |
83 media_stream_manager_->UseFakeDevice(); | 84 media_stream_manager_->UseFakeVideoDevice( |
84 } | 85 scoped_ptr<media::VideoCaptureDeviceFactory>( |
| 86 new media::FakeVideoCaptureDeviceFactory())); |
| 87 media_stream_manager_->UseFakeAudioDevice(); |
| 88 } |
85 | 89 |
86 virtual ~MediaStreamManagerTest() { | 90 virtual ~MediaStreamManagerTest() { |
87 } | 91 } |
88 | 92 |
89 MOCK_METHOD1(Response, void(int index)); | 93 MOCK_METHOD1(Response, void(int index)); |
90 void ResponseCallback(int index, | 94 void ResponseCallback(int index, |
91 const MediaStreamDevices& devices, | 95 const MediaStreamDevices& devices, |
92 scoped_ptr<MediaStreamUIProxy> ui_proxy) { | 96 scoped_ptr<MediaStreamUIProxy> ui_proxy) { |
93 Response(index); | 97 Response(index); |
94 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); | 98 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 std::string label2 = MakeMediaAccessRequest(1); | 176 std::string label2 = MakeMediaAccessRequest(1); |
173 media_stream_manager_->CancelRequest(label1); | 177 media_stream_manager_->CancelRequest(label1); |
174 | 178 |
175 // Expecting the callback from the second request will be triggered and | 179 // Expecting the callback from the second request will be triggered and |
176 // quit the test. | 180 // quit the test. |
177 EXPECT_CALL(*this, Response(1)); | 181 EXPECT_CALL(*this, Response(1)); |
178 run_loop_.Run(); | 182 run_loop_.Run(); |
179 } | 183 } |
180 | 184 |
181 } // namespace content | 185 } // namespace content |
OLD | NEW |