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

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 10173001: Add a Profile* member to TemplateURL. This makes some invocations of ReplaceSearchTerms() a bit le… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 "chrome/browser/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 TemplateURLService* turl_model = 118 TemplateURLService* turl_model =
119 TemplateURLServiceFactory::GetForProfile(&profile_); 119 TemplateURLServiceFactory::GetForProfile(&profile_);
120 120
121 turl_model->Load(); 121 turl_model->Load();
122 122
123 // Reset the default TemplateURL. 123 // Reset the default TemplateURL.
124 TemplateURLData data; 124 TemplateURLData data;
125 data.short_name = ASCIIToUTF16("t"); 125 data.short_name = ASCIIToUTF16("t");
126 data.SetURL("http://defaultturl/{searchTerms}"); 126 data.SetURL("http://defaultturl/{searchTerms}");
127 data.suggestions_url = "http://defaultturl2/{searchTerms}"; 127 data.suggestions_url = "http://defaultturl2/{searchTerms}";
128 default_t_url_ = new TemplateURL(data); 128 default_t_url_ = new TemplateURL(&profile_, data);
129 turl_model->Add(default_t_url_); 129 turl_model->Add(default_t_url_);
130 turl_model->SetDefaultSearchProvider(default_t_url_); 130 turl_model->SetDefaultSearchProvider(default_t_url_);
131 TemplateURLID default_provider_id = default_t_url_->id(); 131 TemplateURLID default_provider_id = default_t_url_->id();
132 ASSERT_NE(0, default_provider_id); 132 ASSERT_NE(0, default_provider_id);
133 133
134 // Add url1, with search term term1_. 134 // Add url1, with search term term1_.
135 term1_url_ = AddSearchToHistory(default_t_url_, term1_, 1); 135 term1_url_ = AddSearchToHistory(default_t_url_, term1_, 1);
136 136
137 // Create another TemplateURL. 137 // Create another TemplateURL.
138 data.short_name = ASCIIToUTF16("k"); 138 data.short_name = ASCIIToUTF16("k");
139 data.SetKeyword(ASCIIToUTF16("k")); 139 data.SetKeyword(ASCIIToUTF16("k"));
140 data.SetURL("http://keyword/{searchTerms}"); 140 data.SetURL("http://keyword/{searchTerms}");
141 data.suggestions_url = "http://suggest_keyword/{searchTerms}"; 141 data.suggestions_url = "http://suggest_keyword/{searchTerms}";
142 keyword_t_url_ = new TemplateURL(data); 142 keyword_t_url_ = new TemplateURL(&profile_, data);
143 turl_model->Add(keyword_t_url_); 143 turl_model->Add(keyword_t_url_);
144 ASSERT_NE(0, keyword_t_url_->id()); 144 ASSERT_NE(0, keyword_t_url_->id());
145 145
146 // Add a page and search term for keyword_t_url_. 146 // Add a page and search term for keyword_t_url_.
147 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1); 147 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1);
148 148
149 // Keywords are updated by the InMemoryHistoryBackend only after the message 149 // Keywords are updated by the InMemoryHistoryBackend only after the message
150 // has been processed on the history thread. Block until history processes all 150 // has been processed on the history thread. Block until history processes all
151 // requests to ensure the InMemoryDatabase is the state we expect it. 151 // requests to ensure the InMemoryDatabase is the state we expect it.
152 profile_.BlockUntilHistoryProcessesPendingRequests(); 152 profile_.BlockUntilHistoryProcessesPendingRequests();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 fetcher = NULL; 661 fetcher = NULL;
662 662
663 // Run till the history results complete. 663 // Run till the history results complete.
664 RunTillProviderDone(); 664 RunTillProviderDone();
665 665
666 // Make sure there is a match for 'a.com' and it doesn't have a template_url. 666 // Make sure there is a match for 'a.com' and it doesn't have a template_url.
667 AutocompleteMatch nav_match; 667 AutocompleteMatch nav_match;
668 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); 668 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match));
669 EXPECT_FALSE(nav_match.template_url); 669 EXPECT_FALSE(nav_match.template_url);
670 } 670 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698