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

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

Issue 2968793002: Reland of Change ScopedFeatureList to overrides FeatureList not reset (Closed)
Patch Set: add depends 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 unified diff | Download patch
« no previous file with comments | « base/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
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 #ifndef BASE_TEST_SCOPED_FEATURE_LIST_H_ 5 #ifndef BASE_TEST_SCOPED_FEATURE_LIST_H_
6 #define BASE_TEST_SCOPED_FEATURE_LIST_H_ 6 #define BASE_TEST_SCOPED_FEATURE_LIST_H_
7 7
8 #include <initializer_list> 8 #include <initializer_list>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 14 matching lines...) Expand all
25 // overriden ::testing::Test::SetUp method. For example: 25 // overriden ::testing::Test::SetUp method. For example:
26 // void SetUp() override { 26 // void SetUp() override {
27 // scoped_feature_list_.InitAndEnableFeature(features::kMyFeatureHere); 27 // scoped_feature_list_.InitAndEnableFeature(features::kMyFeatureHere);
28 // InProcessBrowserTest::SetUp(); 28 // InProcessBrowserTest::SetUp();
29 // } 29 // }
30 class ScopedFeatureList final { 30 class ScopedFeatureList final {
31 public: 31 public:
32 ScopedFeatureList(); 32 ScopedFeatureList();
33 ~ScopedFeatureList(); 33 ~ScopedFeatureList();
34 34
35 // WARNING: This method will reset any globally configured features to their
36 // default values, which can hide feature interaction bugs. Please use
37 // sparingly. https://crbug.com/713390
35 // Initializes and registers a FeatureList instance with no overrides. 38 // Initializes and registers a FeatureList instance with no overrides.
36 void Init(); 39 void Init();
37 40
41 // WARNING: This method will reset any globally configured features to their
42 // default values, which can hide feature interaction bugs. Please use
43 // sparingly. https://crbug.com/713390
38 // Initializes and registers the given FeatureList instance. 44 // Initializes and registers the given FeatureList instance.
39 void InitWithFeatureList(std::unique_ptr<FeatureList> feature_list); 45 void InitWithFeatureList(std::unique_ptr<FeatureList> feature_list);
40 46
41 // Initializes and registers a FeatureList instance with the given enabled 47 // WARNING: This method will reset any globally configured features to their
42 // and disabled features. 48 // default values, which can hide feature interaction bugs. Please use
49 // sparingly. https://crbug.com/713390
50 // Initializes and registers a FeatureList instance with only the given
51 // enabled and disabled features (comma-separated names).
52 void InitFromCommandLine(const std::string& enable_features,
53 const std::string& disable_features);
54
55 // Initializes and registers a FeatureList instance based on present
56 // FeatureList and overridden with the given enabled and disabled features.
57 // Any feature overrides already present in the global FeatureList will
58 // continue to apply, unless they conflict with the overrides passed into this
59 // method. This is important for testing potentially unexpected feature
60 // interactions.
43 void InitWithFeatures( 61 void InitWithFeatures(
44 const std::initializer_list<base::Feature>& enabled_features, 62 const std::initializer_list<base::Feature>& enabled_features,
45 const std::initializer_list<base::Feature>& disabled_features); 63 const std::initializer_list<base::Feature>& disabled_features);
46 64
47 // Initializes and registers a FeatureList instance with the given 65 // Initializes and registers a FeatureList instance based on present
48 // enabled and disabled features (comma-separated names). 66 // FeatureList and overridden with single enabled feature.
49 void InitFromCommandLine(const std::string& enable_features,
50 const std::string& disable_features);
51
52 // Initializes and registers a FeatureList instance enabling a single
53 // feature.
54 void InitAndEnableFeature(const base::Feature& feature); 67 void InitAndEnableFeature(const base::Feature& feature);
55 68
56 // Initializes and registers a FeatureList instance disabling a single 69 // Initializes and registers a FeatureList instance based on present
57 // feature. 70 // FeatureList and overridden with single disabled feature.
58 void InitAndDisableFeature(const base::Feature& feature); 71 void InitAndDisableFeature(const base::Feature& feature);
59 72
60 private: 73 private:
61 std::unique_ptr<FeatureList> original_feature_list_; 74 std::unique_ptr<FeatureList> original_feature_list_;
62 75
63 DISALLOW_COPY_AND_ASSIGN(ScopedFeatureList); 76 DISALLOW_COPY_AND_ASSIGN(ScopedFeatureList);
64 }; 77 };
65 78
66 } // namespace test 79 } // namespace test
67 } // namespace base 80 } // namespace base
68 81
69 #endif // BASE_TEST_SCOPED_FEATURE_LIST_H_ 82 #endif // BASE_TEST_SCOPED_FEATURE_LIST_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/test/scoped_feature_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698