Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: content/browser/blob_storage/blob_async_transport_request_builder_unittest.cc

Issue 2339933004: [BlobStorage] BlobMemoryController & tests (Closed)
Patch Set: Fixed windows bug! Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/blob_storage/blob_data_builder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "storage/browser/blob/blob_async_transport_request_builder.h" 11 #include "storage/browser/blob/blob_async_transport_request_builder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace storage { 14 namespace storage {
15 namespace { 15 namespace {
16 16
17 const char kNewUUID[] = "newUUID"; 17 const char kNewUUID[] = "newUUID";
18 const base::FilePath kFuturePopulatingFilePath = base::FilePath::FromUTF8Unsafe(
19 std::string(BlobDataBuilder::kAppendFutureFileTemporaryFileName));
20 const char kFakeBlobUUID[] = "fakeBlob"; 18 const char kFakeBlobUUID[] = "fakeBlob";
21 19
22 void AddMemoryItem(size_t length, std::vector<DataElement>* out) { 20 void AddMemoryItem(size_t length, std::vector<DataElement>* out) {
23 DataElement bytes; 21 DataElement bytes;
24 bytes.SetToBytesDescription(length); 22 bytes.SetToBytesDescription(length);
25 out->push_back(bytes); 23 out->push_back(bytes);
26 } 24 }
27 25
28 void AddShortcutMemoryItem(size_t length, std::vector<DataElement>* out) { 26 void AddShortcutMemoryItem(size_t length, std::vector<DataElement>* out) {
29 DataElement bytes; 27 DataElement bytes;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_EQ(1u, strategy.requests().size()); 78 EXPECT_EQ(1u, strategy.requests().size());
81 79
82 auto& memory_item_request = strategy.requests().at(0); 80 auto& memory_item_request = strategy.requests().at(0);
83 EXPECT_EQ(0u, memory_item_request.browser_item_index); 81 EXPECT_EQ(0u, memory_item_request.browser_item_index);
84 EXPECT_EQ(0u, memory_item_request.browser_item_offset); 82 EXPECT_EQ(0u, memory_item_request.browser_item_offset);
85 EXPECT_EQ( 83 EXPECT_EQ(
86 BlobItemBytesRequest::CreateFileRequest(0u, 0u, 0ull, 305ull, 0u, 0ull), 84 BlobItemBytesRequest::CreateFileRequest(0u, 0u, 0ull, 305ull, 0u, 0ull),
87 memory_item_request.message); 85 memory_item_request.message);
88 86
89 BlobDataBuilder expected_builder(kNewUUID); 87 BlobDataBuilder expected_builder(kNewUUID);
90 expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 305, 88 expected_builder.AppendFutureFile(0, 305, 0);
91 base::Time::FromDoubleT(0));
92 EXPECT_EQ(expected_builder, builder); 89 EXPECT_EQ(expected_builder, builder);
93 } 90 }
94 91
95 TEST(BlobAsyncTransportRequestBuilderTest, TestLargeBlockToFiles) { 92 TEST(BlobAsyncTransportRequestBuilderTest, TestLargeBlockToFiles) {
96 BlobAsyncTransportRequestBuilder strategy; 93 BlobAsyncTransportRequestBuilder strategy;
97 BlobDataBuilder builder(kNewUUID); 94 BlobDataBuilder builder(kNewUUID);
98 std::vector<DataElement> infos; 95 std::vector<DataElement> infos;
99 96
100 AddMemoryItem(1000, &infos); 97 AddMemoryItem(1000, &infos);
101 strategy.InitializeForFileRequests(400, // max_file_size 98 strategy.InitializeForFileRequests(400, // max_file_size
(...skipping 22 matching lines...) Expand all
124 memory_item_request.message); 121 memory_item_request.message);
125 122
126 memory_item_request = strategy.requests().at(2); 123 memory_item_request = strategy.requests().at(2);
127 EXPECT_EQ(2u, memory_item_request.browser_item_index); 124 EXPECT_EQ(2u, memory_item_request.browser_item_index);
128 EXPECT_EQ(0u, memory_item_request.browser_item_offset); 125 EXPECT_EQ(0u, memory_item_request.browser_item_offset);
129 EXPECT_EQ( 126 EXPECT_EQ(
130 BlobItemBytesRequest::CreateFileRequest(2u, 0u, 800ull, 200ull, 2u, 0ull), 127 BlobItemBytesRequest::CreateFileRequest(2u, 0u, 800ull, 200ull, 2u, 0ull),
131 memory_item_request.message); 128 memory_item_request.message);
132 129
133 BlobDataBuilder expected_builder(kNewUUID); 130 BlobDataBuilder expected_builder(kNewUUID);
134 expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 400, 131 expected_builder.AppendFutureFile(0, 400, 0);
135 base::Time::FromDoubleT(0)); 132 expected_builder.AppendFutureFile(0, 400, 1);
136 expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 400, 133 expected_builder.AppendFutureFile(0, 200, 2);
137 base::Time::FromDoubleT(0));
138 expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 200,
139 base::Time::FromDoubleT(0));
140 EXPECT_EQ(expected_builder, builder); 134 EXPECT_EQ(expected_builder, builder);
141 } 135 }
142 136
143 TEST(BlobAsyncTransportRequestBuilderTest, 137 TEST(BlobAsyncTransportRequestBuilderTest,
144 TestLargeBlocksConsolidatingInFiles) { 138 TestLargeBlocksConsolidatingInFiles) {
145 BlobAsyncTransportRequestBuilder strategy; 139 BlobAsyncTransportRequestBuilder strategy;
146 BlobDataBuilder builder(kNewUUID); 140 BlobDataBuilder builder(kNewUUID);
147 std::vector<DataElement> infos; 141 std::vector<DataElement> infos;
148 142
149 // We should have 3 storage items for the memory, two files, 400 each. 143 // We should have 3 storage items for the memory, two files, 400 each.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // We still populate future data, as the strategy assumes we will be 341 // We still populate future data, as the strategy assumes we will be
348 // requesting the data. 342 // requesting the data.
349 BlobDataBuilder expected_builder(kNewUUID); 343 BlobDataBuilder expected_builder(kNewUUID);
350 expected_builder.AppendFutureData(10); 344 expected_builder.AppendFutureData(10);
351 expected_builder.AppendBlob(kFakeBlobUUID); 345 expected_builder.AppendBlob(kFakeBlobUUID);
352 expected_builder.AppendFutureData(80); 346 expected_builder.AppendFutureData(80);
353 EXPECT_EQ(expected_builder, builder); 347 EXPECT_EQ(expected_builder, builder);
354 } 348 }
355 } // namespace 349 } // namespace
356 } // namespace storage 350 } // namespace storage
OLDNEW
« no previous file with comments | « no previous file | content/browser/blob_storage/blob_data_builder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698