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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/multibuffer_data_source_unittest.cc
diff --git a/media/blink/multibuffer_data_source_unittest.cc b/media/blink/multibuffer_data_source_unittest.cc
index c9ebdfbb51d994f209fefa537417ad319d9b99a4..ea90482591765fcf53aa27dda70fe380d0575185 100644
--- a/media/blink/multibuffer_data_source_unittest.cc
+++ b/media/blink/multibuffer_data_source_unittest.cc
@@ -1593,4 +1593,44 @@ TEST_F(MultibufferDataSourceTest, CheckBufferSizes) {
EXPECT_EQ(71 << 20, buffer_size());
}
+// Provoke an edge case where the loading state may not end up transitioning
+// back to "idle" when we're done loading.
+TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) {
+ GURL gurl(kHttpUrl);
+ data_source_.reset(new MockMultibufferDataSource(
+ gurl, UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(), url_index_,
+ view_->mainFrame()->toWebLocalFrame(), &host_));
+ data_source_->SetPreload(preload_);
+
+ response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1));
+ EXPECT_CALL(*this, OnInitialize(true));
+ data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize,
+ base::Unretained(this)));
+ base::RunLoop().RunUntilIdle();
+
+ // Not really loading until after OnInitialize is called.
+ EXPECT_EQ(data_source_->downloading(), false);
+
+ EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
+ Respond(response_generator_->Generate206(0));
+ EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
+ ReceiveData(kDataSize);
+
+ EXPECT_EQ(data_source_->downloading(), true);
+ EXPECT_CALL(host_, AddBufferedByteRange(kDataSize, kDataSize + 1));
+ ReceiveDataLow(1);
+ EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3));
+ data_provider()->didFinishLoading(0);
+
+ EXPECT_CALL(*this, ReadCallback(1));
+ data_source_->Read(kDataSize, 2, buffer_,
+ base::Bind(&MultibufferDataSourceTest::ReadCallback,
+ base::Unretained(this)));
+ base::RunLoop().RunUntilIdle();
+
+ // Make sure we're not downloading anymore.
+ EXPECT_EQ(data_source_->downloading(), false);
+ Stop();
+}
+
} // namespace media
« 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