OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/buffers.h" | 5 #include "media/base/buffers.h" |
6 #include "media/base/decoder_buffer.h" | 6 #include "media/base/decoder_buffer.h" |
7 #include "media/base/decoder_buffer_queue.h" | 7 #include "media/base/decoder_buffer_queue.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 static base::TimeDelta ToTimeDelta(int seconds) { | 12 static base::TimeDelta ToTimeDelta(int seconds) { |
13 if (seconds < 0) | 13 if (seconds < 0) |
14 return kNoTimestamp(); | 14 return kNoTimestamp(); |
15 return base::TimeDelta::FromSeconds(seconds); | 15 return base::TimeDelta::FromSeconds(seconds); |
16 } | 16 } |
17 | 17 |
18 // Helper to create buffers with specified timestamp in seconds. | 18 // Helper to create buffers with specified timestamp in seconds. |
19 // | 19 // |
20 // Negative numbers will be converted to kNoTimestamp(); | 20 // Negative numbers will be converted to kNoTimestamp(); |
21 static scoped_refptr<DecoderBuffer> CreateBuffer(int timestamp) { | 21 static scoped_refptr<DecoderBuffer> CreateBuffer(int timestamp) { |
22 scoped_refptr<DecoderBuffer> buffer = new DecoderBuffer(0); | 22 scoped_refptr<DecoderBuffer> buffer = new DecoderBuffer(0); |
23 buffer->SetTimestamp(ToTimeDelta(timestamp)); | 23 buffer->set_timestamp(ToTimeDelta(timestamp)); |
24 buffer->SetDuration(ToTimeDelta(0)); | 24 buffer->set_duration(ToTimeDelta(0)); |
25 return buffer; | 25 return buffer; |
26 } | 26 } |
27 | 27 |
28 TEST(DecoderBufferQueueTest, IsEmpty) { | 28 TEST(DecoderBufferQueueTest, IsEmpty) { |
29 DecoderBufferQueue queue; | 29 DecoderBufferQueue queue; |
30 EXPECT_TRUE(queue.IsEmpty()); | 30 EXPECT_TRUE(queue.IsEmpty()); |
31 | 31 |
32 queue.Push(CreateBuffer(0)); | 32 queue.Push(CreateBuffer(0)); |
33 EXPECT_FALSE(queue.IsEmpty()); | 33 EXPECT_FALSE(queue.IsEmpty()); |
34 } | 34 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_EQ(0, queue.Duration().InSeconds()); | 129 EXPECT_EQ(0, queue.Duration().InSeconds()); |
130 | 130 |
131 queue.Pop(); | 131 queue.Pop(); |
132 EXPECT_EQ(0, queue.Duration().InSeconds()); | 132 EXPECT_EQ(0, queue.Duration().InSeconds()); |
133 | 133 |
134 queue.Pop(); | 134 queue.Pop(); |
135 EXPECT_EQ(0, queue.Duration().InSeconds()); | 135 EXPECT_EQ(0, queue.Duration().InSeconds()); |
136 } | 136 } |
137 | 137 |
138 } // namespace media | 138 } // namespace media |
OLD | NEW |