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

Unified Diff: media/filters/video_renderer_base_unittest.cc

Issue 12335105: Merge 184048 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/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') | no next file » | 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 184723)
+++ media/filters/video_renderer_base_unittest.cc (working copy)
@@ -5,6 +5,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
+#include "base/debug/stack_trace.h"
#include "base/message_loop.h"
#include "base/stl_util.h"
#include "base/stringprintf.h"
@@ -114,14 +115,18 @@
void InitializeRenderer(PipelineStatus expected) {
SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected));
+ WaitableMessageLoopEvent event;
+ CallInitialize(event.GetPipelineStatusCB());
+ event.RunAndWaitForStatus(expected);
+ }
+
+ void CallInitialize(const PipelineStatusCB& status_cb) {
VideoRendererBase::VideoDecoderList decoders;
decoders.push_back(decoder_);
-
- WaitableMessageLoopEvent event;
renderer_->Initialize(
demuxer_stream_,
decoders,
- event.GetPipelineStatusCB(),
+ status_cb,
base::Bind(&MockStatisticsCB::OnStatistics,
base::Unretained(&statistics_cb_object_)),
base::Bind(&VideoRendererBaseTest::OnTimeUpdate,
@@ -133,7 +138,6 @@
base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)),
base::Bind(&VideoRendererBaseTest::GetDuration,
base::Unretained(this)));
- event.RunAndWaitForStatus(expected);
}
void Play() {
@@ -354,12 +358,44 @@
DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest);
};
+TEST_F(VideoRendererBaseTest, DoNothing) {
+ // Test that creation and deletion doesn't depend on calls to Initialize()
+ // and/or Stop().
+}
+
+TEST_F(VideoRendererBaseTest, StopWithoutInitialize) {
+ Stop();
+}
+
TEST_F(VideoRendererBaseTest, Initialize) {
Initialize();
EXPECT_EQ(0, GetCurrentTimestampInMs());
Shutdown();
}
+static void ExpectNotCalled(PipelineStatus) {
+ base::debug::StackTrace stack;
+ ADD_FAILURE() << "Expected callback not to be called\n" << stack.ToString();
+}
+
+TEST_F(VideoRendererBaseTest, StopWhileInitializing) {
+ EXPECT_CALL(*decoder_, Initialize(_, _, _))
+ .WillOnce(RunCallback<1>(PIPELINE_OK));
+ CallInitialize(base::Bind(&ExpectNotCalled));
+ Stop();
+
+ // ~VideoRendererBase() will CHECK() if we left anything initialized.
+}
+
+TEST_F(VideoRendererBaseTest, StopWhileFlushing) {
+ Initialize();
+ Pause();
+ renderer_->Flush(base::Bind(&ExpectNotCalled, PIPELINE_OK));
+ Stop();
+
+ // ~VideoRendererBase() will CHECK() if we left anything initialized.
+}
+
TEST_F(VideoRendererBaseTest, Play) {
Initialize();
Play();
« no previous file with comments | « media/filters/video_renderer_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698