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