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

Unified Diff: content/renderer/media/capture_video_decoder_unittest.cc

Issue 10824141: Remove VideoDecoder::natural_size() & added VideoFrame::natural_size(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright year. Created 8 years, 5 months 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
« no previous file with comments | « content/renderer/media/capture_video_decoder.cc ('k') | content/renderer/media/rtc_video_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/capture_video_decoder_unittest.cc
diff --git a/content/renderer/media/capture_video_decoder_unittest.cc b/content/renderer/media/capture_video_decoder_unittest.cc
index 643fc509dc4502b9c30cd3c0c35ecb2cc6a2a7dc..57aab50bdfc60e8fadc24fa05c784be5d6be3e1b 100644
--- a/content/renderer/media/capture_video_decoder_unittest.cc
+++ b/content/renderer/media/capture_video_decoder_unittest.cc
@@ -24,19 +24,6 @@ static const int kHeight = 144;
static const int kFPS = 30;
static const media::VideoCaptureSessionId kVideoStreamId = 1;
-ACTION_P3(CreateDataBufferFromCapture, decoder, vc_impl, data_buffer_number) {
- for (int i = 0; i < data_buffer_number; i++) {
- media::VideoCapture::VideoFrameBuffer* buffer;
- buffer = new media::VideoCapture::VideoFrameBuffer();
- buffer->width = arg1.width;
- buffer->height = arg1.height;
- int length = buffer->width * buffer->height * 3 / 2;
- buffer->memory_pointer = new uint8[length];
- buffer->buffer_size = length;
- decoder->OnBufferReady(vc_impl, buffer);
- }
-}
-
ACTION(DeleteDataBuffer) {
delete[] arg0->memory_pointer;
}
@@ -45,6 +32,17 @@ ACTION_P2(CaptureStopped, decoder, vc_impl) {
decoder->OnStopped(vc_impl);
}
+MATCHER_P2(HasSize, width, height, "") {
+ EXPECT_EQ(arg->data_size().width(), width);
+ EXPECT_EQ(arg->data_size().height(), height);
+ EXPECT_EQ(arg->natural_size().width(), width);
+ EXPECT_EQ(arg->natural_size().height(), height);
+ return (arg->data_size().width() == width) &&
+ (arg->data_size().height() == height) &&
+ (arg->natural_size().width() == width) &&
+ (arg->natural_size().height() == height);
+}
+
class MockVideoCaptureImpl : public VideoCaptureImpl {
public:
MockVideoCaptureImpl(const media::VideoCaptureSessionId id,
@@ -119,25 +117,17 @@ class CaptureVideoDecoderTest : public ::testing::Test {
}
void Initialize() {
- // Issue a read.
- EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _));
- decoder_->Read(read_cb_);
-
EXPECT_CALL(*vc_manager_, AddDevice(_, _))
.WillOnce(Return(vc_impl_.get()));
- int buffer_count = 1;
- EXPECT_CALL(*vc_impl_, StartCapture(capture_client(), _))
- .Times(1)
- .WillOnce(CreateDataBufferFromCapture(capture_client(),
- vc_impl_.get(),
- buffer_count));
- EXPECT_CALL(*vc_impl_, FeedBuffer(_))
- .Times(buffer_count)
- .WillRepeatedly(DeleteDataBuffer());
-
+ EXPECT_CALL(*vc_impl_, StartCapture(capture_client(), _));
decoder_->Initialize(NULL,
media::NewExpectedStatusCB(media::PIPELINE_OK),
NewStatisticsCB());
+
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk,
+ HasSize(kWidth, kHeight)));
+ decoder_->Read(read_cb_);
+ SendBufferToDecoder(gfx::Size(kWidth, kHeight));
message_loop_->RunAllPending();
}
@@ -155,6 +145,20 @@ class CaptureVideoDecoderTest : public ::testing::Test {
return static_cast<media::VideoCapture::EventHandler*>(decoder_);
}
+ void SendBufferToDecoder(const gfx::Size& size) {
+ scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer =
+ new media::VideoCapture::VideoFrameBuffer();
+ buffer->width = size.width();
+ buffer->height = size.height();
+ int length = buffer->width * buffer->height * 3 / 2;
+ buffer->memory_pointer = new uint8[length];
+ buffer->buffer_size = length;
+
+ EXPECT_CALL(*vc_impl_, FeedBuffer(_))
+ .WillOnce(DeleteDataBuffer());
+ decoder_->OnBufferReady(vc_impl_.get(), buffer);
+ }
+
MOCK_METHOD2(FrameReady, void(media::VideoDecoder::DecoderStatus status,
const scoped_refptr<media::VideoFrame>&));
@@ -175,11 +179,8 @@ class CaptureVideoDecoderTest : public ::testing::Test {
TEST_F(CaptureVideoDecoderTest, ReadAndReset) {
// Test basic initialize and teardown sequence.
Initialize();
- // Natural size should be initialized to default capability.
- EXPECT_EQ(kWidth, decoder_->natural_size().width());
- EXPECT_EQ(kHeight, decoder_->natural_size().height());
-
- EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _));
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk,
+ HasSize(kWidth, kHeight)));
decoder_->Read(read_cb_);
decoder_->Reset(media::NewExpectedClosure());
message_loop_->RunAllPending();
@@ -200,10 +201,13 @@ TEST_F(CaptureVideoDecoderTest, OnDeviceInfoReceived) {
params.session_id = kVideoStreamId;
decoder_->OnDeviceInfoReceived(vc_impl_.get(), params);
- message_loop_->RunAllPending();
- EXPECT_EQ(expected_size.width(), decoder_->natural_size().width());
- EXPECT_EQ(expected_size.height(), decoder_->natural_size().height());
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk,
+ HasSize(expected_size.width(),
+ expected_size.height())));
+ decoder_->Read(read_cb_);
+ SendBufferToDecoder(expected_size);
+ message_loop_->RunAllPending();
Stop();
}
@@ -213,7 +217,8 @@ TEST_F(CaptureVideoDecoderTest, ReadAndShutdown) {
// teardown the pipeline) even when there's no input frame.
Initialize();
- EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _)).Times(2);
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk,
+ HasSize(0, 0))).Times(2);
decoder_->Read(read_cb_);
decoder_->PrepareForShutdownHack();
decoder_->Read(read_cb_);
@@ -221,4 +226,3 @@ TEST_F(CaptureVideoDecoderTest, ReadAndShutdown) {
Stop();
}
-
« no previous file with comments | « content/renderer/media/capture_video_decoder.cc ('k') | content/renderer/media/rtc_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698