OLD | NEW |
---|---|
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_feature_list.h" | |
11 #include "chrome/browser/after_startup_task_utils.h" | 14 #include "chrome/browser/after_startup_task_utils.h" |
12 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/public/browser/navigation_handle.h" | 19 #include "content/public/browser/navigation_handle.h" |
17 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
19 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
23 #include "content/public/common/content_switches.h" | |
20 #include "net/base/filename_util.h" | 24 #include "net/base/filename_util.h" |
21 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
23 | 27 |
24 namespace { | 28 namespace { |
25 | 29 |
26 class InProcessBrowserTestP | 30 class InProcessBrowserTestP |
27 : public InProcessBrowserTest, | 31 : public InProcessBrowserTest, |
28 public ::testing::WithParamInterface<const char*> { | 32 public ::testing::WithParamInterface<const char*> { |
29 }; | 33 }; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 InProcessAccessibilityBrowserTest, VerifyAccessibilityFail) { | 147 InProcessAccessibilityBrowserTest, VerifyAccessibilityFail) { |
144 ASSERT_TRUE(NavigateToURL(kFailHTML)); | 148 ASSERT_TRUE(NavigateToURL(kFailHTML)); |
145 | 149 |
146 std::string test_result; | 150 std::string test_result; |
147 EXPECT_FALSE(RunAccessibilityChecks(&test_result)); | 151 EXPECT_FALSE(RunAccessibilityChecks(&test_result)); |
148 | 152 |
149 // Error should NOT be empty on failure. | 153 // Error should NOT be empty on failure. |
150 EXPECT_NE("", test_result); | 154 EXPECT_NE("", test_result); |
151 } | 155 } |
152 | 156 |
157 const base::Feature kTestFeatureForBrowserTest{ | |
158 "TestFeatureForBrowserTest", base::FEATURE_DISABLED_BY_DEFAULT}; | |
Ilya Sherman
2017/06/07 21:32:36
Is it worth having both an enabled and a disabled
Ilya Sherman
2017/06/07 21:32:36
nit: Please define this in an anonymous namespace.
chaopeng
2017/06/09 04:49:05
This file is already in anonymous.
| |
159 | |
160 class BrowserTestScopedFeatureListTest : public InProcessBrowserTest { | |
161 public: | |
162 void SetUp() override { | |
163 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
164 enabled_features_ = | |
165 command_line->GetSwitchValueASCII(switches::kEnableFeatures); | |
166 disabled_features_ = | |
167 command_line->GetSwitchValueASCII(switches::kEnableFeatures); | |
Ilya Sherman
2017/06/07 21:32:36
Same questions apply here as for the other test.
| |
168 scoped_feature_list_.InitAndEnableFeature(kTestFeatureForBrowserTest); | |
169 InProcessBrowserTest::SetUp(); | |
170 } | |
171 | |
172 std::string enabled_features_; | |
173 std::string disabled_features_; | |
174 | |
175 private: | |
176 base::test::ScopedFeatureList scoped_feature_list_; | |
177 }; | |
178 | |
179 IN_PROC_BROWSER_TEST_F(BrowserTestScopedFeatureListTest, FeatureListTest) { | |
180 std::string enabled_features0; | |
181 std::string disabled_features0; | |
182 | |
183 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features0, | |
184 &disabled_features0); | |
185 | |
186 base::StringPiece enabled_features = enabled_features0; | |
187 base::StringPiece disabled_features = disabled_features0; | |
188 | |
189 // Ensure we repected the features from command line. | |
190 std::vector<base::StringPiece> original_enabled_features = | |
191 base::SplitStringPiece(enabled_features_, ",", base::TRIM_WHITESPACE, | |
192 base::SPLIT_WANT_NONEMPTY); | |
193 std::vector<base::StringPiece> original_disabled_features = | |
194 base::SplitStringPiece(disabled_features_, ",", base::TRIM_WHITESPACE, | |
195 base::SPLIT_WANT_NONEMPTY); | |
196 | |
197 for (base::StringPiece enabled_feature : original_enabled_features) { | |
198 EXPECT_NE(enabled_features.find(enabled_feature), base::StringPiece::npos); | |
199 } | |
200 | |
201 for (base::StringPiece disabled_feature : original_disabled_features) { | |
202 EXPECT_NE(disabled_features.find(disabled_feature), | |
203 base::StringPiece::npos); | |
204 } | |
205 | |
206 // Ensure kTestFeatureForBrowserTest enabled. | |
207 EXPECT_TRUE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest)); | |
208 } | |
209 | |
153 } // namespace | 210 } // namespace |
OLD | NEW |