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

Unified Diff: media/blink/buffered_data_source_host_impl_unittest.cc

Issue 2796193002: fix canplaythrough (Closed)
Patch Set: comments addressed Created 3 years, 8 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
Index: media/blink/buffered_data_source_host_impl_unittest.cc
diff --git a/media/blink/buffered_data_source_host_impl_unittest.cc b/media/blink/buffered_data_source_host_impl_unittest.cc
index 54ecf75c3b6ea6652d8af115800b0d502a868bbc..2cc1b60af3732a60d1a992f4de4ad40d5db33cb5 100644
--- a/media/blink/buffered_data_source_host_impl_unittest.cc
+++ b/media/blink/buffered_data_source_host_impl_unittest.cc
@@ -2,21 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/macros.h"
#include "media/blink/buffered_data_source_host_impl.h"
+#include "base/bind.h"
DaleCurtis 2017/04/06 22:51:40 add line above.
hubbe 2017/04/07 19:35:51 Done.
+#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
class BufferedDataSourceHostImplTest : public testing::Test {
public:
- BufferedDataSourceHostImplTest() {}
+ BufferedDataSourceHostImplTest()
+ : host_(base::Bind(&BufferedDataSourceHostImplTest::ProgressCallback,
+ base::Unretained(this))) {}
void Add() {
host_.AddBufferedTimeRanges(&ranges_, base::TimeDelta::FromSeconds(10));
}
+ void ProgressCallback() { progress_callback_calls_++; }
+
protected:
+ int progress_callback_calls_ = 0;
BufferedDataSourceHostImpl host_;
Ranges<base::TimeDelta> ranges_;
@@ -73,4 +79,20 @@ TEST_F(BufferedDataSourceHostImplTest, DidLoadingProgress) {
EXPECT_FALSE(host_.DidLoadingProgress());
}
+TEST_F(BufferedDataSourceHostImplTest, CanPlayThrough) {
+ host_.SetTotalBytes(100000);
+ host_.AddBufferedByteRange(0, 10000);
+ host_.AddBufferedByteRange(10000, 20000);
+ host_.AddBufferedByteRange(20000, 30000);
+ host_.AddBufferedByteRange(30000, 40000);
+ host_.AddBufferedByteRange(40000, 50000);
+ host_.AddBufferedByteRange(50000, 60000);
+ host_.AddBufferedByteRange(60000, 70000);
+ host_.AddBufferedByteRange(70000, 80000);
+ host_.AddBufferedByteRange(80000, 90000);
+ EXPECT_EQ(9, progress_callback_calls_);
+ EXPECT_TRUE(host_.CanPlayThrough(base::TimeDelta(),
+ base::TimeDelta::FromSecondsD(1000.0), 1.0));
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698