OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/browser_about_handler.h" | 5 #include "chrome/browser/browser_about_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/test/scoped_feature_list.h" | |
16 #include "chrome/common/chrome_features.h" | |
17 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
19 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/common/referrer.h" | 19 #include "content/public/common/referrer.h" |
22 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "url/gurl.h" | 23 #include "url/gurl.h" |
26 | 24 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost)}, | 69 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost)}, |
72 {GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost), | 70 {GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost), |
73 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost)}, | 71 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost)}, |
74 { | 72 { |
75 GURL(chrome_prefix + "host/path?query#ref"), | 73 GURL(chrome_prefix + "host/path?query#ref"), |
76 GURL(chrome_prefix + "host/path?query#ref"), | 74 GURL(chrome_prefix + "host/path?query#ref"), |
77 }}); | 75 }}); |
78 TestWillHandleBrowserAboutURL(test_cases); | 76 TestWillHandleBrowserAboutURL(test_cases); |
79 } | 77 } |
80 | 78 |
81 #if defined(OS_CHROMEOS) | 79 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForMDSettings) { |
82 // Chrome OS defaults to showing Options in a window and including About in | |
83 // Options. | |
84 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForOptionsChromeOS) { | |
85 base::test::ScopedFeatureList scoped_feature_list; | |
86 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); | |
87 | |
88 std::string chrome_prefix(content::kChromeUIScheme); | 80 std::string chrome_prefix(content::kChromeUIScheme); |
89 chrome_prefix.append(url::kStandardSchemeSeparator); | 81 chrome_prefix.append(url::kStandardSchemeSeparator); |
90 std::vector<AboutURLTestCase> test_cases( | 82 std::vector<AboutURLTestCase> test_cases( |
91 {{GURL(chrome_prefix + chrome::kChromeUISettingsHost), | |
92 GURL(chrome_prefix + chrome::kChromeUISettingsFrameHost)}, | |
93 {GURL(chrome_prefix + chrome::kChromeUIHelpHost), | |
94 GURL(chrome_prefix + chrome::kChromeUISettingsFrameHost + "/" + | |
95 chrome::kChromeUIHelpHost)}}); | |
96 TestWillHandleBrowserAboutURL(test_cases); | |
97 } | |
98 | |
99 #else | |
100 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForOptions) { | |
101 base::test::ScopedFeatureList scoped_feature_list; | |
102 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); | |
103 | |
104 std::string chrome_prefix(content::kChromeUIScheme); | |
105 chrome_prefix.append(url::kStandardSchemeSeparator); | |
106 std::vector<AboutURLTestCase> test_cases( | |
107 {{ | |
108 GURL(chrome_prefix + chrome::kChromeUISettingsHost), | |
109 GURL(chrome_prefix + chrome::kChromeUIUberHost + "/" + | |
110 chrome::kChromeUISettingsHost + "/"), | |
111 }, | |
112 { | |
113 GURL(chrome_prefix + chrome::kChromeUIHelpHost), | |
114 GURL(chrome_prefix + chrome::kChromeUIUberHost + "/" + | |
115 chrome::kChromeUIHelpHost + "/"), | |
116 }}); | |
117 TestWillHandleBrowserAboutURL(test_cases); | |
118 } | |
119 #endif | |
120 | |
121 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForMDSettings) { | |
122 base::test::ScopedFeatureList scoped_feature_list; | |
123 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignSettings); | |
124 | |
125 std::string chrome_prefix(content::kChromeUIScheme); | |
126 chrome_prefix.append(url::kStandardSchemeSeparator); | |
127 std::vector<AboutURLTestCase> test_cases( | |
128 {{GURL(chrome_prefix + chrome::kChromeUISettingsHost), | 83 {{GURL(chrome_prefix + chrome::kChromeUISettingsHost), |
129 GURL(chrome_prefix + chrome::kChromeUISettingsHost)}}); | 84 GURL(chrome_prefix + chrome::kChromeUISettingsHost)}}); |
130 TestWillHandleBrowserAboutURL(test_cases); | 85 TestWillHandleBrowserAboutURL(test_cases); |
131 } | 86 } |
132 | 87 |
133 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForHistory) { | 88 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForHistory) { |
134 TestWillHandleBrowserAboutURL(std::vector<AboutURLTestCase>({ | 89 TestWillHandleBrowserAboutURL(std::vector<AboutURLTestCase>({ |
135 {GURL("about:history"), GURL("chrome://history/")}, | 90 {GURL("about:history"), GURL("chrome://history/")}, |
136 {GURL("about:history-frame"), GURL("chrome://history/")}, | 91 {GURL("about:history-frame"), GURL("chrome://history/")}, |
137 {GURL("chrome://history"), GURL("chrome://history/")}, | 92 {GURL("chrome://history"), GURL("chrome://history/")}, |
(...skipping 19 matching lines...) Expand all Loading... |
157 GURL rewritten_url("http://foo/"); | 112 GURL rewritten_url("http://foo/"); |
158 | 113 |
159 TestingProfile profile; | 114 TestingProfile profile; |
160 std::unique_ptr<NavigationEntry> entry( | 115 std::unique_ptr<NavigationEntry> entry( |
161 NavigationController::CreateNavigationEntry( | 116 NavigationController::CreateNavigationEntry( |
162 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), | 117 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
163 &profile)); | 118 &profile)); |
164 EXPECT_EQ(fixed_url, entry->GetVirtualURL()); | 119 EXPECT_EQ(fixed_url, entry->GetVirtualURL()); |
165 EXPECT_EQ(rewritten_url, entry->GetURL()); | 120 EXPECT_EQ(rewritten_url, entry->GetURL()); |
166 } | 121 } |
OLD | NEW |