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

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

Issue 9982018: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us to eliminate t… (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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 {ASCIIToUTF16("z"), 1, {ASCIIToUTF16("(Keyword: z)")}}, 194 {ASCIIToUTF16("z"), 1, {ASCIIToUTF16("(Keyword: z)")}},
195 {ASCIIToUTF16("z \t"), 1, {ASCIIToUTF16("(Keyword: z)")}}, 195 {ASCIIToUTF16("z \t"), 1, {ASCIIToUTF16("(Keyword: z)")}},
196 {ASCIIToUTF16("z a b c++"), 1, {ASCIIToUTF16("(Keyword: z)")}}, 196 {ASCIIToUTF16("z a b c++"), 1, {ASCIIToUTF16("(Keyword: z)")}},
197 }; 197 };
198 198
199 RunTest<string16>(description_cases, arraysize(description_cases), 199 RunTest<string16>(description_cases, arraysize(description_cases),
200 &AutocompleteMatch::description); 200 &AutocompleteMatch::description);
201 } 201 }
202 202
203 TEST_F(KeywordProviderTest, AddKeyword) { 203 TEST_F(KeywordProviderTest, AddKeyword) {
204 TemplateURL* template_url = new TemplateURL(); 204 TemplateURLData data;
205 data.short_name = ASCIIToUTF16("Test");
205 string16 keyword(ASCIIToUTF16("foo")); 206 string16 keyword(ASCIIToUTF16("foo"));
206 std::string url("http://www.google.com/foo?q={searchTerms}"); 207 data.SetKeyword(keyword);
207 template_url->SetURL(url); 208 data.SetURL("http://www.google.com/foo?q={searchTerms}");
208 template_url->set_keyword(keyword); 209 TemplateURL* template_url = new TemplateURL(data);
209 template_url->set_short_name(ASCIIToUTF16("Test"));
210 model_->Add(template_url); 210 model_->Add(template_url);
211 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword)); 211 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword));
212 } 212 }
213 213
214 TEST_F(KeywordProviderTest, RemoveKeyword) { 214 TEST_F(KeywordProviderTest, RemoveKeyword) {
215 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); 215 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c"));
216 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa"))); 216 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")));
217 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL); 217 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL);
218 } 218 }
219 219
220 TEST_F(KeywordProviderTest, GetKeywordForInput) { 220 TEST_F(KeywordProviderTest, GetKeywordForInput) {
221 EXPECT_EQ(ASCIIToUTF16("aa"), 221 EXPECT_EQ(ASCIIToUTF16("aa"),
222 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa"))); 222 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa")));
223 EXPECT_EQ(string16(), 223 EXPECT_EQ(string16(),
224 kw_provider_->GetKeywordForText(ASCIIToUTF16("aafoo"))); 224 kw_provider_->GetKeywordForText(ASCIIToUTF16("aafoo")));
225 EXPECT_EQ(string16(), 225 EXPECT_EQ(string16(),
226 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa foo"))); 226 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa foo")));
227 } 227 }
228 228
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_unittest.cc ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698