Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: media/cast/video_receiver/video_decoder_unittest.cc

Issue 59753007: Passing frame decoded callback to the codec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responding to review Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/cast/video_receiver/video_decoder_unittest.cc
diff --git a/media/cast/video_receiver/video_decoder_unittest.cc b/media/cast/video_receiver/video_decoder_unittest.cc
index cb40e12752a1a88511e6cdbf99406d70d93d83c4..911d4cb8fd852ab09c58621762d5866e9b3e6a9a 100644
--- a/media/cast/video_receiver/video_decoder_unittest.cc
+++ b/media/cast/video_receiver/video_decoder_unittest.cc
@@ -2,8 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#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_task_runner.h"
#include "media/cast/video_receiver/video_decoder.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -14,44 +21,69 @@ using testing::_;
// Random frame size for testing.
const int kFrameSize = 2345;
+static const int64 kStartMillisecond = GG_INT64_C(1245);
+
+namespace {
+class DecodeTestFrameCallback :
+ public base::RefCountedThreadSafe<DecodeTestFrameCallback> {
+ public:
+ DecodeTestFrameCallback() {}
+
+ void DecodeComplete(scoped_ptr<I420VideoFrame> decoded_frame,
+ const base::TimeTicks& render_time) {}
+ protected:
+ virtual ~DecodeTestFrameCallback() {}
+ private:
+ friend class base::RefCountedThreadSafe<DecodeTestFrameCallback>;
+};
+} // namespace
class VideoDecoderTest : public ::testing::Test {
protected:
- VideoDecoderTest() {
+ VideoDecoderTest()
+ : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
+ cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
+ task_runner_, task_runner_, task_runner_, task_runner_)),
+ test_callback_(new DecodeTestFrameCallback()) {
// Configure to vp8.
config_.codec = kVp8;
config_.use_external_decoder = false;
- decoder_.reset(new VideoDecoder(config_));
+ 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::FakeTaskRunner> task_runner_;
+ scoped_refptr<CastEnvironment> cast_environment_;
+ scoped_refptr<DecodeTestFrameCallback> test_callback_;
};
// TODO(pwestin): EXPECT_DEATH tests can not pass valgrind.
TEST_F(VideoDecoderTest, DISABLED_SizeZero) {
EncodedVideoFrame encoded_frame;
- I420VideoFrame video_frame;
base::TimeTicks render_time;
encoded_frame.codec = kVp8;
-
EXPECT_DEATH(
- decoder_->DecodeVideoFrame(&encoded_frame, render_time, &video_frame),
- "Empty video frame");
+ decoder_->DecodeVideoFrame(&encoded_frame, render_time, base::Bind(
Alpha Left Google 2013/11/06 18:41:49 nit: Indentation should be like this: EXPECT_DEAT
mikhal 2013/11/06 18:53:07 Done.
+ &DecodeTestFrameCallback::DecodeComplete, test_callback_)),
+ "Empty frame");
}
// TODO(pwestin): EXPECT_DEATH tests can not pass valgrind.
TEST_F(VideoDecoderTest, DISABLED_InvalidCodec) {
EncodedVideoFrame encoded_frame;
- I420VideoFrame video_frame;
base::TimeTicks render_time;
encoded_frame.data.assign(kFrameSize, 0);
encoded_frame.codec = kExternalVideo;
EXPECT_DEATH(
- decoder_->DecodeVideoFrame(&encoded_frame, render_time, &video_frame),
- "Invalid codec");
+ decoder_->DecodeVideoFrame(&encoded_frame, render_time, base::Bind(
+ &DecodeTestFrameCallback::DecodeComplete, test_callback_)),
Alpha Left Google 2013/11/06 18:41:49 nit: Same here indentation is incorrect.
mikhal 2013/11/06 18:53:07 Done.
+ "Invalid codec");
}
// TODO(pwestin): Test decoding a real frame.

Powered by Google App Engine
This is Rietveld 408576698