Index: chrome/browser/autocomplete/history_url_provider_unittest.cc |
=================================================================== |
--- chrome/browser/autocomplete/history_url_provider_unittest.cc (revision 31214) |
+++ chrome/browser/autocomplete/history_url_provider_unittest.cc (working copy) |
@@ -83,6 +83,11 @@ |
{"http://go/", L"Intranet URL", 1, 1}, |
{"http://gooey/", L"Intranet URL 2", 5, 5}, |
+ // URLs for testing offset adjustment |
+ {"http://www.\xEA\xB5\x90\xEC\x9C\xA1.kr/", L"Korean", 2, 2}, |
+ {"http://spaces.com/path%20with%20spaces/foo.html", L"Spaces", 2, 2}, |
+ {"http://ms/c++%20style%20guide", L"Style guide", 2, 2}, |
+ {"http://foo:bar@baz.com/", L"HTTP auth", 2, 2}, |
}; |
class HistoryURLProviderTest : public testing::Test, |
@@ -116,6 +121,8 @@ |
const std::string* expected_urls, |
size_t num_results); |
+ void RunAdjustOffsetTest(const std::wstring text, size_t expected_offset); |
+ |
MessageLoopForUI message_loop_; |
ChromeThread ui_thread_; |
ChromeThread file_thread_; |
@@ -144,7 +151,7 @@ |
profile_->CreateHistoryService(true, no_db); |
history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
- autocomplete_ = new HistoryURLProvider(this, profile_.get()); |
+ autocomplete_ = new HistoryURLProvider(this, profile_.get(), L"en-US,en,ko"); |
FillData(); |
} |
@@ -189,6 +196,18 @@ |
EXPECT_EQ(expected_urls[i], matches_[i].destination_url.spec()); |
} |
+void HistoryURLProviderTest::RunAdjustOffsetTest(const std::wstring text, |
+ size_t expected_offset) { |
+ AutocompleteInput input(text, std::wstring(), false, false, false); |
+ autocomplete_->Start(input, false); |
+ if (!autocomplete_->done()) |
+ MessageLoop::current()->Run(); |
+ |
+ matches_ = autocomplete_->matches(); |
+ ASSERT_GE(matches_.size(), 1U) << "Input text: " << text; |
+ EXPECT_EQ(expected_offset, matches_[0].inline_autocomplete_offset); |
+} |
+ |
TEST_F(HistoryURLProviderTest, PromoteShorterURLs) { |
// Test that hosts get synthesized below popular pages. |
const std::string expected_nonsynth[] = { |
@@ -382,6 +401,14 @@ |
RunTest(L"17173", std::wstring(), false, fixup_5, arraysize(fixup_5)); |
} |
+TEST_F(HistoryURLProviderTest, AdjustOffset) { |
+ RunAdjustOffsetTest(L"http://www.\uAD50\uC721", 13); |
+ RunAdjustOffsetTest(L"http://spaces.com/path%20with%20spa", 31); |
+ RunAdjustOffsetTest(L"http://ms/c++ s", 15); |
+ RunAdjustOffsetTest(L"http://foo:ba", std::wstring::npos); |
+ RunAdjustOffsetTest(L"http://foo:bar@ba", 9); |
+} |
+ |
TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { |
// Ensure that we will still produce matches for navigation when there is no |
// database. |