This source file includes following definitions.
- DecodeComplete
- test_callback_
- TEST_F
#include <stdint.h>
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/time/tick_clock.h"
#include "media/cast/cast_config.h"
#include "media/cast/cast_defines.h"
#include "media/cast/cast_environment.h"
#include "media/cast/cast_receiver.h"
#include "media/cast/test/fake_single_thread_task_runner.h"
#include "media/cast/video_receiver/video_decoder.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace media {
namespace cast {
using testing::_;
static const int64 kStartMillisecond = INT64_C(1245);
namespace {
class DecodeTestFrameCallback
: public base::RefCountedThreadSafe<DecodeTestFrameCallback> {
public:
DecodeTestFrameCallback() {}
void DecodeComplete(const scoped_refptr<media::VideoFrame>& decoded_frame,
const base::TimeTicks& render_time) {}
protected:
virtual ~DecodeTestFrameCallback() {}
private:
friend class base::RefCountedThreadSafe<DecodeTestFrameCallback>;
DISALLOW_COPY_AND_ASSIGN(DecodeTestFrameCallback);
};
}
class VideoDecoderTest : public ::testing::Test {
protected:
VideoDecoderTest()
: testing_clock_(new base::SimpleTestTickClock()),
task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)),
cast_environment_(
new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_),
task_runner_,
task_runner_,
task_runner_)),
test_callback_(new DecodeTestFrameCallback()) {
config_.codec = transport::kVp8;
config_.use_external_decoder = false;
decoder_.reset(new VideoDecoder(config_, cast_environment_));
testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
}
virtual ~VideoDecoderTest() {}
scoped_ptr<VideoDecoder> decoder_;
VideoReceiverConfig config_;
base::SimpleTestTickClock* testing_clock_;
scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
scoped_refptr<DecodeTestFrameCallback> test_callback_;
DISALLOW_COPY_AND_ASSIGN(VideoDecoderTest);
};
TEST_F(VideoDecoderTest, DISABLED_SizeZero) {
transport::EncodedVideoFrame encoded_frame;
base::TimeTicks render_time;
encoded_frame.codec = transport::kVp8;
EXPECT_DEATH(
decoder_->DecodeVideoFrame(
&encoded_frame,
render_time,
base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_)),
"Empty frame");
}
}
}