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

Side by Side Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 8304020: Fix Valgrind warnings from r105646. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <deque> 5 #include <deque>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/base/filters.h" 10 #include "media/base/filters.h"
(...skipping 18 matching lines...) Expand all
29 using ::testing::WithArgs; 29 using ::testing::WithArgs;
30 using ::testing::_; 30 using ::testing::_;
31 31
32 namespace media { 32 namespace media {
33 33
34 MATCHER(IsEndOfStreamBuffer, 34 MATCHER(IsEndOfStreamBuffer,
35 std::string(negation ? "isn't" : "is") + " end of stream") { 35 std::string(negation ? "isn't" : "is") + " end of stream") {
36 return arg->IsEndOfStream(); 36 return arg->IsEndOfStream();
37 } 37 }
38 38
39 ACTION(DeleteArg0Buffer) {
40 scoped_refptr<Buffer> buffer(arg0);
41 }
42
39 // Fixture class to facilitate writing tests. Takes care of setting up the 43 // Fixture class to facilitate writing tests. Takes care of setting up the
40 // FFmpeg, pipeline and filter host mocks. 44 // FFmpeg, pipeline and filter host mocks.
41 class FFmpegDemuxerTest : public testing::Test { 45 class FFmpegDemuxerTest : public testing::Test {
42 protected: 46 protected:
43 47
44 FFmpegDemuxerTest() { 48 FFmpegDemuxerTest() {
45 // Create an FFmpegDemuxer. 49 // Create an FFmpegDemuxer.
46 demuxer_ = new FFmpegDemuxer(&message_loop_); 50 demuxer_ = new FFmpegDemuxer(&message_loop_);
47 demuxer_->disable_first_seek_hack_for_testing(); 51 demuxer_->disable_first_seek_hack_for_testing();
48 52
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 400
397 // Expect all calls in sequence. 401 // Expect all calls in sequence.
398 InSequence s; 402 InSequence s;
399 403
400 // Create our mocked callback. The Callback created by base::Bind() will take 404 // Create our mocked callback. The Callback created by base::Bind() will take
401 // ownership of this pointer. 405 // ownership of this pointer.
402 StrictMock<MockReadCallback>* callback = new StrictMock<MockReadCallback>(); 406 StrictMock<MockReadCallback>* callback = new StrictMock<MockReadCallback>();
403 407
404 // The callback should be immediately deleted. We'll use a checkpoint to 408 // The callback should be immediately deleted. We'll use a checkpoint to
405 // verify that it has indeed been deleted. 409 // verify that it has indeed been deleted.
406 EXPECT_CALL(*callback, Run(NotNull())); 410 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer()))
scherkus (not reviewing) 2011/10/17 17:59:18 Woah -- we shouldn't have to do this considering i
411 .WillOnce(DeleteArg0Buffer());
407 EXPECT_CALL(*callback, OnDelete()); 412 EXPECT_CALL(*callback, OnDelete());
408 EXPECT_CALL(*this, CheckPoint(1)); 413 EXPECT_CALL(*this, CheckPoint(1));
409 414
410 // Attempt the read... 415 // Attempt the read...
411 audio->Read(base::Bind(&MockReadCallback::Run, callback)); 416 audio->Read(base::Bind(&MockReadCallback::Run, callback));
412 417
413 message_loop_.RunAllPending(); 418 message_loop_.RunAllPending();
414 419
415 // ...and verify that |callback| was deleted. 420 // ...and verify that |callback| was deleted.
416 CheckPoint(1); 421 CheckPoint(1);
(...skipping 18 matching lines...) Expand all
435 440
436 // Expect all calls in sequence. 441 // Expect all calls in sequence.
437 InSequence s; 442 InSequence s;
438 443
439 // Create our mocked callback. The Callback created by base::Bind() will take 444 // Create our mocked callback. The Callback created by base::Bind() will take
440 // ownership of this pointer. 445 // ownership of this pointer.
441 StrictMock<MockReadCallback>* callback = new StrictMock<MockReadCallback>(); 446 StrictMock<MockReadCallback>* callback = new StrictMock<MockReadCallback>();
442 447
443 // The callback should be immediately deleted. We'll use a checkpoint to 448 // The callback should be immediately deleted. We'll use a checkpoint to
444 // verify that it has indeed been deleted. 449 // verify that it has indeed been deleted.
445 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer())); 450 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer()))
451 .WillOnce(DeleteArg0Buffer());
446 EXPECT_CALL(*callback, OnDelete()); 452 EXPECT_CALL(*callback, OnDelete());
447 EXPECT_CALL(*this, CheckPoint(1)); 453 EXPECT_CALL(*this, CheckPoint(1));
448 454
449 // Release the reference to the demuxer. This should also destroy it. 455 // Release the reference to the demuxer. This should also destroy it.
450 demuxer_ = NULL; 456 demuxer_ = NULL;
451 // |audio| now has a demuxer_ pointer to invalid memory. 457 // |audio| now has a demuxer_ pointer to invalid memory.
452 458
453 // Attempt the read... 459 // Attempt the read...
454 audio->Read(base::Bind(&MockReadCallback::Run, callback)); 460 audio->Read(base::Bind(&MockReadCallback::Run, callback));
455 461
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 message_loop_.RunAllPending(); 689 message_loop_.RunAllPending();
684 EXPECT_TRUE(reader->called()); 690 EXPECT_TRUE(reader->called());
685 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000); 691 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000);
686 692
687 // Manually release the last reference to the buffer and verify it was freed. 693 // Manually release the last reference to the buffer and verify it was freed.
688 reader->Reset(); 694 reader->Reset();
689 message_loop_.RunAllPending(); 695 message_loop_.RunAllPending();
690 } 696 }
691 697
692 } // namespace media 698 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698