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

Unified Diff: chrome/browser/predictors/resource_prefetch_common_unittest.cc

Issue 2729563002: predictors: Disable URL-based learning by default. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_common_unittest.cc
diff --git a/chrome/browser/predictors/resource_prefetch_common_unittest.cc b/chrome/browser/predictors/resource_prefetch_common_unittest.cc
index 836e42289a03da307eaa0674ff35fb5e60854c44..5dff8e358f690d7f36873f4ddb4e81887da64a3b 100644
--- a/chrome/browser/predictors/resource_prefetch_common_unittest.cc
+++ b/chrome/browser/predictors/resource_prefetch_common_unittest.cc
@@ -5,7 +5,6 @@
#include <memory>
#include <string>
-#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/net/prediction_options.h"
@@ -92,7 +91,8 @@ TEST_F(ResourcePrefetchCommonTest, IsDisabledByDefault) {
EXPECT_FALSE(config.IsLearningEnabled());
EXPECT_FALSE(config.IsPrefetchingEnabledForOrigin(profile_.get(),
PrefetchOrigin::EXTERNAL));
- EXPECT_FALSE(config.IsLearningEnabled());
alexilin 2017/03/01 12:57:57 Second check of the same thing. Looks like a bug.
+ EXPECT_FALSE(config.IsPrefetchingEnabledForOrigin(
+ profile_.get(), PrefetchOrigin::NAVIGATION));
TestIsDefaultExtraConfig(config);
}
@@ -133,6 +133,48 @@ TEST_F(ResourcePrefetchCommonTest, EnablePrefetchExternalOnly) {
TestIsDefaultExtraConfig(config);
}
+TEST_F(ResourcePrefetchCommonTest, EnableUrlLearning) {
+ variations::testing::VariationParamsManager params_manager(
+ "dummy-trial",
+ {{kModeParamName, kLearningMode}, {kKeyTypeParamName, kUrlKeyType}},
+ {kSpeculativeResourcePrefetchingFeatureName});
+
+ ResourcePrefetchPredictorConfig config;
+ EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config));
+ TestIsPrefetchLearning(config);
+ EXPECT_TRUE(config.IsURLLearningEnabled());
+ EXPECT_FALSE(config.IsHostLearningEnabled());
+ TestIsDefaultExtraConfig(config);
+}
+
+TEST_F(ResourcePrefetchCommonTest, EnableHostLearning) {
+ variations::testing::VariationParamsManager params_manager(
+ "dummy-trial",
+ {{kModeParamName, kLearningMode}, {kKeyTypeParamName, kHostKeyType}},
+ {kSpeculativeResourcePrefetchingFeatureName});
+
+ ResourcePrefetchPredictorConfig config;
+ EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config));
+ TestIsPrefetchLearning(config);
+ EXPECT_FALSE(config.IsURLLearningEnabled());
+ EXPECT_TRUE(config.IsHostLearningEnabled());
+ TestIsDefaultExtraConfig(config);
+}
+
+TEST_F(ResourcePrefetchCommonTest, EnableBothLearning) {
+ variations::testing::VariationParamsManager params_manager(
+ "dummy-trial",
+ {{kModeParamName, kLearningMode}, {kKeyTypeParamName, kBothKeyType}},
+ {kSpeculativeResourcePrefetchingFeatureName});
+
+ ResourcePrefetchPredictorConfig config;
+ EXPECT_TRUE(IsSpeculativeResourcePrefetchingEnabled(profile_.get(), &config));
+ TestIsPrefetchLearning(config);
+ EXPECT_TRUE(config.IsURLLearningEnabled());
+ EXPECT_TRUE(config.IsHostLearningEnabled());
+ TestIsDefaultExtraConfig(config);
+}
+
// Verifies whether prefetching is disabled according to the network type. But
// learning should not be disabled by network.
TEST_F(ResourcePrefetchCommonTest, RespectsNetworkSettings) {

Powered by Google App Engine
This is Rietveld 408576698