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 30 matching lines...) Expand all Loading... |
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, TestPeekAt) { |
48 const uint8* buf; | 48 const uint8* buf; |
49 int size; | 49 int size; |
50 | 50 |
51 queue_->PeekAt(128, &buf, &size); | |
52 EXPECT_EQ(NULL, buf); | |
53 EXPECT_EQ(0, size); | |
54 | |
55 queue_->PeekAt(400, &buf, &size); | 51 queue_->PeekAt(400, &buf, &size); |
56 EXPECT_EQ(queue_->tail() - 400, size); | 52 EXPECT_EQ(queue_->tail() - 400, size); |
57 EXPECT_EQ(400 - 256, buf[0]); | 53 EXPECT_EQ(400 - 256, buf[0]); |
58 | 54 |
59 queue_->PeekAt(512, &buf, &size); | 55 queue_->PeekAt(512, &buf, &size); |
60 EXPECT_EQ(NULL, buf); | 56 EXPECT_EQ(NULL, buf); |
61 EXPECT_EQ(0, size); | 57 EXPECT_EQ(0, size); |
62 } | 58 } |
63 | 59 |
64 TEST_F(OffsetByteQueueTest, TestTrim) { | 60 TEST_F(OffsetByteQueueTest, TestTrim) { |
(...skipping 22 matching lines...) Expand all Loading... |
87 // 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 |
88 // the preceeding bytes. | 84 // the preceeding bytes. |
89 EXPECT_FALSE(queue_->Trim(513)); | 85 EXPECT_FALSE(queue_->Trim(513)); |
90 | 86 |
91 // 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 |
92 // should alter this behavior. | 88 // should alter this behavior. |
93 EXPECT_TRUE(queue_->Trim(512)); | 89 EXPECT_TRUE(queue_->Trim(512)); |
94 } | 90 } |
95 | 91 |
96 } // namespace media | 92 } // namespace media |
OLD | NEW |