| 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 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 WebURLResponse response = response_generator_->Generate206(0); | 1518 WebURLResponse response = response_generator_->Generate206(0); |
| 1519 const std::string etag("\"arglebargle glop-glyf?\""); | 1519 const std::string etag("\"arglebargle glop-glyf?\""); |
| 1520 response.setHTTPHeaderField(WebString::fromUTF8("Etag"), | 1520 response.setHTTPHeaderField(WebString::fromUTF8("Etag"), |
| 1521 WebString::fromUTF8(etag)); | 1521 WebString::fromUTF8(etag)); |
| 1522 Respond(response); | 1522 Respond(response); |
| 1523 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); | 1523 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
| 1524 ReceiveData(kDataSize); | 1524 ReceiveData(kDataSize); |
| 1525 | 1525 |
| 1526 EXPECT_EQ(url_data()->etag(), etag); | 1526 EXPECT_EQ(url_data()->etag(), etag); |
| 1527 } | 1527 } |
| 1528 |
| 1529 // Provoke an edge case where the loading state may not end up transitioning |
| 1530 // back to "idle" when we're done loading. |
| 1531 TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) { |
| 1532 GURL gurl(kHttpUrl); |
| 1533 data_source_.reset(new MockMultibufferDataSource( |
| 1534 gurl, UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(), url_index_, |
| 1535 view_->mainFrame()->toWebLocalFrame(), &host_)); |
| 1536 data_source_->SetPreload(preload_); |
| 1537 |
| 1538 response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1)); |
| 1539 EXPECT_CALL(*this, OnInitialize(true)); |
| 1540 data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize, |
| 1541 base::Unretained(this))); |
| 1542 base::RunLoop().RunUntilIdle(); |
| 1543 |
| 1544 // Not really loading until after OnInitialize is called. |
| 1545 EXPECT_EQ(data_source_->downloading(), false); |
| 1546 |
| 1547 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); |
| 1548 Respond(response_generator_->Generate206(0)); |
| 1549 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
| 1550 ReceiveData(kDataSize); |
| 1551 |
| 1552 EXPECT_EQ(data_source_->downloading(), true); |
| 1553 EXPECT_CALL(host_, AddBufferedByteRange(kDataSize, kDataSize + 1)); |
| 1554 ReceiveDataLow(1); |
| 1555 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3)); |
| 1556 data_provider()->didFinishLoading(0); |
| 1557 |
| 1558 EXPECT_CALL(*this, ReadCallback(1)); |
| 1559 data_source_->Read(kDataSize, 2, buffer_, |
| 1560 base::Bind(&MultibufferDataSourceTest::ReadCallback, |
| 1561 base::Unretained(this))); |
| 1562 base::RunLoop().RunUntilIdle(); |
| 1563 |
| 1564 // Make sure we're not downloading anymore. |
| 1565 EXPECT_EQ(data_source_->downloading(), false); |
| 1566 Stop(); |
| 1567 } |
| 1568 |
| 1528 } // namespace media | 1569 } // namespace media |
| OLD | NEW |