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

Side by Side Diff: content/test/content_browser_test_test.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 "content/public/test/content_browser_test.h" 5 #include "content/public/test/content_browser_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/process/launch.h" 9 #include "base/process/launch.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/strings/string_split.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/launcher/test_launcher.h" 13 #include "base/test/launcher/test_launcher.h"
14 #include "base/test/scoped_command_line.h"
15 #include "base/test/scoped_feature_list.h"
13 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
14 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
15 #include "build/build_config.h" 18 #include "build/build_config.h"
16 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_process_host_observer.h" 20 #include "content/public/browser/render_process_host_observer.h"
18 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
20 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
21 #include "content/public/test/content_browser_test_utils.h" 24 #include "content/public/test/content_browser_test_utils.h"
22 #include "content/public/test/test_launcher.h" 25 #include "content/public/test/test_launcher.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest, Basic) { 174 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest, Basic) {
172 Test(); 175 Test();
173 } 176 }
174 177
175 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest, SingleProcess) { 178 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest, SingleProcess) {
176 Test(); 179 Test();
177 } 180 }
178 181
179 namespace { 182 namespace {
180 183
184 const base::Feature kTestFeatureForBrowserTest1{
185 "TestFeatureForBrowserTest1", base::FEATURE_DISABLED_BY_DEFAULT};
186 const base::Feature kTestFeatureForBrowserTest2{
187 "TestFeatureForBrowserTest2", base::FEATURE_ENABLED_BY_DEFAULT};
188 const base::Feature kTestFeatureForBrowserTest3{
189 "TestFeatureForBrowserTest3", base::FEATURE_DISABLED_BY_DEFAULT};
190 const base::Feature kTestFeatureForBrowserTest4{
191 "TestFeatureForBrowserTest4", base::FEATURE_ENABLED_BY_DEFAULT};
192
193 } // namespace
194
195 class ContentBrowserTestScopedFeatureListTest : public ContentBrowserTest {
196 public:
197 void SetUp() override {
198 scoped_feature_list_.InitWithFeatures({kTestFeatureForBrowserTest3},
199 {kTestFeatureForBrowserTest4});
200 ContentBrowserTest::SetUp();
201 }
202
203 private:
204 base::test::ScopedFeatureList scoped_feature_list_;
205 };
206
207 IN_PROC_BROWSER_TEST_F(ContentBrowserTestScopedFeatureListTest,
208 FeatureListTest) {
209 EXPECT_TRUE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest1));
210 EXPECT_FALSE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest2));
211 EXPECT_TRUE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest3));
212 EXPECT_FALSE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest4));
213 }
214
215 namespace {
216
181 void CallbackChecker(bool* non_nested_task_ran) { 217 void CallbackChecker(bool* non_nested_task_ran) {
182 *non_nested_task_ran = true; 218 *non_nested_task_ran = true;
183 } 219 }
184 220
185 } // namespace 221 } // namespace
186 222
187 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { 223 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) {
188 bool non_nested_task_ran = false; 224 bool non_nested_task_ran = false;
189 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( 225 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
190 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); 226 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran));
191 content::RunAllPendingInMessageLoop(); 227 content::RunAllPendingInMessageLoop();
192 ASSERT_TRUE(non_nested_task_ran); 228 ASSERT_TRUE(non_nested_task_ran);
193 } 229 }
194 230
195 } // namespace content 231 } // namespace content
OLDNEW
« base/test/test_suite.cc ('K') | « chrome/test/base/test_launcher_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698