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

Unified Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 131092: FFmpegDemuxerStream::Read() now functions properly while stopped. (Closed)
Patch Set: Albert's comments Created 11 years, 6 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/ffmpeg_demuxer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer_unittest.cc
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index df427f87583f4b45152e7aa782dccc191bf332cd..619851cc37ac5363b30dcb2ade1c15a10a59414f 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -21,6 +21,7 @@ using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Return;
using ::testing::SetArgumentPointee;
+using ::testing::StrictMock;
namespace media {
@@ -613,4 +614,57 @@ TEST_F(FFmpegDemuxerTest, MP3Hack) {
MockFFmpeg::get()->CheckPoint(2);
}
+// A mocked callback specialization for calling Read(). Since RunWithParams()
+// is mocked we don't need to pass in object or method pointers.
+typedef CallbackImpl<FFmpegDemuxerTest, void (FFmpegDemuxerTest::*)(Buffer*),
+ Tuple1<Buffer*> > ReadCallback;
+class MockReadCallback : public ReadCallback {
+ public:
+ MockReadCallback()
+ : ReadCallback(NULL, NULL) {
+ }
+
+ virtual ~MockReadCallback() {
+ OnDelete();
+ }
+
+ MOCK_METHOD0(OnDelete, void());
+ MOCK_METHOD1(RunWithParams, void(const Tuple1<Buffer*>& params));
+};
+
+TEST_F(FFmpegDemuxerTest, Stop) {
+ // Tests that calling Read() on a stopped demuxer immediately deletes the
+ // callback.
+ {
+ SCOPED_TRACE("");
+ InitializeDemuxer();
+ }
+
+ // Create our mocked callback. The demuxer will take ownership of this
+ // pointer.
+ scoped_ptr<StrictMock<MockReadCallback> > callback(
+ new StrictMock<MockReadCallback>());
+
+ // Get our stream.
+ scoped_refptr<DemuxerStream> audio = demuxer_->GetStream(DS_STREAM_AUDIO);
+ ASSERT_TRUE(audio);
+
+ // Stop the demuxer.
+ demuxer_->Stop();
+
+ // Expect all calls in sequence.
+ InSequence s;
+
+ // The callback should be immediately deleted. We'll use a checkpoint to
+ // verify that it has indeed been deleted.
+ EXPECT_CALL(*callback, OnDelete());
+ EXPECT_CALL(*MockFFmpeg::get(), CheckPoint(1));
+
+ // Attempt the read...
+ audio->Read(callback.release());
+
+ // ...and verify that |callback| was deleted.
+ MockFFmpeg::get()->CheckPoint(1);
+}
+
} // namespace media
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698