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

Side by Side Diff: chrome/browser/net/predictor_browsertest.cc

Issue 2910843002: [Cleanup] Move all browsertests to use ScopedFeatureList to modify features
Patch Set: Ilya comments addressed Created 3 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/json/json_string_value_serializer.h" 16 #include "base/json/json_string_value_serializer.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "base/single_thread_task_runner.h" 22 #include "base/single_thread_task_runner.h"
23 #include "base/stl_util.h" 23 #include "base/stl_util.h"
24 #include "base/synchronization/lock.h" 24 #include "base/synchronization/lock.h"
25 #include "base/test/scoped_feature_list.h"
25 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
26 #include "build/build_config.h" 27 #include "build/build_config.h"
27 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/browsing_data/browsing_data_helper.h" 29 #include "chrome/browser/browsing_data/browsing_data_helper.h"
29 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 30 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
30 #include "chrome/browser/net/predictor.h" 31 #include "chrome/browser/net/predictor.h"
32 #include "chrome/browser/net/predictor_tab_helper.h"
Ilya Sherman 2017/06/28 19:56:05 nit: Is this #include needed as part of this CL?
chaopeng 2017/06/30 19:32:36 Done.
31 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 35 #include "chrome/browser/ui/tabs/tab_strip_model.h"
36 #include "chrome/common/chrome_features.h"
34 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
35 #include "chrome/test/base/in_process_browser_test.h" 38 #include "chrome/test/base/in_process_browser_test.h"
36 #include "chrome/test/base/ui_test_utils.h" 39 #include "chrome/test/base/ui_test_utils.h"
37 #include "components/prefs/pref_service.h" 40 #include "components/prefs/pref_service.h"
38 #include "content/public/browser/browsing_data_remover.h" 41 #include "content/public/browser/browsing_data_remover.h"
39 #include "content/public/common/content_switches.h" 42 #include "content/public/common/content_switches.h"
40 #include "content/public/test/browser_test_utils.h" 43 #include "content/public/test/browser_test_utils.h"
41 #include "content/public/test/test_utils.h" 44 #include "content/public/test/test_utils.h"
42 #include "net/base/host_port_pair.h" 45 #include "net/base/host_port_pair.h"
43 #include "net/base/ip_endpoint.h" 46 #include "net/base/ip_endpoint.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 "127.0.0.1", 1000 * 60); 513 "127.0.0.1", 1000 * 60);
511 } 514 }
512 515
513 protected: 516 protected:
514 void SetUpInProcessBrowserTestFixture() override { 517 void SetUpInProcessBrowserTestFixture() override {
515 scoped_host_resolver_proc_.reset(new net::ScopedDefaultHostResolverProc( 518 scoped_host_resolver_proc_.reset(new net::ScopedDefaultHostResolverProc(
516 rule_based_resolver_proc_.get())); 519 rule_based_resolver_proc_.get()));
517 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); 520 InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
518 } 521 }
519 522
523 void SetUp() override {
524 scoped_feature_list_.InitAndEnableFeature(features::kPreconnectMore);
525 InProcessBrowserTest::SetUp();
526 }
527
520 void SetUpCommandLine(base::CommandLine* command_line) override { 528 void SetUpCommandLine(base::CommandLine* command_line) override {
521 command_line->AppendSwitch( 529 command_line->AppendSwitch(
522 switches::kEnableExperimentalWebPlatformFeatures); 530 switches::kEnableExperimentalWebPlatformFeatures);
523 command_line->AppendSwitchASCII(switches::kEnableFeatures,
524 "PreconnectMore");
525 } 531 }
526 532
527 void SetUpOnMainThread() override { 533 void SetUpOnMainThread() override {
528 DCHECK_CURRENTLY_ON(BrowserThread::UI); 534 DCHECK_CURRENTLY_ON(BrowserThread::UI);
529 task_runner_ = base::ThreadTaskRunnerHandle::Get(); 535 task_runner_ = base::ThreadTaskRunnerHandle::Get();
530 cross_site_test_server()->ServeFilesFromSourceDirectory( 536 cross_site_test_server()->ServeFilesFromSourceDirectory(
531 "chrome/test/data/"); 537 "chrome/test/data/");
532 538
533 connection_listener_.reset(new ConnectionListener()); 539 connection_listener_.reset(new ConnectionListener());
534 cross_site_connection_listener_.reset(new ConnectionListener()); 540 cross_site_connection_listener_.reset(new ConnectionListener());
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 std::unique_ptr<ConnectionListener> connection_listener_; 797 std::unique_ptr<ConnectionListener> connection_listener_;
792 std::unique_ptr<ConnectionListener> cross_site_connection_listener_; 798 std::unique_ptr<ConnectionListener> cross_site_connection_listener_;
793 799
794 private: 800 private:
795 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_proc_; 801 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_proc_;
796 std::unique_ptr<net::ScopedDefaultHostResolverProc> 802 std::unique_ptr<net::ScopedDefaultHostResolverProc>
797 scoped_host_resolver_proc_; 803 scoped_host_resolver_proc_;
798 std::unique_ptr<net::EmbeddedTestServer> cross_site_test_server_; 804 std::unique_ptr<net::EmbeddedTestServer> cross_site_test_server_;
799 std::unique_ptr<CrossSitePredictorObserver> observer_; 805 std::unique_ptr<CrossSitePredictorObserver> observer_;
800 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 806 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
807 base::test::ScopedFeatureList scoped_feature_list_;
801 }; 808 };
802 809
803 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, SingleLookupTest) { 810 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, SingleLookupTest) {
804 DiscardAllResultsOnUIThread(); 811 DiscardAllResultsOnUIThread();
805 GURL url("http://www.example.test/"); 812 GURL url("http://www.example.test/");
806 813
807 // Try to flood the predictor with many concurrent requests. 814 // Try to flood the predictor with many concurrent requests.
808 std::vector<GURL> names{url}; 815 std::vector<GURL> names{url};
809 FloodResolveRequestsOnUIThread(names); 816 FloodResolveRequestsOnUIThread(names);
810 observer()->WaitUntilHostLookedUp(url); 817 observer()->WaitUntilHostLookedUp(url);
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 // Second navigation to content with an img. 1593 // Second navigation to content with an img.
1587 std::string img_content = 1594 std::string img_content =
1588 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; 1595 "<img src=\"" + preconnect_url.spec() + "test.gif\">";
1589 NavigateToDataURLWithContent(img_content); 1596 NavigateToDataURLWithContent(img_content);
1590 connection_listener_->WaitUntilFirstConnectionRead(); 1597 connection_listener_->WaitUntilFirstConnectionRead();
1591 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); 1598 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount());
1592 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); 1599 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount());
1593 } 1600 }
1594 1601
1595 } // namespace chrome_browser_net 1602 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698