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

Unified 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 side-by-side diff with in-line comments
Download patch
« base/test/scoped_feature_list.cc ('K') | « base/test/scoped_feature_list.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_feature_list_unittest.cc
diff --git a/base/test/scoped_feature_list_unittest.cc b/base/test/scoped_feature_list_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..574b6b1050209d90a89c40606342eaf29fb76db2
--- /dev/null
+++ b/base/test/scoped_feature_list_unittest.cc
@@ -0,0 +1,78 @@
+// Copyright 2017 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.
+
+#include "base/test/scoped_feature_list.h"
+
+#include <string>
+
+#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.
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+
+class ScopedFeatureListTest : public testing::Test {
+ public:
+ 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.
+ // Clear default feature list;
+ feature_list.Init();
+ }
+
+ void ExpectFeatures(const std::string& enabled_features,
+ const std::string& disabled_features) {
+ base::FeatureList* list = base::FeatureList::GetInstance();
+ std::string actual_enabled_features;
+ std::string actual_disabled_features;
+
+ list->GetFeatureOverrides(&actual_enabled_features,
+ &actual_disabled_features);
+
+ EXPECT_EQ(enabled_features, actual_enabled_features);
+ EXPECT_EQ(disabled_features, actual_disabled_features);
+ }
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.
+
+ private:
+ 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.
+};
+
+TEST_F(ScopedFeatureListTest, BasicScoped) {
+ ExpectFeatures(std::string(), std::string());
+ {
+ test::ScopedFeatureList feature_list1;
+ feature_list1.InitFromCommandLine(std::string(), "OverlayScrollbar");
+ ExpectFeatures(std::string(), "OverlayScrollbar");
+ }
+ ExpectFeatures(std::string(), std::string());
+}
+
+TEST_F(ScopedFeatureListTest, TestInitWithFeatureListAndOverrides) {
+ ExpectFeatures(std::string(), std::string());
+ {
+ test::ScopedFeatureList feature_list1;
Ilya Sherman 2017/04/20 20:53:07 I think it would be more realistic for the outer l
+ std::vector<std::string> features{"OverlayScrollbar"};
+ feature_list1.InitWithFeatureListAndOverrides(std::vector<std::string>(),
+ features);
+ ExpectFeatures(std::string(), "OverlayScrollbar");
+
+ {
+ test::ScopedFeatureList feature_list2;
+ ExpectFeatures(std::string(), "OverlayScrollbar");
+ // Given enabled list should override given feature list.
+ feature_list2.InitWithFeatureListAndOverrides(features,
+ std::vector<std::string>());
+ ExpectFeatures("OverlayScrollbar", std::string());
+ }
+
+ {
+ test::ScopedFeatureList feature_list2;
+ ExpectFeatures(std::string(), "OverlayScrollbar");
+ // Given same feature should not appear duplicate in feature list.
+ feature_list2.InitWithFeatureListAndOverrides(std::vector<std::string>(),
+ features);
+ ExpectFeatures(std::string(), "OverlayScrollbar");
+ }
+ }
+ ExpectFeatures(std::string(), std::string());
+}
+
+} // namespace base
« 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