Remove INJECT_EVENTS permissions from test APKs.
[chromium-blink-merge.git] / media / blink / buffered_data_source_host_impl_unittest.cc
blobef0a461afa523632601778461c0046c03d420d96
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
3 // found in the LICENSE file.
5 #include "media/blink/buffered_data_source_host_impl.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace media {
10 class BufferedDataSourceHostImplTest : public testing::Test {
11 public:
12 BufferedDataSourceHostImplTest() {}
14 void Add() {
15 host_.AddBufferedTimeRanges(&ranges_, base::TimeDelta::FromSeconds(10));
18 protected:
19 BufferedDataSourceHostImpl host_;
20 Ranges<base::TimeDelta> ranges_;
22 DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceHostImplTest);
25 TEST_F(BufferedDataSourceHostImplTest, Empty) {
26 EXPECT_FALSE(host_.DidLoadingProgress());
27 Add();
28 EXPECT_EQ(0u, ranges_.size());
31 TEST_F(BufferedDataSourceHostImplTest, AddBufferedTimeRanges) {
32 host_.AddBufferedByteRange(10, 20);
33 host_.SetTotalBytes(100);
34 Add();
35 EXPECT_EQ(1u, ranges_.size());
36 EXPECT_EQ(base::TimeDelta::FromSeconds(1), ranges_.start(0));
37 EXPECT_EQ(base::TimeDelta::FromSeconds(2), ranges_.end(0));
40 TEST_F(BufferedDataSourceHostImplTest, AddBufferedTimeRanges_Merges) {
41 ranges_.Add(base::TimeDelta::FromSeconds(0), base::TimeDelta::FromSeconds(1));
42 host_.AddBufferedByteRange(10, 20);
43 host_.SetTotalBytes(100);
44 Add();
45 EXPECT_EQ(1u, ranges_.size());
46 EXPECT_EQ(base::TimeDelta::FromSeconds(0), ranges_.start(0));
47 EXPECT_EQ(base::TimeDelta::FromSeconds(2), ranges_.end(0));
50 TEST_F(BufferedDataSourceHostImplTest, AddBufferedTimeRanges_Snaps) {
51 host_.AddBufferedByteRange(5, 995);
52 host_.SetTotalBytes(1000);
53 Add();
54 EXPECT_EQ(1u, ranges_.size());
55 EXPECT_EQ(base::TimeDelta::FromSeconds(0), ranges_.start(0));
56 EXPECT_EQ(base::TimeDelta::FromSeconds(10), ranges_.end(0));
59 TEST_F(BufferedDataSourceHostImplTest, SetTotalBytes) {
60 host_.AddBufferedByteRange(10, 20);
61 Add();
62 EXPECT_EQ(0u, ranges_.size());
64 host_.SetTotalBytes(100);
65 Add();
66 EXPECT_EQ(1u, ranges_.size());
69 TEST_F(BufferedDataSourceHostImplTest, DidLoadingProgress) {
70 host_.AddBufferedByteRange(10, 20);
71 EXPECT_TRUE(host_.DidLoadingProgress());
72 EXPECT_FALSE(host_.DidLoadingProgress());
75 } // namespace media