| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 test_util_.ResetObserverCount(); | 1006 test_util_.ResetObserverCount(); |
| 1007 test_util_.SetGoogleBaseURL(GURL("http://google.co.uk/")); | 1007 test_util_.SetGoogleBaseURL(GURL("http://google.co.uk/")); |
| 1008 VerifyObserverCount(1); | 1008 VerifyObserverCount(1); |
| 1009 | 1009 |
| 1010 // Make sure the host->TemplateURL map was updated appropriately. | 1010 // Make sure the host->TemplateURL map was updated appropriately. |
| 1011 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.co.uk")); | 1011 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.co.uk")); |
| 1012 EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL); | 1012 EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL); |
| 1013 EXPECT_EQ("google.co.uk", t_url->url_ref().GetHost()); | 1013 EXPECT_EQ("google.co.uk", t_url->url_ref().GetHost()); |
| 1014 EXPECT_EQ(ASCIIToUTF16("google.co.uk"), t_url->keyword()); | 1014 EXPECT_EQ(ASCIIToUTF16("google.co.uk"), t_url->keyword()); |
| 1015 EXPECT_EQ("http://google.co.uk/?q=x", t_url->url_ref().ReplaceSearchTerms( | 1015 EXPECT_EQ("http://google.co.uk/?q=x", t_url->url_ref().ReplaceSearchTerms( |
| 1016 ASCIIToUTF16("x"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); | 1016 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("x")))); |
| 1017 | 1017 |
| 1018 // Now add a manual entry and then change the Google base URL such that the | 1018 // Now add a manual entry and then change the Google base URL such that the |
| 1019 // autogenerated Google search keyword would conflict. | 1019 // autogenerated Google search keyword would conflict. |
| 1020 TemplateURL* manual = AddKeywordWithDate("manual", "google.de", | 1020 TemplateURL* manual = AddKeywordWithDate("manual", "google.de", |
| 1021 "http://google.de/search?q={searchTerms}", std::string(), std::string(), | 1021 "http://google.de/search?q={searchTerms}", std::string(), std::string(), |
| 1022 false, "UTF-8", Time(), Time()); | 1022 false, "UTF-8", Time(), Time()); |
| 1023 test_util_.SetGoogleBaseURL(GURL("http://google.de")); | 1023 test_util_.SetGoogleBaseURL(GURL("http://google.de")); |
| 1024 | 1024 |
| 1025 // Verify that the manual entry is untouched, and the autogenerated keyword | 1025 // Verify that the manual entry is untouched, and the autogenerated keyword |
| 1026 // has not changed. | 1026 // has not changed. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1053 | 1053 |
| 1054 // Create a keyword. | 1054 // Create a keyword. |
| 1055 TemplateURL* t_url = AddKeywordWithDate("keyword", "keyword", | 1055 TemplateURL* t_url = AddKeywordWithDate("keyword", "keyword", |
| 1056 "http://foo.com/foo?query={searchTerms}", "http://sugg1", "http://icon1", | 1056 "http://foo.com/foo?query={searchTerms}", "http://sugg1", "http://icon1", |
| 1057 true, "UTF-8;UTF-16", base::Time::Now(), base::Time::Now()); | 1057 true, "UTF-8;UTF-16", base::Time::Now(), base::Time::Now()); |
| 1058 | 1058 |
| 1059 // Add a visit that matches the url of the keyword. | 1059 // Add a visit that matches the url of the keyword. |
| 1060 HistoryService* history = | 1060 HistoryService* history = |
| 1061 test_util_.profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 1061 test_util_.profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 1062 history->AddPage( | 1062 history->AddPage( |
| 1063 GURL(t_url->url_ref().ReplaceSearchTerms(ASCIIToUTF16("blah"), | 1063 GURL(t_url->url_ref().ReplaceSearchTerms( |
| 1064 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), | 1064 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah")))), |
| 1065 NULL, 0, GURL(), content::PAGE_TRANSITION_KEYWORD, | 1065 NULL, 0, GURL(), content::PAGE_TRANSITION_KEYWORD, |
| 1066 history::RedirectList(), history::SOURCE_BROWSED, false); | 1066 history::RedirectList(), history::SOURCE_BROWSED, false); |
| 1067 | 1067 |
| 1068 // Wait for history to finish processing the request. | 1068 // Wait for history to finish processing the request. |
| 1069 test_util_.profile()->BlockUntilHistoryProcessesPendingRequests(); | 1069 test_util_.profile()->BlockUntilHistoryProcessesPendingRequests(); |
| 1070 | 1070 |
| 1071 // Query history for the generated url. | 1071 // Query history for the generated url. |
| 1072 CancelableRequestConsumer consumer; | 1072 CancelableRequestConsumer consumer; |
| 1073 QueryHistoryCallbackImpl callback; | 1073 QueryHistoryCallbackImpl callback; |
| 1074 history->QueryURL(GURL("http://keyword"), true, &consumer, | 1074 history->QueryURL(GURL("http://keyword"), true, &consumer, |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 | 1427 |
| 1428 // Reload the model to verify it was actually saved to the database and | 1428 // Reload the model to verify it was actually saved to the database and |
| 1429 // assigned a new GUID when brought back. | 1429 // assigned a new GUID when brought back. |
| 1430 test_util_.ResetModel(true); | 1430 test_util_.ResetModel(true); |
| 1431 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); | 1431 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); |
| 1432 const TemplateURL* loaded_url = | 1432 const TemplateURL* loaded_url = |
| 1433 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); | 1433 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); |
| 1434 ASSERT_TRUE(loaded_url != NULL); | 1434 ASSERT_TRUE(loaded_url != NULL); |
| 1435 ASSERT_FALSE(loaded_url->sync_guid().empty()); | 1435 ASSERT_FALSE(loaded_url->sync_guid().empty()); |
| 1436 } | 1436 } |
| OLD | NEW |