Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: content/renderer/media/buffered_data_source_unittest.cc

Issue 302553006: Suppress pause and buffer for local resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/media/buffered_data_source.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
scherkus (not reviewing) 2014/06/02 20:02:33 instead of setting this private variable it'd be p
amogh.bihani 2014/06/03 10:15:43 Ummm... We want to have 'range_supported_' to be t
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
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());
scherkus (not reviewing) 2014/06/02 20:02:33 I believe this only tests the initial value and no
amogh.bihani 2014/06/03 10:15:43 Done.
681
682 Stop();
683 }
684
685 TEST_F(BufferedDataSourceTest, ExternalResource_PauseAndBufferDeferStrategy) {
686 InitializeWith206Response();
687
688 EXPECT_FALSE(is_local_source());
689 EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
690
691 // Test for pause-and-buffer.
692 // When the playback has started and the media player is paused, the browser
693 // tries to load as much data as possible till it feels that the cashed data
694 // won't be useful in the future (Then it falls back to kCapacityDefer).
695 data_source_->MediaIsPlaying();
696 set_might_be_reused_from_cache_in_future(true);
697 data_source_->MediaIsPaused();
698 EXPECT_EQ(BufferedResourceLoader::kNeverDefer, defer_strategy());
699
700 data_source_->MediaIsPlaying();
701 set_might_be_reused_from_cache_in_future(false);
702 data_source_->MediaIsPaused();
703 EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
704
705 Stop();
706 }
707
672 } // namespace content 708 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/buffered_data_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698