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

Side by Side Diff: components/network_time/network_time_test_utils.cc

Issue 2448943004: Add experimental feature info to certificate reports (Closed)
Patch Set: battre comment Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/network_time/network_time_test_utils.h" 5 #include "components/network_time/network_time_test_utils.h"
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 FieldTrialTest* FieldTrialTest::CreateForBrowserTest() { 60 FieldTrialTest* FieldTrialTest::CreateForBrowserTest() {
61 FieldTrialTest* test = new FieldTrialTest(); 61 FieldTrialTest* test = new FieldTrialTest();
62 test->create_field_trial_list_ = false; 62 test->create_field_trial_list_ = false;
63 return test; 63 return test;
64 } 64 }
65 65
66 void FieldTrialTest::SetNetworkQueriesWithVariationsService( 66 void FieldTrialTest::SetNetworkQueriesWithVariationsService(
67 bool enable, 67 bool enable,
68 float query_probability, 68 float query_probability,
69 FetchBehavior fetch_behavior) { 69 NetworkTimeTracker::FetchBehavior fetch_behavior) {
70 const std::string kTrialName = "Trial"; 70 const std::string kTrialName = "Trial";
71 const std::string kGroupName = "group"; 71 const std::string kGroupName = "group";
72 const base::Feature kFeature{"NetworkTimeServiceQuerying", 72 const base::Feature kFeature{"NetworkTimeServiceQuerying",
73 base::FEATURE_DISABLED_BY_DEFAULT}; 73 base::FEATURE_DISABLED_BY_DEFAULT};
74 74
75 // Clear all the things. 75 // Clear all the things.
76 variations::testing::ClearAllVariationParams(); 76 variations::testing::ClearAllVariationParams();
77 77
78 std::map<std::string, std::string> params; 78 std::map<std::string, std::string> params;
79 params["RandomQueryProbability"] = base::DoubleToString(query_probability); 79 params["RandomQueryProbability"] = base::DoubleToString(query_probability);
80 params["CheckTimeIntervalSeconds"] = base::Int64ToString(360); 80 params["CheckTimeIntervalSeconds"] = base::Int64ToString(360);
81 std::string fetch_behavior_param; 81 std::string fetch_behavior_param;
82 switch (fetch_behavior) { 82 switch (fetch_behavior) {
83 case FETCHES_IN_BACKGROUND_ONLY: 83 case NetworkTimeTracker::FETCH_BEHAVIOR_UNKNOWN:
84 NOTREACHED();
85 fetch_behavior_param = "unknown";
86 break;
87 case NetworkTimeTracker::FETCHES_IN_BACKGROUND_ONLY:
84 fetch_behavior_param = "background-only"; 88 fetch_behavior_param = "background-only";
85 break; 89 break;
86 case FETCHES_ON_DEMAND_ONLY: 90 case NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY:
87 fetch_behavior_param = "on-demand-only"; 91 fetch_behavior_param = "on-demand-only";
88 break; 92 break;
89 case FETCHES_IN_BACKGROUND_AND_ON_DEMAND: 93 case NetworkTimeTracker::FETCHES_IN_BACKGROUND_AND_ON_DEMAND:
90 fetch_behavior_param = "background-and-on-demand"; 94 fetch_behavior_param = "background-and-on-demand";
91 break; 95 break;
92 } 96 }
93 params["FetchBehavior"] = fetch_behavior_param; 97 params["FetchBehavior"] = fetch_behavior_param;
94 98
95 // There are 3 things here: a FieldTrial, a FieldTrialList, and a 99 // There are 3 things here: a FieldTrial, a FieldTrialList, and a
96 // FeatureList. Don't get confused! The FieldTrial is reference-counted, 100 // FeatureList. Don't get confused! The FieldTrial is reference-counted,
97 // and a reference is held by the FieldTrialList. The FieldTrialList and 101 // and a reference is held by the FieldTrialList. The FieldTrialList and
98 // FeatureList are both singletons. The authorized way to reset the former 102 // FeatureList are both singletons. The authorized way to reset the former
99 // for testing is to destruct it (above). The latter, by contrast, should 103 // for testing is to destruct it (above). The latter, by contrast, should
(...skipping 18 matching lines...) Expand all
118 kFeature.name, enable ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 122 kFeature.name, enable ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
119 : base::FeatureList::OVERRIDE_DISABLE_FEATURE, 123 : base::FeatureList::OVERRIDE_DISABLE_FEATURE,
120 trial); 124 trial);
121 scoped_feature_list_.reset(new base::test::ScopedFeatureList); 125 scoped_feature_list_.reset(new base::test::ScopedFeatureList);
122 scoped_feature_list_->InitWithFeatureList(std::move(feature_list)); 126 scoped_feature_list_->InitWithFeatureList(std::move(feature_list));
123 } 127 }
124 128
125 FieldTrialTest::FieldTrialTest() {} 129 FieldTrialTest::FieldTrialTest() {}
126 130
127 } // namespace network_time 131 } // namespace network_time
OLDNEW
« no previous file with comments | « components/network_time/network_time_test_utils.h ('k') | components/network_time/network_time_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698