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

Side by Side Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 1509663003: make multibuffer work with layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_cache.integrate3
Patch Set: Created 5 years 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
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 "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "media/base/media_log.h" 8 #include "media/base/media_log.h"
9 #include "media/base/mock_filters.h" 9 #include "media/base/mock_filters.h"
10 #include "media/base/test_helpers.h" 10 #include "media/base/test_helpers.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 gurl, message_loop_.task_runner(), url_index_, 236 gurl, message_loop_.task_runner(), url_index_,
237 view_->mainFrame()->toWebLocalFrame(), &host_)); 237 view_->mainFrame()->toWebLocalFrame(), &host_));
238 data_source_->SetPreload(preload_); 238 data_source_->SetPreload(preload_);
239 239
240 response_generator_.reset(new TestResponseGenerator(gurl, kFileSize)); 240 response_generator_.reset(new TestResponseGenerator(gurl, kFileSize));
241 EXPECT_CALL(*this, OnInitialize(expected)); 241 EXPECT_CALL(*this, OnInitialize(expected));
242 data_source_->Initialize(base::Bind( 242 data_source_->Initialize(base::Bind(
243 &MultibufferDataSourceTest::OnInitialize, base::Unretained(this))); 243 &MultibufferDataSourceTest::OnInitialize, base::Unretained(this)));
244 message_loop_.RunUntilIdle(); 244 message_loop_.RunUntilIdle();
245 245
246 // Always loading after initialize. 246 // Not really loading until after OnInitialize is called.
247 EXPECT_EQ(data_source_->downloading(), true); 247 EXPECT_EQ(data_source_->downloading(), false);
248 } 248 }
249 249
250 // Helper to initialize tests with a valid 200 response. 250 // Helper to initialize tests with a valid 200 response.
251 void InitializeWith200Response() { 251 void InitializeWith200Response() {
252 Initialize(kHttpUrl, true); 252 Initialize(kHttpUrl, true);
253 253
254 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); 254 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
255 Respond(response_generator_->Generate200()); 255 Respond(response_generator_->Generate200());
256 256
257 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); 257 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 EXPECT_TRUE(data_source_->downloading()); 1028 EXPECT_TRUE(data_source_->downloading());
1029 1029
1030 Stop(); 1030 Stop();
1031 } 1031 }
1032 1032
1033 TEST_F(MultibufferDataSourceTest, File_FinishLoading) { 1033 TEST_F(MultibufferDataSourceTest, File_FinishLoading) {
1034 InitializeWithFileResponse(); 1034 InitializeWithFileResponse();
1035 1035
1036 ReceiveData(kDataSize); 1036 ReceiveData(kDataSize);
1037 1037
1038 EXPECT_TRUE(data_source_->downloading()); 1038 EXPECT_FALSE(data_source_->downloading());
1039 // premature didFinishLoading() will cause a retry. 1039 // premature didFinishLoading() will cause a retry.
1040 FinishLoading(); 1040 FinishLoading();
1041 EXPECT_TRUE(data_source_->downloading()); 1041 EXPECT_FALSE(data_source_->downloading());
1042 1042
1043 Stop(); 1043 Stop();
1044 } 1044 }
1045 1045
1046 TEST_F(MultibufferDataSourceTest, LocalResource_DeferStrategy) { 1046 TEST_F(MultibufferDataSourceTest, LocalResource_DeferStrategy) {
1047 InitializeWithFileResponse(); 1047 InitializeWithFileResponse();
1048 1048
1049 EXPECT_EQ(MultibufferDataSource::AUTO, preload()); 1049 EXPECT_EQ(MultibufferDataSource::AUTO, preload());
1050 EXPECT_TRUE(is_local_source()); 1050 EXPECT_TRUE(is_local_source());
1051 CheckCapacityDefer(); 1051 CheckCapacityDefer();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 ASSERT_TRUE(active_loader()); 1196 ASSERT_TRUE(active_loader());
1197 1197
1198 EXPECT_CALL(*this, ReadCallback(kDataSize)); 1198 EXPECT_CALL(*this, ReadCallback(kDataSize));
1199 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 1199 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
1200 ReceiveData(kDataSize); 1200 ReceiveData(kDataSize);
1201 1201
1202 EXPECT_FALSE(active_loader_allownull()); 1202 EXPECT_FALSE(active_loader_allownull());
1203 } 1203 }
1204 1204
1205 } // namespace media 1205 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698