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" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 } | 520 } |
521 | 521 |
522 TEST_F(MultibufferDataSourceTest, Range_NotSupported) { | 522 TEST_F(MultibufferDataSourceTest, Range_NotSupported) { |
523 InitializeWith200Response(); | 523 InitializeWith200Response(); |
524 | 524 |
525 EXPECT_TRUE(loading()); | 525 EXPECT_TRUE(loading()); |
526 EXPECT_TRUE(data_source_->IsStreaming()); | 526 EXPECT_TRUE(data_source_->IsStreaming()); |
527 Stop(); | 527 Stop(); |
528 } | 528 } |
529 | 529 |
| 530 TEST_F(MultibufferDataSourceTest, Range_NotSatisfiable) { |
| 531 Initialize(kHttpUrl, true); |
| 532 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
| 533 Respond(response_generator_->GenerateResponse(416)); |
| 534 EXPECT_FALSE(loading()); |
| 535 Stop(); |
| 536 } |
| 537 |
530 // Special carve-out for Apache versions that choose to return a 200 for | 538 // Special carve-out for Apache versions that choose to return a 200 for |
531 // Range:0- ("because it's more efficient" than a 206) | 539 // Range:0- ("because it's more efficient" than a 206) |
532 TEST_F(MultibufferDataSourceTest, Range_SupportedButReturned200) { | 540 TEST_F(MultibufferDataSourceTest, Range_SupportedButReturned200) { |
533 Initialize(kHttpUrl, true); | 541 Initialize(kHttpUrl, true); |
534 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); | 542 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); |
535 WebURLResponse response = response_generator_->Generate200(); | 543 WebURLResponse response = response_generator_->Generate200(); |
536 response.setHTTPHeaderField(WebString::fromUTF8("Accept-Ranges"), | 544 response.setHTTPHeaderField(WebString::fromUTF8("Accept-Ranges"), |
537 WebString::fromUTF8("bytes")); | 545 WebString::fromUTF8("bytes")); |
538 Respond(response); | 546 Respond(response); |
539 | 547 |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); | 1377 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
1370 ReceiveData(kDataSize); | 1378 ReceiveData(kDataSize); |
1371 | 1379 |
1372 EXPECT_FALSE(data_source_->IsStreaming()); | 1380 EXPECT_FALSE(data_source_->IsStreaming()); |
1373 | 1381 |
1374 FinishLoading(); | 1382 FinishLoading(); |
1375 EXPECT_FALSE(loading()); | 1383 EXPECT_FALSE(loading()); |
1376 Stop(); | 1384 Stop(); |
1377 } | 1385 } |
1378 | 1386 |
| 1387 TEST_F(MultibufferDataSourceTest, Http_RangeNotSatisfiableAfterRedirect) { |
| 1388 Initialize(kHttpUrl, true); |
| 1389 |
| 1390 // Server responds with a redirect. |
| 1391 blink::WebURLRequest request((GURL(kHttpDifferentPathUrl))); |
| 1392 blink::WebURLResponse response((GURL(kHttpUrl))); |
| 1393 response.setHTTPStatusCode(307); |
| 1394 data_provider()->willFollowRedirect(url_loader(), request, response); |
| 1395 |
| 1396 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
| 1397 Respond(response_generator_->GenerateResponse(416)); |
| 1398 Stop(); |
| 1399 } |
| 1400 |
1379 TEST_F(MultibufferDataSourceTest, LengthKnownAtEOF) { | 1401 TEST_F(MultibufferDataSourceTest, LengthKnownAtEOF) { |
1380 Initialize(kHttpUrl, true); | 1402 Initialize(kHttpUrl, true); |
1381 // Server responds without content-length. | 1403 // Server responds without content-length. |
1382 WebURLResponse response = response_generator_->Generate200(); | 1404 WebURLResponse response = response_generator_->Generate200(); |
1383 response.clearHTTPHeaderField(WebString::fromUTF8("Content-Length")); | 1405 response.clearHTTPHeaderField(WebString::fromUTF8("Content-Length")); |
1384 response.setExpectedContentLength(kPositionNotSpecified); | 1406 response.setExpectedContentLength(kPositionNotSpecified); |
1385 Respond(response); | 1407 Respond(response); |
1386 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); | 1408 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
1387 ReceiveData(kDataSize); | 1409 ReceiveData(kDataSize); |
1388 int64_t len; | 1410 int64_t len; |
1389 EXPECT_FALSE(data_source_->GetSize(&len)); | 1411 EXPECT_FALSE(data_source_->GetSize(&len)); |
1390 EXPECT_TRUE(data_source_->IsStreaming()); | 1412 EXPECT_TRUE(data_source_->IsStreaming()); |
1391 EXPECT_CALL(*this, ReadCallback(kDataSize)); | 1413 EXPECT_CALL(*this, ReadCallback(kDataSize)); |
1392 ReadAt(0); | 1414 ReadAt(0); |
1393 | 1415 |
1394 ReadAt(kDataSize); | 1416 ReadAt(kDataSize); |
1395 EXPECT_CALL(host_, SetTotalBytes(kDataSize)); | 1417 EXPECT_CALL(host_, SetTotalBytes(kDataSize)); |
1396 EXPECT_CALL(*this, ReadCallback(0)); | 1418 EXPECT_CALL(*this, ReadCallback(0)); |
1397 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); | 1419 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); |
1398 FinishLoading(); | 1420 FinishLoading(); |
1399 | 1421 |
1400 // Done loading, now we should know the length. | 1422 // Done loading, now we should know the length. |
1401 EXPECT_TRUE(data_source_->GetSize(&len)); | 1423 EXPECT_TRUE(data_source_->GetSize(&len)); |
1402 EXPECT_EQ(kDataSize, len); | 1424 EXPECT_EQ(kDataSize, len); |
1403 Stop(); | 1425 Stop(); |
1404 } | 1426 } |
1405 | 1427 |
1406 } // namespace media | 1428 } // namespace media |
OLD | NEW |