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

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

Issue 2879293002: Move setup of base::test::ScopedFeatureList earlier, to avoid data race. (Closed)
Patch Set: . Created 3 years, 7 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 | content/browser/top_document_isolation_browsertest.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"
11 11
12 namespace base { 12 namespace base {
13 namespace test { 13 namespace test {
14 14
15 // ScopedFeatureList resets the global FeatureList instance to a new empty 15 // ScopedFeatureList resets the global FeatureList instance to a new empty
16 // instance and restores the original instance upon destruction. 16 // instance and restores the original instance upon destruction.
17 // Note: Re-using the same object is not allowed. To reset the feature 17 // Note: Re-using the same object is not allowed. To reset the feature
18 // list and initialize it anew, destroy an existing scoped list and init 18 // list and initialize it anew, destroy an existing scoped list and init
19 // a new one. 19 // a new one.
20 //
21 // ScopedFeatureList needs to be initialized (via one of Init... methods)
22 // before running code that inspects the state of features. In practice this
23 // means:
24 // - In browser tests, one of Init... methods should be called from the
25 // overriden ::testing::Test::SetUp method. For example:
26 // void SetUp() override {
27 // scoped_feature_list_.InitAndEnableFeature(features::kMyFeatureHere);
28 // InProcessBrowserTest::SetUp();
29 // }
20 class ScopedFeatureList final { 30 class ScopedFeatureList final {
21 public: 31 public:
22 ScopedFeatureList(); 32 ScopedFeatureList();
23 ~ScopedFeatureList(); 33 ~ScopedFeatureList();
24 34
25 // Initializes and registers a FeatureList instance with no overrides. 35 // Initializes and registers a FeatureList instance with no overrides.
26 void Init(); 36 void Init();
27 37
28 // Initializes and registers the given FeatureList instance. 38 // Initializes and registers the given FeatureList instance.
29 void InitWithFeatureList(std::unique_ptr<FeatureList> feature_list); 39 void InitWithFeatureList(std::unique_ptr<FeatureList> feature_list);
(...skipping 20 matching lines...) Expand all
50 private: 60 private:
51 std::unique_ptr<FeatureList> original_feature_list_; 61 std::unique_ptr<FeatureList> original_feature_list_;
52 62
53 DISALLOW_COPY_AND_ASSIGN(ScopedFeatureList); 63 DISALLOW_COPY_AND_ASSIGN(ScopedFeatureList);
54 }; 64 };
55 65
56 } // namespace test 66 } // namespace test
57 } // namespace base 67 } // namespace base
58 68
59 #endif // BASE_TEST_SCOPED_FEATURE_LIST_H_ 69 #endif // BASE_TEST_SCOPED_FEATURE_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/top_document_isolation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698