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

Unified Diff: net/disk_cache/simple/simple_experiment_unittest.cc

Issue 2918893002: evict larger entries first (Closed)
Patch Set: -SortHelper 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_experiment.cc ('k') | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_experiment_unittest.cc
diff --git a/net/disk_cache/simple/simple_experiment_unittest.cc b/net/disk_cache/simple/simple_experiment_unittest.cc
index 66d04000ed9f80ccff8bbf5149a2a38792e5285d..311a5bcb61fa0dc794869d6f6f46bd42ab226029 100644
--- a/net/disk_cache/simple/simple_experiment_unittest.cc
+++ b/net/disk_cache/simple/simple_experiment_unittest.cc
@@ -49,6 +49,28 @@ class SimpleExperimentTest : public testing::Test {
scoped_feature_list_.InitWithFeatureList(std::move(feature_list));
}
+ void ConfigureEvictWithSizeTrial(bool enabled,
+ base::Optional<uint32_t> param) {
+ const std::string kTrialName = "EvictWithSizeTrial";
+ const std::string kGroupName = "GroupFoo"; // Value not used
+
+ scoped_refptr<base::FieldTrial> trial =
+ base::FieldTrialList::CreateFieldTrial(kTrialName, kGroupName);
+
+ if (param) {
+ std::map<std::string, std::string> params;
+ params[kSizeEvictionParam] = base::UintToString(param.value());
+ base::FieldTrialParamAssociator::GetInstance()->AssociateFieldTrialParams(
+ kTrialName, kGroupName, params);
+ }
+
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
+ feature_list->RegisterFieldTrialOverride(
+ kSimpleCacheEvictionWithSizeExperiment.name,
+ base::FeatureList::OVERRIDE_ENABLE_FEATURE, trial.get());
+ scoped_feature_list_.InitWithFeatureList(std::move(feature_list));
+ }
+
std::unique_ptr<base::FieldTrialList> field_trial_list_;
base::test::ScopedFeatureList scoped_feature_list_;
};
@@ -88,4 +110,33 @@ TEST_F(SimpleExperimentTest, SizeTrialProperlyConfiguredWrongCacheType) {
EXPECT_EQ(0u, experiment.param);
}
+TEST_F(SimpleExperimentTest, EvictWithSizeMissingParam) {
+ base::test::ScopedFeatureList scoped_feature_list;
+ ConfigureEvictWithSizeTrial(true, base::Optional<uint32_t>());
+
+ SimpleExperiment experiment = GetSimpleExperiment(net::DISK_CACHE);
+ EXPECT_EQ(SimpleExperimentType::NONE, experiment.type);
+ EXPECT_EQ(0u, experiment.param);
+}
+
+TEST_F(SimpleExperimentTest, EvictWithSizeProperlyConfigured) {
+ const uint32_t kParam = 1u;
+ base::test::ScopedFeatureList scoped_feature_list;
+ ConfigureEvictWithSizeTrial(true, base::Optional<uint32_t>(kParam));
+
+ SimpleExperiment experiment = GetSimpleExperiment(net::DISK_CACHE);
+ EXPECT_EQ(SimpleExperimentType::EVICT_WITH_SIZE, experiment.type);
+ EXPECT_EQ(kParam, experiment.param);
+}
+
+TEST_F(SimpleExperimentTest, EvictWithSizeProperlyConfiguredWrongCacheType) {
+ const uint32_t kParam = 125u;
+ base::test::ScopedFeatureList scoped_feature_list;
+ ConfigureEvictWithSizeTrial(true, base::Optional<uint32_t>(kParam));
+
+ SimpleExperiment experiment = GetSimpleExperiment(net::APP_CACHE);
+ EXPECT_EQ(SimpleExperimentType::NONE, experiment.type);
+ EXPECT_EQ(0u, experiment.param);
+}
+
} // namespace disk_cache
« no previous file with comments | « net/disk_cache/simple/simple_experiment.cc ('k') | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698