| OLD | NEW |
| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.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" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 // Sets up expectations to allow the demuxer to initialize. | 100 // Sets up expectations to allow the demuxer to initialize. |
| 101 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 101 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 102 void InitializeDemuxer(MockDemuxerStreamVector* streams, | 102 void InitializeDemuxer(MockDemuxerStreamVector* streams, |
| 103 const base::TimeDelta& duration) { | 103 const base::TimeDelta& duration) { |
| 104 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration( | 104 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration( |
| 105 kTotalBytes, kBufferedBytes, duration); | 105 kTotalBytes, kBufferedBytes, duration); |
| 106 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); | 106 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); |
| 107 EXPECT_CALL(*mocks_->demuxer(), SetPreload(AUTO)); | |
| 108 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) | 107 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 109 .WillOnce(Invoke(&RunPipelineStatusCB)); | 108 .WillOnce(Invoke(&RunPipelineStatusCB)); |
| 110 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 109 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 111 .WillOnce(Invoke(&RunStopFilterCallback)); | 110 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 112 | 111 |
| 113 // Configure the demuxer to return the streams. | 112 // Configure the demuxer to return the streams. |
| 114 for (size_t i = 0; i < streams->size(); ++i) { | 113 for (size_t i = 0; i < streams->size(); ++i) { |
| 115 scoped_refptr<DemuxerStream> stream((*streams)[i]); | 114 scoped_refptr<DemuxerStream> stream((*streams)[i]); |
| 116 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) | 115 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) |
| 117 .WillRepeatedly(Return(stream)); | 116 .WillRepeatedly(Return(stream)); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 PipelineStatus /* status */) { | 753 PipelineStatus /* status */) { |
| 755 CHECK(pipeline); | 754 CHECK(pipeline); |
| 756 CHECK(message_loop); | 755 CHECK(message_loop); |
| 757 | 756 |
| 758 // When we get to this stage, the message loop should be empty. | 757 // When we get to this stage, the message loop should be empty. |
| 759 message_loop->AssertIdle(); | 758 message_loop->AssertIdle(); |
| 760 | 759 |
| 761 // Make calls on pipeline after error has occurred. | 760 // Make calls on pipeline after error has occurred. |
| 762 pipeline->SetPlaybackRate(0.5f); | 761 pipeline->SetPlaybackRate(0.5f); |
| 763 pipeline->SetVolume(0.5f); | 762 pipeline->SetVolume(0.5f); |
| 764 pipeline->SetPreload(AUTO); | |
| 765 | 763 |
| 766 // No additional tasks should be queued as a result of these calls. | 764 // No additional tasks should be queued as a result of these calls. |
| 767 message_loop->AssertIdle(); | 765 message_loop->AssertIdle(); |
| 768 } | 766 } |
| 769 | 767 |
| 770 TEST_F(PipelineTest, NoMessageDuringTearDownFromError) { | 768 TEST_F(PipelineTest, NoMessageDuringTearDownFromError) { |
| 771 CreateAudioStream(); | 769 CreateAudioStream(); |
| 772 MockDemuxerStreamVector streams; | 770 MockDemuxerStreamVector streams; |
| 773 streams.push_back(audio_stream()); | 771 streams.push_back(audio_stream()); |
| 774 | 772 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 883 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 886 } | 884 } |
| 887 | 885 |
| 888 // Test that different-thread, some-delay callback (the expected common case) | 886 // Test that different-thread, some-delay callback (the expected common case) |
| 889 // works correctly. | 887 // works correctly. |
| 890 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 888 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 891 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 889 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 892 } | 890 } |
| 893 | 891 |
| 894 } // namespace media | 892 } // namespace media |
| OLD | NEW |