| OLD | NEW |
| (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_ |
| OLD | NEW |