Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / video_receiver / video_decoder_unittest.cc
blob105d1fedaa6e741ab22da1575c717476c09ef3e0
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_single_thread_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) {}
34 protected:
35 virtual ~DecodeTestFrameCallback() {}
37 private:
38 friend class base::RefCountedThreadSafe<DecodeTestFrameCallback>;
40 DISALLOW_COPY_AND_ASSIGN(DecodeTestFrameCallback);
42 } // namespace
44 class VideoDecoderTest : public ::testing::Test {
45 protected:
46 VideoDecoderTest()
47 : testing_clock_(new base::SimpleTestTickClock()),
48 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)),
49 cast_environment_(
50 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_),
51 task_runner_,
52 task_runner_,
53 task_runner_,
54 task_runner_,
55 task_runner_,
56 task_runner_,
57 GetDefaultCastReceiverLoggingConfig())),
58 test_callback_(new DecodeTestFrameCallback()) {
59 // Configure to vp8.
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;
84 EXPECT_DEATH(
85 decoder_->DecodeVideoFrame(
86 &encoded_frame,
87 render_time,
88 base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_)),
89 "Empty frame");
92 // TODO(pwestin): Test decoding a real frame.
94 } // namespace cast
95 } // namespace media