| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 using testing::_; | 24 using testing::_; |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class MockAudioManager : public media::FakeAudioManager { | 30 class MockAudioManager : public media::FakeAudioManager { |
| 31 public: | 31 public: |
| 32 MockAudioManager(size_t num_devices) | 32 MockAudioManager(size_t num_devices) |
| 33 : FakeAudioManager(&fake_audio_log_factory_), num_devices_(num_devices) {} | 33 : FakeAudioManager(base::ThreadTaskRunnerHandle::Get(), |
| 34 base::ThreadTaskRunnerHandle::Get(), |
| 35 &fake_audio_log_factory_), |
| 36 num_devices_(num_devices) {} |
| 34 MockAudioManager() : MockAudioManager(0) {} | 37 MockAudioManager() : MockAudioManager(0) {} |
| 35 ~MockAudioManager() override {} | 38 ~MockAudioManager() override {} |
| 36 | 39 |
| 37 MOCK_METHOD1(MockGetAudioOutputDeviceNames, void(media::AudioDeviceNames*)); | 40 MOCK_METHOD1(MockGetAudioOutputDeviceNames, void(media::AudioDeviceNames*)); |
| 38 | 41 |
| 39 void GetAudioOutputDeviceNames( | 42 void GetAudioOutputDeviceNames( |
| 40 media::AudioDeviceNames* device_names) override { | 43 media::AudioDeviceNames* device_names) override { |
| 41 DCHECK(device_names->empty()); | 44 DCHECK(device_names->empty()); |
| 42 MockGetAudioOutputDeviceNames(device_names); | 45 MockGetAudioOutputDeviceNames(device_names); |
| 43 if (num_devices_ > 0) { | 46 if (num_devices_ > 0) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 EXPECT_EQ(num_entries_expected, result.devices.size()); | 114 EXPECT_EQ(num_entries_expected, result.devices.size()); |
| 112 task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); | 115 task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); |
| 113 } | 116 } |
| 114 | 117 |
| 115 void QuitCallback(const AudioOutputDeviceEnumeration& result) { | 118 void QuitCallback(const AudioOutputDeviceEnumeration& result) { |
| 116 MockCallback(result); | 119 MockCallback(result); |
| 117 task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); | 120 task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); |
| 118 } | 121 } |
| 119 | 122 |
| 120 protected: | 123 protected: |
| 121 scoped_ptr<MockAudioManager> audio_manager_; | 124 scoped_ptr<MockAudioManager, media::AudioManagerDeleter> audio_manager_; |
| 122 TestBrowserThreadBundle thread_bundle_; | 125 TestBrowserThreadBundle thread_bundle_; |
| 123 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 126 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 124 base::RunLoop run_loop_; | 127 base::RunLoop run_loop_; |
| 125 | 128 |
| 126 private: | 129 private: |
| 127 DISALLOW_COPY_AND_ASSIGN(AudioOutputDeviceEnumeratorTest); | 130 DISALLOW_COPY_AND_ASSIGN(AudioOutputDeviceEnumeratorTest); |
| 128 }; | 131 }; |
| 129 | 132 |
| 130 TEST_F(AudioOutputDeviceEnumeratorTest, EnumerateWithCache) { | 133 TEST_F(AudioOutputDeviceEnumeratorTest, EnumerateWithCache) { |
| 131 const int num_calls = 10; | 134 const int num_calls = 10; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 AudioOutputDeviceEnumerator enumerator( | 203 AudioOutputDeviceEnumerator enumerator( |
| 201 audio_manager_.get(), | 204 audio_manager_.get(), |
| 202 AudioOutputDeviceEnumerator::CACHE_POLICY_NO_CACHING); | 205 AudioOutputDeviceEnumerator::CACHE_POLICY_NO_CACHING); |
| 203 enumerator.Enumerate( | 206 enumerator.Enumerate( |
| 204 base::Bind(&AudioOutputDeviceEnumeratorTest::EnumerateCountCallback, | 207 base::Bind(&AudioOutputDeviceEnumeratorTest::EnumerateCountCallback, |
| 205 base::Unretained(this), num_devices + 1, true)); | 208 base::Unretained(this), num_devices + 1, true)); |
| 206 run_loop_.Run(); | 209 run_loop_.Run(); |
| 207 } | 210 } |
| 208 | 211 |
| 209 } // namespace content | 212 } // namespace content |
| OLD | NEW |