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

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

Issue 2930613002: Update a comment in network time test helper (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 // There are 3 things here: a FieldTrial, a FieldTrialList, and a 89 // There are 3 things here: a FieldTrial, a FieldTrialList, and a
90 // FeatureList. Don't get confused! The FieldTrial is reference-counted, 90 // FeatureList. Don't get confused! The FieldTrial is reference-counted,
91 // and a reference is held by the FieldTrialList. The FieldTrialList and 91 // and a reference is held by the FieldTrialList. The FieldTrialList and
92 // FeatureList are both singletons. The authorized way to reset the former 92 // FeatureList are both singletons. The authorized way to reset the former
93 // for testing is to destruct it (above). The latter, by contrast, should 93 // for testing is to destruct it (above). The latter, by contrast, should
94 // should already start in a clean state and can be manipulated via the 94 // should already start in a clean state and can be manipulated via the
95 // ScopedFeatureList helper class. If this comment was useful to you 95 // ScopedFeatureList helper class. If this comment was useful to you
96 // please send me a postcard. 96 // please send me a postcard.
97 97
98 field_trial_list_.reset(); // Averts a CHECK fail in constructor below. 98 // SetNetworkQueriesWithVariationsService() is usually called during test
99 // fixture setup (to establish a default state) and then again in certain
100 // tests that want to set special params. FieldTrialList is meant to be a
101 // singleton with only one instance existing at once, and the constructor
102 // fails a CHECK if this is violated. To allow these duplicate calls to this
103 // method, any existing FieldTrialList must be destroyed before creating a new
104 // one.
meacer 2017/06/07 17:29:20 nit: Would it make sense to mention the alternativ
105 field_trial_list_.reset();
99 field_trial_list_.reset( 106 field_trial_list_.reset(
100 new base::FieldTrialList(base::MakeUnique<base::MockEntropyProvider>())); 107 new base::FieldTrialList(base::MakeUnique<base::MockEntropyProvider>()));
101 108
102 // refcounted, and reference held by the singleton FieldTrialList. 109 // refcounted, and reference held by the singleton FieldTrialList.
103 base::FieldTrial* trial = base::FieldTrialList::FactoryGetFieldTrial( 110 base::FieldTrial* trial = base::FieldTrialList::FactoryGetFieldTrial(
104 kTrialName, 100, kGroupName, 1971, 1, 1, 111 kTrialName, 100, kGroupName, 1971, 1, 1,
105 base::FieldTrial::SESSION_RANDOMIZED, nullptr /* default_group_number */); 112 base::FieldTrial::SESSION_RANDOMIZED, nullptr /* default_group_number */);
106 ASSERT_TRUE( 113 ASSERT_TRUE(
107 variations::AssociateVariationParams(kTrialName, kGroupName, params)); 114 variations::AssociateVariationParams(kTrialName, kGroupName, params));
108 115
109 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 116 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
110 feature_list->RegisterFieldTrialOverride( 117 feature_list->RegisterFieldTrialOverride(
111 kFeature.name, enable ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 118 kFeature.name, enable ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
112 : base::FeatureList::OVERRIDE_DISABLE_FEATURE, 119 : base::FeatureList::OVERRIDE_DISABLE_FEATURE,
113 trial); 120 trial);
114 scoped_feature_list_.reset(new base::test::ScopedFeatureList); 121 scoped_feature_list_.reset(new base::test::ScopedFeatureList);
115 scoped_feature_list_->InitWithFeatureList(std::move(feature_list)); 122 scoped_feature_list_->InitWithFeatureList(std::move(feature_list));
116 } 123 }
117 124
118 } // namespace network_time 125 } // namespace network_time
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698