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 "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" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 369 |
370 // Create a B->C->A redirect chain, but set the visit counts such that they | 370 // Create a B->C->A redirect chain, but set the visit counts such that they |
371 // will appear in A,B,C order in the results. The autocomplete query will | 371 // will appear in A,B,C order in the results. The autocomplete query will |
372 // search for the most recent visit when looking for redirects, so this will | 372 // search for the most recent visit when looking for redirects, so this will |
373 // be found even though the previous visits had no redirects. | 373 // be found even though the previous visits had no redirects. |
374 history::RedirectList redirects_to_a; | 374 history::RedirectList redirects_to_a; |
375 redirects_to_a.push_back(GURL(test_cases[1].url)); | 375 redirects_to_a.push_back(GURL(test_cases[1].url)); |
376 redirects_to_a.push_back(GURL(test_cases[2].url)); | 376 redirects_to_a.push_back(GURL(test_cases[2].url)); |
377 redirects_to_a.push_back(GURL(test_cases[0].url)); | 377 redirects_to_a.push_back(GURL(test_cases[0].url)); |
378 history_service_->AddPage(GURL(test_cases[0].url), NULL, 0, GURL(), | 378 history_service_->AddPage(GURL(test_cases[0].url), NULL, 0, GURL(), |
379 PageTransition::TYPED, redirects_to_a, history::SOURCE_BROWSED, true); | 379 content::PAGE_TRANSITION_TYPED, redirects_to_a, history::SOURCE_BROWSED, |
| 380 true); |
380 | 381 |
381 // Because all the results are part of a redirect chain with other results, | 382 // Because all the results are part of a redirect chain with other results, |
382 // all but the first one (A) should be culled. We should get the default | 383 // all but the first one (A) should be culled. We should get the default |
383 // "what you typed" result, plus this one. | 384 // "what you typed" result, plus this one. |
384 const string16 typing(ASCIIToUTF16("http://redirects/")); | 385 const string16 typing(ASCIIToUTF16("http://redirects/")); |
385 const std::string expected_results[] = { | 386 const std::string expected_results[] = { |
386 UTF16ToUTF8(typing), | 387 UTF16ToUTF8(typing), |
387 test_cases[0].url, | 388 test_cases[0].url, |
388 }; | 389 }; |
389 RunTest(typing, string16(), true, expected_results, | 390 RunTest(typing, string16(), true, expected_results, |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 "\\@st" | 637 "\\@st" |
637 }; | 638 }; |
638 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 639 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
639 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, | 640 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, |
640 false, true, AutocompleteInput::ALL_MATCHES); | 641 false, true, AutocompleteInput::ALL_MATCHES); |
641 autocomplete_->Start(input, false); | 642 autocomplete_->Start(input, false); |
642 if (!autocomplete_->done()) | 643 if (!autocomplete_->done()) |
643 MessageLoop::current()->Run(); | 644 MessageLoop::current()->Run(); |
644 } | 645 } |
645 } | 646 } |
OLD | NEW |