Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 2481673004: media: Make sure we transition back to a non-loading state (Closed)
Patch Set: merged Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/multibuffer_data_source.cc ('k') | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source.cc ('k') | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698