Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: media/audio/win/core_audio_util_win_unittest.cc

Issue 1130753005: Get audio_unittests passing with h/w on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: MTA -> STA Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/win/audio_output_win_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 tests must run on a COM thread.
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) {
27 DCHECK(com_init_.succeeded()); 26 DCHECK(com_init_.succeeded());
28 } 27 }
29 ~CoreAudioUtilWinTest() override {} 28 ~CoreAudioUtilWinTest() override {}
30 29
31 bool DevicesAvailable() { 30 bool DevicesAvailable() {
32 if (!CoreAudioUtil::IsSupported()) 31 return CoreAudioUtil::IsSupported() &&
33 return false; 32 CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 &&
34 return CoreAudioUtil::NumberOfActiveDevices(eCapture) > 0 &&
35 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0; 33 CoreAudioUtil::NumberOfActiveDevices(eRender) > 0;
36 } 34 }
37 35
38 ScopedCOMInitializer com_init_; 36 ScopedCOMInitializer com_init_;
39 }; 37 };
40 38
41 TEST_F(CoreAudioUtilWinTest, NumberOfActiveDevices) { 39 TEST_F(CoreAudioUtilWinTest, NumberOfActiveDevices) {
42 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); 40 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable());
43 41
44 int render_devices = CoreAudioUtil::NumberOfActiveDevices(eRender); 42 int render_devices = CoreAudioUtil::NumberOfActiveDevices(eRender);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 490 }
493 491
494 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { 492 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) {
495 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); 493 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable());
496 494
497 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); 495 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID());
498 EXPECT_FALSE(default_device_id.empty()); 496 EXPECT_FALSE(default_device_id.empty());
499 } 497 }
500 498
501 } // namespace media 499 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_output_win_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698