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

Side by Side Diff: chrome/browser/autocomplete/keyword_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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/autocomplete/autocomplete_match.h" 7 #include "chrome/browser/autocomplete/autocomplete_match.h"
8 #include "chrome/browser/autocomplete/keyword_provider.h" 8 #include "chrome/browser/autocomplete/keyword_provider.h"
9 #include "chrome/browser/search_engines/template_url.h" 9 #include "chrome/browser/search_engines/template_url.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 RunTest<string16>(description_cases, arraysize(description_cases), 198 RunTest<string16>(description_cases, arraysize(description_cases),
199 &AutocompleteMatch::description); 199 &AutocompleteMatch::description);
200 } 200 }
201 201
202 TEST_F(KeywordProviderTest, AddKeyword) { 202 TEST_F(KeywordProviderTest, AddKeyword) {
203 TemplateURLData data; 203 TemplateURLData data;
204 data.short_name = ASCIIToUTF16("Test"); 204 data.short_name = ASCIIToUTF16("Test");
205 string16 keyword(ASCIIToUTF16("foo")); 205 string16 keyword(ASCIIToUTF16("foo"));
206 data.SetKeyword(keyword); 206 data.SetKeyword(keyword);
207 data.SetURL("http://www.google.com/foo?q={searchTerms}"); 207 data.SetURL("http://www.google.com/foo?q={searchTerms}");
208 TemplateURL* template_url = new TemplateURL(data); 208 TemplateURL* template_url = new TemplateURL(NULL, data);
209 model_->Add(template_url); 209 model_->Add(template_url);
210 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword)); 210 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword));
211 } 211 }
212 212
213 TEST_F(KeywordProviderTest, RemoveKeyword) { 213 TEST_F(KeywordProviderTest, RemoveKeyword) {
214 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); 214 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c"));
215 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa"))); 215 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")));
216 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL); 216 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL);
217 } 217 }
218 218
219 TEST_F(KeywordProviderTest, GetKeywordForInput) { 219 TEST_F(KeywordProviderTest, GetKeywordForInput) {
220 EXPECT_EQ(ASCIIToUTF16("aa"), 220 EXPECT_EQ(ASCIIToUTF16("aa"),
221 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa"))); 221 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa")));
222 EXPECT_EQ(string16(), 222 EXPECT_EQ(string16(),
223 kw_provider_->GetKeywordForText(ASCIIToUTF16("aafoo"))); 223 kw_provider_->GetKeywordForText(ASCIIToUTF16("aafoo")));
224 EXPECT_EQ(string16(), 224 EXPECT_EQ(string16(),
225 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa foo"))); 225 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa foo")));
226 } 226 }
227 227
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698