Index: chrome/browser/autocomplete/keyword_provider_unittest.cc |
=================================================================== |
--- chrome/browser/autocomplete/keyword_provider_unittest.cc (revision 72331) |
+++ chrome/browser/autocomplete/keyword_provider_unittest.cc (working copy) |
@@ -15,7 +15,7 @@ |
protected: |
template<class ResultType> |
struct test_data { |
- const std::wstring input; |
+ const string16 input; |
const size_t num_results; |
const ResultType output[3]; |
}; |
@@ -64,13 +64,13 @@ |
ResultType AutocompleteMatch::* member) { |
ACMatches matches; |
for (int i = 0; i < num_cases; ++i) { |
- AutocompleteInput input(keyword_cases[i].input, std::wstring(), true, |
+ AutocompleteInput input(keyword_cases[i].input, string16(), true, |
false, true, false); |
kw_provider_->Start(input, false); |
EXPECT_TRUE(kw_provider_->done()); |
matches = kw_provider_->matches(); |
EXPECT_EQ(keyword_cases[i].num_results, matches.size()) << |
- L"Input was: " + keyword_cases[i].input; |
+ ASCIIToUTF16("Input was: ") + keyword_cases[i].input; |
if (matches.size() == keyword_cases[i].num_results) { |
for (size_t j = 0; j < keyword_cases[i].num_results; ++j) { |
EXPECT_EQ(keyword_cases[i].output[j], matches[j].*member); |
@@ -80,61 +80,69 @@ |
} |
TEST_F(KeywordProviderTest, Edit) { |
- test_data<std::wstring> edit_cases[] = { |
+ test_data<string16> edit_cases[] = { |
// Searching for a nonexistent prefix should give nothing. |
- {L"Not Found", 0, {}}, |
- {L"aaaaaNot Found", 0, {}}, |
+ {ASCIIToUTF16("Not Found"), 0, {}}, |
+ {ASCIIToUTF16("aaaaaNot Found"), 0, {}}, |
// Check that tokenization only collapses whitespace between first tokens, |
// no-query-input cases have a space appended, and action is not escaped. |
- {L"z foo", 1, {L"z foo"}}, |
- {L"z", 1, {L"z "}}, |
- {L"z \t", 1, {L"z "}}, |
- {L"z a b c++", 1, {L"z a b c++"}}, |
+ {ASCIIToUTF16("z foo"), 1, {ASCIIToUTF16("z foo")}}, |
+ {ASCIIToUTF16("z"), 1, {ASCIIToUTF16("z ")}}, |
+ {ASCIIToUTF16("z \t"), 1, {ASCIIToUTF16("z ")}}, |
+ {ASCIIToUTF16("z a b c++"), 1, {ASCIIToUTF16("z a b c++")}}, |
// Matches should be limited to three, and sorted in quality order, not |
// alphabetical. |
- {L"aaa", 2, {L"aaaa ", L"aaaaa "}}, |
- {L"a 1 2 3", 3, {L"aa 1 2 3", L"ab 1 2 3", L"aaaa 1 2 3"}}, |
- {L"www.a", 3, {L"aa ", L"ab ", L"aaaa "}}, |
+ {ASCIIToUTF16("aaa"), 2, {ASCIIToUTF16("aaaa "), |
+ ASCIIToUTF16("aaaaa ")}}, |
+ {ASCIIToUTF16("a 1 2 3"), 3, {ASCIIToUTF16("aa 1 2 3"), |
+ ASCIIToUTF16("ab 1 2 3"), |
+ ASCIIToUTF16("aaaa 1 2 3")}}, |
+ {ASCIIToUTF16("www.a"), 3, {ASCIIToUTF16("aa "), |
+ ASCIIToUTF16("ab "), |
+ ASCIIToUTF16("aaaa ")}}, |
// Exact matches should prevent returning inexact matches. |
- {L"aaaa foo", 1, {L"aaaa foo"}}, |
- {L"www.aaaa foo", 1, {L"aaaa foo"}}, |
+ {ASCIIToUTF16("aaaa foo"), 1, {ASCIIToUTF16("aaaa foo")}}, |
+ {ASCIIToUTF16("www.aaaa foo"), 1, {ASCIIToUTF16("aaaa foo")}}, |
// Clean up keyword input properly. "http" and "https" are the only |
// allowed schemes. |
- {L"www", 1, {L"www "}}, |
- {L"www.", 0, {}}, |
- {L"www.w w", 2, {L"www w", L"weasel w"}}, |
- {L"http://www", 1, {L"www "}}, |
- {L"http://www.", 0, {}}, |
- {L"ftp: blah", 0, {}}, |
- {L"mailto:z", 0, {}}, |
- {L"ftp://z", 0, {}}, |
- {L"https://z", 1, {L"z "}}, |
+ {ASCIIToUTF16("www"), 1, {ASCIIToUTF16("www ")}}, |
+ {ASCIIToUTF16("www."), 0, {}}, |
+ {ASCIIToUTF16("www.w w"), 2, {ASCIIToUTF16("www w"), |
+ ASCIIToUTF16("weasel w")}}, |
+ {ASCIIToUTF16("http://www"), 1, {ASCIIToUTF16("www ")}}, |
+ {ASCIIToUTF16("http://www."), 0, {}}, |
+ {ASCIIToUTF16("ftp: blah"), 0, {}}, |
+ {ASCIIToUTF16("mailto:z"), 0, {}}, |
+ {ASCIIToUTF16("ftp://z"), 0, {}}, |
+ {ASCIIToUTF16("https://z"), 1, {ASCIIToUTF16("z ")}}, |
}; |
- RunTest<std::wstring>(edit_cases, arraysize(edit_cases), |
- &AutocompleteMatch::fill_into_edit); |
+ RunTest<string16>(edit_cases, arraysize(edit_cases), |
+ &AutocompleteMatch::fill_into_edit); |
} |
TEST_F(KeywordProviderTest, URL) { |
test_data<GURL> url_cases[] = { |
// No query input -> empty destination URL. |
- {L"z", 1, {GURL()}}, |
- {L"z \t", 1, {GURL()}}, |
+ {ASCIIToUTF16("z"), 1, {GURL()}}, |
+ {ASCIIToUTF16("z \t"), 1, {GURL()}}, |
// Check that tokenization only collapses whitespace between first tokens |
// and query input, but not rest of URL, is escaped. |
- {L"z a b c++", 1, {GURL("a+++b+++c%2B%2B=z")}}, |
- {L"www.www www", 1, {GURL(" +%2B?=wwwfoo ")}}, |
+ {ASCIIToUTF16("z a b c++"), 1, {GURL("a+++b+++c%2B%2B=z")}}, |
+ {ASCIIToUTF16("www.www www"), 1, {GURL(" +%2B?=wwwfoo ")}}, |
// Substitution should work with various locations of the "%s". |
- {L"aaa 1a2b", 2, {GURL("http://aaaa/?aaaa=1&b=1a2b&c"), |
- GURL("1a2b")}}, |
- {L"a 1 2 3", 3, {GURL("aa.com?foo=1+2+3"), GURL("bogus URL 1+2+3"), |
- GURL("http://aaaa/?aaaa=1&b=1+2+3&c")}}, |
- {L"www.w w", 2, {GURL(" +%2B?=wfoo "), GURL("weaselwweasel")}}, |
+ {ASCIIToUTF16("aaa 1a2b"), 2, {GURL("http://aaaa/?aaaa=1&b=1a2b&c"), |
+ GURL("1a2b")}}, |
+ {ASCIIToUTF16("a 1 2 3"), 3, {GURL("aa.com?foo=1+2+3"), |
+ GURL("bogus URL 1+2+3"), |
+ GURL("http://aaaa/?aaaa=1&b=1+2+3&c")}}, |
+ {ASCIIToUTF16("www.w w"), 2, {GURL(" +%2B?=wfoo "), |
+ GURL("weaselwweasel")}}, |
}; |
RunTest<GURL>(url_cases, arraysize(url_cases), |
@@ -142,44 +150,51 @@ |
} |
TEST_F(KeywordProviderTest, Contents) { |
- test_data<std::wstring> contents_cases[] = { |
+ test_data<string16> contents_cases[] = { |
// No query input -> substitute "<enter query>" into contents. |
- {L"z", 1, {L"Search z for <enter query>"}}, |
- {L"z \t", 1, {L"Search z for <enter query>"}}, |
+ {ASCIIToUTF16("z"), 1, |
+ {ASCIIToUTF16("Search z for <enter query>")}}, |
+ {ASCIIToUTF16("z \t"), 1, |
+ {ASCIIToUTF16("Search z for <enter query>")}}, |
// Check that tokenization only collapses whitespace between first tokens |
// and contents are not escaped or unescaped. |
- {L"z a b c++", 1, {L"Search z for a b c++"}}, |
- {L"www.www www", 1, {L"Search www for www"}}, |
+ {ASCIIToUTF16("z a b c++"), 1, |
+ {ASCIIToUTF16("Search z for a b c++")}}, |
+ {ASCIIToUTF16("www.www www"), 1, {ASCIIToUTF16("Search www for www")}}, |
// Substitution should work with various locations of the "%s". |
- {L"aaa", 2, {L"Search aaaa for <enter query>", |
- L"Search aaaaa for <enter query>"}}, |
- {L"a 1 2 3", 3, {L"Search aa for 1 2 3", L"Search ab for 1 2 3", |
- L"Search aaaa for 1 2 3"}}, |
- {L"www.w w", 2, {L"Search www for w", L"Search weasel for w"}}, |
+ {ASCIIToUTF16("aaa"), 2, |
+ {ASCIIToUTF16("Search aaaa for <enter query>"), |
+ ASCIIToUTF16("Search aaaaa for <enter query>")}}, |
+ {ASCIIToUTF16("a 1 2 3"), 3, {ASCIIToUTF16("Search aa for 1 2 3"), |
+ ASCIIToUTF16("Search ab for 1 2 3"), |
+ ASCIIToUTF16("Search aaaa for 1 2 3")}}, |
+ {ASCIIToUTF16("www.w w"), 2, {ASCIIToUTF16("Search www for w"), |
+ ASCIIToUTF16("Search weasel for w")}}, |
}; |
- RunTest<std::wstring>(contents_cases, arraysize(contents_cases), |
+ RunTest<string16>(contents_cases, arraysize(contents_cases), |
&AutocompleteMatch::contents); |
} |
TEST_F(KeywordProviderTest, Description) { |
- test_data<std::wstring> description_cases[] = { |
+ test_data<string16> description_cases[] = { |
// Whole keyword should be returned for both exact and inexact matches. |
- {L"z foo", 1, {L"(Keyword: z)"}}, |
- {L"a foo", 3, {L"(Keyword: aa)", L"(Keyword: ab)", |
- L"(Keyword: aaaa)"}}, |
- {L"ftp://www.www w", 0, {}}, |
- {L"http://www.ab w", 1, {L"(Keyword: ab)"}}, |
+ {ASCIIToUTF16("z foo"), 1, {ASCIIToUTF16("(Keyword: z)")}}, |
+ {ASCIIToUTF16("a foo"), 3, {ASCIIToUTF16("(Keyword: aa)"), |
+ ASCIIToUTF16("(Keyword: ab)"), |
+ ASCIIToUTF16("(Keyword: aaaa)")}}, |
+ {ASCIIToUTF16("ftp://www.www w"), 0, {}}, |
+ {ASCIIToUTF16("http://www.ab w"), 1, {ASCIIToUTF16("(Keyword: ab)")}}, |
// Keyword should be returned regardless of query input. |
- {L"z", 1, {L"(Keyword: z)"}}, |
- {L"z \t", 1, {L"(Keyword: z)"}}, |
- {L"z a b c++", 1, {L"(Keyword: z)"}}, |
+ {ASCIIToUTF16("z"), 1, {ASCIIToUTF16("(Keyword: z)")}}, |
+ {ASCIIToUTF16("z \t"), 1, {ASCIIToUTF16("(Keyword: z)")}}, |
+ {ASCIIToUTF16("z a b c++"), 1, {ASCIIToUTF16("(Keyword: z)")}}, |
}; |
- RunTest<std::wstring>(description_cases, arraysize(description_cases), |
+ RunTest<string16>(description_cases, arraysize(description_cases), |
&AutocompleteMatch::description); |
} |