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

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

Issue 6322001: Remove wstring from TemplateURL and friends.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 2010 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autocomplete/autocomplete_match.h" 7 #include "chrome/browser/autocomplete/autocomplete_match.h"
7 #include "chrome/browser/autocomplete/keyword_provider.h" 8 #include "chrome/browser/autocomplete/keyword_provider.h"
8 #include "chrome/browser/search_engines/template_url.h" 9 #include "chrome/browser/search_engines/template_url.h"
9 #include "chrome/browser/search_engines/template_url_model.h" 10 #include "chrome/browser/search_engines/template_url_model.h"
10 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 class KeywordProviderTest : public testing::Test { 14 class KeywordProviderTest : public testing::Test {
14 protected: 15 protected:
15 template<class ResultType> 16 template<class ResultType>
(...skipping 14 matching lines...) Expand all
30 int num_cases, 31 int num_cases,
31 ResultType AutocompleteMatch::* member); 32 ResultType AutocompleteMatch::* member);
32 33
33 protected: 34 protected:
34 scoped_refptr<KeywordProvider> kw_provider_; 35 scoped_refptr<KeywordProvider> kw_provider_;
35 scoped_ptr<TemplateURLModel> model_; 36 scoped_ptr<TemplateURLModel> model_;
36 }; 37 };
37 38
38 void KeywordProviderTest::SetUp() { 39 void KeywordProviderTest::SetUp() {
39 static const TemplateURLModel::Initializer kTestKeywordData[] = { 40 static const TemplateURLModel::Initializer kTestKeywordData[] = {
40 { L"aa", "aa.com?foo=%s", L"aa" }, 41 { "aa", "aa.com?foo=%s", "aa" },
41 { L"aaaa", "http://aaaa/?aaaa=1&b=%s&c", L"aaaa" }, 42 { "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" },
42 { L"aaaaa", "%s", L"aaaaa" }, 43 { "aaaaa", "%s", "aaaaa" },
43 { L"ab", "bogus URL %s", L"ab" }, 44 { "ab", "bogus URL %s", "ab" },
44 { L"weasel", "weasel%sweasel", L"weasel" }, 45 { "weasel", "weasel%sweasel", "weasel" },
45 { L"www", " +%2B?=%sfoo ", L"www" }, 46 { "www", " +%2B?=%sfoo ", "www" },
46 { L"z", "%s=z", L"z" }, 47 { "z", "%s=z", "z" },
47 }; 48 };
48 49
49 model_.reset(new TemplateURLModel(kTestKeywordData, 50 model_.reset(new TemplateURLModel(kTestKeywordData,
50 arraysize(kTestKeywordData))); 51 arraysize(kTestKeywordData)));
51 kw_provider_ = new KeywordProvider(NULL, model_.get()); 52 kw_provider_ = new KeywordProvider(NULL, model_.get());
52 } 53 }
53 54
54 void KeywordProviderTest::TearDown() { 55 void KeywordProviderTest::TearDown() {
55 model_.reset(); 56 model_.reset();
56 kw_provider_ = NULL; 57 kw_provider_ = NULL;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 {L"z \t", 1, {L"(Keyword: z)"}}, 178 {L"z \t", 1, {L"(Keyword: z)"}},
178 {L"z a b c++", 1, {L"(Keyword: z)"}}, 179 {L"z a b c++", 1, {L"(Keyword: z)"}},
179 }; 180 };
180 181
181 RunTest<std::wstring>(description_cases, arraysize(description_cases), 182 RunTest<std::wstring>(description_cases, arraysize(description_cases),
182 &AutocompleteMatch::description); 183 &AutocompleteMatch::description);
183 } 184 }
184 185
185 TEST_F(KeywordProviderTest, AddKeyword) { 186 TEST_F(KeywordProviderTest, AddKeyword) {
186 TemplateURL* template_url = new TemplateURL(); 187 TemplateURL* template_url = new TemplateURL();
187 std::wstring keyword(L"foo"); 188 string16 keyword(ASCIIToUTF16("foo"));
188 std::string url("http://www.google.com/foo?q={searchTerms}"); 189 std::string url("http://www.google.com/foo?q={searchTerms}");
189 template_url->SetURL(url, 0, 0); 190 template_url->SetURL(url, 0, 0);
190 template_url->set_keyword(keyword); 191 template_url->set_keyword(keyword);
191 template_url->set_short_name(L"Test"); 192 template_url->set_short_name(ASCIIToUTF16("Test"));
192 model_->Add(template_url); 193 model_->Add(template_url);
193 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword)); 194 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword));
194 } 195 }
195 196
196 TEST_F(KeywordProviderTest, RemoveKeyword) { 197 TEST_F(KeywordProviderTest, RemoveKeyword) {
197 std::wstring url(L"http://aaaa/?aaaa=1&b={searchTerms}&c"); 198 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c"));
198 model_->Remove(model_->GetTemplateURLForKeyword(L"aaaa")); 199 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")));
199 ASSERT_TRUE(model_->GetTemplateURLForKeyword(L"aaaa") == NULL); 200 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL);
200 } 201 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.cc ('k') | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698