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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #define MAYBE_AudioInputDeviceManagerTest DISABLED_AudioInputDeviceManagerTest | 48 #define MAYBE_AudioInputDeviceManagerTest DISABLED_AudioInputDeviceManagerTest |
49 #else | 49 #else |
50 #define MAYBE_AudioInputDeviceManagerTest AudioInputDeviceManagerTest | 50 #define MAYBE_AudioInputDeviceManagerTest AudioInputDeviceManagerTest |
51 #endif | 51 #endif |
52 | 52 |
53 class MAYBE_AudioInputDeviceManagerTest : public testing::Test { | 53 class MAYBE_AudioInputDeviceManagerTest : public testing::Test { |
54 public: | 54 public: |
55 MAYBE_AudioInputDeviceManagerTest() {} | 55 MAYBE_AudioInputDeviceManagerTest() {} |
56 | 56 |
57 protected: | 57 protected: |
58 virtual void SetUp() override { | 58 void SetUp() override { |
59 // The test must run on Browser::IO. | 59 // The test must run on Browser::IO. |
60 message_loop_.reset(new base::MessageLoopForIO); | 60 message_loop_.reset(new base::MessageLoopForIO); |
61 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 61 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
62 message_loop_.get())); | 62 message_loop_.get())); |
63 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 63 audio_manager_.reset(media::AudioManager::CreateForTesting()); |
64 // Wait for audio thread initialization to complete. Otherwise the | 64 // Wait for audio thread initialization to complete. Otherwise the |
65 // enumeration type may not have been set yet. | 65 // enumeration type may not have been set yet. |
66 base::WaitableEvent event(false, false); | 66 base::WaitableEvent event(false, false); |
67 audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( | 67 audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( |
68 &base::WaitableEvent::Signal, base::Unretained(&event))); | 68 &base::WaitableEvent::Signal, base::Unretained(&event))); |
69 event.Wait(); | 69 event.Wait(); |
70 manager_ = new AudioInputDeviceManager(audio_manager_.get()); | 70 manager_ = new AudioInputDeviceManager(audio_manager_.get()); |
71 manager_->UseFakeDevice(); | 71 manager_->UseFakeDevice(); |
72 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 72 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
73 manager_->Register(audio_input_listener_.get(), | 73 manager_->Register(audio_input_listener_.get(), |
74 message_loop_->message_loop_proxy().get()); | 74 message_loop_->message_loop_proxy().get()); |
75 | 75 |
76 // Gets the enumerated device list from the AudioInputDeviceManager. | 76 // Gets the enumerated device list from the AudioInputDeviceManager. |
77 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 77 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
78 EXPECT_CALL(*audio_input_listener_, | 78 EXPECT_CALL(*audio_input_listener_, |
79 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) | 79 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) |
80 .Times(1) | 80 .Times(1) |
81 .WillOnce(SaveArg<1>(&devices_)); | 81 .WillOnce(SaveArg<1>(&devices_)); |
82 | 82 |
83 // Wait until we get the list. | 83 // Wait until we get the list. |
84 message_loop_->RunUntilIdle(); | 84 message_loop_->RunUntilIdle(); |
85 } | 85 } |
86 | 86 |
87 virtual void TearDown() override { | 87 void TearDown() override { |
88 manager_->Unregister(); | 88 manager_->Unregister(); |
89 io_thread_.reset(); | 89 io_thread_.reset(); |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<base::MessageLoop> message_loop_; | 92 scoped_ptr<base::MessageLoop> message_loop_; |
93 scoped_ptr<BrowserThreadImpl> io_thread_; | 93 scoped_ptr<BrowserThreadImpl> io_thread_; |
94 scoped_refptr<AudioInputDeviceManager> manager_; | 94 scoped_refptr<AudioInputDeviceManager> manager_; |
95 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; | 95 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; |
96 scoped_ptr<media::AudioManager> audio_manager_; | 96 scoped_ptr<media::AudioManager> audio_manager_; |
97 StreamDeviceInfoArray devices_; | 97 StreamDeviceInfoArray devices_; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 DCHECK(!info); | 279 DCHECK(!info); |
280 | 280 |
281 manager_->Close(session_id); | 281 manager_->Close(session_id); |
282 EXPECT_CALL(*audio_input_listener_, | 282 EXPECT_CALL(*audio_input_listener_, |
283 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) | 283 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) |
284 .Times(1); | 284 .Times(1); |
285 message_loop_->RunUntilIdle(); | 285 message_loop_->RunUntilIdle(); |
286 } | 286 } |
287 | 287 |
288 } // namespace content | 288 } // namespace content |
OLD | NEW |