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

Side by Side 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, 6 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 | « chromecast/media/audio/cast_audio_manager.cc ('k') | chromecast/media/audio/cast_audio_mixer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/media/audio/cast_audio_manager.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/test/test_message_loop.h"
9 #include "chromecast/media/cma/test/mock_media_pipeline_backend.h"
10 #include "chromecast/media/cma/test/mock_media_pipeline_backend_factory.h"
11 #include "media/audio/fake_audio_log_factory.h"
12 #include "media/audio/test_audio_thread.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 using testing::_;
17 using testing::Invoke;
18 using testing::Return;
19 using testing::StrictMock;
20
21 namespace chromecast {
22 namespace media {
23 namespace {
24
25 const ::media::AudioParameters kDefaultAudioParams(
26 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
27 ::media::CHANNEL_LAYOUT_STEREO,
28 ::media::AudioParameters::kAudioCDSampleRate,
29 16,
30 256);
31
32 class CastAudioManagerTest : public testing::Test {
33 public:
34 CastAudioManagerTest() : media_thread_("CastMediaThread") {
35 CHECK(media_thread_.Start());
36
37 backend_factory_ = new MockMediaPipelineBackendFactory();
38 audio_manager_ = base::MakeUnique<CastAudioManager>(
39 base::MakeUnique<::media::TestAudioThread>(), &audio_log_factory_,
40 base::WrapUnique(backend_factory_), media_thread_.task_runner(), false);
41 }
42
43 ~CastAudioManagerTest() override { audio_manager_->Shutdown(); }
44
45 protected:
46 base::TestMessageLoop message_loop_;
47 base::Thread media_thread_;
48 ::media::FakeAudioLogFactory audio_log_factory_;
49 std::unique_ptr<CastAudioManager> audio_manager_;
50
51 // Owned by |audio_manager_|
52 MockMediaPipelineBackendFactory* backend_factory_;
53 };
54
55 TEST_F(CastAudioManagerTest, MakeAudioOutputStreamProxy) {
56 StrictMock<MockAudioDecoder> audio_decoder;
57 EXPECT_CALL(audio_decoder, SetDelegate(_)).Times(1);
58 EXPECT_CALL(audio_decoder, SetConfig(_)).WillOnce(Return(true));
59
60 auto backend = base::MakeUnique<StrictMock<MockMediaPipelineBackend>>();
61 EXPECT_CALL(*backend, CreateAudioDecoder()).WillOnce(Return(&audio_decoder));
62 EXPECT_CALL(*backend, Initialize()).WillOnce(Return(true));
63
64 EXPECT_CALL(*backend_factory_, CreateBackend(_))
65 .WillOnce(Invoke([&backend](const MediaPipelineDeviceParams&) {
66 return std::move(backend);
67 }));
68
69 ::media::AudioOutputStream* stream =
70 audio_manager_->MakeAudioOutputStreamProxy(kDefaultAudioParams,
71 std::string());
72 EXPECT_TRUE(stream->Open());
73 stream->Close();
74 }
75
76 } // namespace
77 } // namespace media
78 } // namespace chromecast
OLDNEW
« 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