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

Side by Side Diff: media/audio/audio_manager_unittest.cc

Issue 1339183002: Add localized default audio device names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize in run_all_unittests. Created 5 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/bind.h" 5 #include "base/bind.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "media/audio/audio_manager.h" 10 #include "media/audio/audio_manager.h"
11 #include "media/audio/audio_manager_base.h" 11 #include "media/audio/audio_manager_base.h"
12 #include "media/audio/audio_unittest_util.h" 12 #include "media/audio/audio_unittest_util.h"
13 #include "media/audio/fake_audio_log_factory.h" 13 #include "media/audio/fake_audio_log_factory.h"
14 #include "media/base/fake_media_resources.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 #if defined(USE_ALSA) 17 #if defined(USE_ALSA)
17 #include "media/audio/alsa/audio_manager_alsa.h" 18 #include "media/audio/alsa/audio_manager_alsa.h"
18 #endif // defined(USE_ALSA) 19 #endif // defined(USE_ALSA)
19 20
20 #if defined(OS_WIN) 21 #if defined(OS_WIN)
21 #include "base/win/scoped_com_initializer.h" 22 #include "base/win/scoped_com_initializer.h"
22 #include "media/audio/win/audio_manager_win.h" 23 #include "media/audio/win/audio_manager_win.h"
23 #include "media/audio/win/wavein_input_win.h" 24 #include "media/audio/win/wavein_input_win.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #endif 75 #endif
75 76
76 // Helper method which verifies that the device list starts with a valid 77 // Helper method which verifies that the device list starts with a valid
77 // default record followed by non-default device names. 78 // default record followed by non-default device names.
78 static void CheckDeviceNames(const AudioDeviceNames& device_names) { 79 static void CheckDeviceNames(const AudioDeviceNames& device_names) {
79 DVLOG(2) << "Got " << device_names.size() << " audio devices."; 80 DVLOG(2) << "Got " << device_names.size() << " audio devices.";
80 if (!device_names.empty()) { 81 if (!device_names.empty()) {
81 AudioDeviceNames::const_iterator it = device_names.begin(); 82 AudioDeviceNames::const_iterator it = device_names.begin();
82 83
83 // The first device in the list should always be the default device. 84 // The first device in the list should always be the default device.
84 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), 85 EXPECT_EQ(AudioManager::GetDefaultDeviceName(), it->device_name);
85 it->device_name);
86 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); 86 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id);
87 ++it; 87 ++it;
88 88
89 // Other devices should have non-empty name and id and should not contain 89 // Other devices should have non-empty name and id and should not contain
90 // default name or id. 90 // default name or id.
91 while (it != device_names.end()) { 91 while (it != device_names.end()) {
92 EXPECT_FALSE(it->device_name.empty()); 92 EXPECT_FALSE(it->device_name.empty());
93 EXPECT_FALSE(it->unique_id.empty()); 93 EXPECT_FALSE(it->unique_id.empty());
94 DVLOG(2) << "Device ID(" << it->unique_id 94 DVLOG(2) << "Device ID(" << it->unique_id
95 << "), label: " << it->device_name; 95 << "), label: " << it->device_name;
96 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), 96 EXPECT_NE(AudioManager::GetDefaultDeviceName(), it->device_name);
97 it->device_name);
98 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), 97 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId),
99 it->unique_id); 98 it->unique_id);
100 ++it; 99 ++it;
101 } 100 }
102 } else { 101 } else {
103 // Log a warning so we can see the status on the build bots. No need to 102 // Log a warning so we can see the status on the build bots. No need to
104 // break the test though since this does successfully test the code and 103 // break the test though since this does successfully test the code and
105 // some failure cases. 104 // some failure cases.
106 LOG(WARNING) << "No input devices detected"; 105 LOG(WARNING) << "No input devices detected";
107 } 106 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 DVLOG(2) << it->unique_id << " matches with " << output_device_id; 360 DVLOG(2) << it->unique_id << " matches with " << output_device_id;
362 found_an_associated_device = true; 361 found_an_associated_device = true;
363 } 362 }
364 } 363 }
365 364
366 EXPECT_TRUE(found_an_associated_device); 365 EXPECT_TRUE(found_an_associated_device);
367 #endif // defined(OS_WIN) || defined(OS_MACOSX) 366 #endif // defined(OS_WIN) || defined(OS_MACOSX)
368 } 367 }
369 368
370 } // namespace media 369 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698