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

Unified Diff: webkit/media/buffered_data_source_unittest.cc

Issue 9113023: Fire canplaythrough as soon as download defers to fix autoplay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 8 years, 11 months 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 | « webkit/media/buffered_data_source.cc ('k') | webkit/media/webmediaplayer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/buffered_data_source_unittest.cc
diff --git a/webkit/media/buffered_data_source_unittest.cc b/webkit/media/buffered_data_source_unittest.cc
index 98a34d6d5ec6d36587e96d95c9e2842c72f51cef..c4c75ef68be01b64613bd43458aa895cb7720fd8 100644
--- a/webkit/media/buffered_data_source_unittest.cc
+++ b/webkit/media/buffered_data_source_unittest.cc
@@ -16,8 +16,8 @@
using ::testing::_;
using ::testing::Assign;
+using ::testing::AtLeast;
using ::testing::Invoke;
-using ::testing::StrictMock;
using ::testing::NiceMock;
using WebKit::WebFrame;
@@ -83,7 +83,6 @@ class BufferedDataSourceTest : public testing::Test {
data_source_ = new MockBufferedDataSource(message_loop_,
view_->mainFrame());
- data_source_->set_host(&host_);
}
virtual ~BufferedDataSourceTest() {
@@ -91,6 +90,13 @@ class BufferedDataSourceTest : public testing::Test {
}
void Initialize(media::PipelineStatus expected) {
+ Initialize(expected, true);
+ }
+
+ void Initialize(media::PipelineStatus expected, bool set_host) {
+ if (set_host)
+ data_source_->set_host(&host_);
+
ExpectCreateResourceLoader();
data_source_->Initialize(response_generator_.gurl().spec(),
media::NewExpectedStatusCB(expected));
@@ -101,8 +107,10 @@ class BufferedDataSourceTest : public testing::Test {
void InitializeWith206Response() {
Initialize(media::PIPELINE_OK);
- EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()));
- EXPECT_CALL(host_, SetBufferedBytes(0));
+ EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()))
+ .Times(AtLeast(1));
+ EXPECT_CALL(host_, SetBufferedBytes(0))
+ .Times(AtLeast(1));
Respond(response_generator_.Generate206(0));
}
@@ -176,7 +184,7 @@ class BufferedDataSourceTest : public testing::Test {
MockWebFrameClient client_;
WebView* view_;
- StrictMock<media::MockDataSourceHost> host_;
+ NiceMock<media::MockDataSourceHost> host_;
MessageLoop* message_loop_;
private:
@@ -441,8 +449,10 @@ TEST_F(BufferedDataSourceTest, Read) {
ReadAt(0);
// When the read completes we'll update our network status.
- EXPECT_CALL(host_, SetBufferedBytes(kDataSize));
- EXPECT_CALL(host_, SetNetworkActivity(true));
+ EXPECT_CALL(host_, SetBufferedBytes(kDataSize))
+ .Times(AtLeast(1));
+ EXPECT_CALL(host_, SetNetworkActivity(true))
+ .Times(AtLeast(1));
EXPECT_CALL(*this, ReadCallback(kDataSize));
FinishRead();
@@ -454,4 +464,18 @@ TEST_F(BufferedDataSourceTest, Read) {
Stop();
}
+// Make sure information regarding loaded data propogates to the host even if it
+// gets initialized before the host is set.
+TEST_F(BufferedDataSourceTest, HostSetAfterResponse) {
+ Initialize(media::PIPELINE_OK, false);
+ Respond(response_generator_.Generate206(0));
+
+ EXPECT_CALL(host_, SetNetworkActivity(_));
+ EXPECT_CALL(host_, SetTotalBytes(_));
+ EXPECT_CALL(host_, SetBufferedBytes(_));
+ data_source_->set_host(&host_);
+
+ Stop();
+}
+
} // namespace webkit_media
« no previous file with comments | « webkit/media/buffered_data_source.cc ('k') | webkit/media/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698