OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "content/public/common/url_constants.h" | 7 #include "content/public/common/url_constants.h" |
8 #include "content/renderer/media/buffered_data_source.h" | 8 #include "content/renderer/media/buffered_data_source.h" |
9 #include "content/renderer/media/test_response_generator.h" | 9 #include "content/renderer/media/test_response_generator.h" |
10 #include "content/test/mock_webframeclient.h" | 10 #include "content/test/mock_webframeclient.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 } | 212 } |
213 | 213 |
214 Preload preload() { return data_source_->preload_; } | 214 Preload preload() { return data_source_->preload_; } |
215 BufferedResourceLoader::DeferStrategy defer_strategy() { | 215 BufferedResourceLoader::DeferStrategy defer_strategy() { |
216 return loader()->defer_strategy_; | 216 return loader()->defer_strategy_; |
217 } | 217 } |
218 int data_source_bitrate() { return data_source_->bitrate_; } | 218 int data_source_bitrate() { return data_source_->bitrate_; } |
219 int data_source_playback_rate() { return data_source_->playback_rate_; } | 219 int data_source_playback_rate() { return data_source_->playback_rate_; } |
220 int loader_bitrate() { return loader()->bitrate_; } | 220 int loader_bitrate() { return loader()->bitrate_; } |
221 int loader_playback_rate() { return loader()->playback_rate_; } | 221 int loader_playback_rate() { return loader()->playback_rate_; } |
222 bool is_local_source() { return data_source_->assume_fully_buffered_; } | |
223 void set_might_be_reused_from_cache_in_future(bool value) { | |
224 loader()->might_be_reused_from_cache_in_future_ = value; | |
225 } | |
222 | 226 |
223 scoped_ptr<MockBufferedDataSource> data_source_; | 227 scoped_ptr<MockBufferedDataSource> data_source_; |
224 | 228 |
225 scoped_ptr<TestResponseGenerator> response_generator_; | 229 scoped_ptr<TestResponseGenerator> response_generator_; |
226 MockWebFrameClient client_; | 230 MockWebFrameClient client_; |
227 WebView* view_; | 231 WebView* view_; |
228 WebLocalFrame* frame_; | 232 WebLocalFrame* frame_; |
229 | 233 |
230 StrictMock<MockBufferedDataSourceHost> host_; | 234 StrictMock<MockBufferedDataSourceHost> host_; |
231 base::MessageLoop message_loop_; | 235 base::MessageLoop message_loop_; |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 TEST_F(BufferedDataSourceTest, File_FinishLoading) { | 666 TEST_F(BufferedDataSourceTest, File_FinishLoading) { |
663 InitializeWithFileResponse(); | 667 InitializeWithFileResponse(); |
664 | 668 |
665 EXPECT_FALSE(data_source_->downloading()); | 669 EXPECT_FALSE(data_source_->downloading()); |
666 FinishLoading(); | 670 FinishLoading(); |
667 EXPECT_FALSE(data_source_->downloading()); | 671 EXPECT_FALSE(data_source_->downloading()); |
668 | 672 |
669 Stop(); | 673 Stop(); |
670 } | 674 } |
671 | 675 |
676 TEST_F(BufferedDataSourceTest, LocalResource_DeferStrategy) { | |
677 InitializeWithFileResponse(); | |
678 | |
679 EXPECT_TRUE(is_local_source()); | |
680 EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy()); | |
681 | |
682 // Test for pause-and-buffer | |
scherkus (not reviewing)
2014/05/30 20:37:39
nit: comments should end with periods
you should
amogh.bihani
2014/06/02 05:01:28
Done.
| |
683 data_source_->MediaIsPlaying(); | |
684 data_source_->MediaIsPaused(); | |
685 EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy()); | |
686 | |
687 Stop(); | |
688 } | |
689 | |
690 TEST_F(BufferedDataSourceTest, ExternalResource_DeferStrategy) { | |
691 InitializeWith206Response(); | |
692 | |
693 EXPECT_FALSE(is_local_source()); | |
694 EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy()); | |
695 | |
696 // Test for pause-and-buffer | |
697 data_source_->MediaIsPlaying(); | |
698 set_might_be_reused_from_cache_in_future(true); | |
amogh.bihani
2014/05/29 09:38:57
Need to do this as buffered_resource_loader set it
| |
699 data_source_->MediaIsPaused(); | |
700 EXPECT_EQ(BufferedResourceLoader::kNeverDefer, defer_strategy()); | |
701 | |
702 Stop(); | |
703 } | |
704 | |
672 } // namespace content | 705 } // namespace content |
OLD | NEW |