| 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 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() | 25 CoreAudioUtilWinTest() |
| 26 : com_init_(ScopedCOMInitializer::kMTA) { | 26 : com_init_(ScopedCOMInitializer::kMTA) { |
| 27 DCHECK(com_init_.succeeded()); | 27 DCHECK(com_init_.succeeded()); |
| 28 } | 28 } |
| 29 virtual ~CoreAudioUtilWinTest() {} | 29 ~CoreAudioUtilWinTest() override {} |
| 30 | 30 |
| 31 bool DevicesAvailable() { | 31 bool DevicesAvailable() { |
| 32 if (!CoreAudioUtil::IsSupported()) | 32 if (!CoreAudioUtil::IsSupported()) |
| 33 return false; | 33 return false; |
| 34 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 && | 34 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 && |
| 35 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; | 35 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; |
| 36 } | 36 } |
| 37 | 37 |
| 38 ScopedCOMInitializer com_init_; | 38 ScopedCOMInitializer com_init_; |
| 39 }; | 39 }; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 492 } |
| 493 | 493 |
| 494 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { | 494 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { |
| 495 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); | 495 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); |
| 496 | 496 |
| 497 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); | 497 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); |
| 498 EXPECT_FALSE(default_device_id.empty()); | 498 EXPECT_FALSE(default_device_id.empty()); |
| 499 } | 499 } |
| 500 | 500 |
| 501 } // namespace media | 501 } // namespace media |
| OLD | NEW |