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 <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "media/mp4/offset_byte_queue.h" | 9 #include "media/mp4/offset_byte_queue.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 queue_->Pop(384); | 24 queue_->Pop(384); |
25 | 25 |
26 // Queue will start with 128 bytes of data and an offset of 384 bytes. | 26 // Queue will start with 128 bytes of data and an offset of 384 bytes. |
27 // These values are used throughout the test. | 27 // These values are used throughout the test. |
28 } | 28 } |
29 | 29 |
30 protected: | 30 protected: |
31 scoped_ptr<OffsetByteQueue> queue_; | 31 scoped_ptr<OffsetByteQueue> queue_; |
32 }; | 32 }; |
33 | 33 |
34 TEST_F(OffsetByteQueueTest, TestSetUp) { | 34 TEST_F(OffsetByteQueueTest, SetUp) { |
35 EXPECT_EQ(384, queue_->head()); | 35 EXPECT_EQ(384, queue_->head()); |
36 EXPECT_EQ(512, queue_->tail()); | 36 EXPECT_EQ(512, queue_->tail()); |
37 | 37 |
38 const uint8* buf; | 38 const uint8* buf; |
39 int size; | 39 int size; |
40 | 40 |
41 queue_->Peek(&buf, &size); | 41 queue_->Peek(&buf, &size); |
42 EXPECT_EQ(128, size); | 42 EXPECT_EQ(128, size); |
43 EXPECT_EQ(128, buf[0]); | 43 EXPECT_EQ(128, buf[0]); |
44 EXPECT_EQ(255, buf[size-1]); | 44 EXPECT_EQ(255, buf[size-1]); |
45 } | 45 } |
46 | 46 |
47 TEST_F(OffsetByteQueueTest, TestPeekAt) { | 47 TEST_F(OffsetByteQueueTest, PeekAt) { |
48 const uint8* buf; | 48 const uint8* buf; |
49 int size; | 49 int size; |
50 | 50 |
51 queue_->PeekAt(400, &buf, &size); | 51 queue_->PeekAt(400, &buf, &size); |
52 EXPECT_EQ(queue_->tail() - 400, size); | 52 EXPECT_EQ(queue_->tail() - 400, size); |
53 EXPECT_EQ(400 - 256, buf[0]); | 53 EXPECT_EQ(400 - 256, buf[0]); |
54 | 54 |
55 queue_->PeekAt(512, &buf, &size); | 55 queue_->PeekAt(512, &buf, &size); |
56 EXPECT_EQ(NULL, buf); | 56 EXPECT_EQ(NULL, buf); |
57 EXPECT_EQ(0, size); | 57 EXPECT_EQ(0, size); |
58 } | 58 } |
59 | 59 |
60 TEST_F(OffsetByteQueueTest, TestTrim) { | 60 TEST_F(OffsetByteQueueTest, Trim) { |
61 EXPECT_TRUE(queue_->Trim(128)); | 61 EXPECT_TRUE(queue_->Trim(128)); |
62 EXPECT_TRUE(queue_->Trim(384)); | 62 EXPECT_TRUE(queue_->Trim(384)); |
63 EXPECT_EQ(384, queue_->head()); | 63 EXPECT_EQ(384, queue_->head()); |
64 EXPECT_EQ(512, queue_->tail()); | 64 EXPECT_EQ(512, queue_->tail()); |
65 | 65 |
66 EXPECT_TRUE(queue_->Trim(400)); | 66 EXPECT_TRUE(queue_->Trim(400)); |
67 EXPECT_EQ(400, queue_->head()); | 67 EXPECT_EQ(400, queue_->head()); |
68 EXPECT_EQ(512, queue_->tail()); | 68 EXPECT_EQ(512, queue_->tail()); |
69 | 69 |
70 const uint8* buf; | 70 const uint8* buf; |
(...skipping 12 matching lines...) Expand all Loading... |
83 // Trimming past the end of the buffer should return 'false'; we haven't seen | 83 // Trimming past the end of the buffer should return 'false'; we haven't seen |
84 // the preceeding bytes. | 84 // the preceeding bytes. |
85 EXPECT_FALSE(queue_->Trim(513)); | 85 EXPECT_FALSE(queue_->Trim(513)); |
86 | 86 |
87 // However, doing that shouldn't affect the EOS case. Only adding new data | 87 // However, doing that shouldn't affect the EOS case. Only adding new data |
88 // should alter this behavior. | 88 // should alter this behavior. |
89 EXPECT_TRUE(queue_->Trim(512)); | 89 EXPECT_TRUE(queue_->Trim(512)); |
90 } | 90 } |
91 | 91 |
92 } // namespace media | 92 } // namespace media |
OLD | NEW |