OLD | NEW |
1 // Copyright (c) 2010 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 virtual void TearDown(); | 108 virtual void TearDown(); |
109 | 109 |
110 // Does the real setup. | 110 // Does the real setup. |
111 void SetUpImpl(bool no_db); | 111 void SetUpImpl(bool no_db); |
112 | 112 |
113 // Fills test data into the history system. | 113 // Fills test data into the history system. |
114 void FillData(); | 114 void FillData(); |
115 | 115 |
116 // Runs an autocomplete query on |text| and checks to see that the returned | 116 // Runs an autocomplete query on |text| and checks to see that the returned |
117 // results' destination URLs match those provided. | 117 // results' destination URLs match those provided. |
118 void RunTest(const std::wstring text, | 118 void RunTest(const string16 text, |
119 const std::wstring& desired_tld, | 119 const string16& desired_tld, |
120 bool prevent_inline_autocomplete, | 120 bool prevent_inline_autocomplete, |
121 const std::string* expected_urls, | 121 const std::string* expected_urls, |
122 size_t num_results); | 122 size_t num_results); |
123 | 123 |
124 void RunAdjustOffsetTest(const std::wstring text, size_t expected_offset); | 124 void RunAdjustOffsetTest(const string16 text, size_t expected_offset); |
125 | 125 |
126 MessageLoopForUI message_loop_; | 126 MessageLoopForUI message_loop_; |
127 BrowserThread ui_thread_; | 127 BrowserThread ui_thread_; |
128 BrowserThread file_thread_; | 128 BrowserThread file_thread_; |
129 ACMatches matches_; | 129 ACMatches matches_; |
130 scoped_ptr<TestingProfile> profile_; | 130 scoped_ptr<TestingProfile> profile_; |
131 HistoryService* history_service_; | 131 HistoryService* history_service_; |
132 | 132 |
133 private: | 133 private: |
134 scoped_refptr<HistoryURLProvider> autocomplete_; | 134 scoped_refptr<HistoryURLProvider> autocomplete_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 for (size_t i = 0; i < arraysize(test_db); ++i) { | 173 for (size_t i = 0; i < arraysize(test_db); ++i) { |
174 const TestURLInfo& cur = test_db[i]; | 174 const TestURLInfo& cur = test_db[i]; |
175 const GURL current_url(cur.url); | 175 const GURL current_url(cur.url); |
176 history_service_->AddPageWithDetails(current_url, UTF8ToUTF16(cur.title), | 176 history_service_->AddPageWithDetails(current_url, UTF8ToUTF16(cur.title), |
177 cur.visit_count, cur.typed_count, | 177 cur.visit_count, cur.typed_count, |
178 visit_time, false, | 178 visit_time, false, |
179 history::SOURCE_BROWSED); | 179 history::SOURCE_BROWSED); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 void HistoryURLProviderTest::RunTest(const std::wstring text, | 183 void HistoryURLProviderTest::RunTest(const string16 text, |
184 const std::wstring& desired_tld, | 184 const string16& desired_tld, |
185 bool prevent_inline_autocomplete, | 185 bool prevent_inline_autocomplete, |
186 const std::string* expected_urls, | 186 const std::string* expected_urls, |
187 size_t num_results) { | 187 size_t num_results) { |
188 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, | 188 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, |
189 false, true, false); | 189 false, true, false); |
190 autocomplete_->Start(input, false); | 190 autocomplete_->Start(input, false); |
191 if (!autocomplete_->done()) | 191 if (!autocomplete_->done()) |
192 MessageLoop::current()->Run(); | 192 MessageLoop::current()->Run(); |
193 | 193 |
194 matches_ = autocomplete_->matches(); | 194 matches_ = autocomplete_->matches(); |
195 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 195 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
196 << "\nTLD: \"" << desired_tld << "\""; | 196 << "\nTLD: \"" << desired_tld << "\""; |
197 for (size_t i = 0; i < num_results; ++i) | 197 for (size_t i = 0; i < num_results; ++i) |
198 EXPECT_EQ(expected_urls[i], matches_[i].destination_url.spec()); | 198 EXPECT_EQ(expected_urls[i], matches_[i].destination_url.spec()); |
199 } | 199 } |
200 | 200 |
201 void HistoryURLProviderTest::RunAdjustOffsetTest(const std::wstring text, | 201 void HistoryURLProviderTest::RunAdjustOffsetTest(const string16 text, |
202 size_t expected_offset) { | 202 size_t expected_offset) { |
203 AutocompleteInput input(text, std::wstring(), false, false, true, false); | 203 AutocompleteInput input(text, string16(), false, false, true, false); |
204 autocomplete_->Start(input, false); | 204 autocomplete_->Start(input, false); |
205 if (!autocomplete_->done()) | 205 if (!autocomplete_->done()) |
206 MessageLoop::current()->Run(); | 206 MessageLoop::current()->Run(); |
207 | 207 |
208 matches_ = autocomplete_->matches(); | 208 matches_ = autocomplete_->matches(); |
209 ASSERT_GE(matches_.size(), 1U) << "Input text: " << text; | 209 ASSERT_GE(matches_.size(), 1U) << "Input text: " << text; |
210 EXPECT_EQ(expected_offset, matches_[0].inline_autocomplete_offset); | 210 EXPECT_EQ(expected_offset, matches_[0].inline_autocomplete_offset); |
211 } | 211 } |
212 | 212 |
213 TEST_F(HistoryURLProviderTest, PromoteShorterURLs) { | 213 TEST_F(HistoryURLProviderTest, PromoteShorterURLs) { |
214 // Test that hosts get synthesized below popular pages. | 214 // Test that hosts get synthesized below popular pages. |
215 const std::string expected_nonsynth[] = { | 215 const std::string expected_nonsynth[] = { |
216 "http://slashdot.org/favorite_page.html", | 216 "http://slashdot.org/favorite_page.html", |
217 "http://slashdot.org/", | 217 "http://slashdot.org/", |
218 }; | 218 }; |
219 RunTest(L"slash", std::wstring(), true, expected_nonsynth, | 219 RunTest(ASCIIToUTF16("slash"), string16(), true, expected_nonsynth, |
220 arraysize(expected_nonsynth)); | 220 arraysize(expected_nonsynth)); |
221 | 221 |
222 // Test that hosts get synthesized above less popular pages. | 222 // Test that hosts get synthesized above less popular pages. |
223 const std::string expected_synth[] = { | 223 const std::string expected_synth[] = { |
224 "http://kerneltrap.org/", | 224 "http://kerneltrap.org/", |
225 "http://kerneltrap.org/not_very_popular.html", | 225 "http://kerneltrap.org/not_very_popular.html", |
226 }; | 226 }; |
227 RunTest(L"kernel", std::wstring(), true, expected_synth, | 227 RunTest(ASCIIToUTF16("kernel"), string16(), true, expected_synth, |
228 arraysize(expected_synth)); | 228 arraysize(expected_synth)); |
229 | 229 |
230 // Test that unpopular pages are ignored completely. | 230 // Test that unpopular pages are ignored completely. |
231 RunTest(L"fresh", std::wstring(), true, NULL, 0); | 231 RunTest(ASCIIToUTF16("fresh"), string16(), true, NULL, 0); |
232 | 232 |
233 // Test that if we have a synthesized host that matches a suggestion, they | 233 // Test that if we have a synthesized host that matches a suggestion, they |
234 // get combined into one. | 234 // get combined into one. |
235 const std::string expected_combine[] = { | 235 const std::string expected_combine[] = { |
236 "http://news.google.com/", | 236 "http://news.google.com/", |
237 "http://news.google.com/?ned=us&topic=n", | 237 "http://news.google.com/?ned=us&topic=n", |
238 }; | 238 }; |
239 ASSERT_NO_FATAL_FAILURE(RunTest(L"news", std::wstring(), true, | 239 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("news"), string16(), true, |
240 expected_combine, arraysize(expected_combine))); | 240 expected_combine, arraysize(expected_combine))); |
241 // The title should also have gotten set properly on the host for the | 241 // The title should also have gotten set properly on the host for the |
242 // synthesized one, since it was also in the results. | 242 // synthesized one, since it was also in the results. |
243 EXPECT_EQ(std::wstring(L"Google News"), matches_.front().description); | 243 EXPECT_EQ(ASCIIToUTF16("Google News"), matches_.front().description); |
244 | 244 |
245 // Test that short URL matching works correctly as the user types more | 245 // Test that short URL matching works correctly as the user types more |
246 // (several tests): | 246 // (several tests): |
247 // The entry for foo.com is the best of all five foo.com* entries. | 247 // The entry for foo.com is the best of all five foo.com* entries. |
248 const std::string short_1[] = { | 248 const std::string short_1[] = { |
249 "http://foo.com/", | 249 "http://foo.com/", |
250 "http://foo.com/dir/another/again/myfile.html", | 250 "http://foo.com/dir/another/again/myfile.html", |
251 "http://foo.com/dir/", | 251 "http://foo.com/dir/", |
252 }; | 252 }; |
253 RunTest(L"foo", std::wstring(), true, short_1, arraysize(short_1)); | 253 RunTest(ASCIIToUTF16("foo"), string16(), true, short_1, arraysize(short_1)); |
254 | 254 |
255 // When the user types the whole host, make sure we don't get two results for | 255 // When the user types the whole host, make sure we don't get two results for |
256 // it. | 256 // it. |
257 const std::string short_2[] = { | 257 const std::string short_2[] = { |
258 "http://foo.com/", | 258 "http://foo.com/", |
259 "http://foo.com/dir/another/again/myfile.html", | 259 "http://foo.com/dir/another/again/myfile.html", |
260 "http://foo.com/dir/", | 260 "http://foo.com/dir/", |
261 "http://foo.com/dir/another/", | 261 "http://foo.com/dir/another/", |
262 }; | 262 }; |
263 RunTest(L"foo.com", std::wstring(), true, short_2, arraysize(short_2)); | 263 RunTest(ASCIIToUTF16("foo.com"), string16(), true, short_2, |
264 RunTest(L"foo.com/", std::wstring(), true, short_2, arraysize(short_2)); | 264 arraysize(short_2)); |
| 265 RunTest(ASCIIToUTF16("foo.com/"), string16(), true, short_2, |
| 266 arraysize(short_2)); |
265 | 267 |
266 // The filename is the second best of the foo.com* entries, but there is a | 268 // The filename is the second best of the foo.com* entries, but there is a |
267 // shorter URL that's "good enough". The host doesn't match the user input | 269 // shorter URL that's "good enough". The host doesn't match the user input |
268 // and so should not appear. | 270 // and so should not appear. |
269 const std::string short_3[] = { | 271 const std::string short_3[] = { |
270 "http://foo.com/d", | 272 "http://foo.com/d", |
271 "http://foo.com/dir/another/", | 273 "http://foo.com/dir/another/", |
272 "http://foo.com/dir/another/again/myfile.html", | 274 "http://foo.com/dir/another/again/myfile.html", |
273 "http://foo.com/dir/", | 275 "http://foo.com/dir/", |
274 }; | 276 }; |
275 RunTest(L"foo.com/d", std::wstring(), true, short_3, arraysize(short_3)); | 277 RunTest(ASCIIToUTF16("foo.com/d"), string16(), true, short_3, |
| 278 arraysize(short_3)); |
276 | 279 |
277 // We shouldn't promote shorter URLs than the best if they're not good | 280 // We shouldn't promote shorter URLs than the best if they're not good |
278 // enough. | 281 // enough. |
279 const std::string short_4[] = { | 282 const std::string short_4[] = { |
280 "http://foo.com/dir/another/a", | 283 "http://foo.com/dir/another/a", |
281 "http://foo.com/dir/another/again/myfile.html", | 284 "http://foo.com/dir/another/again/myfile.html", |
282 "http://foo.com/dir/another/again/", | 285 "http://foo.com/dir/another/again/", |
283 }; | 286 }; |
284 RunTest(L"foo.com/dir/another/a", std::wstring(), true, short_4, | 287 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4, |
285 arraysize(short_4)); | 288 arraysize(short_4)); |
286 | 289 |
287 // Exact matches should always be best no matter how much more another match | 290 // Exact matches should always be best no matter how much more another match |
288 // has been typed. | 291 // has been typed. |
289 const std::string short_5a[] = { | 292 const std::string short_5a[] = { |
290 "http://gooey/", | 293 "http://gooey/", |
291 "http://www.google.com/", | 294 "http://www.google.com/", |
292 }; | 295 }; |
293 const std::string short_5b[] = { | 296 const std::string short_5b[] = { |
294 "http://go/", | 297 "http://go/", |
295 "http://gooey/", | 298 "http://gooey/", |
296 "http://www.google.com/", | 299 "http://www.google.com/", |
297 }; | 300 }; |
298 RunTest(L"g", std::wstring(), false, short_5a, arraysize(short_5a)); | 301 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a)); |
299 RunTest(L"go", std::wstring(), false, short_5b, arraysize(short_5b)); | 302 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b)); |
300 } | 303 } |
301 | 304 |
302 TEST_F(HistoryURLProviderTest, CullRedirects) { | 305 TEST_F(HistoryURLProviderTest, CullRedirects) { |
303 // URLs we will be using, plus the visit counts they will initially get | 306 // URLs we will be using, plus the visit counts they will initially get |
304 // (the redirect set below will also increment the visit counts). We want | 307 // (the redirect set below will also increment the visit counts). We want |
305 // the results to be in A,B,C order. Note also that our visit counts are | 308 // the results to be in A,B,C order. Note also that our visit counts are |
306 // all high enough so that domain synthesizing won't get triggered. | 309 // all high enough so that domain synthesizing won't get triggered. |
307 struct RedirectCase { | 310 struct RedirectCase { |
308 const char* url; | 311 const char* url; |
309 int count; | 312 int count; |
(...skipping 19 matching lines...) Expand all Loading... |
329 redirects_to_a.push_back(GURL(redirect[1].url)); | 332 redirects_to_a.push_back(GURL(redirect[1].url)); |
330 redirects_to_a.push_back(GURL(redirect[2].url)); | 333 redirects_to_a.push_back(GURL(redirect[2].url)); |
331 redirects_to_a.push_back(GURL(redirect[0].url)); | 334 redirects_to_a.push_back(GURL(redirect[0].url)); |
332 history_service_->AddPage(GURL(redirect[0].url), NULL, 0, GURL(), | 335 history_service_->AddPage(GURL(redirect[0].url), NULL, 0, GURL(), |
333 PageTransition::TYPED, redirects_to_a, | 336 PageTransition::TYPED, redirects_to_a, |
334 history::SOURCE_BROWSED, true); | 337 history::SOURCE_BROWSED, true); |
335 | 338 |
336 // Because all the results are part of a redirect chain with other results, | 339 // Because all the results are part of a redirect chain with other results, |
337 // all but the first one (A) should be culled. We should get the default | 340 // all but the first one (A) should be culled. We should get the default |
338 // "what you typed" result, plus this one. | 341 // "what you typed" result, plus this one. |
339 const std::wstring typing(L"http://redirects/"); | 342 const string16 typing(ASCIIToUTF16("http://redirects/")); |
340 const std::string expected_results[] = { | 343 const std::string expected_results[] = { |
341 WideToUTF8(typing), | 344 UTF16ToUTF8(typing), |
342 redirect[0].url}; | 345 redirect[0].url}; |
343 RunTest(typing, std::wstring(), true, expected_results, | 346 RunTest(typing, string16(), true, expected_results, |
344 arraysize(expected_results)); | 347 arraysize(expected_results)); |
345 } | 348 } |
346 | 349 |
347 TEST_F(HistoryURLProviderTest, WhatYouTyped) { | 350 TEST_F(HistoryURLProviderTest, WhatYouTyped) { |
348 // Make sure we suggest a What You Typed match at the right times. | 351 // Make sure we suggest a What You Typed match at the right times. |
349 RunTest(L"wytmatch", std::wstring(), false, NULL, 0); | 352 RunTest(ASCIIToUTF16("wytmatch"), string16(), false, NULL, 0); |
350 RunTest(L"wytmatch foo bar", std::wstring(), false, NULL, 0); | 353 RunTest(ASCIIToUTF16("wytmatch foo bar"), string16(), false, NULL, 0); |
351 RunTest(L"wytmatch+foo+bar", std::wstring(), false, NULL, 0); | 354 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), string16(), false, NULL, 0); |
352 RunTest(L"wytmatch+foo+bar.com", std::wstring(), false, NULL, 0); | 355 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), string16(), false, NULL, 0); |
353 | 356 |
354 const std::string results_1[] = {"http://www.wytmatch.com/"}; | 357 const std::string results_1[] = {"http://www.wytmatch.com/"}; |
355 RunTest(L"wytmatch", L"com", false, results_1, arraysize(results_1)); | 358 RunTest(ASCIIToUTF16("wytmatch"), ASCIIToUTF16("com"), false, results_1, |
| 359 arraysize(results_1)); |
356 | 360 |
357 const std::string results_2[] = {"http://wytmatch%20foo%20bar/"}; | 361 const std::string results_2[] = {"http://wytmatch%20foo%20bar/"}; |
358 RunTest(L"http://wytmatch foo bar", std::wstring(), false, results_2, | 362 RunTest(ASCIIToUTF16("http://wytmatch foo bar"), string16(), false, results_2, |
359 arraysize(results_2)); | 363 arraysize(results_2)); |
360 | 364 |
361 const std::string results_3[] = {"https://wytmatch%20foo%20bar/"}; | 365 const std::string results_3[] = {"https://wytmatch%20foo%20bar/"}; |
362 RunTest(L"https://wytmatch foo bar", std::wstring(), false, results_3, | 366 RunTest(ASCIIToUTF16("https://wytmatch foo bar"), string16(), false, |
363 arraysize(results_3)); | 367 results_3, arraysize(results_3)); |
364 | 368 |
365 // Test the corner case where a user has fully typed a previously visited | 369 // Test the corner case where a user has fully typed a previously visited |
366 // intranet address and is now hitting ctrl-enter, which completes to a | 370 // intranet address and is now hitting ctrl-enter, which completes to a |
367 // previously unvisted internet domain. | 371 // previously unvisted internet domain. |
368 const std::string binky_results[] = {"http://binky/"}; | 372 const std::string binky_results[] = {"http://binky/"}; |
369 const std::string binky_com_results[] = { | 373 const std::string binky_com_results[] = { |
370 "http://www.binky.com/", | 374 "http://www.binky.com/", |
371 "http://binky/", | 375 "http://binky/", |
372 }; | 376 }; |
373 RunTest(L"binky", std::wstring(), false, binky_results, | 377 RunTest(ASCIIToUTF16("binky"), string16(), false, binky_results, |
374 arraysize(binky_results)); | 378 arraysize(binky_results)); |
375 RunTest(L"binky", L"com", false, binky_com_results, | 379 RunTest(ASCIIToUTF16("binky"), ASCIIToUTF16("com"), false, binky_com_results, |
376 arraysize(binky_com_results)); | 380 arraysize(binky_com_results)); |
377 | 381 |
378 // Test the related case where a user has fully typed a previously visited | 382 // Test the related case where a user has fully typed a previously visited |
379 // intranet address and is now hitting ctrl-enter, which completes to a | 383 // intranet address and is now hitting ctrl-enter, which completes to a |
380 // previously visted internet domain. | 384 // previously visted internet domain. |
381 const std::string winky_results[] = { | 385 const std::string winky_results[] = { |
382 "http://winky/", | 386 "http://winky/", |
383 "http://www.winky.com/", | 387 "http://www.winky.com/", |
384 }; | 388 }; |
385 const std::string winky_com_results[] = { | 389 const std::string winky_com_results[] = { |
386 "http://www.winky.com/", | 390 "http://www.winky.com/", |
387 "http://winky/", | 391 "http://winky/", |
388 }; | 392 }; |
389 RunTest(L"winky", std::wstring(), false, winky_results, | 393 RunTest(ASCIIToUTF16("winky"), string16(), false, winky_results, |
390 arraysize(winky_results)); | 394 arraysize(winky_results)); |
391 RunTest(L"winky", L"com", false, winky_com_results, | 395 RunTest(ASCIIToUTF16("winky"), ASCIIToUTF16("com"), false, winky_com_results, |
392 arraysize(winky_com_results)); | 396 arraysize(winky_com_results)); |
393 } | 397 } |
394 | 398 |
395 TEST_F(HistoryURLProviderTest, Fixup) { | 399 TEST_F(HistoryURLProviderTest, Fixup) { |
396 // Test for various past crashes we've had. | 400 // Test for various past crashes we've had. |
397 RunTest(L"\\", std::wstring(), false, NULL, 0); | 401 RunTest(ASCIIToUTF16("\\"), string16(), false, NULL, 0); |
398 RunTest(L"#", std::wstring(), false, NULL, 0); | 402 RunTest(ASCIIToUTF16("#"), string16(), false, NULL, 0); |
399 RunTest(L"%20", std::wstring(), false, NULL, 0); | 403 RunTest(ASCIIToUTF16("%20"), string16(), false, NULL, 0); |
400 RunTest(L"\uff65@s", std::wstring(), false, NULL, 0); | 404 RunTest(WideToUTF16(L"\uff65@s"), string16(), false, NULL, 0); |
401 RunTest(L"\u2015\u2015@ \uff7c", std::wstring(), false, NULL, 0); | 405 RunTest(WideToUTF16(L"\u2015\u2015@ \uff7c"), string16(), false, NULL, 0); |
402 | 406 |
403 // Fixing up "file:" should result in an inline autocomplete offset of just | 407 // Fixing up "file:" should result in an inline autocomplete offset of just |
404 // after "file:", not just after "file://". | 408 // after "file:", not just after "file://". |
405 const std::wstring input_1(L"file:"); | 409 const string16 input_1(ASCIIToUTF16("file:")); |
406 const std::string fixup_1[] = {"file:///C:/foo.txt"}; | 410 const std::string fixup_1[] = {"file:///C:/foo.txt"}; |
407 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, std::wstring(), false, fixup_1, | 411 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, string16(), false, fixup_1, |
408 arraysize(fixup_1))); | 412 arraysize(fixup_1))); |
409 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); | 413 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); |
410 | 414 |
411 // Fixing up "http:/" should result in an inline autocomplete offset of just | 415 // Fixing up "http:/" should result in an inline autocomplete offset of just |
412 // after "http:/", not just after "http:". | 416 // after "http:/", not just after "http:". |
413 const std::wstring input_2(L"http:/"); | 417 const string16 input_2(ASCIIToUTF16("http:/")); |
414 const std::string fixup_2[] = { | 418 const std::string fixup_2[] = { |
415 "http://bogussite.com/a", | 419 "http://bogussite.com/a", |
416 "http://bogussite.com/b", | 420 "http://bogussite.com/b", |
417 "http://bogussite.com/c", | 421 "http://bogussite.com/c", |
418 }; | 422 }; |
419 ASSERT_NO_FATAL_FAILURE(RunTest(input_2, std::wstring(), false, fixup_2, | 423 ASSERT_NO_FATAL_FAILURE(RunTest(input_2, string16(), false, fixup_2, |
420 arraysize(fixup_2))); | 424 arraysize(fixup_2))); |
421 EXPECT_EQ(input_2.length(), matches_.front().inline_autocomplete_offset); | 425 EXPECT_EQ(input_2.length(), matches_.front().inline_autocomplete_offset); |
422 | 426 |
423 // Adding a TLD to a small number like "56" should result in "www.56.com" | 427 // Adding a TLD to a small number like "56" should result in "www.56.com" |
424 // rather than "0.0.0.56.com". | 428 // rather than "0.0.0.56.com". |
425 const std::string fixup_3[] = {"http://www.56.com/"}; | 429 const std::string fixup_3[] = {"http://www.56.com/"}; |
426 RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3)); | 430 RunTest(ASCIIToUTF16("56"), ASCIIToUTF16("com"), true, fixup_3, |
| 431 arraysize(fixup_3)); |
427 | 432 |
428 // An input looks like a IP address like "127.0.0.1" should result in | 433 // An input looks like a IP address like "127.0.0.1" should result in |
429 // "http://127.0.0.1/". | 434 // "http://127.0.0.1/". |
430 const std::string fixup_4[] = {"http://127.0.0.1/"}; | 435 const std::string fixup_4[] = {"http://127.0.0.1/"}; |
431 RunTest(L"127.0.0.1", std::wstring(), false, fixup_4, arraysize(fixup_4)); | 436 RunTest(ASCIIToUTF16("127.0.0.1"), string16(), false, fixup_4, |
| 437 arraysize(fixup_4)); |
432 | 438 |
433 // An number "17173" should result in "http://www.17173.com/" in db. | 439 // An number "17173" should result in "http://www.17173.com/" in db. |
434 const std::string fixup_5[] = {"http://www.17173.com/"}; | 440 const std::string fixup_5[] = {"http://www.17173.com/"}; |
435 RunTest(L"17173", std::wstring(), false, fixup_5, arraysize(fixup_5)); | 441 RunTest(ASCIIToUTF16("17173"), string16(), false, fixup_5, |
| 442 arraysize(fixup_5)); |
436 } | 443 } |
437 | 444 |
438 TEST_F(HistoryURLProviderTest, AdjustOffset) { | 445 TEST_F(HistoryURLProviderTest, AdjustOffset) { |
439 RunAdjustOffsetTest(L"http://www.\uAD50\uC721", 13); | 446 RunAdjustOffsetTest(WideToUTF16(L"http://www.\uAD50\uC721"), 13); |
440 RunAdjustOffsetTest(L"http://spaces.com/path%20with%20spa", 31); | 447 RunAdjustOffsetTest(ASCIIToUTF16("http://spaces.com/path%20with%20spa"), 31); |
441 RunAdjustOffsetTest(L"http://ms/c++ s", 15); | 448 RunAdjustOffsetTest(ASCIIToUTF16("http://ms/c++ s"), 15); |
442 } | 449 } |
443 | 450 |
444 TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { | 451 TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { |
445 // Ensure that we will still produce matches for navigation when there is no | 452 // Ensure that we will still produce matches for navigation when there is no |
446 // database. | 453 // database. |
447 std::string navigation_1[] = {"http://test.com/"}; | 454 std::string navigation_1[] = {"http://test.com/"}; |
448 RunTest(L"test.com", std::wstring(), false, navigation_1, | 455 RunTest(ASCIIToUTF16("test.com"), string16(), false, navigation_1, |
449 arraysize(navigation_1)); | 456 arraysize(navigation_1)); |
450 | 457 |
451 std::string navigation_2[] = {"http://slash/"}; | 458 std::string navigation_2[] = {"http://slash/"}; |
452 RunTest(L"slash", std::wstring(), false, navigation_2, | 459 RunTest(ASCIIToUTF16("slash"), string16(), false, navigation_2, |
453 arraysize(navigation_2)); | 460 arraysize(navigation_2)); |
454 | 461 |
455 RunTest(L"this is a query", std::wstring(), false, NULL, 0); | 462 RunTest(ASCIIToUTF16("this is a query"), string16(), false, NULL, 0); |
456 } | 463 } |
OLD | NEW |