| 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 "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 Loading... |
| 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 Loading... |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 ASSERT_TRUE(active_loader()); | 1208 ASSERT_TRUE(active_loader()); |
| 1209 | 1209 |
| 1210 EXPECT_CALL(*this, ReadCallback(kDataSize)); | 1210 EXPECT_CALL(*this, ReadCallback(kDataSize)); |
| 1211 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); | 1211 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); |
| 1212 ReceiveData(kDataSize); | 1212 ReceiveData(kDataSize); |
| 1213 | 1213 |
| 1214 EXPECT_FALSE(active_loader_allownull()); | 1214 EXPECT_FALSE(active_loader_allownull()); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 } // namespace media | 1217 } // namespace media |
| OLD | NEW |