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

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

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: Created 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <deque> 6 #include <deque>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 16 matching lines...) Expand all
27 using ::testing::NotNull; 27 using ::testing::NotNull;
28 using ::testing::Return; 28 using ::testing::Return;
29 using ::testing::SaveArg; 29 using ::testing::SaveArg;
30 using ::testing::SetArgPointee; 30 using ::testing::SetArgPointee;
31 using ::testing::StrictMock; 31 using ::testing::StrictMock;
32 using ::testing::WithArgs; 32 using ::testing::WithArgs;
33 using ::testing::_; 33 using ::testing::_;
34 34
35 namespace media { 35 namespace media {
36 36
37 MATCHER(IsEndOfStreamBuffer, 37 MATCHER(is_end_of_streamBuffer,
scherkus (not reviewing) 2013/06/20 21:26:59 revert this -- looks like it got included in some
38 std::string(negation ? "isn't" : "is") + " end of stream") { 38 std::string(negation ? "isn't" : "is") + " end of stream") {
39 return arg->IsEndOfStream(); 39 return arg->is_end_of_stream();
40 } 40 }
41 41
42 static void EosOnReadDone(bool* got_eos_buffer, 42 static void EosOnReadDone(bool* got_eos_buffer,
43 DemuxerStream::Status status, 43 DemuxerStream::Status status,
44 const scoped_refptr<DecoderBuffer>& buffer) { 44 const scoped_refptr<DecoderBuffer>& buffer) {
45 base::MessageLoop::current()->PostTask( 45 base::MessageLoop::current()->PostTask(
46 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 46 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
47 47
48 EXPECT_EQ(status, DemuxerStream::kOk); 48 EXPECT_EQ(status, DemuxerStream::kOk);
49 if (buffer->IsEndOfStream()) { 49 if (buffer->is_end_of_stream()) {
50 *got_eos_buffer = true; 50 *got_eos_buffer = true;
51 return; 51 return;
52 } 52 }
53 53
54 EXPECT_TRUE(buffer->GetData()); 54 EXPECT_TRUE(buffer->get_data());
55 EXPECT_GT(buffer->GetDataSize(), 0); 55 EXPECT_GT(buffer->get_data_size(), 0);
56 *got_eos_buffer = false; 56 *got_eos_buffer = false;
57 }; 57 };
58 58
59 59
60 // Fixture class to facilitate writing tests. Takes care of setting up the 60 // Fixture class to facilitate writing tests. Takes care of setting up the
61 // FFmpeg, pipeline and filter host mocks. 61 // FFmpeg, pipeline and filter host mocks.
62 class FFmpegDemuxerTest : public testing::Test { 62 class FFmpegDemuxerTest : public testing::Test {
63 protected: 63 protected:
64 FFmpegDemuxerTest() {} 64 FFmpegDemuxerTest() {}
65 65
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 int size, int64 timestampInMicroseconds, 104 int size, int64 timestampInMicroseconds,
105 DemuxerStream::Status status, 105 DemuxerStream::Status status,
106 const scoped_refptr<DecoderBuffer>& buffer) { 106 const scoped_refptr<DecoderBuffer>& buffer) {
107 std::string location_str; 107 std::string location_str;
108 location.Write(true, false, &location_str); 108 location.Write(true, false, &location_str);
109 location_str += "\n"; 109 location_str += "\n";
110 SCOPED_TRACE(location_str); 110 SCOPED_TRACE(location_str);
111 EXPECT_EQ(status, DemuxerStream::kOk); 111 EXPECT_EQ(status, DemuxerStream::kOk);
112 OnReadDoneCalled(size, timestampInMicroseconds); 112 OnReadDoneCalled(size, timestampInMicroseconds);
113 EXPECT_TRUE(buffer.get() != NULL); 113 EXPECT_TRUE(buffer.get() != NULL);
114 EXPECT_EQ(size, buffer->GetDataSize()); 114 EXPECT_EQ(size, buffer->get_data_size());
115 EXPECT_EQ(base::TimeDelta::FromMicroseconds(timestampInMicroseconds), 115 EXPECT_EQ(base::TimeDelta::FromMicroseconds(timestampInMicroseconds),
116 buffer->GetTimestamp()); 116 buffer->get_timestamp());
117 117
118 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); 118 DCHECK_EQ(&message_loop_, base::MessageLoop::current());
119 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 119 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
120 } 120 }
121 121
122 DemuxerStream::ReadCB NewReadCB(const tracked_objects::Location& location, 122 DemuxerStream::ReadCB NewReadCB(const tracked_objects::Location& location,
123 int size, int64 timestampInMicroseconds) { 123 int size, int64 timestampInMicroseconds) {
124 EXPECT_CALL(*this, OnReadDoneCalled(size, timestampInMicroseconds)); 124 EXPECT_CALL(*this, OnReadDoneCalled(size, timestampInMicroseconds));
125 return base::Bind(&FFmpegDemuxerTest::OnReadDone, base::Unretained(this), 125 return base::Bind(&FFmpegDemuxerTest::OnReadDone, base::Unretained(this),
126 location, size, timestampInMicroseconds); 126 location, size, timestampInMicroseconds);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 InitializeDemuxer(); 427 InitializeDemuxer();
428 428
429 // Get our stream. 429 // Get our stream.
430 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); 430 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
431 ASSERT_TRUE(audio); 431 ASSERT_TRUE(audio);
432 432
433 demuxer_->Stop(NewExpectedClosure()); 433 demuxer_->Stop(NewExpectedClosure());
434 434
435 // Reads after being stopped are all EOS buffers. 435 // Reads after being stopped are all EOS buffers.
436 StrictMock<MockReadCB> callback; 436 StrictMock<MockReadCB> callback;
437 EXPECT_CALL(callback, Run(DemuxerStream::kOk, IsEndOfStreamBuffer())); 437 EXPECT_CALL(callback, Run(DemuxerStream::kOk, is_end_of_streamBuffer()));
438 438
439 // Attempt the read... 439 // Attempt the read...
440 audio->Read(base::Bind(&MockReadCB::Run, base::Unretained(&callback))); 440 audio->Read(base::Bind(&MockReadCB::Run, base::Unretained(&callback)));
441 message_loop_.RunUntilIdle(); 441 message_loop_.RunUntilIdle();
442 } 442 }
443 443
444 TEST_F(FFmpegDemuxerTest, DisableAudioStream) { 444 TEST_F(FFmpegDemuxerTest, DisableAudioStream) {
445 // We are doing the following things here: 445 // We are doing the following things here:
446 // 1. Initialize the demuxer with audio and video stream. 446 // 1. Initialize the demuxer with audio and video stream.
447 // 2. Send a "disable audio stream" message to the demuxer. 447 // 2. Send a "disable audio stream" message to the demuxer.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 TEST_F(FFmpegDemuxerTest, MP4_ZeroStszEntry) { 567 TEST_F(FFmpegDemuxerTest, MP4_ZeroStszEntry) {
568 #if !defined(USE_PROPRIETARY_CODECS) 568 #if !defined(USE_PROPRIETARY_CODECS)
569 return; 569 return;
570 #endif 570 #endif
571 CreateDemuxer("bear-1280x720-zero-stsz-entry.mp4"); 571 CreateDemuxer("bear-1280x720-zero-stsz-entry.mp4");
572 InitializeDemuxer(); 572 InitializeDemuxer();
573 ReadUntilEndOfStream(); 573 ReadUntilEndOfStream();
574 } 574 }
575 575
576 } // namespace media 576 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698