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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 data_source_->SetBitrate(80 << 20); // 80 mbit / s | 1586 data_source_->SetBitrate(80 << 20); // 80 mbit / s |
1587 base::RunLoop().RunUntilIdle(); | 1587 base::RunLoop().RunUntilIdle(); |
1588 EXPECT_EQ(80 << 20, data_source_bitrate()); | 1588 EXPECT_EQ(80 << 20, data_source_bitrate()); |
1589 EXPECT_EQ(50 << 20, preload_low()); | 1589 EXPECT_EQ(50 << 20, preload_low()); |
1590 EXPECT_EQ(51 << 20, preload_high()); | 1590 EXPECT_EQ(51 << 20, preload_high()); |
1591 EXPECT_EQ(51 << 20, max_buffer_forward()); | 1591 EXPECT_EQ(51 << 20, max_buffer_forward()); |
1592 EXPECT_EQ(20 << 20, max_buffer_backward()); | 1592 EXPECT_EQ(20 << 20, max_buffer_backward()); |
1593 EXPECT_EQ(71 << 20, buffer_size()); | 1593 EXPECT_EQ(71 << 20, buffer_size()); |
1594 } | 1594 } |
1595 | 1595 |
| 1596 // Provoke an edge case where the loading state may not end up transitioning |
| 1597 // back to "idle" when we're done loading. |
| 1598 TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) { |
| 1599 GURL gurl(kHttpUrl); |
| 1600 data_source_.reset(new MockMultibufferDataSource( |
| 1601 gurl, UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(), url_index_, |
| 1602 view_->mainFrame()->toWebLocalFrame(), &host_)); |
| 1603 data_source_->SetPreload(preload_); |
| 1604 |
| 1605 response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1)); |
| 1606 EXPECT_CALL(*this, OnInitialize(true)); |
| 1607 data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize, |
| 1608 base::Unretained(this))); |
| 1609 base::RunLoop().RunUntilIdle(); |
| 1610 |
| 1611 // Not really loading until after OnInitialize is called. |
| 1612 EXPECT_EQ(data_source_->downloading(), false); |
| 1613 |
| 1614 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); |
| 1615 Respond(response_generator_->Generate206(0)); |
| 1616 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); |
| 1617 ReceiveData(kDataSize); |
| 1618 |
| 1619 EXPECT_EQ(data_source_->downloading(), true); |
| 1620 EXPECT_CALL(host_, AddBufferedByteRange(kDataSize, kDataSize + 1)); |
| 1621 ReceiveDataLow(1); |
| 1622 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3)); |
| 1623 data_provider()->didFinishLoading(0); |
| 1624 |
| 1625 EXPECT_CALL(*this, ReadCallback(1)); |
| 1626 data_source_->Read(kDataSize, 2, buffer_, |
| 1627 base::Bind(&MultibufferDataSourceTest::ReadCallback, |
| 1628 base::Unretained(this))); |
| 1629 base::RunLoop().RunUntilIdle(); |
| 1630 |
| 1631 // Make sure we're not downloading anymore. |
| 1632 EXPECT_EQ(data_source_->downloading(), false); |
| 1633 Stop(); |
| 1634 } |
| 1635 |
1596 } // namespace media | 1636 } // namespace media |
OLD | NEW |