| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
| 11 #include "media/base/filter_host.h" | 11 #include "media/base/filter_host.h" |
| 12 #include "media/base/filters.h" | 12 #include "media/base/filters.h" |
| 13 #include "media/base/media_log.h" | 13 #include "media/base/media_log.h" |
| 14 #include "media/base/pipeline_impl.h" | 14 #include "media/base/pipeline_impl.h" |
| 15 #include "media/base/mock_callback.h" | 15 #include "media/base/mock_callback.h" |
| 16 #include "media/base/mock_filters.h" | 16 #include "media/base/mock_filters.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 19 | 19 |
| 20 using ::testing::_; | 20 using ::testing::_; |
| 21 using ::testing::DeleteArg; | 21 using ::testing::DeleteArg; |
| 22 using ::testing::InSequence; | 22 using ::testing::InSequence; |
| 23 using ::testing::Invoke; | 23 using ::testing::Invoke; |
| 24 using ::testing::InvokeArgument; | |
| 25 using ::testing::Mock; | 24 using ::testing::Mock; |
| 26 using ::testing::NotNull; | 25 using ::testing::NotNull; |
| 27 using ::testing::Return; | 26 using ::testing::Return; |
| 28 using ::testing::ReturnRef; | 27 using ::testing::ReturnRef; |
| 29 using ::testing::StrictMock; | 28 using ::testing::StrictMock; |
| 30 using ::testing::WithArg; | |
| 31 | 29 |
| 32 namespace media { | 30 namespace media { |
| 33 | 31 |
| 34 // Total bytes of the data source. | 32 // Total bytes of the data source. |
| 35 static const int kTotalBytes = 1024; | 33 static const int kTotalBytes = 1024; |
| 36 | 34 |
| 37 // Buffered bytes of the data source. | 35 // Buffered bytes of the data source. |
| 38 static const int kBufferedBytes = 1024; | 36 static const int kBufferedBytes = 1024; |
| 39 | 37 |
| 40 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 38 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 new StrictMock<MockDemuxerStream>(); | 119 new StrictMock<MockDemuxerStream>(); |
| 122 EXPECT_CALL(*stream, type()) | 120 EXPECT_CALL(*stream, type()) |
| 123 .WillRepeatedly(Return(type)); | 121 .WillRepeatedly(Return(type)); |
| 124 return stream; | 122 return stream; |
| 125 } | 123 } |
| 126 | 124 |
| 127 // Sets up expectations to allow the video decoder to initialize. | 125 // Sets up expectations to allow the video decoder to initialize. |
| 128 void InitializeVideoDecoder(MockDemuxerStream* stream) { | 126 void InitializeVideoDecoder(MockDemuxerStream* stream) { |
| 129 EXPECT_CALL(*mocks_->video_decoder(), | 127 EXPECT_CALL(*mocks_->video_decoder(), |
| 130 Initialize(stream, _, _)) | 128 Initialize(stream, _, _)) |
| 131 .WillOnce(WithArg<1>(Invoke(&RunPipelineStatusOKCB))); | 129 .WillOnce(Invoke(&RunFilterCallback3)); |
| 132 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(0.0f)); | 130 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(0.0f)); |
| 133 EXPECT_CALL(*mocks_->video_decoder(), | 131 EXPECT_CALL(*mocks_->video_decoder(), |
| 134 Seek(mocks_->demuxer()->GetStartTime(), _)) | 132 Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 135 .WillOnce(Invoke(&RunFilterStatusCB)); | 133 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 136 EXPECT_CALL(*mocks_->video_decoder(), Stop(_)) | 134 EXPECT_CALL(*mocks_->video_decoder(), Stop(_)) |
| 137 .WillOnce(Invoke(&RunStopFilterCallback)); | 135 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 138 } | 136 } |
| 139 | 137 |
| 140 // Sets up expectations to allow the audio decoder to initialize. | 138 // Sets up expectations to allow the audio decoder to initialize. |
| 141 void InitializeAudioDecoder(MockDemuxerStream* stream) { | 139 void InitializeAudioDecoder(MockDemuxerStream* stream) { |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 TestPipelineStatusNotification(0); | 912 TestPipelineStatusNotification(0); |
| 915 } | 913 } |
| 916 | 914 |
| 917 // Test that different-thread, some-delay callback (the expected common case) | 915 // Test that different-thread, some-delay callback (the expected common case) |
| 918 // works correctly. | 916 // works correctly. |
| 919 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 917 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 920 TestPipelineStatusNotification(20); | 918 TestPipelineStatusNotification(20); |
| 921 } | 919 } |
| 922 | 920 |
| 923 } // namespace media | 921 } // namespace media |
| OLD | NEW |