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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/autocomplete/history_url_provider.h" | 9 #include "chrome/browser/autocomplete/history_url_provider.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 // Test that if we have a synthesized host that matches a suggestion, they | 205 // Test that if we have a synthesized host that matches a suggestion, they |
206 // get combined into one. | 206 // get combined into one. |
207 const std::string expected_combine[] = { | 207 const std::string expected_combine[] = { |
208 "http://news.google.com/", | 208 "http://news.google.com/", |
209 "http://news.google.com/?ned=us&topic=n", | 209 "http://news.google.com/?ned=us&topic=n", |
210 }; | 210 }; |
211 RunTest(L"news", std::wstring(), true, expected_combine, | 211 RunTest(L"news", std::wstring(), true, expected_combine, |
212 arraysize(expected_combine)); | 212 arraysize(expected_combine)); |
213 // The title should also have gotten set properly on the host for the | 213 // The title should also have gotten set properly on the host for the |
214 // synthesized one, since it was also in the results. | 214 // synthesized one, since it was also in the results. |
215 EXPECT_EQ(std::wstring(L"Google News"), matches_[0].description); | 215 if (!matches_.empty()) // If this fails, RunTest() already printed it. |
Paweł Hajdan Jr.
2009/10/17 06:42:24
Could you rather make it ASSERT_FALSE(matches_.emp
| |
216 EXPECT_EQ(std::wstring(L"Google News"), matches_.front().description); | |
216 | 217 |
217 // Test that short URL matching works correctly as the user types more | 218 // Test that short URL matching works correctly as the user types more |
218 // (several tests): | 219 // (several tests): |
219 // The entry for foo.com is the best of all five foo.com* entries. | 220 // The entry for foo.com is the best of all five foo.com* entries. |
220 const std::string short_1[] = { | 221 const std::string short_1[] = { |
221 "http://foo.com/", | 222 "http://foo.com/", |
222 "http://foo.com/dir/another/again/myfile.html", | 223 "http://foo.com/dir/another/again/myfile.html", |
223 "http://foo.com/dir/", | 224 "http://foo.com/dir/", |
224 }; | 225 }; |
225 RunTest(L"foo", std::wstring(), true, short_1, arraysize(short_1)); | 226 RunTest(L"foo", std::wstring(), true, short_1, arraysize(short_1)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 RunTest(L"#", std::wstring(), false, NULL, 0); | 340 RunTest(L"#", std::wstring(), false, NULL, 0); |
340 RunTest(L"%20", std::wstring(), false, NULL, 0); | 341 RunTest(L"%20", std::wstring(), false, NULL, 0); |
341 RunTest(L"\uff65@s", std::wstring(), false, NULL, 0); | 342 RunTest(L"\uff65@s", std::wstring(), false, NULL, 0); |
342 RunTest(L"\u2015\u2015@ \uff7c", std::wstring(), false, NULL, 0); | 343 RunTest(L"\u2015\u2015@ \uff7c", std::wstring(), false, NULL, 0); |
343 | 344 |
344 // Fixing up "file:" should result in an inline autocomplete offset of just | 345 // Fixing up "file:" should result in an inline autocomplete offset of just |
345 // after "file:", not just after "file://". | 346 // after "file:", not just after "file://". |
346 const std::wstring input_1(L"file:"); | 347 const std::wstring input_1(L"file:"); |
347 const std::string fixup_1[] = {"file:///C:/foo.txt"}; | 348 const std::string fixup_1[] = {"file:///C:/foo.txt"}; |
348 RunTest(input_1, std::wstring(), false, fixup_1, arraysize(fixup_1)); | 349 RunTest(input_1, std::wstring(), false, fixup_1, arraysize(fixup_1)); |
349 EXPECT_EQ(input_1.length(), matches_[0].inline_autocomplete_offset); | 350 if (!matches_.empty()) // If this fails, RunTest() already printed it. |
Paweł Hajdan Jr.
2009/10/17 06:42:24
Same here.
| |
351 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); | |
350 | 352 |
351 // Fixing up "http:/" should result in an inline autocomplete offset of just | 353 // Fixing up "http:/" should result in an inline autocomplete offset of just |
352 // after "http:/", not just after "http:". | 354 // after "http:/", not just after "http:". |
353 const std::wstring input_2(L"http:/"); | 355 const std::wstring input_2(L"http:/"); |
354 const std::string fixup_2[] = { | 356 const std::string fixup_2[] = { |
355 "http://bogussite.com/a", | 357 "http://bogussite.com/a", |
356 "http://bogussite.com/b", | 358 "http://bogussite.com/b", |
357 "http://bogussite.com/c", | 359 "http://bogussite.com/c", |
358 }; | 360 }; |
359 RunTest(input_2, std::wstring(), false, fixup_2, arraysize(fixup_2)); | 361 RunTest(input_2, std::wstring(), false, fixup_2, arraysize(fixup_2)); |
360 EXPECT_EQ(input_2.length(), matches_[0].inline_autocomplete_offset); | 362 if (!matches_.empty()) // If this fails, RunTest() already printed it. |
Paweł Hajdan Jr.
2009/10/17 06:42:24
And here.
| |
363 EXPECT_EQ(input_2.length(), matches_.front().inline_autocomplete_offset); | |
361 | 364 |
362 // Adding a TLD to a small number like "56" should result in "www.56.com" | 365 // Adding a TLD to a small number like "56" should result in "www.56.com" |
363 // rather than "0.0.0.56.com". | 366 // rather than "0.0.0.56.com". |
364 std::string fixup_3[] = {"http://www.56.com/"}; | 367 std::string fixup_3[] = {"http://www.56.com/"}; |
365 RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3)); | 368 RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3)); |
366 | 369 |
367 // An input looks like a IP address like "127.0.0.1" should result in | 370 // An input looks like a IP address like "127.0.0.1" should result in |
368 // "http://127.0.0.1/". | 371 // "http://127.0.0.1/". |
369 std::string fixup_4[] = {"http://127.0.0.1/"}; | 372 std::string fixup_4[] = {"http://127.0.0.1/"}; |
370 RunTest(L"127.0.0.1", std::wstring(), false, fixup_4, arraysize(fixup_4)); | 373 RunTest(L"127.0.0.1", std::wstring(), false, fixup_4, arraysize(fixup_4)); |
371 | 374 |
372 // An number "17173" should result in "http://www.17173.com/" in db. | 375 // An number "17173" should result in "http://www.17173.com/" in db. |
373 std::string fixup_5[] = {"http://www.17173.com/"}; | 376 std::string fixup_5[] = {"http://www.17173.com/"}; |
374 RunTest(L"17173", std::wstring(), false, fixup_5, arraysize(fixup_5)); | 377 RunTest(L"17173", std::wstring(), false, fixup_5, arraysize(fixup_5)); |
375 } | 378 } |
OLD | NEW |