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

Unified Diff: chrome/browser/autocomplete/history_url_provider_unittest.cc

Issue 372017: Fix various problems with inline autocomplete and URLs that change length dur... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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.
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.cc ('k') | chrome/browser/bookmarks/bookmark_table_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698