| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 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 // Fixture class to facilitate writing tests. Takes care of setting up the | 39 // Fixture class to facilitate writing tests. Takes care of setting up the |
| 40 // FFmpeg, pipeline and filter host mocks. | 40 // FFmpeg, pipeline and filter host mocks. |
| 41 class FFmpegDemuxerTest : public testing::Test { | 41 class FFmpegDemuxerTest : public testing::Test { |
| 42 protected: | 42 protected: |
| 43 | 43 |
| 44 FFmpegDemuxerTest() { | 44 FFmpegDemuxerTest() { |
| 45 // Create an FFmpegDemuxer. | 45 // Create an FFmpegDemuxer with local data source. |
| 46 demuxer_ = new FFmpegDemuxer(&message_loop_); | 46 demuxer_ = new FFmpegDemuxer(&message_loop_, true); |
| 47 demuxer_->disable_first_seek_hack_for_testing(); | 47 demuxer_->disable_first_seek_hack_for_testing(); |
| 48 | 48 |
| 49 // Inject a filter host and message loop and prepare a data source. | 49 // Inject a filter host and message loop and prepare a data source. |
| 50 demuxer_->set_host(&host_); | 50 demuxer_->set_host(&host_); |
| 51 | 51 |
| 52 EXPECT_CALL(host_, SetTotalBytes(_)).Times(AnyNumber()); | 52 EXPECT_CALL(host_, SetTotalBytes(_)).Times(AnyNumber()); |
| 53 EXPECT_CALL(host_, SetBufferedBytes(_)).Times(AnyNumber()); | 53 EXPECT_CALL(host_, SetBufferedBytes(_)).Times(AnyNumber()); |
| 54 EXPECT_CALL(host_, SetCurrentReadPosition(_)) | 54 EXPECT_CALL(host_, SetCurrentReadPosition(_)) |
| 55 .WillRepeatedly(SaveArg<0>(¤t_read_position_)); | 55 .WillRepeatedly(SaveArg<0>(¤t_read_position_)); |
| 56 } | 56 } |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 reader->Reset(); | 501 reader->Reset(); |
| 502 reader->Read(audio); | 502 reader->Read(audio); |
| 503 message_loop_.RunAllPending(); | 503 message_loop_.RunAllPending(); |
| 504 EXPECT_TRUE(reader->called()); | 504 EXPECT_TRUE(reader->called()); |
| 505 EXPECT_TRUE(reader->buffer()->IsEndOfStream()); | 505 EXPECT_TRUE(reader->buffer()->IsEndOfStream()); |
| 506 } | 506 } |
| 507 | 507 |
| 508 class MockFFmpegDemuxer : public FFmpegDemuxer { | 508 class MockFFmpegDemuxer : public FFmpegDemuxer { |
| 509 public: | 509 public: |
| 510 explicit MockFFmpegDemuxer(MessageLoop* message_loop) | 510 explicit MockFFmpegDemuxer(MessageLoop* message_loop) |
| 511 : FFmpegDemuxer(message_loop) { | 511 : FFmpegDemuxer(message_loop, true) { |
| 512 } | 512 } |
| 513 virtual ~MockFFmpegDemuxer() {} | 513 virtual ~MockFFmpegDemuxer() {} |
| 514 | 514 |
| 515 MOCK_METHOD0(WaitForRead, size_t()); | 515 MOCK_METHOD0(WaitForRead, size_t()); |
| 516 MOCK_METHOD1(SignalReadCompleted, void(size_t size)); | 516 MOCK_METHOD1(SignalReadCompleted, void(size_t size)); |
| 517 | 517 |
| 518 private: | 518 private: |
| 519 DISALLOW_COPY_AND_ASSIGN(MockFFmpegDemuxer); | 519 DISALLOW_COPY_AND_ASSIGN(MockFFmpegDemuxer); |
| 520 }; | 520 }; |
| 521 | 521 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 message_loop_.RunAllPending(); | 696 message_loop_.RunAllPending(); |
| 697 EXPECT_TRUE(reader->called()); | 697 EXPECT_TRUE(reader->called()); |
| 698 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000); | 698 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000); |
| 699 | 699 |
| 700 // Manually release the last reference to the buffer and verify it was freed. | 700 // Manually release the last reference to the buffer and verify it was freed. |
| 701 reader->Reset(); | 701 reader->Reset(); |
| 702 message_loop_.RunAllPending(); | 702 message_loop_.RunAllPending(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 } // namespace media | 705 } // namespace media |
| OLD | NEW |