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

Unified Diff: components/precache/core/precache_fetcher_unittest.cc

Issue 2710673004: precache: Allow experiment bitsets of any size. (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: components/precache/core/precache_fetcher_unittest.cc
diff --git a/components/precache/core/precache_fetcher_unittest.cc b/components/precache/core/precache_fetcher_unittest.cc
index f42c6c39ba1a525dba24316bbbf010103281b0c9..dbcddb2a16967124c65f5c5c42c3561e80fca321 100644
--- a/components/precache/core/precache_fetcher_unittest.cc
+++ b/components/precache/core/precache_fetcher_unittest.cc
@@ -576,7 +576,26 @@ TEST_F(PrecacheFetcherTest, FullPrecache) {
histogram.ExpectTotalCount("Precache.Fetch.TimeToComplete", 1);
}
-TEST_F(PrecacheFetcherTest, PrecacheResourceSelection) {
+class PrecacheFetcherResourceSelectionTest
+ : public PrecacheFetcherTest,
+ public testing::WithParamInterface<PrecacheResourceSelection> {
+ public:
+ // Set bits for kGoodResourceURL, kGoodResourceURLB and kGoodResourceURLD.
+ static PrecacheResourceSelection DeprecatedBitset() {
+ PrecacheResourceSelection ret;
+ ret.set_deprecated_bitset(0b10101);
jamartin 2017/02/22 22:14:01 Can you please change the testcase for one that it
twifkak 2017/02/22 23:55:03 Done. Made it multibyte, too, to test the mixed or
+ return ret;
+ }
+
+ // Set bits for kGoodResourceURL, kGoodResourceURLB and kGoodResourceURLD.
+ static PrecacheResourceSelection Bitset() {
+ PrecacheResourceSelection ret;
+ ret.set_bitset("\x15");
+ return ret;
+ }
+};
+
+TEST_P(PrecacheFetcherResourceSelectionTest, Basic) {
SetDefaultFlags();
std::unique_ptr<PrecacheUnfinishedWork> unfinished_work(
@@ -594,11 +613,8 @@ TEST_F(PrecacheFetcherTest, PrecacheResourceSelection) {
good_manifest.add_resource()->set_url(kGoodResourceURLC);
good_manifest.add_resource()->set_url(kGoodResourceURLD);
- // Set bits for kGoodResourceURL, kGoodResourceURLB and kGoodResourceURLD.
- resource_selection.set_bitset(0b10101);
(*good_manifest.mutable_experiments()
- ->mutable_resources_by_experiment_group())[kExperimentID] =
- resource_selection;
+ ->mutable_resources_by_experiment_group())[kExperimentID] = GetParam();
factory_.SetFakeResponse(GURL(kConfigURL), config.SerializeAsString(),
net::HTTP_OK, net::URLRequestStatus::SUCCESS);
@@ -643,7 +659,7 @@ TEST_F(PrecacheFetcherTest, PrecacheResourceSelection) {
histogram.ExpectTotalCount("Precache.Fetch.TimeToComplete", 1);
}
-TEST_F(PrecacheFetcherTest, PrecacheResourceSelectionMissingBitset) {
+TEST_P(PrecacheFetcherResourceSelectionTest, MissingBitset) {
SetDefaultFlags();
std::unique_ptr<PrecacheUnfinishedWork> unfinished_work(
@@ -662,10 +678,9 @@ TEST_F(PrecacheFetcherTest, PrecacheResourceSelectionMissingBitset) {
good_manifest.add_resource()->set_url(kGoodResourceURLD);
// Set bits for a different experiment group.
- resource_selection.set_bitset(0b1);
(*good_manifest.mutable_experiments()
->mutable_resources_by_experiment_group())[kExperimentID + 1] =
- resource_selection;
+ GetParam();
// Resource selection bitset for the experiment group will be missing and all
// resources will be fetched.
@@ -718,6 +733,12 @@ TEST_F(PrecacheFetcherTest, PrecacheResourceSelectionMissingBitset) {
histogram.ExpectTotalCount("Precache.Fetch.TimeToComplete", 1);
}
+INSTANTIATE_TEST_CASE_P(
+ PrecacheFetcherResourceSelectionTest,
+ PrecacheFetcherResourceSelectionTest,
+ testing::Values(PrecacheFetcherResourceSelectionTest::DeprecatedBitset(),
+ PrecacheFetcherResourceSelectionTest::Bitset()));
+
TEST_F(PrecacheFetcherTest, PrecachePauseResume) {
SetDefaultFlags();

Powered by Google App Engine
This is Rietveld 408576698