Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 10537154: A working implementation of AQS (Assisted Query Stats). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressed comments and added more docs. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 test_util_.ResetObserverCount(); 1007 test_util_.ResetObserverCount();
1008 test_util_.SetGoogleBaseURL(GURL("http://google.co.uk/")); 1008 test_util_.SetGoogleBaseURL(GURL("http://google.co.uk/"));
1009 VerifyObserverCount(1); 1009 VerifyObserverCount(1);
1010 1010
1011 // Make sure the host->TemplateURL map was updated appropriately. 1011 // Make sure the host->TemplateURL map was updated appropriately.
1012 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.co.uk")); 1012 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.co.uk"));
1013 EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL); 1013 EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL);
1014 EXPECT_EQ("google.co.uk", t_url->url_ref().GetHost()); 1014 EXPECT_EQ("google.co.uk", t_url->url_ref().GetHost());
1015 EXPECT_EQ(ASCIIToUTF16("google.co.uk"), t_url->keyword()); 1015 EXPECT_EQ(ASCIIToUTF16("google.co.uk"), t_url->keyword());
1016 EXPECT_EQ("http://google.co.uk/?q=x", t_url->url_ref().ReplaceSearchTerms( 1016 EXPECT_EQ("http://google.co.uk/?q=x", t_url->url_ref().ReplaceSearchTerms(
1017 ASCIIToUTF16("x"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); 1017 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("x"))));
1018 1018
1019 // Now add a manual entry and then change the Google base URL such that the 1019 // Now add a manual entry and then change the Google base URL such that the
1020 // autogenerated Google search keyword would conflict. 1020 // autogenerated Google search keyword would conflict.
1021 TemplateURL* manual = AddKeywordWithDate("manual", "google.de", 1021 TemplateURL* manual = AddKeywordWithDate("manual", "google.de",
1022 "http://google.de/search?q={searchTerms}", std::string(), std::string(), 1022 "http://google.de/search?q={searchTerms}", std::string(), std::string(),
1023 false, "UTF-8", Time(), Time()); 1023 false, "UTF-8", Time(), Time());
1024 test_util_.SetGoogleBaseURL(GURL("http://google.de")); 1024 test_util_.SetGoogleBaseURL(GURL("http://google.de"));
1025 1025
1026 // Verify that the manual entry is untouched, and the autogenerated keyword 1026 // Verify that the manual entry is untouched, and the autogenerated keyword
1027 // has not changed. 1027 // has not changed.
(...skipping 27 matching lines...) Expand all
1055 // Create a keyword. 1055 // Create a keyword.
1056 TemplateURL* t_url = AddKeywordWithDate("keyword", "keyword", 1056 TemplateURL* t_url = AddKeywordWithDate("keyword", "keyword",
1057 "http://foo.com/foo?query={searchTerms}", "http://sugg1", "http://icon1", 1057 "http://foo.com/foo?query={searchTerms}", "http://sugg1", "http://icon1",
1058 true, "UTF-8;UTF-16", base::Time::Now(), base::Time::Now()); 1058 true, "UTF-8;UTF-16", base::Time::Now(), base::Time::Now());
1059 1059
1060 // Add a visit that matches the url of the keyword. 1060 // Add a visit that matches the url of the keyword.
1061 HistoryService* history = 1061 HistoryService* history =
1062 HistoryServiceFactory::GetForProfile(test_util_.profile(), 1062 HistoryServiceFactory::GetForProfile(test_util_.profile(),
1063 Profile::EXPLICIT_ACCESS); 1063 Profile::EXPLICIT_ACCESS);
1064 history->AddPage( 1064 history->AddPage(
1065 GURL(t_url->url_ref().ReplaceSearchTerms(ASCIIToUTF16("blah"), 1065 GURL(t_url->url_ref().ReplaceSearchTerms(
1066 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), 1066 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah")))),
1067 NULL, 0, GURL(), content::PAGE_TRANSITION_KEYWORD, 1067 NULL, 0, GURL(), content::PAGE_TRANSITION_KEYWORD,
1068 history::RedirectList(), history::SOURCE_BROWSED, false); 1068 history::RedirectList(), history::SOURCE_BROWSED, false);
1069 1069
1070 // Wait for history to finish processing the request. 1070 // Wait for history to finish processing the request.
1071 test_util_.profile()->BlockUntilHistoryProcessesPendingRequests(); 1071 test_util_.profile()->BlockUntilHistoryProcessesPendingRequests();
1072 1072
1073 // Query history for the generated url. 1073 // Query history for the generated url.
1074 CancelableRequestConsumer consumer; 1074 CancelableRequestConsumer consumer;
1075 QueryHistoryCallbackImpl callback; 1075 QueryHistoryCallbackImpl callback;
1076 history->QueryURL(GURL("http://keyword"), true, &consumer, 1076 history->QueryURL(GURL("http://keyword"), true, &consumer,
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 1462
1463 // Reload the model to verify it was actually saved to the database and 1463 // Reload the model to verify it was actually saved to the database and
1464 // assigned a new GUID when brought back. 1464 // assigned a new GUID when brought back.
1465 test_util_.ResetModel(true); 1465 test_util_.ResetModel(true);
1466 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1466 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1467 const TemplateURL* loaded_url = 1467 const TemplateURL* loaded_url =
1468 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1468 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1469 ASSERT_TRUE(loaded_url != NULL); 1469 ASSERT_TRUE(loaded_url != NULL);
1470 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1470 ASSERT_FALSE(loaded_url->sync_guid().empty());
1471 } 1471 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698