OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/browser/autocomplete/autocomplete.h" | 7 #include "chrome/browser/autocomplete/autocomplete.h" |
8 #include "chrome/common/notification_registrar.h" | 8 #include "chrome/common/notification_registrar.h" |
9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 struct test_data { | 203 struct test_data { |
204 const wchar_t* input; | 204 const wchar_t* input; |
205 const AutocompleteInput::Type type; | 205 const AutocompleteInput::Type type; |
206 } input_cases[] = { | 206 } input_cases[] = { |
207 { L"", AutocompleteInput::INVALID }, | 207 { L"", AutocompleteInput::INVALID }, |
208 { L"?", AutocompleteInput::FORCED_QUERY }, | 208 { L"?", AutocompleteInput::FORCED_QUERY }, |
209 { L"?foo", AutocompleteInput::FORCED_QUERY }, | 209 { L"?foo", AutocompleteInput::FORCED_QUERY }, |
210 { L"?foo bar", AutocompleteInput::FORCED_QUERY }, | 210 { L"?foo bar", AutocompleteInput::FORCED_QUERY }, |
211 { L"?http://foo.com/bar", AutocompleteInput::FORCED_QUERY }, | 211 { L"?http://foo.com/bar", AutocompleteInput::FORCED_QUERY }, |
212 { L"foo", AutocompleteInput::UNKNOWN }, | 212 { L"foo", AutocompleteInput::UNKNOWN }, |
| 213 { L"foo.c", AutocompleteInput::UNKNOWN }, |
213 { L"foo.com", AutocompleteInput::URL }, | 214 { L"foo.com", AutocompleteInput::URL }, |
214 { L"-.com", AutocompleteInput::QUERY }, | 215 { L"-.com", AutocompleteInput::QUERY }, |
215 { L"foo/bar", AutocompleteInput::URL }, | 216 { L"foo/bar", AutocompleteInput::URL }, |
216 { L"foo/bar baz", AutocompleteInput::UNKNOWN }, | 217 { L"foo/bar baz", AutocompleteInput::UNKNOWN }, |
217 { L"http://foo/bar baz", AutocompleteInput::URL }, | 218 { L"http://foo/bar baz", AutocompleteInput::URL }, |
218 { L"foo bar", AutocompleteInput::QUERY }, | 219 { L"foo bar", AutocompleteInput::QUERY }, |
219 { L"\"foo:bar\"", AutocompleteInput::QUERY }, | 220 { L"\"foo:bar\"", AutocompleteInput::QUERY }, |
220 { L"link:foo.com", AutocompleteInput::UNKNOWN }, | 221 { L"link:foo.com", AutocompleteInput::UNKNOWN }, |
221 { L"www.foo.com:81", AutocompleteInput::URL }, | 222 { L"www.foo.com:81", AutocompleteInput::URL }, |
222 { L"localhost:8080", AutocompleteInput::URL }, | 223 { L"localhost:8080", AutocompleteInput::URL }, |
223 { L"foo.com:123456", AutocompleteInput::QUERY }, | 224 { L"foo.com:123456", AutocompleteInput::QUERY }, |
224 { L"foo.com:abc", AutocompleteInput::QUERY }, | 225 { L"foo.com:abc", AutocompleteInput::QUERY }, |
| 226 { L"user@foo.com", AutocompleteInput::UNKNOWN }, |
| 227 { L"user:pass@foo.com", AutocompleteInput::UNKNOWN }, |
| 228 { L"1.2", AutocompleteInput::UNKNOWN }, |
| 229 { L"1.2/45", AutocompleteInput::UNKNOWN }, |
| 230 { L"ps/2 games", AutocompleteInput::UNKNOWN }, |
225 { L"en.wikipedia.org/wiki/James Bond", AutocompleteInput::URL }, | 231 { L"en.wikipedia.org/wiki/James Bond", AutocompleteInput::URL }, |
226 // In Chrome itself, mailto: will get handled by ShellExecute, but in | 232 // In Chrome itself, mailto: will get handled by ShellExecute, but in |
227 // unittest mode, we don't have the data loaded in the external protocol | 233 // unittest mode, we don't have the data loaded in the external protocol |
228 // handler to know this. | 234 // handler to know this. |
229 // { L"mailto:abuse@foo.com", AutocompleteInput::URL }, | 235 // { L"mailto:abuse@foo.com", AutocompleteInput::URL }, |
230 { L"view-source:http://www.foo.com/", AutocompleteInput::URL }, | 236 { L"view-source:http://www.foo.com/", AutocompleteInput::URL }, |
231 { L"javascript:alert(\"Hey there!\");", AutocompleteInput::URL }, | 237 { L"javascript:alert(\"Hey there!\");", AutocompleteInput::URL }, |
232 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
233 { L"C:\\Program Files", AutocompleteInput::URL }, | 239 { L"C:\\Program Files", AutocompleteInput::URL }, |
234 { L"\\\\Server\\Folder\\File", AutocompleteInput::URL }, | 240 { L"\\\\Server\\Folder\\File", AutocompleteInput::URL }, |
235 #endif // defined(OS_WIN) | 241 #endif // defined(OS_WIN) |
236 { L"http://foo.com/", AutocompleteInput::URL }, | 242 { L"http:foo", AutocompleteInput::URL }, |
| 243 { L"http://foo", AutocompleteInput::URL }, |
| 244 { L"http://foo.c", AutocompleteInput::URL }, |
| 245 { L"http://foo.com", AutocompleteInput::URL }, |
| 246 { L"http://-.com", AutocompleteInput::QUERY }, |
| 247 { L"http://foo.com:abc", AutocompleteInput::QUERY }, |
| 248 { L"http://foo.com:123456", AutocompleteInput::QUERY }, |
| 249 { L"http:user@foo.com", AutocompleteInput::URL }, |
| 250 { L"http://user@foo.com", AutocompleteInput::URL }, |
| 251 { L"http://user:pass@foo.com", AutocompleteInput::URL }, |
| 252 { L"http://1.2", AutocompleteInput::URL }, |
| 253 { L"http://1.2/45", AutocompleteInput::URL }, |
| 254 { L"http:ps/2 games", AutocompleteInput::URL }, |
| 255 { L"http://ps/2 games", AutocompleteInput::URL }, |
237 { L"127.0.0.1", AutocompleteInput::URL }, | 256 { L"127.0.0.1", AutocompleteInput::URL }, |
238 { L"127.0.1", AutocompleteInput::UNKNOWN }, | 257 { L"127.0.1", AutocompleteInput::UNKNOWN }, |
239 { L"127.0.1/", AutocompleteInput::UNKNOWN }, | 258 { L"127.0.1/", AutocompleteInput::UNKNOWN }, |
240 { L"browser.tabs.closeButtons", AutocompleteInput::UNKNOWN }, | 259 { L"browser.tabs.closeButtons", AutocompleteInput::UNKNOWN }, |
241 { L"\u6d4b\u8bd5", AutocompleteInput::UNKNOWN }, | 260 { L"\u6d4b\u8bd5", AutocompleteInput::UNKNOWN }, |
242 { L"[2001:]", AutocompleteInput::QUERY }, // Not a valid IP | 261 { L"[2001:]", AutocompleteInput::QUERY }, // Not a valid IP |
243 { L"[2001:dB8::1]", AutocompleteInput::URL }, | 262 { L"[2001:dB8::1]", AutocompleteInput::URL }, |
244 { L"192.168.0.256", AutocompleteInput::QUERY }, // Invalid IPv4 literal. | 263 { L"192.168.0.256", AutocompleteInput::QUERY }, // Invalid IPv4 literal. |
245 { L"[foo.com]", AutocompleteInput::QUERY }, // Invalid IPv6 literal. | 264 { L"[foo.com]", AutocompleteInput::QUERY }, // Invalid IPv6 literal. |
246 }; | 265 }; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << | 344 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << |
326 input_cases[i].input; | 345 input_cases[i].input; |
327 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << | 346 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << |
328 input_cases[i].input; | 347 input_cases[i].input; |
329 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << | 348 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << |
330 input_cases[i].input; | 349 input_cases[i].input; |
331 } | 350 } |
332 } | 351 } |
333 | 352 |
334 } // namespace | 353 } // namespace |
OLD | NEW |