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