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

Side by Side Diff: base/test/scoped_feature_list_unittest.cc

Issue 2834583002: Change ScopedFeatureList to overrides FeatureList not reset (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2017 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 #include "base/test/scoped_feature_list.h"
6
7 #include <string>
8
9 #include "testing/gmock/include/gmock/gmock.h"
Ilya Sherman 2017/04/20 20:53:07 nit: Is gmock being used?
chaopeng 2017/04/21 02:36:22 Done.
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace base {
13
14 class ScopedFeatureListTest : public testing::Test {
15 public:
16 void SetUp() override {
Ilya Sherman 2017/04/20 20:53:08 nit: Please do this work in the constructor instea
chaopeng 2017/04/21 02:36:22 Done.
17 // Clear default feature list;
18 feature_list.Init();
19 }
20
21 void ExpectFeatures(const std::string& enabled_features,
22 const std::string& disabled_features) {
23 base::FeatureList* list = base::FeatureList::GetInstance();
24 std::string actual_enabled_features;
25 std::string actual_disabled_features;
26
27 list->GetFeatureOverrides(&actual_enabled_features,
28 &actual_disabled_features);
29
30 EXPECT_EQ(enabled_features, actual_enabled_features);
31 EXPECT_EQ(disabled_features, actual_disabled_features);
32 }
Ilya Sherman 2017/04/20 20:53:07 nit: This doesn't need to be part of the class AFA
chaopeng 2017/04/21 02:36:22 Done.
33
34 private:
35 test::ScopedFeatureList feature_list;
Ilya Sherman 2017/04/20 20:53:08 nit: Private members should end with a trailing un
chaopeng 2017/04/21 02:36:22 Done.
36 };
37
38 TEST_F(ScopedFeatureListTest, BasicScoped) {
39 ExpectFeatures(std::string(), std::string());
40 {
41 test::ScopedFeatureList feature_list1;
42 feature_list1.InitFromCommandLine(std::string(), "OverlayScrollbar");
43 ExpectFeatures(std::string(), "OverlayScrollbar");
44 }
45 ExpectFeatures(std::string(), std::string());
46 }
47
48 TEST_F(ScopedFeatureListTest, TestInitWithFeatureListAndOverrides) {
49 ExpectFeatures(std::string(), std::string());
50 {
51 test::ScopedFeatureList feature_list1;
Ilya Sherman 2017/04/20 20:53:07 I think it would be more realistic for the outer l
52 std::vector<std::string> features{"OverlayScrollbar"};
53 feature_list1.InitWithFeatureListAndOverrides(std::vector<std::string>(),
54 features);
55 ExpectFeatures(std::string(), "OverlayScrollbar");
56
57 {
58 test::ScopedFeatureList feature_list2;
59 ExpectFeatures(std::string(), "OverlayScrollbar");
60 // Given enabled list should override given feature list.
61 feature_list2.InitWithFeatureListAndOverrides(features,
62 std::vector<std::string>());
63 ExpectFeatures("OverlayScrollbar", std::string());
64 }
65
66 {
67 test::ScopedFeatureList feature_list2;
68 ExpectFeatures(std::string(), "OverlayScrollbar");
69 // Given same feature should not appear duplicate in feature list.
70 feature_list2.InitWithFeatureListAndOverrides(std::vector<std::string>(),
71 features);
72 ExpectFeatures(std::string(), "OverlayScrollbar");
73 }
74 }
75 ExpectFeatures(std::string(), std::string());
76 }
77
78 } // namespace base
OLDNEW
« base/test/scoped_feature_list.cc ('K') | « base/test/scoped_feature_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698