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

Side by Side Diff: chrome/browser/prefetch/prefetch_browsertest.cc

Issue 1777833003: Unbundle link rel=prefetch from privacy settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed expectations in PrefetchBrowserTestPrediction.PreferenceWorks Created 4 years, 9 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
« no previous file with comments | « chrome/browser/prefetch/prefetch.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/net/prediction_options.h" 8 #include "chrome/browser/net/prediction_options.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // Prefetch is disabled via field experiment. Prefetch should be dropped. 91 // Prefetch is disabled via field experiment. Prefetch should be dropped.
92 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionDisabled, 92 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionDisabled,
93 ExperimentDisabled) { 93 ExperimentDisabled) {
94 EXPECT_TRUE(RunPrefetchExperiment(false, browser())); 94 EXPECT_TRUE(RunPrefetchExperiment(false, browser()));
95 // Should not prefetch even if preference is WIFI_ONLY. 95 // Should not prefetch even if preference is WIFI_ONLY.
96 SetPreference(NetworkPredictionOptions::NETWORK_PREDICTION_WIFI_ONLY); 96 SetPreference(NetworkPredictionOptions::NETWORK_PREDICTION_WIFI_ONLY);
97 EXPECT_TRUE(RunPrefetchExperiment(false, browser())); 97 EXPECT_TRUE(RunPrefetchExperiment(false, browser()));
98 } 98 }
99 99
100 // Prefetch should be allowed depending on preference and network type. 100 // When initiated from the renderer, prefetch should be allowed regardless of
101 // the network type.
101 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPrediction, PreferenceWorks) { 102 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPrediction, PreferenceWorks) {
102 // Set real NetworkChangeNotifier singleton aside. 103 // Set real NetworkChangeNotifier singleton aside.
103 scoped_ptr<NetworkChangeNotifier::DisableForTest> disable_for_test( 104 scoped_ptr<NetworkChangeNotifier::DisableForTest> disable_for_test(
104 new NetworkChangeNotifier::DisableForTest); 105 new NetworkChangeNotifier::DisableForTest);
105 106
106 // Preference defaults to WIFI_ONLY: prefetch when not on cellular. 107 // Preference defaults to ALWAYS.
107 { 108 {
108 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifierWIFI); 109 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifierWIFI);
109 EXPECT_TRUE(RunPrefetchExperiment(true, browser())); 110 EXPECT_TRUE(RunPrefetchExperiment(true, browser()));
110 } 111 }
111 { 112 {
112 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifier4G); 113 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifier4G);
113 EXPECT_TRUE(RunPrefetchExperiment(false, browser())); 114 EXPECT_TRUE(RunPrefetchExperiment(true, browser()));
114 } 115 }
115 116
116 // Set preference to NEVER: never prefetch. 117 // Set preference to NEVER: prefetch should be unaffected.
117 SetPreference(NetworkPredictionOptions::NETWORK_PREDICTION_NEVER); 118 SetPreference(NetworkPredictionOptions::NETWORK_PREDICTION_NEVER);
118 { 119 {
119 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifierWIFI); 120 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifierWIFI);
120 EXPECT_TRUE(RunPrefetchExperiment(false, browser())); 121 EXPECT_TRUE(RunPrefetchExperiment(true, browser()));
121 } 122 }
122 { 123 {
123 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifier4G); 124 scoped_ptr<NetworkChangeNotifier> mock(new MockNetworkChangeNotifier4G);
124 EXPECT_TRUE(RunPrefetchExperiment(false, browser())); 125 EXPECT_TRUE(RunPrefetchExperiment(true, browser()));
125 } 126 }
126 } 127 }
127 128
128 // Bug 339909: When in incognito mode the browser crashed due to an 129 // Bug 339909: When in incognito mode the browser crashed due to an
129 // uninitialized preference member. Verify that it no longer does. 130 // uninitialized preference member. Verify that it no longer does.
130 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPrediction, IncognitoTest) { 131 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPrediction, IncognitoTest) {
131 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); 132 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
132 Browser* incognito_browser = 133 Browser* incognito_browser =
133 new Browser(Browser::CreateParams(incognito_profile)); 134 new Browser(Browser::CreateParams(incognito_profile));
134 135
135 // Navigate just to have a tab in this window, otherwise there is no 136 // Navigate just to have a tab in this window, otherwise there is no
136 // WebContents for the incognito browser. 137 // WebContents for the incognito browser.
137 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); 138 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank"));
138 139
139 EXPECT_TRUE(RunPrefetchExperiment(true, incognito_browser)); 140 EXPECT_TRUE(RunPrefetchExperiment(true, incognito_browser));
140 } 141 }
141 142
142 } // namespace 143 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/prefetch/prefetch.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698