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/autocomplete/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 16 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
16 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
17 #include "chrome/browser/autocomplete/history_quick_provider.h" | 18 #include "chrome/browser/autocomplete/history_quick_provider.h" |
18 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
20 #include "chrome/browser/net/url_fixer_upper.h" | 21 #include "chrome/browser/net/url_fixer_upper.h" |
21 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 } | 406 } |
406 | 407 |
407 // Create a B->C->A redirect chain, but set the visit counts such that they | 408 // Create a B->C->A redirect chain, but set the visit counts such that they |
408 // will appear in A,B,C order in the results. The autocomplete query will | 409 // will appear in A,B,C order in the results. The autocomplete query will |
409 // search for the most recent visit when looking for redirects, so this will | 410 // search for the most recent visit when looking for redirects, so this will |
410 // be found even though the previous visits had no redirects. | 411 // be found even though the previous visits had no redirects. |
411 history::RedirectList redirects_to_a; | 412 history::RedirectList redirects_to_a; |
412 redirects_to_a.push_back(GURL(test_cases[1].url)); | 413 redirects_to_a.push_back(GURL(test_cases[1].url)); |
413 redirects_to_a.push_back(GURL(test_cases[2].url)); | 414 redirects_to_a.push_back(GURL(test_cases[2].url)); |
414 redirects_to_a.push_back(GURL(test_cases[0].url)); | 415 redirects_to_a.push_back(GURL(test_cases[0].url)); |
415 history_service_->AddPage(GURL(test_cases[0].url), NULL, 0, GURL(), | 416 history_service_->AddPage(GURL(test_cases[0].url), base::Time::Now(), |
416 content::PAGE_TRANSITION_TYPED, redirects_to_a, history::SOURCE_BROWSED, | 417 NULL, 0, GURL(), redirects_to_a, content::PAGE_TRANSITION_TYPED, |
417 true); | 418 history::SOURCE_BROWSED, true); |
418 | 419 |
419 // Because all the results are part of a redirect chain with other results, | 420 // Because all the results are part of a redirect chain with other results, |
420 // all but the first one (A) should be culled. We should get the default | 421 // all but the first one (A) should be culled. We should get the default |
421 // "what you typed" result, plus this one. | 422 // "what you typed" result, plus this one. |
422 const string16 typing(ASCIIToUTF16("http://redirects/")); | 423 const string16 typing(ASCIIToUTF16("http://redirects/")); |
423 const std::string expected_results[] = { | 424 const std::string expected_results[] = { |
424 UTF16ToUTF8(typing), | 425 UTF16ToUTF8(typing), |
425 test_cases[0].url, | 426 test_cases[0].url, |
426 }; | 427 }; |
427 RunTest(typing, string16(), true, expected_results, | 428 RunTest(typing, string16(), true, expected_results, |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 "\\@st" | 703 "\\@st" |
703 }; | 704 }; |
704 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 705 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
705 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, | 706 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, |
706 false, true, AutocompleteInput::ALL_MATCHES); | 707 false, true, AutocompleteInput::ALL_MATCHES); |
707 autocomplete_->Start(input, false); | 708 autocomplete_->Start(input, false); |
708 if (!autocomplete_->done()) | 709 if (!autocomplete_->done()) |
709 MessageLoop::current()->Run(); | 710 MessageLoop::current()->Run(); |
710 } | 711 } |
711 } | 712 } |
OLD | NEW |