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

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

Issue 2484613002: Migrate more tests to ScopedFeatureList. (Closed)
Patch Set: rebase 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
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>
11 #include <tuple> 11 #include <tuple>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/feature_list.h"
18 #include "base/format_macros.h" 17 #include "base/format_macros.h"
19 #include "base/logging.h" 18 #include "base/logging.h"
20 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
21 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
22 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
23 #include "base/process/process.h" 22 #include "base/process/process.h"
24 #include "base/run_loop.h" 23 #include "base/run_loop.h"
25 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/test/scoped_feature_list.h"
26 #include "content/browser/loader/resource_dispatcher_host_impl.h" 26 #include "content/browser/loader/resource_dispatcher_host_impl.h"
27 #include "content/browser/loader/resource_loader.h" 27 #include "content/browser/loader/resource_loader.h"
28 #include "content/browser/loader/resource_loader_delegate.h" 28 #include "content/browser/loader/resource_loader_delegate.h"
29 #include "content/browser/loader/resource_message_filter.h" 29 #include "content/browser/loader/resource_message_filter.h"
30 #include "content/browser/loader/resource_request_info_impl.h" 30 #include "content/browser/loader/resource_request_info_impl.h"
31 #include "content/common/resource_messages.h" 31 #include "content/common/resource_messages.h"
32 #include "content/common/resource_request.h" 32 #include "content/common/resource_request.h"
33 #include "content/public/browser/resource_context.h" 33 #include "content/public/browser/resource_context.h"
34 #include "content/public/browser/resource_request_info.h" 34 #include "content/public/browser/resource_request_info.h"
35 #include "content/public/common/content_features.h" 35 #include "content/public/common/content_features.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 int encoded_data_length = std::get<3>(params); 256 int encoded_data_length = std::get<3>(params);
257 EXPECT_EQ(4096, encoded_data_length); 257 EXPECT_EQ(4096, encoded_data_length);
258 int encoded_body_length = std::get<4>(params); 258 int encoded_body_length = std::get<4>(params);
259 EXPECT_EQ(4096, encoded_body_length); 259 EXPECT_EQ(4096, encoded_body_length);
260 } 260 }
261 261
262 TEST_F(AsyncResourceHandlerTest, InlinedChunkLengths) { 262 TEST_F(AsyncResourceHandlerTest, InlinedChunkLengths) {
263 // TODO(ricea): Remove this Feature-enabling code once the feature is on by 263 // TODO(ricea): Remove this Feature-enabling code once the feature is on by
264 // default. 264 // default.
265 auto feature_list = base::MakeUnique<base::FeatureList>(); 265 base::test::ScopedFeatureList scoped_feature_list;
266 feature_list->InitializeFromCommandLine( 266 scoped_feature_list.InitAndEnableFeature(
267 features::kOptimizeLoadingIPCForSmallResources.name, ""); 267 features::kOptimizeLoadingIPCForSmallResources);
268 base::FeatureList::ClearInstanceForTesting();
269 base::FeatureList::SetInstance(std::move(feature_list));
270 268
271 // Smaller than kInlinedLeadingChunkSize. 269 // Smaller than kInlinedLeadingChunkSize.
272 StartRequestAndWaitWithResponseDataSize(8); 270 StartRequestAndWaitWithResponseDataSize(8);
273 const auto& messages = filter_->messages(); 271 const auto& messages = filter_->messages();
274 ASSERT_EQ(3u, messages.size()); 272 ASSERT_EQ(3u, messages.size());
275 ASSERT_EQ(ResourceMsg_InlinedDataChunkReceived::ID, messages[1]->type()); 273 ASSERT_EQ(ResourceMsg_InlinedDataChunkReceived::ID, messages[1]->type());
276 ResourceMsg_InlinedDataChunkReceived::Param params; 274 ResourceMsg_InlinedDataChunkReceived::Param params;
277 ResourceMsg_InlinedDataChunkReceived::Read(messages[1].get(), &params); 275 ResourceMsg_InlinedDataChunkReceived::Read(messages[1].get(), &params);
278 276
279 int encoded_data_length = std::get<2>(params); 277 int encoded_data_length = std::get<2>(params);
(...skipping 21 matching lines...) Expand all
301 299
302 encoded_data_length = std::get<3>(params); 300 encoded_data_length = std::get<3>(params);
303 EXPECT_EQ(32768, encoded_data_length); 301 EXPECT_EQ(32768, encoded_data_length);
304 encoded_body_length = std::get<4>(params); 302 encoded_body_length = std::get<4>(params);
305 EXPECT_EQ(32768, encoded_body_length); 303 EXPECT_EQ(32768, encoded_body_length);
306 } 304 }
307 305
308 } // namespace 306 } // namespace
309 307
310 } // namespace content 308 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698