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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/string_number_conversions.h" |
12 #include "media/base/media_log.h" | 13 #include "media/base/media_log.h" |
13 #include "media/base/mock_filters.h" | 14 #include "media/base/mock_filters.h" |
14 #include "media/base/test_helpers.h" | 15 #include "media/base/test_helpers.h" |
15 #include "media/blink/buffered_data_source.h" | 16 #include "media/blink/buffered_data_source.h" |
16 #include "media/blink/mock_webframeclient.h" | 17 #include "media/blink/mock_webframeclient.h" |
17 #include "media/blink/mock_weburlloader.h" | 18 #include "media/blink/mock_weburlloader.h" |
18 #include "media/blink/multibuffer_data_source.h" | 19 #include "media/blink/multibuffer_data_source.h" |
19 #include "media/blink/multibuffer_reader.h" | 20 #include "media/blink/multibuffer_reader.h" |
20 #include "media/blink/resource_multibuffer_data_provider.h" | 21 #include "media/blink/resource_multibuffer_data_provider.h" |
21 #include "media/blink/test_response_generator.h" | 22 #include "media/blink/test_response_generator.h" |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 EXPECT_CALL(*this, ReadCallback(0)); | 1419 EXPECT_CALL(*this, ReadCallback(0)); |
1419 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); | 1420 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); |
1420 FinishLoading(); | 1421 FinishLoading(); |
1421 | 1422 |
1422 // Done loading, now we should know the length. | 1423 // Done loading, now we should know the length. |
1423 EXPECT_TRUE(data_source_->GetSize(&len)); | 1424 EXPECT_TRUE(data_source_->GetSize(&len)); |
1424 EXPECT_EQ(kDataSize, len); | 1425 EXPECT_EQ(kDataSize, len); |
1425 Stop(); | 1426 Stop(); |
1426 } | 1427 } |
1427 | 1428 |
| 1429 TEST_F(MultibufferDataSourceTest, FileSizeLessThanBlockSize) { |
| 1430 Initialize(kHttpUrl, true); |
| 1431 GURL gurl(kHttpUrl); |
| 1432 blink::WebURLResponse response(gurl); |
| 1433 response.setHTTPStatusCode(200); |
| 1434 response.setHTTPHeaderField( |
| 1435 WebString::fromUTF8("Content-Length"), |
| 1436 WebString::fromUTF8(base::Int64ToString(kDataSize / 2))); |
| 1437 response.setExpectedContentLength(kDataSize / 2); |
| 1438 Respond(response); |
| 1439 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize / 2)); |
| 1440 EXPECT_CALL(host_, SetTotalBytes(kDataSize / 2)); |
| 1441 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); |
| 1442 ReceiveData(kDataSize / 2); |
| 1443 FinishLoading(); |
| 1444 |
| 1445 int64_t len = 0; |
| 1446 EXPECT_TRUE(data_source_->GetSize(&len)); |
| 1447 EXPECT_EQ(kDataSize / 2, len); |
| 1448 Stop(); |
| 1449 } |
| 1450 |
1428 } // namespace media | 1451 } // namespace media |
OLD | NEW |