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

Unified Diff: media/filters/video_renderer_base_unittest.cc

Issue 12096081: Replace VideoRendererBase Get/PutCurrentFrame() with a VideoFrame-containing callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
Index: media/filters/video_renderer_base_unittest.cc
diff --git a/media/filters/video_renderer_base_unittest.cc b/media/filters/video_renderer_base_unittest.cc
index b1498490df16d0d2cadd1e743631c1c25f5d6969..1049735cd0385f6569220f619181023c5d711919 100644
--- a/media/filters/video_renderer_base_unittest.cc
+++ b/media/filters/video_renderer_base_unittest.cc
@@ -63,8 +63,6 @@ class VideoRendererBaseTest : public ::testing::Test {
.Times(AnyNumber());
EXPECT_CALL(*this, OnTimeUpdate(_))
.Times(AnyNumber());
- EXPECT_CALL(*this, OnPaint())
- .Times(AnyNumber());
EXPECT_CALL(*this, OnSetOpaque(_))
.Times(AnyNumber());
}
@@ -72,7 +70,6 @@ class VideoRendererBaseTest : public ::testing::Test {
virtual ~VideoRendererBaseTest() {}
// Callbacks passed into VideoRendererBase().
- MOCK_CONST_METHOD0(OnPaint, void());
MOCK_CONST_METHOD1(OnSetOpaque, void(bool));
// Callbacks passed into Initialize().
@@ -228,11 +225,14 @@ class VideoRendererBaseTest : public ::testing::Test {
}
}
+ void ResetCurrentFrame() {
+ base::AutoLock l(lock_);
+ current_frame_ = NULL;
+ }
+
scoped_refptr<VideoFrame> GetCurrentFrame() {
- scoped_refptr<VideoFrame> frame;
- renderer_->GetCurrentFrame(&frame);
- renderer_->PutCurrentFrame(frame);
- return frame;
+ base::AutoLock l(lock_);
+ return current_frame_;
}
int GetCurrentTimestampInMs() {
@@ -305,6 +305,11 @@ class VideoRendererBaseTest : public ::testing::Test {
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());
@@ -335,9 +340,10 @@ class VideoRendererBaseTest : public ::testing::Test {
VideoDecoderConfig video_config_;
- // Used to protect |time_|.
+ // Used to protect |time_| and |current_frame_|.
base::Lock lock_;
base::TimeDelta time_;
+ scoped_refptr<VideoFrame> current_frame_;
// Used for satisfying reads.
VideoDecoder::ReadCB read_cb_;
@@ -488,8 +494,12 @@ TEST_F(VideoRendererBaseTest, GetCurrentFrame_Flushed) {
Initialize();
Play();
Pause();
+
+ // Frame shouldn't be updated.
+ ResetCurrentFrame();
Flush();
EXPECT_FALSE(GetCurrentFrame());
+
Shutdown();
}
@@ -501,6 +511,9 @@ TEST_F(VideoRendererBaseTest, GetCurrentFrame_EndOfStream) {
// Preroll only end of stream frames.
QueueEndOfStream();
+
+ // Frame shouldn't be updated.
+ ResetCurrentFrame();
Preroll(0, PIPELINE_OK);
EXPECT_FALSE(GetCurrentFrame());
@@ -513,6 +526,9 @@ TEST_F(VideoRendererBaseTest, GetCurrentFrame_EndOfStream) {
TEST_F(VideoRendererBaseTest, GetCurrentFrame_Shutdown) {
Initialize();
+
+ // Frame shouldn't be updated.
+ ResetCurrentFrame();
Shutdown();
EXPECT_FALSE(GetCurrentFrame());
}
@@ -520,31 +536,11 @@ TEST_F(VideoRendererBaseTest, GetCurrentFrame_Shutdown) {
// Stop() is called immediately during an error.
TEST_F(VideoRendererBaseTest, GetCurrentFrame_Error) {
Initialize();
- 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();
+ // Frame shouldn't be updated.
+ ResetCurrentFrame();
Stop();
+ EXPECT_FALSE(GetCurrentFrame());
}
// Verify that a late decoder response doesn't break invariants in the renderer.

Powered by Google App Engine
This is Rietveld 408576698