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

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: clean up 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..3212c0edf9662342a09d381e64afa346639f926e 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);
Alpha Left Google 2013/11/06 02:22:06 nit: This doesn't need to be static right?
mikhal 2013/11/06 18:29:16 Keeping for consistency - Static through out the c
+
+class DecodeTestFrameCallback :
Alpha Left Google 2013/11/06 02:22:06 Put this in an anonymous namespace otherwise it mi
mikhal 2013/11/06 18:29:16 Done.
+ 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>;
+};
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()) {
Alpha Left Google 2013/11/06 02:22:06 nit: indentation is incorrect.
mikhal 2013/11/06 18:29:16 Done.
// 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;
-
+ VideoFrameDecodedCallback frame_decoded_callback =
+ base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_);
EXPECT_DEATH(
- decoder_->DecodeVideoFrame(&encoded_frame, render_time, &video_frame),
- "Empty video frame");
+ decoder_->DecodeVideoFrame(&encoded_frame, render_time,
+ frame_decoded_callback), "Empty video frame");
Alpha Left Google 2013/11/06 02:22:06 nit: indentation is incorrect, this should align w
}
// 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;
+ VideoFrameDecodedCallback frame_decoded_callback =
+ base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_);
EXPECT_DEATH(
- decoder_->DecodeVideoFrame(&encoded_frame, render_time, &video_frame),
- "Invalid codec");
+ decoder_->DecodeVideoFrame(&encoded_frame, render_time,
+ frame_decoded_callback), "Invalid codec");
Alpha Left Google 2013/11/06 02:22:06 nit: indentation is incorrect, it should align wit
mikhal 2013/11/06 18:29:16 Done.
}
// TODO(pwestin): Test decoding a real frame.

Powered by Google App Engine
This is Rietveld 408576698