1 // Copyright 2015 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.
6 #include "base/macros.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h"
11 #include "chromecast/media/cma/backend/media_pipeline_device_default.h"
12 #include "chromecast/media/cma/base/buffering_defs.h"
13 #include "chromecast/media/cma/filters/cma_renderer.h"
14 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h"
15 #include "media/base/demuxer_stream_provider.h"
16 #include "media/base/fake_demuxer_stream.h"
17 #include "media/base/null_video_sink.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h"
21 namespace chromecast
{
26 class CmaEndToEndTest
: public testing::Test
{
29 demuxer_stream_provider_
.reset(
30 new ::media::FakeDemuxerStreamProvider(1, 1, false));
31 null_sink_
.reset(new ::media::NullVideoSink(
32 false, base::TimeDelta::FromSecondsD(1.0 / 60),
33 base::Bind(&MockCB::OnFrameReceived
, base::Unretained(&mock_
)),
34 message_loop_
.task_runner()));
36 scoped_ptr
<MediaPipelineImpl
> media_pipeline(new MediaPipelineImpl());
37 media_pipeline
->Initialize(
39 make_scoped_ptr(new MediaPipelineDeviceDefault()));
41 renderer_
.reset(new CmaRenderer(media_pipeline
.Pass(), null_sink_
.get()));
44 ~CmaEndToEndTest() override
{}
47 base::MessageLoop message_loop_
;
48 scoped_ptr
<::media::FakeDemuxerStreamProvider
> demuxer_stream_provider_
;
49 scoped_ptr
<CmaRenderer
> renderer_
;
53 MOCK_METHOD1(OnInitialized
, void(::media::PipelineStatus
));
54 MOCK_METHOD1(OnFrameReceived
,
55 void(const scoped_refptr
<::media::VideoFrame
>&));
56 MOCK_METHOD1(OnStatistics
, void(const ::media::PipelineStatistics
&));
57 MOCK_METHOD1(OnBufferingState
, void(::media::BufferingState
));
58 MOCK_METHOD0(OnEnded
, void());
59 MOCK_METHOD1(OnError
, void(::media::PipelineStatus
));
60 MOCK_METHOD0(OnWaitingForDecryptionKey
, void());
65 scoped_ptr
<::media::NullVideoSink
> null_sink_
;
67 DISALLOW_COPY_AND_ASSIGN(CmaEndToEndTest
);
72 TEST_F(CmaEndToEndTest
, TestInitialization
) {
73 renderer_
->Initialize(
74 demuxer_stream_provider_
.get(),
75 base::Bind(&MockCB::OnInitialized
, base::Unretained(&mock_
)),
76 base::Bind(&MockCB::OnStatistics
, base::Unretained(&mock_
)),
77 base::Bind(&MockCB::OnBufferingState
, base::Unretained(&mock_
)),
78 base::Bind(&MockCB::OnEnded
, base::Unretained(&mock_
)),
79 base::Bind(&MockCB::OnError
, base::Unretained(&mock_
)),
80 base::Bind(&MockCB::OnWaitingForDecryptionKey
, base::Unretained(&mock_
)));
82 EXPECT_CALL(mock_
, OnInitialized(::media::PIPELINE_OK
));
83 message_loop_
.RunUntilIdle();
88 } // namespace chromecast