OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // The test buffer data is 52 bytes, wrap position is set to 20 (this is | 5 // The test buffer data is 52 bytes, wrap position is set to 20 (this is |
6 // arbitrarily chosen). The total buffer size is allocated dynamically based on | 6 // arbitrarily chosen). The total buffer size is allocated dynamically based on |
7 // the actual header size. This gives: | 7 // the actual header size. This gives: |
8 // Header of some size, non-wrapping part 20 bytes, wrapping part 32 bytes. | 8 // Header of some size, non-wrapping part 20 bytes, wrapping part 32 bytes. |
9 // As input data, a 14 byte array is used and repeatedly written. It's chosen | 9 // As input data, a 14 byte array is used and repeatedly written. It's chosen |
10 // not to be an integer factor smaller than the wrapping part. This ensures that | 10 // not to be an integer factor smaller than the wrapping part. This ensures that |
11 // the wrapped data isn't repeated at the same position. | 11 // the wrapped data isn't repeated at the same position. |
12 // Note that desipte the number of wraps (if one or more), the reference output | 12 // Note that desipte the number of wraps (if one or more), the reference output |
13 // data is the same since the offset at each wrap is always the same. | 13 // data is the same since the offset at each wrap is always the same. |
14 | 14 |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "content/common/partial_circular_buffer.h" | 16 #include "chrome/common/partial_circular_buffer.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace content { | |
20 | |
21 const uint32 kWrapPosition = 20; | 19 const uint32 kWrapPosition = 20; |
22 const uint8 kInputData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; | 20 const uint8 kInputData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
23 const uint8 kOutputRefDataWrap[] = | 21 const uint8 kOutputRefDataWrap[] = |
24 // The 20 bytes in the non-wrapping part. | 22 // The 20 bytes in the non-wrapping part. |
25 {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, | 23 {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, |
26 // The 32 bytes in wrapping part. | 24 // The 32 bytes in wrapping part. |
27 11, 12, 13, 14, | 25 11, 12, 13, 14, |
28 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | 26 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
29 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; | 27 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
30 | 28 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 EXPECT_EQ(size_per_read, | 125 EXPECT_EQ(size_per_read, |
128 pcb_read_->Read(output_data + read, size_per_read)); | 126 pcb_read_->Read(output_data + read, size_per_read)); |
129 } | 127 } |
130 EXPECT_EQ(sizeof(output_data) - read, | 128 EXPECT_EQ(sizeof(output_data) - read, |
131 pcb_read_->Read(output_data + read, size_per_read)); | 129 pcb_read_->Read(output_data + read, size_per_read)); |
132 | 130 |
133 EXPECT_EQ(0, memcmp(kOutputRefDataWrap, output_data, sizeof(output_data))); | 131 EXPECT_EQ(0, memcmp(kOutputRefDataWrap, output_data, sizeof(output_data))); |
134 | 132 |
135 EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data))); | 133 EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data))); |
136 } | 134 } |
137 | |
138 } // namespace content | |
OLD | NEW |