Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/blink/buffered_data_source_host_impl.h" | |
| 6 #include "base/bind.h" | |
|
DaleCurtis
2017/04/06 22:51:40
add line above.
hubbe
2017/04/07 19:35:51
Done.
| |
| 5 #include "base/macros.h" | 7 #include "base/macros.h" |
| 6 #include "media/blink/buffered_data_source_host_impl.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 namespace media { | 10 namespace media { |
| 10 | 11 |
| 11 class BufferedDataSourceHostImplTest : public testing::Test { | 12 class BufferedDataSourceHostImplTest : public testing::Test { |
| 12 public: | 13 public: |
| 13 BufferedDataSourceHostImplTest() {} | 14 BufferedDataSourceHostImplTest() |
| 15 : host_(base::Bind(&BufferedDataSourceHostImplTest::ProgressCallback, | |
| 16 base::Unretained(this))) {} | |
| 14 | 17 |
| 15 void Add() { | 18 void Add() { |
| 16 host_.AddBufferedTimeRanges(&ranges_, base::TimeDelta::FromSeconds(10)); | 19 host_.AddBufferedTimeRanges(&ranges_, base::TimeDelta::FromSeconds(10)); |
| 17 } | 20 } |
| 18 | 21 |
| 22 void ProgressCallback() { progress_callback_calls_++; } | |
| 23 | |
| 19 protected: | 24 protected: |
| 25 int progress_callback_calls_ = 0; | |
| 20 BufferedDataSourceHostImpl host_; | 26 BufferedDataSourceHostImpl host_; |
| 21 Ranges<base::TimeDelta> ranges_; | 27 Ranges<base::TimeDelta> ranges_; |
| 22 | 28 |
| 23 DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceHostImplTest); | 29 DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceHostImplTest); |
| 24 }; | 30 }; |
| 25 | 31 |
| 26 TEST_F(BufferedDataSourceHostImplTest, Empty) { | 32 TEST_F(BufferedDataSourceHostImplTest, Empty) { |
| 27 EXPECT_FALSE(host_.DidLoadingProgress()); | 33 EXPECT_FALSE(host_.DidLoadingProgress()); |
| 28 Add(); | 34 Add(); |
| 29 EXPECT_EQ(0u, ranges_.size()); | 35 EXPECT_EQ(0u, ranges_.size()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 Add(); | 72 Add(); |
| 67 EXPECT_EQ(1u, ranges_.size()); | 73 EXPECT_EQ(1u, ranges_.size()); |
| 68 } | 74 } |
| 69 | 75 |
| 70 TEST_F(BufferedDataSourceHostImplTest, DidLoadingProgress) { | 76 TEST_F(BufferedDataSourceHostImplTest, DidLoadingProgress) { |
| 71 host_.AddBufferedByteRange(10, 20); | 77 host_.AddBufferedByteRange(10, 20); |
| 72 EXPECT_TRUE(host_.DidLoadingProgress()); | 78 EXPECT_TRUE(host_.DidLoadingProgress()); |
| 73 EXPECT_FALSE(host_.DidLoadingProgress()); | 79 EXPECT_FALSE(host_.DidLoadingProgress()); |
| 74 } | 80 } |
| 75 | 81 |
| 82 TEST_F(BufferedDataSourceHostImplTest, CanPlayThrough) { | |
| 83 host_.SetTotalBytes(100000); | |
| 84 host_.AddBufferedByteRange(0, 10000); | |
| 85 host_.AddBufferedByteRange(10000, 20000); | |
| 86 host_.AddBufferedByteRange(20000, 30000); | |
| 87 host_.AddBufferedByteRange(30000, 40000); | |
| 88 host_.AddBufferedByteRange(40000, 50000); | |
| 89 host_.AddBufferedByteRange(50000, 60000); | |
| 90 host_.AddBufferedByteRange(60000, 70000); | |
| 91 host_.AddBufferedByteRange(70000, 80000); | |
| 92 host_.AddBufferedByteRange(80000, 90000); | |
| 93 EXPECT_EQ(9, progress_callback_calls_); | |
| 94 EXPECT_TRUE(host_.CanPlayThrough(base::TimeDelta(), | |
| 95 base::TimeDelta::FromSecondsD(1000.0), 1.0)); | |
| 96 } | |
| 97 | |
| 76 } // namespace media | 98 } // namespace media |
| OLD | NEW |