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

Unified Diff: chromecast/media/audio/cast_audio_manager_unittest.cc

Issue 2879703003: [chromecast] Moves CastAudioOutputStream::Backend to CMA thread. (Closed)
Patch Set: addressed comments Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/media/audio/cast_audio_manager.cc ('k') | chromecast/media/audio/cast_audio_mixer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/media/audio/cast_audio_manager_unittest.cc
diff --git a/chromecast/media/audio/cast_audio_manager_unittest.cc b/chromecast/media/audio/cast_audio_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ef8ea9590c49debb13b8b6a40a72233396dc6463
--- /dev/null
+++ b/chromecast/media/audio/cast_audio_manager_unittest.cc
@@ -0,0 +1,78 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromecast/media/audio/cast_audio_manager.h"
+
+#include "base/memory/ptr_util.h"
+#include "base/test/test_message_loop.h"
+#include "chromecast/media/cma/test/mock_media_pipeline_backend.h"
+#include "chromecast/media/cma/test/mock_media_pipeline_backend_factory.h"
+#include "media/audio/fake_audio_log_factory.h"
+#include "media/audio/test_audio_thread.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::_;
+using testing::Invoke;
+using testing::Return;
+using testing::StrictMock;
+
+namespace chromecast {
+namespace media {
+namespace {
+
+const ::media::AudioParameters kDefaultAudioParams(
+ ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ ::media::CHANNEL_LAYOUT_STEREO,
+ ::media::AudioParameters::kAudioCDSampleRate,
+ 16,
+ 256);
+
+class CastAudioManagerTest : public testing::Test {
+ public:
+ CastAudioManagerTest() : media_thread_("CastMediaThread") {
+ CHECK(media_thread_.Start());
+
+ backend_factory_ = new MockMediaPipelineBackendFactory();
+ audio_manager_ = base::MakeUnique<CastAudioManager>(
+ base::MakeUnique<::media::TestAudioThread>(), &audio_log_factory_,
+ base::WrapUnique(backend_factory_), media_thread_.task_runner(), false);
+ }
+
+ ~CastAudioManagerTest() override { audio_manager_->Shutdown(); }
+
+ protected:
+ base::TestMessageLoop message_loop_;
+ base::Thread media_thread_;
+ ::media::FakeAudioLogFactory audio_log_factory_;
+ std::unique_ptr<CastAudioManager> audio_manager_;
+
+ // Owned by |audio_manager_|
+ MockMediaPipelineBackendFactory* backend_factory_;
+};
+
+TEST_F(CastAudioManagerTest, MakeAudioOutputStreamProxy) {
+ StrictMock<MockAudioDecoder> audio_decoder;
+ EXPECT_CALL(audio_decoder, SetDelegate(_)).Times(1);
+ EXPECT_CALL(audio_decoder, SetConfig(_)).WillOnce(Return(true));
+
+ auto backend = base::MakeUnique<StrictMock<MockMediaPipelineBackend>>();
+ EXPECT_CALL(*backend, CreateAudioDecoder()).WillOnce(Return(&audio_decoder));
+ EXPECT_CALL(*backend, Initialize()).WillOnce(Return(true));
+
+ EXPECT_CALL(*backend_factory_, CreateBackend(_))
+ .WillOnce(Invoke([&backend](const MediaPipelineDeviceParams&) {
+ return std::move(backend);
+ }));
+
+ ::media::AudioOutputStream* stream =
+ audio_manager_->MakeAudioOutputStreamProxy(kDefaultAudioParams,
+ std::string());
+ EXPECT_TRUE(stream->Open());
+ stream->Close();
+}
+
+} // namespace
+} // namespace media
+} // namespace chromecast
« no previous file with comments | « chromecast/media/audio/cast_audio_manager.cc ('k') | chromecast/media/audio/cast_audio_mixer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698