1 // Copyright 2013 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/memory/scoped_ptr.h"
7 #include "base/test/simple_test_tick_clock.h"
8 #include "base/time/tick_clock.h"
9 #include "media/cast/cast_config.h"
10 #include "media/cast/cast_defines.h"
11 #include "media/cast/cast_environment.h"
12 #include "media/cast/cast_receiver.h"
13 #include "media/cast/test/fake_single_thread_task_runner.h"
14 #include "media/cast/video_receiver/video_decoder.h"
15 #include "testing/gmock/include/gmock/gmock.h"
22 // Random frame size for testing.
23 static const int64 kStartMillisecond
= GG_INT64_C(1245);
26 class DecodeTestFrameCallback
27 : public base::RefCountedThreadSafe
<DecodeTestFrameCallback
> {
29 DecodeTestFrameCallback() {}
31 void DecodeComplete(const scoped_refptr
<media::VideoFrame
>& decoded_frame
,
32 const base::TimeTicks
& render_time
) {}
35 virtual ~DecodeTestFrameCallback() {}
38 friend class base::RefCountedThreadSafe
<DecodeTestFrameCallback
>;
40 DISALLOW_COPY_AND_ASSIGN(DecodeTestFrameCallback
);
44 class VideoDecoderTest
: public ::testing::Test
{
47 : testing_clock_(new base::SimpleTestTickClock()),
48 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_
)),
50 new CastEnvironment(scoped_ptr
<base::TickClock
>(testing_clock_
),
57 GetDefaultCastReceiverLoggingConfig())),
58 test_callback_(new DecodeTestFrameCallback()) {
60 config_
.codec
= transport::kVp8
;
61 config_
.use_external_decoder
= false;
62 decoder_
.reset(new VideoDecoder(config_
, cast_environment_
));
63 testing_clock_
->Advance(
64 base::TimeDelta::FromMilliseconds(kStartMillisecond
));
67 virtual ~VideoDecoderTest() {}
69 scoped_ptr
<VideoDecoder
> decoder_
;
70 VideoReceiverConfig config_
;
71 base::SimpleTestTickClock
* testing_clock_
; // Owned by CastEnvironment.
72 scoped_refptr
<test::FakeSingleThreadTaskRunner
> task_runner_
;
73 scoped_refptr
<CastEnvironment
> cast_environment_
;
74 scoped_refptr
<DecodeTestFrameCallback
> test_callback_
;
76 DISALLOW_COPY_AND_ASSIGN(VideoDecoderTest
);
79 // TODO(pwestin): EXPECT_DEATH tests can not pass valgrind.
80 TEST_F(VideoDecoderTest
, DISABLED_SizeZero
) {
81 transport::EncodedVideoFrame encoded_frame
;
82 base::TimeTicks render_time
;
83 encoded_frame
.codec
= transport::kVp8
;
85 decoder_
->DecodeVideoFrame(
88 base::Bind(&DecodeTestFrameCallback::DecodeComplete
, test_callback_
)),
92 // TODO(pwestin): Test decoding a real frame.