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

Unified Diff: media/audio/audio_manager_unittest.cc

Issue 1490533002: Merge M48: "Ensure both default audio device IDs are handled for creation." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager_unittest.cc
diff --git a/media/audio/audio_manager_unittest.cc b/media/audio/audio_manager_unittest.cc
index 9fb0182de0e3d82c9acaae56561db85d617da73b..31563888c1ad0a7f536a950fd995bec7b66fd62c 100644
--- a/media/audio/audio_manager_unittest.cc
+++ b/media/audio/audio_manager_unittest.cc
@@ -9,8 +9,10 @@
#include "base/synchronization/waitable_event.h"
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
+#include "media/audio/audio_output_proxy.h"
#include "media/audio/audio_unittest_util.h"
#include "media/audio/fake_audio_log_factory.h"
+#include "media/audio/fake_audio_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_ALSA)
@@ -32,6 +34,37 @@ namespace media {
// Test fixture which allows us to override the default enumeration API on
// Windows.
class AudioManagerTest : public ::testing::Test {
+ public:
+ void HandleDefaultDeviceIDsTest() {
+ AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 48000, 16, 2048);
+
+ // Create a stream with the default device id "".
+ AudioOutputStream* stream =
+ audio_manager_->MakeAudioOutputStreamProxy(params, "");
+ ASSERT_TRUE(stream);
+ AudioOutputDispatcher* dispatcher1 =
+ reinterpret_cast<AudioOutputProxy*>(stream)
+ ->get_dispatcher_for_testing();
+
+ // Closing this stream will put it up for reuse.
+ stream->Close();
+ stream = audio_manager_->MakeAudioOutputStreamProxy(
+ params, AudioManagerBase::kDefaultDeviceId);
+
+ // Verify both streams are created with the same dispatcher (which is unique
+ // per device).
+ ASSERT_EQ(dispatcher1, reinterpret_cast<AudioOutputProxy*>(stream)
+ ->get_dispatcher_for_testing());
+ stream->Close();
+
+ // Create a non-default device and ensure it gets a different dispatcher.
+ stream = audio_manager_->MakeAudioOutputStreamProxy(params, "123456");
+ ASSERT_NE(dispatcher1, reinterpret_cast<AudioOutputProxy*>(stream)
+ ->get_dispatcher_for_testing());
+ stream->Close();
+ }
+
protected:
AudioManagerTest() : audio_manager_(AudioManager::CreateForTesting()) {
// Wait for audio thread initialization to complete. Otherwise the
@@ -150,6 +183,14 @@ class AudioManagerTest : public ::testing::Test {
scoped_ptr<AudioManager> audio_manager_;
};
+TEST_F(AudioManagerTest, HandleDefaultDeviceIDs) {
+ // Use a fake manager so we can makeup device ids, this will still use the
+ // AudioManagerBase code.
+ audio_manager_.reset(new FakeAudioManager(&fake_audio_log_factory_));
+ RunOnAudioThread(base::Bind(&AudioManagerTest::HandleDefaultDeviceIDsTest,
+ base::Unretained(this)));
+}
+
// Test that devices can be enumerated.
TEST_F(AudioManagerTest, EnumerateInputDevices) {
ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable());
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698