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

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

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