Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / media / cast / video_receiver / video_decoder_unittest.cc
blob1d9cf7759fed97f3aa7731af3316f0708f7119c1
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.
5 #include "base/bind.h"
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_task_runner.h"
14 #include "media/cast/video_receiver/video_decoder.h"
15 #include "testing/gmock/include/gmock/gmock.h"
17 namespace media {
18 namespace cast {
20 using testing::_;
22 // Random frame size for testing.
23 static const int64 kStartMillisecond = GG_INT64_C(1245);
25 namespace {
26 class DecodeTestFrameCallback :
27 public base::RefCountedThreadSafe<DecodeTestFrameCallback> {
28 public:
29 DecodeTestFrameCallback() {}
31 void DecodeComplete(const scoped_refptr<media::VideoFrame>& decoded_frame,
32 const base::TimeTicks& render_time) {}
33 protected:
34 virtual ~DecodeTestFrameCallback() {}
35 private:
36 friend class base::RefCountedThreadSafe<DecodeTestFrameCallback>;
38 } // namespace
40 class VideoDecoderTest : public ::testing::Test {
41 protected:
42 VideoDecoderTest()
43 : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
44 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
45 task_runner_, task_runner_, task_runner_, task_runner_,
46 task_runner_, GetDefaultCastLoggingConfig())),
47 test_callback_(new DecodeTestFrameCallback()) {
48 // Configure to vp8.
49 config_.codec = transport::kVp8;
50 config_.use_external_decoder = false;
51 decoder_.reset(new VideoDecoder(config_, cast_environment_));
52 testing_clock_.Advance(
53 base::TimeDelta::FromMilliseconds(kStartMillisecond));
56 virtual ~VideoDecoderTest() {}
58 scoped_ptr<VideoDecoder> decoder_;
59 VideoReceiverConfig config_;
60 base::SimpleTestTickClock testing_clock_;
61 scoped_refptr<test::FakeTaskRunner> task_runner_;
62 scoped_refptr<CastEnvironment> cast_environment_;
63 scoped_refptr<DecodeTestFrameCallback> test_callback_;
66 // TODO(pwestin): EXPECT_DEATH tests can not pass valgrind.
67 TEST_F(VideoDecoderTest, DISABLED_SizeZero) {
68 transport::EncodedVideoFrame encoded_frame;
69 base::TimeTicks render_time;
70 encoded_frame.codec = transport::kVp8;
71 EXPECT_DEATH(
72 decoder_->DecodeVideoFrame(
73 &encoded_frame, render_time,
74 base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_)),
75 "Empty frame");
78 // TODO(pwestin): Test decoding a real frame.
80 } // namespace cast
81 } // namespace media