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

Unified Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 2495633002: media: Make sure we transition back to a non-loading state (Closed)
Patch Set: 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 70ab655283ac1331540570542c6132f373912c87..7ffe5538b68290a048cc05eedfae6970faee0aec 100644
--- a/media/blink/multibuffer_data_source_unittest.cc
+++ b/media/blink/multibuffer_data_source_unittest.cc
@@ -1525,4 +1525,45 @@ TEST_F(MultibufferDataSourceTest, EtagTest) {
EXPECT_EQ(url_data()->etag(), etag);
}
+
+// 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