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> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "content/browser/speech/chunked_byte_buffer.h" | 8 #include "content/browser/speech/chunked_byte_buffer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace speech { | 11 namespace content { |
12 | 12 |
13 typedef std::vector<uint8> ByteVector; | 13 typedef std::vector<uint8> ByteVector; |
14 | 14 |
15 TEST(ChunkedByteBufferTest, BasicTest) { | 15 TEST(ChunkedByteBufferTest, BasicTest) { |
16 ChunkedByteBuffer buffer; | 16 ChunkedByteBuffer buffer; |
17 | 17 |
18 const uint8 kChunks[] = { | 18 const uint8 kChunks[] = { |
19 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04, // Chunk 1: 4 bytes | 19 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04, // Chunk 1: 4 bytes |
20 0x00, 0x00, 0x00, 0x02, 0x05, 0x06, // Chunk 2: 2 bytes | 20 0x00, 0x00, 0x00, 0x02, 0x05, 0x06, // Chunk 2: 2 bytes |
21 0x00, 0x00, 0x00, 0x01, 0x07 // Chunk 3: 1 bytes | 21 0x00, 0x00, 0x00, 0x01, 0x07 // Chunk 3: 1 bytes |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // Remove and check chunk 3. | 67 // Remove and check chunk 3. |
68 chunk = buffer.PopChunk(); | 68 chunk = buffer.PopChunk(); |
69 EXPECT_TRUE(chunk != NULL); | 69 EXPECT_TRUE(chunk != NULL); |
70 EXPECT_EQ(1U, chunk->size()); | 70 EXPECT_EQ(1U, chunk->size()); |
71 EXPECT_EQ((*chunk)[0], kChunks[18]); | 71 EXPECT_EQ((*chunk)[0], kChunks[18]); |
72 EXPECT_EQ(0U, buffer.GetTotalLength()); | 72 EXPECT_EQ(0U, buffer.GetTotalLength()); |
73 EXPECT_FALSE(buffer.HasChunks()); | 73 EXPECT_FALSE(buffer.HasChunks()); |
74 } | 74 } |
75 | 75 |
76 } // namespace speech | 76 } // namespace content |
OLD | NEW |