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

Unified Diff: media/filters/video_renderer_base_unittest.cc

Issue 12262058: Revert r180578, r180591, and r180604 from 1410 branch. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 10 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 | « media/filters/video_renderer_base.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_base_unittest.cc
===================================================================
--- media/filters/video_renderer_base_unittest.cc (revision 182591)
+++ media/filters/video_renderer_base_unittest.cc (working copy)
@@ -44,12 +44,12 @@
demuxer_stream_(new MockDemuxerStream()),
video_config_(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, false) {
- renderer_.reset(new VideoRendererBase(
+ renderer_ = new VideoRendererBase(
message_loop_.message_loop_proxy(),
media::SetDecryptorReadyCB(),
base::Bind(&VideoRendererBaseTest::OnPaint, base::Unretained(this)),
base::Bind(&VideoRendererBaseTest::OnSetOpaque, base::Unretained(this)),
- true));
+ true);
EXPECT_CALL(*demuxer_stream_, type())
.WillRepeatedly(Return(DemuxerStream::VIDEO));
@@ -63,6 +63,8 @@
.Times(AnyNumber());
EXPECT_CALL(*this, OnTimeUpdate(_))
.Times(AnyNumber());
+ EXPECT_CALL(*this, OnPaint())
+ .Times(AnyNumber());
EXPECT_CALL(*this, OnSetOpaque(_))
.Times(AnyNumber());
}
@@ -70,6 +72,7 @@
virtual ~VideoRendererBaseTest() {}
// Callbacks passed into VideoRendererBase().
+ MOCK_CONST_METHOD0(OnPaint, void());
MOCK_CONST_METHOD1(OnSetOpaque, void(bool));
// Callbacks passed into Initialize().
@@ -225,14 +228,11 @@
}
}
- void ResetCurrentFrame() {
- base::AutoLock l(lock_);
- current_frame_ = NULL;
- }
-
scoped_refptr<VideoFrame> GetCurrentFrame() {
- base::AutoLock l(lock_);
- return current_frame_;
+ scoped_refptr<VideoFrame> frame;
+ renderer_->GetCurrentFrame(&frame);
+ renderer_->PutCurrentFrame(frame);
+ return frame;
}
int GetCurrentTimestampInMs() {
@@ -290,7 +290,7 @@
protected:
// Fixture members.
- scoped_ptr<VideoRendererBase> renderer_;
+ scoped_refptr<VideoRendererBase> renderer_;
scoped_refptr<MockVideoDecoder> decoder_;
scoped_refptr<MockDemuxerStream> demuxer_stream_;
MockStatisticsCB statistics_cb_object_;
@@ -305,11 +305,6 @@
return duration_;
}
- void OnPaint(const scoped_refptr<VideoFrame>& frame) {
- base::AutoLock l(lock_);
- current_frame_ = frame;
- }
-
void FrameRequested(const VideoDecoder::ReadCB& read_cb) {
DCHECK_EQ(&message_loop_, MessageLoop::current());
CHECK(read_cb_.is_null());
@@ -340,10 +335,9 @@
VideoDecoderConfig video_config_;
- // Used to protect |time_| and |current_frame_|.
+ // Used to protect |time_|.
base::Lock lock_;
base::TimeDelta time_;
- scoped_refptr<VideoFrame> current_frame_;
// Used for satisfying reads.
VideoDecoder::ReadCB read_cb_;
@@ -494,12 +488,8 @@
Initialize();
Play();
Pause();
-
- // Frame shouldn't be updated.
- ResetCurrentFrame();
Flush();
EXPECT_FALSE(GetCurrentFrame());
-
Shutdown();
}
@@ -511,9 +501,6 @@
// Preroll only end of stream frames.
QueueEndOfStream();
-
- // Frame shouldn't be updated.
- ResetCurrentFrame();
Preroll(0, PIPELINE_OK);
EXPECT_FALSE(GetCurrentFrame());
@@ -526,9 +513,6 @@
TEST_F(VideoRendererBaseTest, GetCurrentFrame_Shutdown) {
Initialize();
-
- // Frame shouldn't be updated.
- ResetCurrentFrame();
Shutdown();
EXPECT_FALSE(GetCurrentFrame());
}
@@ -536,13 +520,33 @@
// Stop() is called immediately during an error.
TEST_F(VideoRendererBaseTest, GetCurrentFrame_Error) {
Initialize();
-
- // Frame shouldn't be updated.
- ResetCurrentFrame();
Stop();
EXPECT_FALSE(GetCurrentFrame());
}
+// Verify that shutdown can only proceed after we return the current frame.
+TEST_F(VideoRendererBaseTest, Shutdown_DuringPaint) {
+ Initialize();
+ Play();
+
+ // Grab the frame.
+ scoped_refptr<VideoFrame> frame;
+ renderer_->GetCurrentFrame(&frame);
+ EXPECT_TRUE(frame);
+
+ Pause();
+
+ // Start flushing -- it won't complete until we return the frame.
+ WaitableMessageLoopEvent event;
+ renderer_->Flush(event.GetClosure());
+
+ // Return the frame and wait.
+ renderer_->PutCurrentFrame(frame);
+ event.RunAndWait();
+
+ Stop();
+}
+
// Verify that a late decoder response doesn't break invariants in the renderer.
TEST_F(VideoRendererBaseTest, StopDuringOutstandingRead) {
Initialize();
« no previous file with comments | « media/filters/video_renderer_base.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698