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 multithreaded apartment (MTA). | 22 // The test runs on a COM thread in the singlethreaded apartment (STA). |
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() | 25 CoreAudioUtilWinTest() { DCHECK(com_init_.succeeded()); } |
26 : com_init_(ScopedCOMInitializer::kMTA) { | |
27 DCHECK(com_init_.succeeded()); | |
28 } | |
29 virtual ~CoreAudioUtilWinTest() {} | 26 virtual ~CoreAudioUtilWinTest() {} |
30 | 27 |
31 bool DevicesAvailable() { | 28 bool DevicesAvailable() { |
32 if (!CoreAudioUtil::IsSupported()) | 29 if (!CoreAudioUtil::IsSupported()) |
33 return false; | 30 return false; |
34 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 && | 31 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 && |
35 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; | 32 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; |
36 } | 33 } |
37 | 34 |
38 ScopedCOMInitializer com_init_; | 35 ScopedCOMInitializer com_init_; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 } | 489 } |
493 | 490 |
494 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { | 491 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { |
495 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); | 492 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); |
496 | 493 |
497 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); | 494 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); |
498 EXPECT_FALSE(default_device_id.empty()); | 495 EXPECT_FALSE(default_device_id.empty()); |
499 } | 496 } |
500 | 497 |
501 } // namespace media | 498 } // namespace media |
OLD | NEW |