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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/win/scoped_co_mem.h" | 8 #include "base/win/scoped_co_mem.h" |
9 #include "base/win/scoped_com_initializer.h" | 9 #include "base/win/scoped_com_initializer.h" |
10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
11 #include "media/audio/audio_unittest_util.h" | 11 #include "media/audio/audio_unittest_util.h" |
12 #include "media/audio/win/core_audio_util_win.h" | 12 #include "media/audio/win/core_audio_util_win.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using base::win::ScopedCOMInitializer; | 16 using base::win::ScopedCOMInitializer; |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 | 19 |
20 class CoreAudioUtilWinTest : public ::testing::Test { | 20 class CoreAudioUtilWinTest : public ::testing::Test { |
21 protected: | 21 protected: |
22 // The test runs on a COM thread in the singlethreaded apartment (STA). | 22 // The test runs on a COM thread in the multithreaded apartment (MTA). |
23 // If we don't initialize the COM library on a thread before using COM, | 23 // If we don't initialize the COM library on a thread before using COM, |
24 // all function calls will return CO_E_NOTINITIALIZED. | 24 // all function calls will return CO_E_NOTINITIALIZED. |
25 CoreAudioUtilWinTest() { DCHECK(com_init_.succeeded()); } | 25 CoreAudioUtilWinTest() |
| 26 : com_init_(ScopedCOMInitializer::kMTA) { |
| 27 DCHECK(com_init_.succeeded()); |
| 28 } |
26 virtual ~CoreAudioUtilWinTest() {} | 29 virtual ~CoreAudioUtilWinTest() {} |
27 | 30 |
28 bool DevicesAvailable() { | 31 bool DevicesAvailable() { |
29 if (!CoreAudioUtil::IsSupported()) | 32 if (!CoreAudioUtil::IsSupported()) |
30 return false; | 33 return false; |
31 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 && | 34 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 && |
32 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; | 35 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; |
33 } | 36 } |
34 | 37 |
35 ScopedCOMInitializer com_init_; | 38 ScopedCOMInitializer com_init_; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 492 } |
490 | 493 |
491 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { | 494 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { |
492 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); | 495 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); |
493 | 496 |
494 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); | 497 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); |
495 EXPECT_FALSE(default_device_id.empty()); | 498 EXPECT_FALSE(default_device_id.empty()); |
496 } | 499 } |
497 | 500 |
498 } // namespace media | 501 } // namespace media |
OLD | NEW |