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

Side by Side Diff: content/browser/loader/async_resource_handler_unittest.cc

Issue 2167853003: [DevTools] Always report encodedDataLength in Network.ResponseReceived. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/loader/async_resource_handler.h" 5 #include "content/browser/loader/async_resource_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // Larger than kInlinedLeadingChunkSize and smaller than 248 // Larger than kInlinedLeadingChunkSize and smaller than
249 // kMaxAllocationSize. 249 // kMaxAllocationSize.
250 StartRequestAndWaitWithResponseDataSize(4096); 250 StartRequestAndWaitWithResponseDataSize(4096);
251 const auto& messages = filter_->messages(); 251 const auto& messages = filter_->messages();
252 ASSERT_EQ(4u, messages.size()); 252 ASSERT_EQ(4u, messages.size());
253 ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[2]->type()); 253 ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[2]->type());
254 ResourceMsg_DataReceived::Param params; 254 ResourceMsg_DataReceived::Param params;
255 ResourceMsg_DataReceived::Read(messages[2].get(), &params); 255 ResourceMsg_DataReceived::Read(messages[2].get(), &params);
256 256
257 int encoded_data_length = std::get<3>(params); 257 int encoded_data_length = std::get<3>(params);
258 EXPECT_EQ(4157, encoded_data_length); 258 EXPECT_EQ(4096, encoded_data_length);
259 int encoded_body_length = std::get<4>(params); 259 int encoded_body_length = std::get<4>(params);
260 EXPECT_EQ(4096, encoded_body_length); 260 EXPECT_EQ(4096, encoded_body_length);
261 } 261 }
262 262
263 TEST_F(AsyncResourceHandlerTest, InlinedChunkLengths) { 263 TEST_F(AsyncResourceHandlerTest, InlinedChunkLengths) {
264 // TODO(ricea): Remove this Feature-enabling code once the feature is on by 264 // TODO(ricea): Remove this Feature-enabling code once the feature is on by
265 // default. 265 // default.
266 auto feature_list = base::MakeUnique<base::FeatureList>(); 266 auto feature_list = base::MakeUnique<base::FeatureList>();
267 feature_list->InitializeFromCommandLine( 267 feature_list->InitializeFromCommandLine(
268 features::kOptimizeLoadingIPCForSmallResources.name, ""); 268 features::kOptimizeLoadingIPCForSmallResources.name, "");
269 base::FeatureList::ClearInstanceForTesting(); 269 base::FeatureList::ClearInstanceForTesting();
270 base::FeatureList::SetInstance(std::move(feature_list)); 270 base::FeatureList::SetInstance(std::move(feature_list));
271 271
272 // Smaller than kInlinedLeadingChunkSize. 272 // Smaller than kInlinedLeadingChunkSize.
273 StartRequestAndWaitWithResponseDataSize(8); 273 StartRequestAndWaitWithResponseDataSize(8);
274 const auto& messages = filter_->messages(); 274 const auto& messages = filter_->messages();
275 ASSERT_EQ(3u, messages.size()); 275 ASSERT_EQ(3u, messages.size());
276 ASSERT_EQ(ResourceMsg_InlinedDataChunkReceived::ID, messages[1]->type()); 276 ASSERT_EQ(ResourceMsg_InlinedDataChunkReceived::ID, messages[1]->type());
277 ResourceMsg_InlinedDataChunkReceived::Param params; 277 ResourceMsg_InlinedDataChunkReceived::Param params;
278 ResourceMsg_InlinedDataChunkReceived::Read(messages[1].get(), &params); 278 ResourceMsg_InlinedDataChunkReceived::Read(messages[1].get(), &params);
279 279
280 int encoded_data_length = std::get<2>(params); 280 int encoded_data_length = std::get<2>(params);
281 EXPECT_EQ(66, encoded_data_length); 281 EXPECT_EQ(8, encoded_data_length);
282 int encoded_body_length = std::get<3>(params); 282 int encoded_body_length = std::get<3>(params);
283 EXPECT_EQ(8, encoded_body_length); 283 EXPECT_EQ(8, encoded_body_length);
284 } 284 }
285 285
286 TEST_F(AsyncResourceHandlerTest, TwoChunksLengths) { 286 TEST_F(AsyncResourceHandlerTest, TwoChunksLengths) {
287 // Larger than kMaxAllocationSize. 287 // Larger than kMaxAllocationSize.
288 StartRequestAndWaitWithResponseDataSize(64*1024); 288 StartRequestAndWaitWithResponseDataSize(64*1024);
289 const auto& messages = filter_->messages(); 289 const auto& messages = filter_->messages();
290 ASSERT_EQ(5u, messages.size()); 290 ASSERT_EQ(5u, messages.size());
291 ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[2]->type()); 291 ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[2]->type());
292 ResourceMsg_DataReceived::Param params; 292 ResourceMsg_DataReceived::Param params;
293 ResourceMsg_DataReceived::Read(messages[2].get(), &params); 293 ResourceMsg_DataReceived::Read(messages[2].get(), &params);
294 294
295 int encoded_data_length = std::get<3>(params); 295 int encoded_data_length = std::get<3>(params);
296 EXPECT_EQ(32830, encoded_data_length); 296 EXPECT_EQ(32768, encoded_data_length);
297 int encoded_body_length = std::get<4>(params); 297 int encoded_body_length = std::get<4>(params);
298 EXPECT_EQ(32768, encoded_body_length); 298 EXPECT_EQ(32768, encoded_body_length);
299 299
300 ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[3]->type()); 300 ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[3]->type());
301 ResourceMsg_DataReceived::Read(messages[3].get(), &params); 301 ResourceMsg_DataReceived::Read(messages[3].get(), &params);
302 302
303 encoded_data_length = std::get<3>(params); 303 encoded_data_length = std::get<3>(params);
304 EXPECT_EQ(32768, encoded_data_length); 304 EXPECT_EQ(32768, encoded_data_length);
305 encoded_body_length = std::get<4>(params); 305 encoded_body_length = std::get<4>(params);
306 EXPECT_EQ(32768, encoded_body_length); 306 EXPECT_EQ(32768, encoded_body_length);
307 } 307 }
308 308
309 } // namespace 309 } // namespace
310 310
311 } // namespace content 311 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698