Chromium Code Reviews| 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}; | |
| 159 | |
| 160 class BrowserTestScopedFeatureListTest : public InProcessBrowserTest { | |
| 161 public: | |
| 162 void SetUp() override { | |
| 163 std::string disabled_features; | |
| 164 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features_, | |
| 165 &disabled_features); | |
| 166 scoped_feature_list_.InitAndEnableFeature(kTestFeatureForBrowserTest); | |
| 167 InProcessBrowserTest::SetUp(); | |
| 168 } | |
| 169 | |
| 170 std::string enabled_features_; | |
| 171 | |
| 172 private: | |
| 173 base::test::ScopedFeatureList scoped_feature_list_; | |
| 174 }; | |
| 175 | |
| 176 IN_PROC_BROWSER_TEST_F(BrowserTestScopedFeatureListTest, FeatureListTest) { | |
| 177 std::string enabled_features0; | |
| 178 std::string disabled_features0; | |
| 179 | |
| 180 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features0, | |
| 181 &disabled_features0); | |
| 182 | |
| 183 base::StringPiece enabled_features = enabled_features0; | |
| 184 | |
| 185 // Ensure we repected the features from command line. | |
| 186 std::vector<base::StringPiece> original_enabled_features = | |
| 187 base::SplitStringPiece(enabled_features_, ",", base::TRIM_WHITESPACE, | |
| 188 base::SPLIT_WANT_NONEMPTY); | |
| 189 | |
| 190 for (base::StringPiece enabled_feature : original_enabled_features) { | |
| 191 EXPECT_NE(enabled_features.find(enabled_feature), base::StringPiece::npos); | |
| 192 } | |
| 193 | |
| 194 // Ensure kTestFeatureForBrowserTest enabled. | |
| 195 EXPECT_TRUE(base::FeatureList::IsEnabled(kTestFeatureForBrowserTest)); | |
|
Ilya Sherman
2017/06/13 22:42:48
IMO this part of the test is useful. The EXPECT_N
chaopeng
2017/06/28 14:16:51
Done.
| |
| 196 } | |
| 197 | |
| 153 } // namespace | 198 } // namespace |
| OLD | NEW |