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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
9 #include "chrome/browser/search_engines/template_url_model.h" | 9 #include "chrome/browser/search_engines/template_url_model.h" |
10 #include "chrome/common/pref_service.h" | 10 #include "chrome/common/pref_service.h" |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 TemplateURL* t_url = AddKeywordWithDate( | 664 TemplateURL* t_url = AddKeywordWithDate( |
665 L"keyword", false, L"http://foo.com/foo?query={searchTerms}", | 665 L"keyword", false, L"http://foo.com/foo?query={searchTerms}", |
666 L"keyword", true, base::Time::Now()); | 666 L"keyword", true, base::Time::Now()); |
667 | 667 |
668 // Add a visit that matches the url of the keyword. | 668 // Add a visit that matches the url of the keyword. |
669 HistoryService* history = | 669 HistoryService* history = |
670 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 670 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
671 history->AddPage( | 671 history->AddPage( |
672 GURL(WideToUTF8(t_url->url()->ReplaceSearchTerms(*t_url, L"blah", 0, | 672 GURL(WideToUTF8(t_url->url()->ReplaceSearchTerms(*t_url, L"blah", 0, |
673 std::wstring()))), | 673 std::wstring()))), |
674 NULL, 0, GURL(), PageTransition::KEYWORD, HistoryService::RedirectList()); | 674 NULL, 0, GURL(), PageTransition::KEYWORD, HistoryService::RedirectList(), |
| 675 false); |
675 | 676 |
676 // Wait for history to finish processing the request. | 677 // Wait for history to finish processing the request. |
677 profile_->BlockUntilHistoryProcessesPendingRequests(); | 678 profile_->BlockUntilHistoryProcessesPendingRequests(); |
678 | 679 |
679 // Query history for the generated url. | 680 // Query history for the generated url. |
680 CancelableRequestConsumer consumer; | 681 CancelableRequestConsumer consumer; |
681 QueryHistoryCallbackImpl callback; | 682 QueryHistoryCallbackImpl callback; |
682 history->QueryURL(GURL("http://keyword"), true, &consumer, | 683 history->QueryURL(GURL("http://keyword"), true, &consumer, |
683 NewCallback(&callback, &QueryHistoryCallbackImpl::Callback)); | 684 NewCallback(&callback, &QueryHistoryCallbackImpl::Callback)); |
684 | 685 |
685 // Wait for the request to be processed. | 686 // Wait for the request to be processed. |
686 profile_->BlockUntilHistoryProcessesPendingRequests(); | 687 profile_->BlockUntilHistoryProcessesPendingRequests(); |
687 | 688 |
688 // And make sure the url and visit were added. | 689 // And make sure the url and visit were added. |
689 EXPECT_TRUE(callback.success); | 690 EXPECT_TRUE(callback.success); |
690 EXPECT_NE(0, callback.row.id()); | 691 EXPECT_NE(0, callback.row.id()); |
691 ASSERT_EQ(1U, callback.visits.size()); | 692 ASSERT_EQ(1U, callback.visits.size()); |
692 EXPECT_EQ(PageTransition::KEYWORD_GENERATED, | 693 EXPECT_EQ(PageTransition::KEYWORD_GENERATED, |
693 PageTransition::StripQualifier(callback.visits[0].transition)); | 694 PageTransition::StripQualifier(callback.visits[0].transition)); |
694 } | 695 } |
OLD | NEW |