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/formats/common/offset_byte_queue.h" | |
|
xhwang
2016/04/11 18:56:43
Where's the rule that this header should be the fi
Nico
2016/04/11 19:00:01
dcheng's script for adding these puts them there.
| |
| 6 | |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 #include <string.h> | 8 #include <string.h> |
| 7 | 9 |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include <memory> |
| 9 #include "media/formats/common/offset_byte_queue.h" | 11 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 namespace media { | 14 namespace media { |
| 13 | 15 |
| 14 class OffsetByteQueueTest : public testing::Test { | 16 class OffsetByteQueueTest : public testing::Test { |
| 15 public: | 17 public: |
| 16 void SetUp() override { | 18 void SetUp() override { |
| 17 uint8_t buf[256]; | 19 uint8_t buf[256]; |
| 18 for (int i = 0; i < 256; i++) { | 20 for (int i = 0; i < 256; i++) { |
| 19 buf[i] = i; | 21 buf[i] = i; |
| 20 } | 22 } |
| 21 queue_.reset(new OffsetByteQueue); | 23 queue_.reset(new OffsetByteQueue); |
| 22 queue_->Push(buf, sizeof(buf)); | 24 queue_->Push(buf, sizeof(buf)); |
| 23 queue_->Push(buf, sizeof(buf)); | 25 queue_->Push(buf, sizeof(buf)); |
| 24 queue_->Pop(384); | 26 queue_->Pop(384); |
| 25 | 27 |
| 26 // Queue will start with 128 bytes of data and an offset of 384 bytes. | 28 // Queue will start with 128 bytes of data and an offset of 384 bytes. |
| 27 // These values are used throughout the test. | 29 // These values are used throughout the test. |
| 28 } | 30 } |
| 29 | 31 |
| 30 protected: | 32 protected: |
| 31 scoped_ptr<OffsetByteQueue> queue_; | 33 std::unique_ptr<OffsetByteQueue> queue_; |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 TEST_F(OffsetByteQueueTest, SetUp) { | 36 TEST_F(OffsetByteQueueTest, SetUp) { |
| 35 EXPECT_EQ(384, queue_->head()); | 37 EXPECT_EQ(384, queue_->head()); |
| 36 EXPECT_EQ(512, queue_->tail()); | 38 EXPECT_EQ(512, queue_->tail()); |
| 37 | 39 |
| 38 const uint8_t* buf; | 40 const uint8_t* buf; |
| 39 int size; | 41 int size; |
| 40 | 42 |
| 41 queue_->Peek(&buf, &size); | 43 queue_->Peek(&buf, &size); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // Trimming past the end of the buffer should return 'false'; we haven't seen | 85 // Trimming past the end of the buffer should return 'false'; we haven't seen |
| 84 // the preceeding bytes. | 86 // the preceeding bytes. |
| 85 EXPECT_FALSE(queue_->Trim(513)); | 87 EXPECT_FALSE(queue_->Trim(513)); |
| 86 | 88 |
| 87 // However, doing that shouldn't affect the EOS case. Only adding new data | 89 // However, doing that shouldn't affect the EOS case. Only adding new data |
| 88 // should alter this behavior. | 90 // should alter this behavior. |
| 89 EXPECT_TRUE(queue_->Trim(512)); | 91 EXPECT_TRUE(queue_->Trim(512)); |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace media | 94 } // namespace media |
| OLD | NEW |