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

Side by Side Diff: chrome/test/base/in_process_browser_test_browsertest.cc

Issue 2876153002: Support Using ScopedFeatureList in BrowserTest (Closed)
Patch Set: revert changes in commandline Created 3 years, 5 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <stddef.h> 5 #include <stddef.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "base/command_line.h"
8 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/strings/string_split.h"
13 #include "base/test/scoped_command_line.h"
14 #include "base/test/scoped_feature_list.h"
11 #include "chrome/browser/after_startup_task_utils.h" 15 #include "chrome/browser/after_startup_task_utils.h"
12 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/navigation_handle.h" 20 #include "content/public/browser/navigation_handle.h"
17 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
18 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_observer.h" 23 #include "content/public/browser/web_contents_observer.h"
24 #include "content/public/common/content_switches.h"
20 #include "net/base/filename_util.h" 25 #include "net/base/filename_util.h"
21 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
22 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
23 28
24 namespace { 29 namespace {
25 30
26 class InProcessBrowserTestP 31 class InProcessBrowserTestP
27 : public InProcessBrowserTest, 32 : public InProcessBrowserTest,
28 public ::testing::WithParamInterface<const char*> { 33 public ::testing::WithParamInterface<const char*> {
29 }; 34 };
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 InProcessAccessibilityBrowserTest, VerifyAccessibilityFail) { 148 InProcessAccessibilityBrowserTest, VerifyAccessibilityFail) {
144 ASSERT_TRUE(NavigateToURL(kFailHTML)); 149 ASSERT_TRUE(NavigateToURL(kFailHTML));
145 150
146 std::string test_result; 151 std::string test_result;
147 EXPECT_FALSE(RunAccessibilityChecks(&test_result)); 152 EXPECT_FALSE(RunAccessibilityChecks(&test_result));
148 153
149 // Error should NOT be empty on failure. 154 // Error should NOT be empty on failure.
150 EXPECT_NE("", test_result); 155 EXPECT_NE("", test_result);
151 } 156 }
152 157
158 const base::Feature kTestFeatureForBrowserTest1{
159 "TestFeatureForBrowserTest1", base::FEATURE_DISABLED_BY_DEFAULT};
160 const base::Feature kTestFeatureForBrowserTest2{
161 "TestFeatureForBrowserTest2", base::FEATURE_ENABLED_BY_DEFAULT};
162 const base::Feature kTestFeatureForBrowserTest3{
163 "TestFeatureForBrowserTest3", base::FEATURE_DISABLED_BY_DEFAULT};
164 const base::Feature kTestFeatureForBrowserTest4{
165 "TestFeatureForBrowserTest4", base::FEATURE_ENABLED_BY_DEFAULT};
166
167 class BrowserTestScopedFeatureListTest : public InProcessBrowserTest {
168 public:
169 void SetUp() override {
170 scoped_feature_list_.InitWithFeatures({kTestFeatureForBrowserTest3},
171 {kTestFeatureForBrowserTest4});
172 InProcessBrowserTest::SetUp();
173 }
174
175 private:
176 base::test::ScopedFeatureList scoped_feature_list_;
177 };
178
179 IN_PROC_BROWSER_TEST_F(BrowserTestScopedFeatureListTest, FeatureListTest) {
180 EXPECT_TRUE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest1));
181 EXPECT_FALSE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest2));
182 EXPECT_TRUE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest3));
183 EXPECT_FALSE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest4));
184 }
185
153 } // namespace 186 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698