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

Side by Side Diff: content/renderer/media/capture_video_decoder_unittest.cc

Issue 10248002: Report VideoDecoder status through ReadCB instead of through FilterHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename VideoDecoder::Status to VideoDecoder::DecoderStatus since Status has been polluted by Xlib.h. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "content/renderer/media/capture_video_decoder.h" 6 #include "content/renderer/media/capture_video_decoder.h"
7 #include "content/renderer/media/video_capture_impl.h" 7 #include "content/renderer/media/video_capture_impl.h"
8 #include "content/renderer/media/video_capture_impl_manager.h" 8 #include "content/renderer/media/video_capture_impl_manager.h"
9 #include "media/base/filters.h" 9 #include "media/base/filters.h"
10 #include "media/base/limits.h" 10 #include "media/base/limits.h"
11 #include "media/base/mock_callback.h" 11 #include "media/base/mock_callback.h"
12 #include "media/base/mock_filter_host.h"
13 #include "media/base/mock_filters.h" 12 #include "media/base/mock_filters.h"
14 #include "media/base/pipeline_status.h" 13 #include "media/base/pipeline_status.h"
15 #include "media/video/capture/video_capture_types.h" 14 #include "media/video/capture/video_capture_types.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
17 16
18 using ::testing::_; 17 using ::testing::_;
19 using ::testing::AnyNumber; 18 using ::testing::AnyNumber;
20 using ::testing::Return; 19 using ::testing::Return;
21 using ::testing::StrictMock; 20 using ::testing::StrictMock;
22 21
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 media::VideoCaptureCapability capability; 90 media::VideoCaptureCapability capability;
92 capability.width = kWidth; 91 capability.width = kWidth;
93 capability.height = kHeight; 92 capability.height = kHeight;
94 capability.frame_rate = kFPS; 93 capability.frame_rate = kFPS;
95 capability.expected_capture_delay = 0; 94 capability.expected_capture_delay = 0;
96 capability.color = media::VideoFrame::I420; 95 capability.color = media::VideoFrame::I420;
97 capability.interlaced = false; 96 capability.interlaced = false;
98 97
99 decoder_ = new CaptureVideoDecoder(message_loop_proxy_, 98 decoder_ = new CaptureVideoDecoder(message_loop_proxy_,
100 kVideoStreamId, vc_manager_, capability); 99 kVideoStreamId, vc_manager_, capability);
101 decoder_->set_host(&host_);
102 EXPECT_CALL(statistics_cb_object_, OnStatistics(_)) 100 EXPECT_CALL(statistics_cb_object_, OnStatistics(_))
103 .Times(AnyNumber()); 101 .Times(AnyNumber());
104 102
105 read_cb_ = base::Bind(&CaptureVideoDecoderTest::FrameReady, 103 read_cb_ = base::Bind(&CaptureVideoDecoderTest::FrameReady,
106 base::Unretained(this)); 104 base::Unretained(this));
107 105
108 vc_impl_.reset(new MockVideoCaptureImpl( 106 vc_impl_.reset(new MockVideoCaptureImpl(
109 kVideoStreamId, message_loop_proxy_, new VideoCaptureMessageFilter())); 107 kVideoStreamId, message_loop_proxy_, new VideoCaptureMessageFilter()));
110 } 108 }
111 109
112 virtual ~CaptureVideoDecoderTest() { 110 virtual ~CaptureVideoDecoderTest() {
113 message_loop_->RunAllPending(); 111 message_loop_->RunAllPending();
114 } 112 }
115 113
116 media::StatisticsCB NewStatisticsCB() { 114 media::StatisticsCB NewStatisticsCB() {
117 return base::Bind(&media::MockStatisticsCB::OnStatistics, 115 return base::Bind(&media::MockStatisticsCB::OnStatistics,
118 base::Unretained(&statistics_cb_object_)); 116 base::Unretained(&statistics_cb_object_));
119 } 117 }
120 118
121 void Initialize() { 119 void Initialize() {
122 // Issue a read. 120 // Issue a read.
123 EXPECT_CALL(*this, FrameReady(_)); 121 EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _));
124 decoder_->Read(read_cb_); 122 decoder_->Read(read_cb_);
125 123
126 EXPECT_CALL(*vc_manager_, AddDevice(_, _)) 124 EXPECT_CALL(*vc_manager_, AddDevice(_, _))
127 .WillOnce(Return(vc_impl_.get())); 125 .WillOnce(Return(vc_impl_.get()));
128 int buffer_count = 1; 126 int buffer_count = 1;
129 EXPECT_CALL(*vc_impl_, StartCapture(capture_client(), _)) 127 EXPECT_CALL(*vc_impl_, StartCapture(capture_client(), _))
130 .Times(1) 128 .Times(1)
131 .WillOnce(CreateDataBufferFromCapture(capture_client(), 129 .WillOnce(CreateDataBufferFromCapture(capture_client(),
132 vc_impl_.get(), 130 vc_impl_.get(),
133 buffer_count)); 131 buffer_count));
134 EXPECT_CALL(*vc_impl_, FeedBuffer(_)) 132 EXPECT_CALL(*vc_impl_, FeedBuffer(_))
135 .Times(buffer_count) 133 .Times(buffer_count)
136 .WillRepeatedly(DeleteDataBuffer()); 134 .WillRepeatedly(DeleteDataBuffer());
137 135
138 decoder_->Initialize(NULL, 136 decoder_->Initialize(NULL,
139 media::NewExpectedStatusCB(media::PIPELINE_OK), 137 media::NewExpectedStatusCB(media::PIPELINE_OK),
140 NewStatisticsCB()); 138 NewStatisticsCB());
141 message_loop_->RunAllPending(); 139 message_loop_->RunAllPending();
142 } 140 }
143 141
144 void Play() { 142 void Play() {
145 decoder_->Play(media::NewExpectedClosure()); 143 decoder_->Play(media::NewExpectedClosure());
146 message_loop_->RunAllPending(); 144 message_loop_->RunAllPending();
147 } 145 }
148 146
149 void Flush() { 147 void Flush() {
150 // Issue a read. 148 // Issue a read.
151 EXPECT_CALL(*this, FrameReady(_)); 149 EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _));
152 decoder_->Read(read_cb_); 150 decoder_->Read(read_cb_);
153 151
154 decoder_->Pause(media::NewExpectedClosure()); 152 decoder_->Pause(media::NewExpectedClosure());
155 decoder_->Flush(media::NewExpectedClosure()); 153 decoder_->Flush(media::NewExpectedClosure());
156 message_loop_->RunAllPending(); 154 message_loop_->RunAllPending();
157 } 155 }
158 156
159 void Stop() { 157 void Stop() {
160 EXPECT_CALL(*vc_impl_, StopCapture(capture_client())) 158 EXPECT_CALL(*vc_impl_, StopCapture(capture_client()))
161 .Times(1) 159 .Times(1)
162 .WillOnce(CaptureStopped(capture_client(), vc_impl_.get())); 160 .WillOnce(CaptureStopped(capture_client(), vc_impl_.get()));
163 EXPECT_CALL(*vc_manager_, RemoveDevice(_, _)) 161 EXPECT_CALL(*vc_manager_, RemoveDevice(_, _))
164 .WillOnce(Return()); 162 .WillOnce(Return());
165 decoder_->Stop(media::NewExpectedClosure()); 163 decoder_->Stop(media::NewExpectedClosure());
166 message_loop_->RunAllPending(); 164 message_loop_->RunAllPending();
167 } 165 }
168 166
169 media::VideoCapture::EventHandler* capture_client() { 167 media::VideoCapture::EventHandler* capture_client() {
170 return static_cast<media::VideoCapture::EventHandler*>(decoder_); 168 return static_cast<media::VideoCapture::EventHandler*>(decoder_);
171 } 169 }
172 170
173 MOCK_METHOD1(FrameReady, void(scoped_refptr<media::VideoFrame>)); 171 MOCK_METHOD2(FrameReady, void(media::VideoDecoder::DecoderStatus status,
172 scoped_refptr<media::VideoFrame>));
174 173
175 // Fixture members. 174 // Fixture members.
176 scoped_refptr<CaptureVideoDecoder> decoder_; 175 scoped_refptr<CaptureVideoDecoder> decoder_;
177 scoped_refptr<MockVideoCaptureImplManager> vc_manager_; 176 scoped_refptr<MockVideoCaptureImplManager> vc_manager_;
178 scoped_ptr<MockVideoCaptureImpl> vc_impl_; 177 scoped_ptr<MockVideoCaptureImpl> vc_impl_;
179 media::MockStatisticsCB statistics_cb_object_; 178 media::MockStatisticsCB statistics_cb_object_;
180 StrictMock<media::MockFilterHost> host_;
181 scoped_ptr<MessageLoop> message_loop_; 179 scoped_ptr<MessageLoop> message_loop_;
182 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 180 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
183 media::VideoDecoder::ReadCB read_cb_; 181 media::VideoDecoder::ReadCB read_cb_;
184 182
185 private: 183 private:
186 DISALLOW_COPY_AND_ASSIGN(CaptureVideoDecoderTest); 184 DISALLOW_COPY_AND_ASSIGN(CaptureVideoDecoderTest);
187 }; 185 };
188 186
189 TEST_F(CaptureVideoDecoderTest, Play) { 187 TEST_F(CaptureVideoDecoderTest, Play) {
190 // Test basic initialize, play, and teardown sequence. 188 // Test basic initialize, play, and teardown sequence.
(...skipping 19 matching lines...) Expand all
210 params.session_id = kVideoStreamId; 208 params.session_id = kVideoStreamId;
211 209
212 decoder_->OnDeviceInfoReceived(vc_impl_.get(), params); 210 decoder_->OnDeviceInfoReceived(vc_impl_.get(), params);
213 message_loop_->RunAllPending(); 211 message_loop_->RunAllPending();
214 212
215 EXPECT_EQ(expected_size.width(), decoder_->natural_size().width()); 213 EXPECT_EQ(expected_size.width(), decoder_->natural_size().width());
216 EXPECT_EQ(expected_size.height(), decoder_->natural_size().height()); 214 EXPECT_EQ(expected_size.height(), decoder_->natural_size().height());
217 215
218 Stop(); 216 Stop();
219 } 217 }
OLDNEW
« no previous file with comments | « content/renderer/media/capture_video_decoder.cc ('k') | content/renderer/media/rtc_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698