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

Side by Side Diff: content/public/test/browser_test_base.cc

Issue 2847003003: Fix SitePerProcessBrowserTest.ProcessTransferAfterError to not requiring modifying the mock HostRes… (Closed)
Patch Set: remove unnecessary include Created 3 years, 7 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/public/test/browser_test_base.h" 5 #include "content/public/test/browser_test_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 use_software_compositing_ = true; 366 use_software_compositing_ = true;
367 } 367 }
368 368
369 bool BrowserTestBase::UsingSoftwareGL() const { 369 bool BrowserTestBase::UsingSoftwareGL() const {
370 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 370 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
371 return cmd->GetSwitchValueASCII(switches::kUseGL) == 371 return cmd->GetSwitchValueASCII(switches::kUseGL) ==
372 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation()); 372 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation());
373 } 373 }
374 374
375 void BrowserTestBase::InitializeNetworkProcess() { 375 void BrowserTestBase::InitializeNetworkProcess() {
376 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 376 const testing::TestInfo* const test_info =
377 switches::kEnableNetworkService)) 377 testing::UnitTest::GetInstance()->current_test_info();
378 bool network_service = base::CommandLine::ForCurrentProcess()->HasSwitch(
379 switches::kEnableNetworkService);
380 // ProcessTransferAfterError is the only browser test which needs to modify
381 // the host rules (when not using the network service).
382 if (network_service ||
383 std::string(test_info->name()) != "ProcessTransferAfterError") {
384 // TODO(jam): enable this once all access to host_resolver() is in
385 // SetUpOnMainThread or before. http://crbug.com/713847
386 // host_resolver()->DisableModifications();
387 }
388
389 if (!network_service)
378 return; 390 return;
379 391
380 net::RuleBasedHostResolverProc::RuleList rules = host_resolver()->GetRules(); 392 net::RuleBasedHostResolverProc::RuleList rules = host_resolver()->GetRules();
381 std::vector<mojom::RulePtr> mojo_rules; 393 std::vector<mojom::RulePtr> mojo_rules;
382 for (const auto& rule : rules) { 394 for (const auto& rule : rules) {
383 // For now, this covers all the rules used in content's tests. 395 // For now, this covers all the rules used in content's tests.
384 // TODO(jam: expand this when we try to make browser_tests and 396 // TODO(jam: expand this when we try to make browser_tests and
385 // components_browsertests work. 397 // components_browsertests work.
386 if (rule.resolver_type != 398 if (rule.resolver_type !=
387 net::RuleBasedHostResolverProc::Rule::kResolverTypeSystem || 399 net::RuleBasedHostResolverProc::Rule::kResolverTypeSystem ||
388 rule.address_family != net::AddressFamily::ADDRESS_FAMILY_UNSPECIFIED || 400 rule.address_family != net::AddressFamily::ADDRESS_FAMILY_UNSPECIFIED ||
389 !!rule.latency_ms || rule.replacement.empty()) 401 !!rule.latency_ms || rule.replacement.empty())
390 continue; 402 continue;
391 mojom::RulePtr mojo_rule = mojom::Rule::New(); 403 mojom::RulePtr mojo_rule = mojom::Rule::New();
392 mojo_rule->host_pattern = rule.host_pattern; 404 mojo_rule->host_pattern = rule.host_pattern;
393 mojo_rule->replacement = rule.replacement; 405 mojo_rule->replacement = rule.replacement;
394 mojo_rules.push_back(std::move(mojo_rule)); 406 mojo_rules.push_back(std::move(mojo_rule));
395 } 407 }
396 408
397 if (mojo_rules.empty()) 409 if (mojo_rules.empty())
398 return; 410 return;
399 411
400 mojom::NetworkServiceTestPtr network_service_test; 412 mojom::NetworkServiceTestPtr network_service_test;
401 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( 413 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
402 mojom::kNetworkServiceName, &network_service_test); 414 mojom::kNetworkServiceName, &network_service_test);
403 network_service_test->AddRules(std::move(mojo_rules)); 415 network_service_test->AddRules(std::move(mojo_rules));
404
405 // TODO(jam): enable this once all access to host_resolver() is in
406 // SetUpOnMainThread or before. http://crbug.com/713847
407 // host_resolver()->DisableModifications();
408 } 416 }
409 417
410 } // namespace content 418 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698