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

Side by Side Diff: base/test/scoped_feature_list.h

Issue 2226063002: Add a ScopedFeatureList class for testing and start using it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue in previous patchset. Created 4 years, 4 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 | « base/test/BUILD.gn ('k') | base/test/scoped_feature_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_TEST_SCOPED_FEATURE_LIST_H_
6 #define BASE_TEST_SCOPED_FEATURE_LIST_H_
7
8 #include "base/feature_list.h"
9
10 namespace base {
11 namespace test {
12
13 // ScopedFeatureList resets the global FeatureList instance to a new empty
14 // instance and restores the original instance upon destruction.
15 // Note: Re-using the same object is not allowed. To reset the feature
16 // list and initialize it anew, destroy an existing scoped list and init
17 // a new one.
18 class ScopedFeatureList final {
19 public:
20 ScopedFeatureList();
21 ~ScopedFeatureList();
22
23 // Initializes and registers a FeatureList instance with no overrides.
24 void Init();
25
26 // Initializes and registers the given FeatureList instance.
27 void InitWithFeatureList(std::unique_ptr<FeatureList> feature_list);
28
29 // Initializes and registers a FeatureList instance with the given
30 // enabled and disabled features (comma-separated names).
31 void InitFromCommandLine(const std::string& enable_features,
32 const std::string& disable_features);
33
34 // Initializes and registers a FeatureList instance enabling a single
35 // feature.
36 void InitAndEnableFeature(const base::Feature& feature);
37
38 // Initializes and registers a FeatureList instance disabling a single
39 // feature.
40 void InitAndDisableFeature(const base::Feature& feature);
41
42 private:
43 std::unique_ptr<FeatureList> original_feature_list_;
44
45 DISALLOW_COPY_AND_ASSIGN(ScopedFeatureList);
46 };
47
48 } // namespace test
49 } // namespace base
50
51 #endif // BASE_TEST_SCOPED_FEATURE_LIST_H_
OLDNEW
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_feature_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698