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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 class MAYBE_AudioInputDeviceManagerTest : public testing::Test { | 58 class MAYBE_AudioInputDeviceManagerTest : public testing::Test { |
59 public: | 59 public: |
60 MAYBE_AudioInputDeviceManagerTest() {} | 60 MAYBE_AudioInputDeviceManagerTest() {} |
61 | 61 |
62 protected: | 62 protected: |
63 void SetUp() override { | 63 void SetUp() override { |
64 // The test must run on Browser::IO. | 64 // The test must run on Browser::IO. |
65 message_loop_.reset(new base::MessageLoopForIO); | 65 message_loop_.reset(new base::MessageLoopForIO); |
66 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 66 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
67 message_loop_.get())); | 67 message_loop_.get())); |
68 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 68 audio_manager_ = |
69 // Wait for audio thread initialization to complete. Otherwise the | 69 media::AudioManager::CreateForTesting(message_loop_->task_runner()); |
70 // enumeration type may not have been set yet. | |
71 base::WaitableEvent event(false, false); | |
72 audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( | |
73 &base::WaitableEvent::Signal, base::Unretained(&event))); | |
74 event.Wait(); | |
75 manager_ = new AudioInputDeviceManager(audio_manager_.get()); | 70 manager_ = new AudioInputDeviceManager(audio_manager_.get()); |
76 manager_->UseFakeDevice(); | 71 manager_->UseFakeDevice(); |
77 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 72 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
78 manager_->Register(audio_input_listener_.get(), | 73 manager_->Register(audio_input_listener_.get(), |
79 message_loop_->task_runner().get()); | 74 message_loop_->task_runner().get()); |
80 | 75 |
81 // Gets the enumerated device list from the AudioInputDeviceManager. | 76 // Gets the enumerated device list from the AudioInputDeviceManager. |
82 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 77 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
83 EXPECT_CALL(*audio_input_listener_, | 78 EXPECT_CALL(*audio_input_listener_, |
84 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) | 79 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) |
85 .Times(1) | 80 .Times(1) |
86 .WillOnce(SaveArg<1>(&devices_)); | 81 .WillOnce(SaveArg<1>(&devices_)); |
87 | 82 |
88 // Wait until we get the list. | 83 // Wait until we get the list. |
89 message_loop_->RunUntilIdle(); | 84 message_loop_->RunUntilIdle(); |
90 } | 85 } |
91 | 86 |
92 void TearDown() override { | 87 void TearDown() override { |
93 manager_->Unregister(); | 88 manager_->Unregister(); |
94 io_thread_.reset(); | 89 io_thread_.reset(); |
95 } | 90 } |
96 | 91 |
97 scoped_ptr<base::MessageLoop> message_loop_; | 92 scoped_ptr<base::MessageLoop> message_loop_; |
98 scoped_ptr<BrowserThreadImpl> io_thread_; | 93 scoped_ptr<BrowserThreadImpl> io_thread_; |
99 scoped_refptr<AudioInputDeviceManager> manager_; | 94 scoped_refptr<AudioInputDeviceManager> manager_; |
100 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; | 95 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; |
101 scoped_ptr<media::AudioManager> audio_manager_; | 96 media::ScopedAudioManagerPtr audio_manager_; |
102 StreamDeviceInfoArray devices_; | 97 StreamDeviceInfoArray devices_; |
103 | 98 |
104 private: | 99 private: |
105 DISALLOW_COPY_AND_ASSIGN(MAYBE_AudioInputDeviceManagerTest); | 100 DISALLOW_COPY_AND_ASSIGN(MAYBE_AudioInputDeviceManagerTest); |
106 }; | 101 }; |
107 | 102 |
108 // Opens and closes the devices. | 103 // Opens and closes the devices. |
109 TEST_F(MAYBE_AudioInputDeviceManagerTest, OpenAndCloseDevice) { | 104 TEST_F(MAYBE_AudioInputDeviceManagerTest, OpenAndCloseDevice) { |
110 | 105 |
111 ASSERT_FALSE(devices_.empty()); | 106 ASSERT_FALSE(devices_.empty()); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 DCHECK(!info); | 279 DCHECK(!info); |
285 | 280 |
286 manager_->Close(session_id); | 281 manager_->Close(session_id); |
287 EXPECT_CALL(*audio_input_listener_, | 282 EXPECT_CALL(*audio_input_listener_, |
288 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) | 283 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) |
289 .Times(1); | 284 .Times(1); |
290 message_loop_->RunUntilIdle(); | 285 message_loop_->RunUntilIdle(); |
291 } | 286 } |
292 | 287 |
293 } // namespace content | 288 } // namespace content |
OLD | NEW |