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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_common_unittest.cc

Issue 2804963002: predictors: Put manifests for ResourcePrefetchPredictor behind a flag. (Closed)
Patch Set: Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/net/prediction_options.h" 10 #include "chrome/browser/net/prediction_options.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 profile_.get(), PrefetchOrigin::NAVIGATION)); 65 profile_.get(), PrefetchOrigin::NAVIGATION));
66 EXPECT_GT(config.min_resource_hits_to_trigger_prefetch, 1U); 66 EXPECT_GT(config.min_resource_hits_to_trigger_prefetch, 1U);
67 } 67 }
68 68
69 void TestIsDefaultExtraConfig(const ResourcePrefetchPredictorConfig& config) { 69 void TestIsDefaultExtraConfig(const ResourcePrefetchPredictorConfig& config) {
70 EXPECT_FALSE(config.IsLowConfidenceForTest()); 70 EXPECT_FALSE(config.IsLowConfidenceForTest());
71 EXPECT_FALSE(config.IsHighConfidenceForTest()); 71 EXPECT_FALSE(config.IsHighConfidenceForTest());
72 EXPECT_FALSE(config.IsMoreResourcesEnabledForTest()); 72 EXPECT_FALSE(config.IsMoreResourcesEnabledForTest());
73 EXPECT_FALSE(config.IsSmallDBEnabledForTest()); 73 EXPECT_FALSE(config.IsSmallDBEnabledForTest());
74 EXPECT_FALSE(config.is_url_learning_enabled); 74 EXPECT_FALSE(config.is_url_learning_enabled);
75 EXPECT_FALSE(config.is_manifests_enabled);
75 EXPECT_GT(config.min_resource_hits_to_trigger_prefetch, 1U); 76 EXPECT_GT(config.min_resource_hits_to_trigger_prefetch, 1U);
76 } 77 }
77 78
78 protected: 79 protected:
79 base::MessageLoop loop_; 80 base::MessageLoop loop_;
80 content::TestBrowserThread ui_thread_; 81 content::TestBrowserThread ui_thread_;
81 std::unique_ptr<TestingProfile> profile_; 82 std::unique_ptr<TestingProfile> profile_;
82 }; 83 };
83 84
84 ResourcePrefetchCommonTest::ResourcePrefetchCommonTest() 85 ResourcePrefetchCommonTest::ResourcePrefetchCommonTest()
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 "dummy-trial", 142 "dummy-trial",
142 {{kModeParamName, kLearningMode}, {kEnableUrlLearningParamName, "true"}}, 143 {{kModeParamName, kLearningMode}, {kEnableUrlLearningParamName, "true"}},
143 {kSpeculativeResourcePrefetchingFeatureName}); 144 {kSpeculativeResourcePrefetchingFeatureName});
144 145
145 ResourcePrefetchPredictorConfig config; 146 ResourcePrefetchPredictorConfig config;
146 EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config)); 147 EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config));
147 TestIsPrefetchLearning(config); 148 TestIsPrefetchLearning(config);
148 EXPECT_TRUE(config.is_url_learning_enabled); 149 EXPECT_TRUE(config.is_url_learning_enabled);
149 } 150 }
150 151
152 TEST_F(ResourcePrefetchCommonTest, EnableManifests) {
153 variations::testing::VariationParamsManager params_manager(
154 "dummy-trial",
155 {{kModeParamName, kLearningMode}, {kEnableManifestsParamName, "true"}},
156 {kSpeculativeResourcePrefetchingFeatureName});
157
158 ResourcePrefetchPredictorConfig config;
159 EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config));
160 TestIsPrefetchLearning(config);
161 EXPECT_TRUE(config.is_manifests_enabled);
162 }
163
151 // Verifies whether prefetching is disabled according to the network type. But 164 // Verifies whether prefetching is disabled according to the network type. But
152 // learning should not be disabled by network. 165 // learning should not be disabled by network.
153 TEST_F(ResourcePrefetchCommonTest, RespectsNetworkSettings) { 166 TEST_F(ResourcePrefetchCommonTest, RespectsNetworkSettings) {
154 variations::testing::VariationParamsManager params_manager( 167 variations::testing::VariationParamsManager params_manager(
155 "dummy-trial", {{kModeParamName, kPrefetchingMode}}, 168 "dummy-trial", {{kModeParamName, kPrefetchingMode}},
156 {kSpeculativeResourcePrefetchingFeatureName}); 169 {kSpeculativeResourcePrefetchingFeatureName});
157 170
158 ResourcePrefetchPredictorConfig config; 171 ResourcePrefetchPredictorConfig config;
159 EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config)); 172 EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config));
160 TestIsPrefetchEnabledForOrigin(config, PrefetchOrigin::EXTERNAL); 173 TestIsPrefetchEnabledForOrigin(config, PrefetchOrigin::EXTERNAL);
(...skipping 20 matching lines...) Expand all
181 TestIsPrefetchLearning(config); 194 TestIsPrefetchLearning(config);
182 } 195 }
183 { 196 {
184 std::unique_ptr<NetworkChangeNotifier> mock( 197 std::unique_ptr<NetworkChangeNotifier> mock(
185 new MockNetworkChangeNotifier4G); 198 new MockNetworkChangeNotifier4G);
186 TestIsPrefetchLearning(config); 199 TestIsPrefetchLearning(config);
187 } 200 }
188 } 201 }
189 202
190 } // namespace predictors 203 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_common.cc ('k') | chrome/browser/predictors/resource_prefetch_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698