| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/autocomplete/autocomplete_match.h" | 7 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 8 #include "chrome/browser/autocomplete/builtin_provider.h" | 8 #include "chrome/browser/autocomplete/builtin_provider.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/testing_browser_process.h" | 10 #include "chrome/test/testing_browser_process.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 TEST_F(BuiltinProviderTest, ChromeURLs) { | 135 TEST_F(BuiltinProviderTest, ChromeURLs) { |
| 136 const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme); | 136 const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme); |
| 137 const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme); | 137 const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme); |
| 138 const string16 kSeparator1 = ASCIIToUTF16(":"); | 138 const string16 kSeparator1 = ASCIIToUTF16(":"); |
| 139 const string16 kSeparator2 = ASCIIToUTF16(":/"); | 139 const string16 kSeparator2 = ASCIIToUTF16(":/"); |
| 140 const string16 kSeparator3 = ASCIIToUTF16(chrome::kStandardSchemeSeparator); | 140 const string16 kSeparator3 = ASCIIToUTF16(chrome::kStandardSchemeSeparator); |
| 141 | 141 |
| 142 // This makes assumptions about the chrome URLs listed by the BuiltinProvider. | 142 // This makes assumptions about the chrome URLs listed by the BuiltinProvider. |
| 143 // Currently they are derived from ChromePaths() in browser_about_handler.cc. | 143 // Currently they are derived from ChromePaths() in browser_about_handler.cc. |
| 144 const string16 kHostA = ASCIIToUTF16(chrome::kChromeUIAppCacheInternalsHost); | 144 const string16 kHostE = ASCIIToUTF16(chrome::kChromeUIExtensionsHost); |
| 145 const GURL kURLA = GURL(kChrome + kSeparator3 + kHostA); | 145 const GURL kURLE = GURL(kChrome + kSeparator3 + kHostE); |
| 146 const string16 kHostF1 = ASCIIToUTF16(chrome::kChromeUIFlagsHost); | 146 const string16 kHostF1 = ASCIIToUTF16(chrome::kChromeUIFlagsHost); |
| 147 const string16 kHostF2 = ASCIIToUTF16(chrome::kChromeUIFlashHost); | 147 const string16 kHostF2 = ASCIIToUTF16(chrome::kChromeUIFlashHost); |
| 148 const GURL kURLF1 = GURL(kChrome + kSeparator3 + kHostF1); | 148 const GURL kURLF1 = GURL(kChrome + kSeparator3 + kHostF1); |
| 149 const GURL kURLF2 = GURL(kChrome + kSeparator3 + kHostF2); | 149 const GURL kURLF2 = GURL(kChrome + kSeparator3 + kHostF2); |
| 150 | 150 |
| 151 test_data<GURL> chrome_url_cases[] = { | 151 test_data<GURL> chrome_url_cases[] = { |
| 152 // Typing an about URL with an unknown host should give nothing. | 152 // Typing an about URL with an unknown host should give nothing. |
| 153 {kAbout + kSeparator1 + ASCIIToUTF16("host"), 0, {}}, | 153 {kAbout + kSeparator1 + ASCIIToUTF16("host"), 0, {}}, |
| 154 {kAbout + kSeparator2 + ASCIIToUTF16("host"), 0, {}}, | 154 {kAbout + kSeparator2 + ASCIIToUTF16("host"), 0, {}}, |
| 155 {kAbout + kSeparator3 + ASCIIToUTF16("host"), 0, {}}, | 155 {kAbout + kSeparator3 + ASCIIToUTF16("host"), 0, {}}, |
| 156 | 156 |
| 157 // Typing a chrome URL with an unknown host should give nothing. | 157 // Typing a chrome URL with an unknown host should give nothing. |
| 158 {kChrome + kSeparator1 + ASCIIToUTF16("host"), 0, {}}, | 158 {kChrome + kSeparator1 + ASCIIToUTF16("host"), 0, {}}, |
| 159 {kChrome + kSeparator2 + ASCIIToUTF16("host"), 0, {}}, | 159 {kChrome + kSeparator2 + ASCIIToUTF16("host"), 0, {}}, |
| 160 {kChrome + kSeparator3 + ASCIIToUTF16("host"), 0, {}}, | 160 {kChrome + kSeparator3 + ASCIIToUTF16("host"), 0, {}}, |
| 161 | 161 |
| 162 // Typing an about URL for a unique host should provide that full URL. | 162 // Typing an about URL for a unique host should provide that full URL. |
| 163 {kAbout + kSeparator1 + kHostA.substr(0, 1), 1, {kURLA}}, | 163 {kAbout + kSeparator1 + kHostE.substr(0, 1), 1, {kURLE}}, |
| 164 {kAbout + kSeparator2 + kHostA.substr(0, 2), 1, {kURLA}}, | 164 {kAbout + kSeparator2 + kHostE.substr(0, 2), 1, {kURLE}}, |
| 165 {kAbout + kSeparator3 + kHostA.substr(0, kHostA.length() - 1), 1, {kURLA}}, | 165 {kAbout + kSeparator3 + kHostE.substr(0, kHostE.length() - 1), 1, {kURLE}}, |
| 166 {kAbout + kSeparator1 + kHostA, 1, {kURLA}}, | 166 {kAbout + kSeparator1 + kHostE, 1, {kURLE}}, |
| 167 {kAbout + kSeparator2 + kHostA, 1, {kURLA}}, | 167 {kAbout + kSeparator2 + kHostE, 1, {kURLE}}, |
| 168 {kAbout + kSeparator3 + kHostA, 1, {kURLA}}, | 168 {kAbout + kSeparator3 + kHostE, 1, {kURLE}}, |
| 169 | 169 |
| 170 // Typing a chrome URL for a unique host should provide that full URL. | 170 // Typing a chrome URL for a unique host should provide that full URL. |
| 171 {kChrome + kSeparator1 + kHostA.substr(0, 1), 1, {kURLA}}, | 171 {kChrome + kSeparator1 + kHostE.substr(0, 1), 1, {kURLE}}, |
| 172 {kChrome + kSeparator2 + kHostA.substr(0, 2), 1, {kURLA}}, | 172 {kChrome + kSeparator2 + kHostE.substr(0, 2), 1, {kURLE}}, |
| 173 {kChrome + kSeparator3 + kHostA.substr(0, kHostA.length() - 1), 1, {kURLA}}, | 173 {kChrome + kSeparator3 + kHostE.substr(0, kHostE.length() - 1), 1, {kURLE}}, |
| 174 {kChrome + kSeparator1 + kHostA, 1, {kURLA}}, | 174 {kChrome + kSeparator1 + kHostE, 1, {kURLE}}, |
| 175 {kChrome + kSeparator2 + kHostA, 1, {kURLA}}, | 175 {kChrome + kSeparator2 + kHostE, 1, {kURLE}}, |
| 176 {kChrome + kSeparator3 + kHostA, 1, {kURLA}}, | 176 {kChrome + kSeparator3 + kHostE, 1, {kURLE}}, |
| 177 | 177 |
| 178 // Typing an about URL with a non-unique host should provide matching URLs. | 178 // Typing an about URL with a non-unique host should provide matching URLs. |
| 179 {kAbout + kSeparator1 + kHostF1.substr(0, 1), 2, {kURLF1, kURLF2}}, | 179 {kAbout + kSeparator1 + kHostF1.substr(0, 1), 2, {kURLF1, kURLF2}}, |
| 180 {kAbout + kSeparator2 + kHostF1.substr(0, 2), 2, {kURLF1, kURLF2}}, | 180 {kAbout + kSeparator2 + kHostF1.substr(0, 2), 2, {kURLF1, kURLF2}}, |
| 181 {kAbout + kSeparator3 + kHostF2.substr(0, 3), 2, {kURLF1, kURLF2}}, | 181 {kAbout + kSeparator3 + kHostF2.substr(0, 3), 2, {kURLF1, kURLF2}}, |
| 182 {kAbout + kSeparator3 + kHostF1.substr(0, 4), 1, {kURLF1}}, | 182 {kAbout + kSeparator3 + kHostF1.substr(0, 4), 1, {kURLF1}}, |
| 183 {kAbout + kSeparator3 + kHostF2.substr(0, 4), 1, {kURLF2}}, | 183 {kAbout + kSeparator3 + kHostF2.substr(0, 4), 1, {kURLF2}}, |
| 184 {kAbout + kSeparator3 + kHostF1, 1, {kURLF1}}, | 184 {kAbout + kSeparator3 + kHostF1, 1, {kURLF1}}, |
| 185 {kAbout + kSeparator2 + kHostF2, 1, {kURLF2}}, | 185 {kAbout + kSeparator2 + kHostF2, 1, {kURLF2}}, |
| 186 | 186 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 {kSettings + kPage1.substr(0, 1), 2, {kURL1, kURL2}}, | 219 {kSettings + kPage1.substr(0, 1), 2, {kURL1, kURL2}}, |
| 220 {kSettings + kPage1.substr(0, 2), 1, {kURL1}}, | 220 {kSettings + kPage1.substr(0, 2), 1, {kURL1}}, |
| 221 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}}, | 221 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}}, |
| 222 {kSettings + kPage1, 1, {kURL1}}, | 222 {kSettings + kPage1, 1, {kURL1}}, |
| 223 {kSettings + kPage2, 1, {kURL2}}, | 223 {kSettings + kPage2, 1, {kURL2}}, |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 RunTest<GURL>(settings_subpage_cases, arraysize(settings_subpage_cases), | 226 RunTest<GURL>(settings_subpage_cases, arraysize(settings_subpage_cases), |
| 227 &AutocompleteMatch::destination_url); | 227 &AutocompleteMatch::destination_url); |
| 228 } | 228 } |
| OLD | NEW |