| 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 string16 text, | 118 void RunTest(const std::wstring text, |
| 119 const string16& desired_tld, | 119 const std::wstring& 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 string16 text, size_t expected_offset); | 124 void RunAdjustOffsetTest(const std::wstring 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 string16 text, | 183 void HistoryURLProviderTest::RunTest(const std::wstring text, |
| 184 const string16& desired_tld, | 184 const std::wstring& 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 string16 text, | 201 void HistoryURLProviderTest::RunAdjustOffsetTest(const std::wstring text, |
| 202 size_t expected_offset) { | 202 size_t expected_offset) { |
| 203 AutocompleteInput input(text, string16(), false, false, true, false); | 203 AutocompleteInput input(text, std::wstring(), 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(ASCIIToUTF16("slash"), string16(), true, expected_nonsynth, | 219 RunTest(L"slash", std::wstring(), 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(ASCIIToUTF16("kernel"), string16(), true, expected_synth, | 227 RunTest(L"kernel", std::wstring(), 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(ASCIIToUTF16("fresh"), string16(), true, NULL, 0); | 231 RunTest(L"fresh", std::wstring(), 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(ASCIIToUTF16("news"), string16(), true, | 239 ASSERT_NO_FATAL_FAILURE(RunTest(L"news", std::wstring(), 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(ASCIIToUTF16("Google News"), matches_.front().description); | 243 EXPECT_EQ(std::wstring(L"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(ASCIIToUTF16("foo"), string16(), true, short_1, arraysize(short_1)); | 253 RunTest(L"foo", std::wstring(), 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(ASCIIToUTF16("foo.com"), string16(), true, short_2, | 263 RunTest(L"foo.com", std::wstring(), true, short_2, arraysize(short_2)); |
| 264 arraysize(short_2)); | 264 RunTest(L"foo.com/", std::wstring(), true, short_2, arraysize(short_2)); |
| 265 RunTest(ASCIIToUTF16("foo.com/"), string16(), true, short_2, | |
| 266 arraysize(short_2)); | |
| 267 | 265 |
| 268 // The filename is the second best of the foo.com* entries, but there is a | 266 // The filename is the second best of the foo.com* entries, but there is a |
| 269 // shorter URL that's "good enough". The host doesn't match the user input | 267 // shorter URL that's "good enough". The host doesn't match the user input |
| 270 // and so should not appear. | 268 // and so should not appear. |
| 271 const std::string short_3[] = { | 269 const std::string short_3[] = { |
| 272 "http://foo.com/d", | 270 "http://foo.com/d", |
| 273 "http://foo.com/dir/another/", | 271 "http://foo.com/dir/another/", |
| 274 "http://foo.com/dir/another/again/myfile.html", | 272 "http://foo.com/dir/another/again/myfile.html", |
| 275 "http://foo.com/dir/", | 273 "http://foo.com/dir/", |
| 276 }; | 274 }; |
| 277 RunTest(ASCIIToUTF16("foo.com/d"), string16(), true, short_3, | 275 RunTest(L"foo.com/d", std::wstring(), true, short_3, arraysize(short_3)); |
| 278 arraysize(short_3)); | |
| 279 | 276 |
| 280 // We shouldn't promote shorter URLs than the best if they're not good | 277 // We shouldn't promote shorter URLs than the best if they're not good |
| 281 // enough. | 278 // enough. |
| 282 const std::string short_4[] = { | 279 const std::string short_4[] = { |
| 283 "http://foo.com/dir/another/a", | 280 "http://foo.com/dir/another/a", |
| 284 "http://foo.com/dir/another/again/myfile.html", | 281 "http://foo.com/dir/another/again/myfile.html", |
| 285 "http://foo.com/dir/another/again/", | 282 "http://foo.com/dir/another/again/", |
| 286 }; | 283 }; |
| 287 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4, | 284 RunTest(L"foo.com/dir/another/a", std::wstring(), true, short_4, |
| 288 arraysize(short_4)); | 285 arraysize(short_4)); |
| 289 | 286 |
| 290 // Exact matches should always be best no matter how much more another match | 287 // Exact matches should always be best no matter how much more another match |
| 291 // has been typed. | 288 // has been typed. |
| 292 const std::string short_5a[] = { | 289 const std::string short_5a[] = { |
| 293 "http://gooey/", | 290 "http://gooey/", |
| 294 "http://www.google.com/", | 291 "http://www.google.com/", |
| 295 }; | 292 }; |
| 296 const std::string short_5b[] = { | 293 const std::string short_5b[] = { |
| 297 "http://go/", | 294 "http://go/", |
| 298 "http://gooey/", | 295 "http://gooey/", |
| 299 "http://www.google.com/", | 296 "http://www.google.com/", |
| 300 }; | 297 }; |
| 301 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a)); | 298 RunTest(L"g", std::wstring(), false, short_5a, arraysize(short_5a)); |
| 302 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b)); | 299 RunTest(L"go", std::wstring(), false, short_5b, arraysize(short_5b)); |
| 303 } | 300 } |
| 304 | 301 |
| 305 TEST_F(HistoryURLProviderTest, CullRedirects) { | 302 TEST_F(HistoryURLProviderTest, CullRedirects) { |
| 306 // URLs we will be using, plus the visit counts they will initially get | 303 // URLs we will be using, plus the visit counts they will initially get |
| 307 // (the redirect set below will also increment the visit counts). We want | 304 // (the redirect set below will also increment the visit counts). We want |
| 308 // the results to be in A,B,C order. Note also that our visit counts are | 305 // the results to be in A,B,C order. Note also that our visit counts are |
| 309 // all high enough so that domain synthesizing won't get triggered. | 306 // all high enough so that domain synthesizing won't get triggered. |
| 310 struct RedirectCase { | 307 struct RedirectCase { |
| 311 const char* url; | 308 const char* url; |
| 312 int count; | 309 int count; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 332 redirects_to_a.push_back(GURL(redirect[1].url)); | 329 redirects_to_a.push_back(GURL(redirect[1].url)); |
| 333 redirects_to_a.push_back(GURL(redirect[2].url)); | 330 redirects_to_a.push_back(GURL(redirect[2].url)); |
| 334 redirects_to_a.push_back(GURL(redirect[0].url)); | 331 redirects_to_a.push_back(GURL(redirect[0].url)); |
| 335 history_service_->AddPage(GURL(redirect[0].url), NULL, 0, GURL(), | 332 history_service_->AddPage(GURL(redirect[0].url), NULL, 0, GURL(), |
| 336 PageTransition::TYPED, redirects_to_a, | 333 PageTransition::TYPED, redirects_to_a, |
| 337 history::SOURCE_BROWSED, true); | 334 history::SOURCE_BROWSED, true); |
| 338 | 335 |
| 339 // Because all the results are part of a redirect chain with other results, | 336 // Because all the results are part of a redirect chain with other results, |
| 340 // all but the first one (A) should be culled. We should get the default | 337 // all but the first one (A) should be culled. We should get the default |
| 341 // "what you typed" result, plus this one. | 338 // "what you typed" result, plus this one. |
| 342 const string16 typing(ASCIIToUTF16("http://redirects/")); | 339 const std::wstring typing(L"http://redirects/"); |
| 343 const std::string expected_results[] = { | 340 const std::string expected_results[] = { |
| 344 UTF16ToUTF8(typing), | 341 WideToUTF8(typing), |
| 345 redirect[0].url}; | 342 redirect[0].url}; |
| 346 RunTest(typing, string16(), true, expected_results, | 343 RunTest(typing, std::wstring(), true, expected_results, |
| 347 arraysize(expected_results)); | 344 arraysize(expected_results)); |
| 348 } | 345 } |
| 349 | 346 |
| 350 TEST_F(HistoryURLProviderTest, WhatYouTyped) { | 347 TEST_F(HistoryURLProviderTest, WhatYouTyped) { |
| 351 // Make sure we suggest a What You Typed match at the right times. | 348 // Make sure we suggest a What You Typed match at the right times. |
| 352 RunTest(ASCIIToUTF16("wytmatch"), string16(), false, NULL, 0); | 349 RunTest(L"wytmatch", std::wstring(), false, NULL, 0); |
| 353 RunTest(ASCIIToUTF16("wytmatch foo bar"), string16(), false, NULL, 0); | 350 RunTest(L"wytmatch foo bar", std::wstring(), false, NULL, 0); |
| 354 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), string16(), false, NULL, 0); | 351 RunTest(L"wytmatch+foo+bar", std::wstring(), false, NULL, 0); |
| 355 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), string16(), false, NULL, 0); | 352 RunTest(L"wytmatch+foo+bar.com", std::wstring(), false, NULL, 0); |
| 356 | 353 |
| 357 const std::string results_1[] = {"http://www.wytmatch.com/"}; | 354 const std::string results_1[] = {"http://www.wytmatch.com/"}; |
| 358 RunTest(ASCIIToUTF16("wytmatch"), ASCIIToUTF16("com"), false, results_1, | 355 RunTest(L"wytmatch", L"com", false, results_1, arraysize(results_1)); |
| 359 arraysize(results_1)); | |
| 360 | 356 |
| 361 const std::string results_2[] = {"http://wytmatch%20foo%20bar/"}; | 357 const std::string results_2[] = {"http://wytmatch%20foo%20bar/"}; |
| 362 RunTest(ASCIIToUTF16("http://wytmatch foo bar"), string16(), false, results_2, | 358 RunTest(L"http://wytmatch foo bar", std::wstring(), false, results_2, |
| 363 arraysize(results_2)); | 359 arraysize(results_2)); |
| 364 | 360 |
| 365 const std::string results_3[] = {"https://wytmatch%20foo%20bar/"}; | 361 const std::string results_3[] = {"https://wytmatch%20foo%20bar/"}; |
| 366 RunTest(ASCIIToUTF16("https://wytmatch foo bar"), string16(), false, | 362 RunTest(L"https://wytmatch foo bar", std::wstring(), false, results_3, |
| 367 results_3, arraysize(results_3)); | 363 arraysize(results_3)); |
| 368 | 364 |
| 369 // Test the corner case where a user has fully typed a previously visited | 365 // Test the corner case where a user has fully typed a previously visited |
| 370 // intranet address and is now hitting ctrl-enter, which completes to a | 366 // intranet address and is now hitting ctrl-enter, which completes to a |
| 371 // previously unvisted internet domain. | 367 // previously unvisted internet domain. |
| 372 const std::string binky_results[] = {"http://binky/"}; | 368 const std::string binky_results[] = {"http://binky/"}; |
| 373 const std::string binky_com_results[] = { | 369 const std::string binky_com_results[] = { |
| 374 "http://www.binky.com/", | 370 "http://www.binky.com/", |
| 375 "http://binky/", | 371 "http://binky/", |
| 376 }; | 372 }; |
| 377 RunTest(ASCIIToUTF16("binky"), string16(), false, binky_results, | 373 RunTest(L"binky", std::wstring(), false, binky_results, |
| 378 arraysize(binky_results)); | 374 arraysize(binky_results)); |
| 379 RunTest(ASCIIToUTF16("binky"), ASCIIToUTF16("com"), false, binky_com_results, | 375 RunTest(L"binky", L"com", false, binky_com_results, |
| 380 arraysize(binky_com_results)); | 376 arraysize(binky_com_results)); |
| 381 | 377 |
| 382 // Test the related case where a user has fully typed a previously visited | 378 // Test the related case where a user has fully typed a previously visited |
| 383 // intranet address and is now hitting ctrl-enter, which completes to a | 379 // intranet address and is now hitting ctrl-enter, which completes to a |
| 384 // previously visted internet domain. | 380 // previously visted internet domain. |
| 385 const std::string winky_results[] = { | 381 const std::string winky_results[] = { |
| 386 "http://winky/", | 382 "http://winky/", |
| 387 "http://www.winky.com/", | 383 "http://www.winky.com/", |
| 388 }; | 384 }; |
| 389 const std::string winky_com_results[] = { | 385 const std::string winky_com_results[] = { |
| 390 "http://www.winky.com/", | 386 "http://www.winky.com/", |
| 391 "http://winky/", | 387 "http://winky/", |
| 392 }; | 388 }; |
| 393 RunTest(ASCIIToUTF16("winky"), string16(), false, winky_results, | 389 RunTest(L"winky", std::wstring(), false, winky_results, |
| 394 arraysize(winky_results)); | 390 arraysize(winky_results)); |
| 395 RunTest(ASCIIToUTF16("winky"), ASCIIToUTF16("com"), false, winky_com_results, | 391 RunTest(L"winky", L"com", false, winky_com_results, |
| 396 arraysize(winky_com_results)); | 392 arraysize(winky_com_results)); |
| 397 } | 393 } |
| 398 | 394 |
| 399 TEST_F(HistoryURLProviderTest, Fixup) { | 395 TEST_F(HistoryURLProviderTest, Fixup) { |
| 400 // Test for various past crashes we've had. | 396 // Test for various past crashes we've had. |
| 401 RunTest(ASCIIToUTF16("\\"), string16(), false, NULL, 0); | 397 RunTest(L"\\", std::wstring(), false, NULL, 0); |
| 402 RunTest(ASCIIToUTF16("#"), string16(), false, NULL, 0); | 398 RunTest(L"#", std::wstring(), false, NULL, 0); |
| 403 RunTest(ASCIIToUTF16("%20"), string16(), false, NULL, 0); | 399 RunTest(L"%20", std::wstring(), false, NULL, 0); |
| 404 RunTest(WideToUTF16(L"\uff65@s"), string16(), false, NULL, 0); | 400 RunTest(L"\uff65@s", std::wstring(), false, NULL, 0); |
| 405 RunTest(WideToUTF16(L"\u2015\u2015@ \uff7c"), string16(), false, NULL, 0); | 401 RunTest(L"\u2015\u2015@ \uff7c", std::wstring(), false, NULL, 0); |
| 406 | 402 |
| 407 // Fixing up "file:" should result in an inline autocomplete offset of just | 403 // Fixing up "file:" should result in an inline autocomplete offset of just |
| 408 // after "file:", not just after "file://". | 404 // after "file:", not just after "file://". |
| 409 const string16 input_1(ASCIIToUTF16("file:")); | 405 const std::wstring input_1(L"file:"); |
| 410 const std::string fixup_1[] = {"file:///C:/foo.txt"}; | 406 const std::string fixup_1[] = {"file:///C:/foo.txt"}; |
| 411 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, string16(), false, fixup_1, | 407 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, std::wstring(), false, fixup_1, |
| 412 arraysize(fixup_1))); | 408 arraysize(fixup_1))); |
| 413 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); | 409 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); |
| 414 | 410 |
| 415 // Fixing up "http:/" should result in an inline autocomplete offset of just | 411 // Fixing up "http:/" should result in an inline autocomplete offset of just |
| 416 // after "http:/", not just after "http:". | 412 // after "http:/", not just after "http:". |
| 417 const string16 input_2(ASCIIToUTF16("http:/")); | 413 const std::wstring input_2(L"http:/"); |
| 418 const std::string fixup_2[] = { | 414 const std::string fixup_2[] = { |
| 419 "http://bogussite.com/a", | 415 "http://bogussite.com/a", |
| 420 "http://bogussite.com/b", | 416 "http://bogussite.com/b", |
| 421 "http://bogussite.com/c", | 417 "http://bogussite.com/c", |
| 422 }; | 418 }; |
| 423 ASSERT_NO_FATAL_FAILURE(RunTest(input_2, string16(), false, fixup_2, | 419 ASSERT_NO_FATAL_FAILURE(RunTest(input_2, std::wstring(), false, fixup_2, |
| 424 arraysize(fixup_2))); | 420 arraysize(fixup_2))); |
| 425 EXPECT_EQ(input_2.length(), matches_.front().inline_autocomplete_offset); | 421 EXPECT_EQ(input_2.length(), matches_.front().inline_autocomplete_offset); |
| 426 | 422 |
| 427 // Adding a TLD to a small number like "56" should result in "www.56.com" | 423 // Adding a TLD to a small number like "56" should result in "www.56.com" |
| 428 // rather than "0.0.0.56.com". | 424 // rather than "0.0.0.56.com". |
| 429 const std::string fixup_3[] = {"http://www.56.com/"}; | 425 const std::string fixup_3[] = {"http://www.56.com/"}; |
| 430 RunTest(ASCIIToUTF16("56"), ASCIIToUTF16("com"), true, fixup_3, | 426 RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3)); |
| 431 arraysize(fixup_3)); | |
| 432 | 427 |
| 433 // An input looks like a IP address like "127.0.0.1" should result in | 428 // An input looks like a IP address like "127.0.0.1" should result in |
| 434 // "http://127.0.0.1/". | 429 // "http://127.0.0.1/". |
| 435 const std::string fixup_4[] = {"http://127.0.0.1/"}; | 430 const std::string fixup_4[] = {"http://127.0.0.1/"}; |
| 436 RunTest(ASCIIToUTF16("127.0.0.1"), string16(), false, fixup_4, | 431 RunTest(L"127.0.0.1", std::wstring(), false, fixup_4, arraysize(fixup_4)); |
| 437 arraysize(fixup_4)); | |
| 438 | 432 |
| 439 // An number "17173" should result in "http://www.17173.com/" in db. | 433 // An number "17173" should result in "http://www.17173.com/" in db. |
| 440 const std::string fixup_5[] = {"http://www.17173.com/"}; | 434 const std::string fixup_5[] = {"http://www.17173.com/"}; |
| 441 RunTest(ASCIIToUTF16("17173"), string16(), false, fixup_5, | 435 RunTest(L"17173", std::wstring(), false, fixup_5, arraysize(fixup_5)); |
| 442 arraysize(fixup_5)); | |
| 443 } | 436 } |
| 444 | 437 |
| 445 TEST_F(HistoryURLProviderTest, AdjustOffset) { | 438 TEST_F(HistoryURLProviderTest, AdjustOffset) { |
| 446 RunAdjustOffsetTest(WideToUTF16(L"http://www.\uAD50\uC721"), 13); | 439 RunAdjustOffsetTest(L"http://www.\uAD50\uC721", 13); |
| 447 RunAdjustOffsetTest(ASCIIToUTF16("http://spaces.com/path%20with%20spa"), 31); | 440 RunAdjustOffsetTest(L"http://spaces.com/path%20with%20spa", 31); |
| 448 RunAdjustOffsetTest(ASCIIToUTF16("http://ms/c++ s"), 15); | 441 RunAdjustOffsetTest(L"http://ms/c++ s", 15); |
| 449 } | 442 } |
| 450 | 443 |
| 451 TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { | 444 TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { |
| 452 // Ensure that we will still produce matches for navigation when there is no | 445 // Ensure that we will still produce matches for navigation when there is no |
| 453 // database. | 446 // database. |
| 454 std::string navigation_1[] = {"http://test.com/"}; | 447 std::string navigation_1[] = {"http://test.com/"}; |
| 455 RunTest(ASCIIToUTF16("test.com"), string16(), false, navigation_1, | 448 RunTest(L"test.com", std::wstring(), false, navigation_1, |
| 456 arraysize(navigation_1)); | 449 arraysize(navigation_1)); |
| 457 | 450 |
| 458 std::string navigation_2[] = {"http://slash/"}; | 451 std::string navigation_2[] = {"http://slash/"}; |
| 459 RunTest(ASCIIToUTF16("slash"), string16(), false, navigation_2, | 452 RunTest(L"slash", std::wstring(), false, navigation_2, |
| 460 arraysize(navigation_2)); | 453 arraysize(navigation_2)); |
| 461 | 454 |
| 462 RunTest(ASCIIToUTF16("this is a query"), string16(), false, NULL, 0); | 455 RunTest(L"this is a query", std::wstring(), false, NULL, 0); |
| 463 } | 456 } |
| OLD | NEW |