| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "platform/blob/BlobData.h" | 5 #include "platform/blob/BlobData.h" |
| 6 | 6 |
| 7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "wtf/PtrUtil.h" | 9 #include "wtf/OwnPtr.h" |
| 10 #include <memory> | 10 #include "wtf/PassOwnPtr.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 TEST(BlobDataTest, Consolidation) | 14 TEST(BlobDataTest, Consolidation) |
| 15 { | 15 { |
| 16 const size_t kMaxConsolidatedItemSizeInBytes = 15 * 1024; | 16 const size_t kMaxConsolidatedItemSizeInBytes = 15 * 1024; |
| 17 BlobData data; | 17 BlobData data; |
| 18 const char* text1 = "abc"; | 18 const char* text1 = "abc"; |
| 19 const char* text2 = "def"; | 19 const char* text2 = "def"; |
| 20 data.appendBytes(text1, 3u); | 20 data.appendBytes(text1, 3u); |
| 21 data.appendBytes(text2, 3u); | 21 data.appendBytes(text2, 3u); |
| 22 data.appendText("ps1", false); | 22 data.appendText("ps1", false); |
| 23 data.appendText("ps2", false); | 23 data.appendText("ps2", false); |
| 24 | 24 |
| 25 | 25 |
| 26 EXPECT_EQ(1u, data.m_items.size()); | 26 EXPECT_EQ(1u, data.m_items.size()); |
| 27 EXPECT_EQ(12u, data.m_items[0].data->length()); | 27 EXPECT_EQ(12u, data.m_items[0].data->length()); |
| 28 EXPECT_EQ(0, memcmp(data.m_items[0].data->data(), "abcdefps1ps2", 12)); | 28 EXPECT_EQ(0, memcmp(data.m_items[0].data->data(), "abcdefps1ps2", 12)); |
| 29 | 29 |
| 30 | 30 |
| 31 std::unique_ptr<char[]> large_data = wrapArrayUnique(new char[kMaxConsolidat
edItemSizeInBytes]); | 31 OwnPtr<char[]> large_data = adoptArrayPtr(new char[kMaxConsolidatedItemSizeI
nBytes]); |
| 32 data.appendBytes(large_data.get(), kMaxConsolidatedItemSizeInBytes); | 32 data.appendBytes(large_data.get(), kMaxConsolidatedItemSizeInBytes); |
| 33 | 33 |
| 34 EXPECT_EQ(2u, data.m_items.size()); | 34 EXPECT_EQ(2u, data.m_items.size()); |
| 35 EXPECT_EQ(12u, data.m_items[0].data->length()); | 35 EXPECT_EQ(12u, data.m_items[0].data->length()); |
| 36 EXPECT_EQ(kMaxConsolidatedItemSizeInBytes, data.m_items[1].data->length()); | 36 EXPECT_EQ(kMaxConsolidatedItemSizeInBytes, data.m_items[1].data->length()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |