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

Unified Diff: media/audio/android/audio_android_unittest.cc

Issue 110173003: Refactor audio manager for Android to avoid heavy tasks at startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed mActive state Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/android/audio_android_unittest.cc
diff --git a/media/audio/android/audio_android_unittest.cc b/media/audio/android/audio_android_unittest.cc
index 300e1545322feabcb104f35947b66c866404455d..a1a0027796acea324306a89440b609429101721d 100644
--- a/media/audio/android/audio_android_unittest.cc
+++ b/media/audio/android/audio_android_unittest.cc
@@ -84,6 +84,40 @@ static double ExpectedTimeBetweenCallbacks(AudioParameters params) {
static_cast<double>(params.sample_rate()))).InMillisecondsF();
}
+// Helper method which verifies that the device list starts with a valid
+// default device name followed by non-default device names.
+static void CheckDeviceNames(const AudioDeviceNames& device_names) {
+ VLOG(2) << "Got " << device_names.size() << " audio devices.";
+ if (device_names.empty()) {
+ // Log a warning so we can see the status on the build bots. No need to
+ // break the test though since this does successfully test the code and
+ // some failure cases.
+ LOG(WARNING) << "No input devices detected";
+ }
+
+ AudioDeviceNames::const_iterator it = device_names.begin();
+
+ // The first device in the list should always be the default device.
+ EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName),
+ it->device_name);
+ EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id);
+ ++it;
+
+ // Other devices should have non-empty name and id and should not contain
+ // default name or id.
+ while (it != device_names.end()) {
+ EXPECT_FALSE(it->device_name.empty());
+ EXPECT_FALSE(it->unique_id.empty());
+ VLOG(2) << "Device ID(" << it->unique_id
+ << "), label: " << it->device_name;
+ EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName),
+ it->device_name);
+ EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId),
+ it->unique_id);
+ ++it;
+ }
+}
+
std::ostream& operator<<(std::ostream& os, const AudioParameters& params) {
using namespace std;
os << endl << "format: " << FormatToString(params.format()) << endl
@@ -524,10 +558,36 @@ TEST_F(AudioAndroidTest, IsAudioLowLatencySupported) {
: VLOG(0) << "Low latency output is *not* supported";
}
+// Verify input device enumeration.
+TEST_F(AudioAndroidTest, GetAudioInputDeviceNames) {
+ if (!audio_manager()->HasAudioInputDevices())
+ return;
+ AudioDeviceNames devices;
+ audio_manager()->GetAudioInputDeviceNames(&devices);
+ CheckDeviceNames(devices);
+}
+
+// Verify output device enumeration.
+TEST_F(AudioAndroidTest, GetAudioOutputDeviceNames) {
+ if (!audio_manager()->HasAudioOutputDevices())
+ return;
+ AudioDeviceNames devices;
+ audio_manager()->GetAudioOutputDeviceNames(&devices);
+ CheckDeviceNames(devices);
+}
+
// Ensure that a default input stream can be created and closed.
TEST_F(AudioAndroidTest, CreateAndCloseInputStream) {
AudioParameters params = GetDefaultInputStreamParameters();
+ const char kInvalidId1[] = "_InVaLiDdEvIcEId_";
AudioInputStream* ais = audio_manager()->MakeAudioInputStream(
+ params, kInvalidId1);
+ EXPECT_FALSE(ais);
+ const char kInvalidId2[] = "192837464";
+ ais = audio_manager()->MakeAudioInputStream(
+ params, kInvalidId2);
+ EXPECT_FALSE(ais);
+ ais = audio_manager()->MakeAudioInputStream(
params, AudioManagerBase::kDefaultDeviceId);
EXPECT_TRUE(ais);
ais->Close();
« no previous file with comments | « no previous file | media/audio/android/audio_manager_android.h » ('j') | media/audio/android/audio_manager_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698