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

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

Issue 7558014: Add a URL param to indicate group selection in Instant field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passing NULL as far as possible Created 9 years, 4 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) 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 "base/callback.h" 5 #include "base/callback.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/test/mock_time_provider.h" 8 #include "base/test/mock_time_provider.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // Change the Google base url. 884 // Change the Google base url.
885 test_util_.ResetObserverCount(); 885 test_util_.ResetObserverCount();
886 SetGoogleBaseURL("http://foo.com/"); 886 SetGoogleBaseURL("http://foo.com/");
887 VerifyObserverCount(1); 887 VerifyObserverCount(1);
888 888
889 // Make sure the host->TemplateURL map was updated appropriately. 889 // Make sure the host->TemplateURL map was updated appropriately.
890 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("foo.com")); 890 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("foo.com"));
891 EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL); 891 EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL);
892 EXPECT_EQ("foo.com", t_url->url()->GetHost()); 892 EXPECT_EQ("foo.com", t_url->url()->GetHost());
893 EXPECT_EQ(ASCIIToUTF16("foo.com"), t_url->keyword()); 893 EXPECT_EQ(ASCIIToUTF16("foo.com"), t_url->keyword());
894 EXPECT_EQ("http://foo.com/?q=x", t_url->url()->ReplaceSearchTerms(*t_url, 894 EXPECT_EQ("http://foo.com/?q=x", t_url->url()->ReplaceSearchTerms(NULL,
895 ASCIIToUTF16("x"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); 895 *t_url, ASCIIToUTF16("x"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
896 string16()));
896 } 897 }
897 898
898 struct QueryHistoryCallbackImpl { 899 struct QueryHistoryCallbackImpl {
899 QueryHistoryCallbackImpl() : success(false) {} 900 QueryHistoryCallbackImpl() : success(false) {}
900 901
901 void Callback(HistoryService::Handle handle, 902 void Callback(HistoryService::Handle handle,
902 bool success, const history::URLRow* row, 903 bool success, const history::URLRow* row,
903 history::VisitVector* visits) { 904 history::VisitVector* visits) {
904 this->success = success; 905 this->success = success;
905 if (row) 906 if (row)
(...skipping 16 matching lines...) Expand all
922 // Create a keyword. 923 // Create a keyword.
923 TemplateURL* t_url = AddKeywordWithDate( 924 TemplateURL* t_url = AddKeywordWithDate(
924 "keyword", false, "http://foo.com/foo?query={searchTerms}", 925 "keyword", false, "http://foo.com/foo?query={searchTerms}",
925 "http://sugg1", "http://icon1", "UTF-8;UTF-16", "keyword", 926 "http://sugg1", "http://icon1", "UTF-8;UTF-16", "keyword",
926 true, base::Time::Now(), base::Time::Now()); 927 true, base::Time::Now(), base::Time::Now());
927 928
928 // Add a visit that matches the url of the keyword. 929 // Add a visit that matches the url of the keyword.
929 HistoryService* history = 930 HistoryService* history =
930 profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); 931 profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
931 history->AddPage( 932 history->AddPage(
932 GURL(t_url->url()->ReplaceSearchTerms(*t_url, ASCIIToUTF16("blah"), 0, 933 GURL(t_url->url()->ReplaceSearchTerms(NULL, *t_url, ASCIIToUTF16("blah"),
933 string16())), 934 0, string16())),
934 NULL, 0, GURL(), PageTransition::KEYWORD, history::RedirectList(), 935 NULL, 0, GURL(), PageTransition::KEYWORD, history::RedirectList(),
935 history::SOURCE_BROWSED, false); 936 history::SOURCE_BROWSED, false);
936 937
937 // Wait for history to finish processing the request. 938 // Wait for history to finish processing the request.
938 profile()->BlockUntilHistoryProcessesPendingRequests(); 939 profile()->BlockUntilHistoryProcessesPendingRequests();
939 940
940 // Query history for the generated url. 941 // Query history for the generated url.
941 CancelableRequestConsumer consumer; 942 CancelableRequestConsumer consumer;
942 QueryHistoryCallbackImpl callback; 943 QueryHistoryCallbackImpl callback;
943 history->QueryURL(GURL("http://keyword"), true, &consumer, 944 history->QueryURL(GURL("http://keyword"), true, &consumer,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 model()->SetDefaultSearchProvider(t_url); 1238 model()->SetDefaultSearchProvider(t_url);
1238 EXPECT_EQ(t_url, model()->GetDefaultSearchProvider()); 1239 EXPECT_EQ(t_url, model()->GetDefaultSearchProvider());
1239 1240
1240 // Now reset the model again but load it after setting the preferences. 1241 // Now reset the model again but load it after setting the preferences.
1241 ResetModel(false); 1242 ResetModel(false);
1242 SetManagedDefaultSearchPreferences(false, "", "", "", "", "", ""); 1243 SetManagedDefaultSearchPreferences(false, "", "", "", "", "", "");
1243 VerifyLoad(); 1244 VerifyLoad();
1244 EXPECT_TRUE(model()->is_default_search_managed()); 1245 EXPECT_TRUE(model()->is_default_search_managed());
1245 EXPECT_TRUE(model()->GetDefaultSearchProvider() == NULL); 1246 EXPECT_TRUE(model()->GetDefaultSearchProvider() == NULL);
1246 } 1247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698