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

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

Issue 353223002: Omnibox: Fix URL-What-You-Typed Allowed-To-Be-Default-Match Issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove some test cases; add dcheck Created 6 years, 5 months 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_quick_provider_unittest.cc
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index 14bb024ec49678ffbda1dfa670e56d7df3acb379..9f9e36b47b3fe32d2be9e531fd41ccc143cbb4e7 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -152,6 +152,15 @@ class HistoryQuickProviderTest : public testing::Test,
base::string16 expected_fill_into_edit,
base::string16 autocompletion);
+ // As above, simply with a cursor position specified.
+ void RunTestWithCursor(const base::string16 text,
+ const size_t cursor_position,
+ bool prevent_inline_autocomplete,
+ std::vector<std::string> expected_urls,
+ bool can_inline_top_result,
+ base::string16 expected_fill_into_edit,
+ base::string16 autocompletion);
+
history::HistoryBackend* history_backend() {
return history_service_->history_backend_;
}
@@ -255,16 +264,29 @@ void HistoryQuickProviderTest::SetShouldContain::operator()(
<< "Results did not contain '" << expected << "' but should have.";
}
+void HistoryQuickProviderTest::RunTest(
+ const base::string16 text,
+ bool prevent_inline_autocomplete,
+ std::vector<std::string> expected_urls,
+ bool can_inline_top_result,
+ base::string16 expected_fill_into_edit,
+ base::string16 expected_autocompletion) {
+ RunTestWithCursor(text, base::string16::npos, prevent_inline_autocomplete,
+ expected_urls, can_inline_top_result,
+ expected_fill_into_edit, expected_autocompletion);
+}
-void HistoryQuickProviderTest::RunTest(const base::string16 text,
- bool prevent_inline_autocomplete,
- std::vector<std::string> expected_urls,
- bool can_inline_top_result,
- base::string16 expected_fill_into_edit,
- base::string16 expected_autocompletion) {
+void HistoryQuickProviderTest::RunTestWithCursor(
+ const base::string16 text,
+ const size_t cursor_position,
+ bool prevent_inline_autocomplete,
+ std::vector<std::string> expected_urls,
+ bool can_inline_top_result,
+ base::string16 expected_fill_into_edit,
+ base::string16 expected_autocompletion) {
SCOPED_TRACE(text); // Minimal hint to query being run.
base::MessageLoop::current()->RunUntilIdle();
- AutocompleteInput input(text, base::string16::npos, base::string16(),
+ AutocompleteInput input(text, cursor_position, base::string16(),
GURL(), metrics::OmniboxEventProto::INVALID_SPEC,
prevent_inline_autocomplete, false, true, true,
ChromeAutocompleteSchemeClassifier(profile_.get()));
@@ -322,6 +344,24 @@ TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) {
ASCIIToUTF16(".org/favorite_page.html"));
}
+TEST_F(HistoryQuickProviderTest, SingleMatchWithCursor) {
+ std::vector<std::string> expected_urls;
+ expected_urls.push_back("http://slashdot.org/favorite_page.html");
+ // With cursor after "slash", we should retrieve the desired result but it
+ // should not be allowed to be the default match.
+ RunTestWithCursor(ASCIIToUTF16("slashfavorite_page.html"), 5, false,
+ expected_urls, false,
+ ASCIIToUTF16("slashdot.org/favorite_page.html"),
+ base::string16());
+ // If the cursor is in the middle of a valid URL suggestion, it should be
+ // allowed to be the default match. The inline completion will be empty
+ // though as no completion is necessary.
+ RunTestWithCursor(ASCIIToUTF16("slashdot.org/favorite_page.html"), 5, false,
+ expected_urls, true,
+ ASCIIToUTF16("slashdot.org/favorite_page.html"),
+ base::string16());
+}
+
TEST_F(HistoryQuickProviderTest, WordBoundariesWithPunctuationMatch) {
std::vector<std::string> expected_urls;
expected_urls.push_back("http://popularsitewithpathonly.com/moo");

Powered by Google App Engine
This is Rietveld 408576698