| Index: base/test/scoped_feature_list.h
|
| diff --git a/base/test/scoped_feature_list.h b/base/test/scoped_feature_list.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..02603e1c1239bebe69468d050a10e4c851562785
|
| --- /dev/null
|
| +++ b/base/test/scoped_feature_list.h
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef BASE_TEST_SCOPED_FEATURE_LIST_H_
|
| +#define BASE_TEST_SCOPED_FEATURE_LIST_H_
|
| +
|
| +#include "base/feature_list.h"
|
| +
|
| +namespace base {
|
| +namespace test {
|
| +
|
| +// ScopedFeatureList resets the global FeatureList instance to a new empty
|
| +// instance and restores the original instance upon destruction.
|
| +// Note: Re-using the same object is not allowed. To reset the feature
|
| +// list and initialize it anew, destroy an existing scoped list and init
|
| +// a new one.
|
| +class ScopedFeatureList final {
|
| + public:
|
| + ScopedFeatureList();
|
| + ~ScopedFeatureList();
|
| +
|
| + // Initializes and registers a FeatureList instance with no overrides.
|
| + void Init();
|
| +
|
| + // Initializes and registers the given FeatureList instance.
|
| + void InitWithFeatureList(std::unique_ptr<FeatureList> feature_list);
|
| +
|
| + // Initializes and registers a FeatureList instance with the given
|
| + // enabled and disabled features (comma-separated names).
|
| + void InitFromCommandLine(const std::string& enable_features,
|
| + const std::string& disable_features);
|
| +
|
| + // Initializes and registers a FeatureList instance enabling a single
|
| + // feature.
|
| + void InitAndEnableFeature(const base::Feature& feature);
|
| +
|
| + // Initializes and registers a FeatureList instance disabling a single
|
| + // feature.
|
| + void InitAndDisableFeature(const base::Feature& feature);
|
| +
|
| + private:
|
| + std::unique_ptr<FeatureList> original_feature_list_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ScopedFeatureList);
|
| +};
|
| +
|
| +} // namespace test
|
| +} // namespace base
|
| +
|
| +#endif // BASE_TEST_SCOPED_FEATURE_LIST_H_
|
|
|