Chromium Code Reviews| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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.c", AutocompleteInput::UNKNOWN }, |
| 214 { L"foo.com", AutocompleteInput::URL }, | 214 { L"foo.com", AutocompleteInput::URL }, |
| 215 { L"-.com", AutocompleteInput::QUERY }, | 215 { L"-.com", AutocompleteInput::UNKNOWN }, |
| 216 { L"foo/bar", AutocompleteInput::URL }, | 216 { L"foo/bar", AutocompleteInput::URL }, |
| 217 { L"foo/bar baz", AutocompleteInput::UNKNOWN }, | 217 { L"foo/bar baz", AutocompleteInput::UNKNOWN }, |
| 218 { L"foo bar.com", AutocompleteInput::QUERY }, | |
| 218 { L"http://foo/bar baz", AutocompleteInput::URL }, | 219 { L"http://foo/bar baz", AutocompleteInput::URL }, |
| 219 { L"foo bar", AutocompleteInput::QUERY }, | 220 { L"foo bar", AutocompleteInput::QUERY }, |
| 221 { L"foo+bar", AutocompleteInput::QUERY }, | |
|
brettw
2009/11/03 03:30:22
Can you add "foo+bar.com"? It would make it a litt
| |
| 220 { L"\"foo:bar\"", AutocompleteInput::QUERY }, | 222 { L"\"foo:bar\"", AutocompleteInput::QUERY }, |
| 221 { L"link:foo.com", AutocompleteInput::UNKNOWN }, | 223 { L"link:foo.com", AutocompleteInput::UNKNOWN }, |
| 222 { L"www.foo.com:81", AutocompleteInput::URL }, | 224 { L"www.foo.com:81", AutocompleteInput::URL }, |
| 223 { L"localhost:8080", AutocompleteInput::URL }, | 225 { L"localhost:8080", AutocompleteInput::URL }, |
| 224 { L"foo.com:123456", AutocompleteInput::QUERY }, | 226 { L"foo.com:123456", AutocompleteInput::QUERY }, |
| 225 { L"foo.com:abc", AutocompleteInput::QUERY }, | 227 { L"foo.com:abc", AutocompleteInput::QUERY }, |
| 226 { L"user@foo.com", AutocompleteInput::UNKNOWN }, | 228 { L"user@foo.com", AutocompleteInput::UNKNOWN }, |
| 227 { L"user:pass@foo.com", AutocompleteInput::UNKNOWN }, | 229 { L"user:pass@foo.com", AutocompleteInput::UNKNOWN }, |
| 228 { L"1.2", AutocompleteInput::UNKNOWN }, | 230 { L"1.2", AutocompleteInput::UNKNOWN }, |
| 229 { L"1.2/45", AutocompleteInput::UNKNOWN }, | 231 { L"1.2/45", AutocompleteInput::UNKNOWN }, |
| 230 { L"ps/2 games", AutocompleteInput::UNKNOWN }, | 232 { L"ps/2 games", AutocompleteInput::UNKNOWN }, |
| 231 { L"en.wikipedia.org/wiki/James Bond", AutocompleteInput::URL }, | 233 { L"en.wikipedia.org/wiki/James Bond", AutocompleteInput::URL }, |
| 232 // In Chrome itself, mailto: will get handled by ShellExecute, but in | 234 // In Chrome itself, mailto: will get handled by ShellExecute, but in |
| 233 // unittest mode, we don't have the data loaded in the external protocol | 235 // unittest mode, we don't have the data loaded in the external protocol |
| 234 // handler to know this. | 236 // handler to know this. |
| 235 // { L"mailto:abuse@foo.com", AutocompleteInput::URL }, | 237 // { L"mailto:abuse@foo.com", AutocompleteInput::URL }, |
| 236 { L"view-source:http://www.foo.com/", AutocompleteInput::URL }, | 238 { L"view-source:http://www.foo.com/", AutocompleteInput::URL }, |
| 237 { L"javascript:alert(\"Hey there!\");", AutocompleteInput::URL }, | 239 { L"javascript:alert(\"Hey there!\");", AutocompleteInput::URL }, |
| 238 #if defined(OS_WIN) | 240 #if defined(OS_WIN) |
| 239 { L"C:\\Program Files", AutocompleteInput::URL }, | 241 { L"C:\\Program Files", AutocompleteInput::URL }, |
| 240 { L"\\\\Server\\Folder\\File", AutocompleteInput::URL }, | 242 { L"\\\\Server\\Folder\\File", AutocompleteInput::URL }, |
| 241 #endif // defined(OS_WIN) | 243 #endif // defined(OS_WIN) |
| 242 { L"http:foo", AutocompleteInput::URL }, | 244 { L"http:foo", AutocompleteInput::URL }, |
| 243 { L"http://foo", AutocompleteInput::URL }, | 245 { L"http://foo", AutocompleteInput::URL }, |
| 244 { L"http://foo.c", AutocompleteInput::URL }, | 246 { L"http://foo.c", AutocompleteInput::URL }, |
| 245 { L"http://foo.com", AutocompleteInput::URL }, | 247 { L"http://foo.com", AutocompleteInput::URL }, |
| 246 { L"http://foo_bar.com", AutocompleteInput::URL }, | 248 { L"http://foo_bar.com", AutocompleteInput::URL }, |
| 247 { L"http://-.com", AutocompleteInput::QUERY }, | 249 { L"http://-.com", AutocompleteInput::UNKNOWN }, |
| 248 { L"http://_foo_.com", AutocompleteInput::QUERY }, | 250 { L"http://_foo_.com", AutocompleteInput::UNKNOWN }, |
| 249 { L"http://foo.com:abc", AutocompleteInput::QUERY }, | 251 { L"http://foo.com:abc", AutocompleteInput::QUERY }, |
| 250 { L"http://foo.com:123456", AutocompleteInput::QUERY }, | 252 { L"http://foo.com:123456", AutocompleteInput::QUERY }, |
| 251 { L"http:user@foo.com", AutocompleteInput::URL }, | 253 { L"http:user@foo.com", AutocompleteInput::URL }, |
| 252 { L"http://user@foo.com", AutocompleteInput::URL }, | 254 { L"http://user@foo.com", AutocompleteInput::URL }, |
| 253 { L"http://user:pass@foo.com", AutocompleteInput::URL }, | 255 { L"http://user:pass@foo.com", AutocompleteInput::URL }, |
| 254 { L"http://1.2", AutocompleteInput::URL }, | 256 { L"http://1.2", AutocompleteInput::URL }, |
| 255 { L"http://1.2/45", AutocompleteInput::URL }, | 257 { L"http://1.2/45", AutocompleteInput::URL }, |
| 256 { L"http:ps/2 games", AutocompleteInput::URL }, | 258 { L"http:ps/2 games", AutocompleteInput::URL }, |
| 257 { L"http://ps/2 games", AutocompleteInput::URL }, | 259 { L"http://ps/2 games", AutocompleteInput::URL }, |
| 258 { L"127.0.0.1", AutocompleteInput::URL }, | 260 { L"127.0.0.1", AutocompleteInput::URL }, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << | 348 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << |
| 347 input_cases[i].input; | 349 input_cases[i].input; |
| 348 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << | 350 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << |
| 349 input_cases[i].input; | 351 input_cases[i].input; |
| 350 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << | 352 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << |
| 351 input_cases[i].input; | 353 input_cases[i].input; |
| 352 } | 354 } |
| 353 } | 355 } |
| 354 | 356 |
| 355 } // namespace | 357 } // namespace |
| OLD | NEW |