Commit eccdb2b8 authored by open.hyperion's avatar open.hyperion Committed by Commit bot

Updated and refactored URLIndexPrivateData::HistoryItemsForTerms to handle...

Updated and refactored URLIndexPrivateData::HistoryItemsForTerms to handle searching the history for both the original search string as well as the string with a break inserted.

The goal is to support mid-word autocomplete in the Omnibox.  Currently, if the user types "funtimes", inserts the cursor between the "n" and the "t" and begins typing the word "good" the Ominbox will search for URL results that match "fungood times" only.  We want to also search for "fungoodtimes".

BUG=591979
TEST=0. Clear browser history.
1. Visit the following link: https://twitter.com/fungoodtimes
2. Open a new browser tab.
3.Type into the Omnibox "funtimes".  Note the lack of the suggestion for the above URL.
4. Insert the cursor between the "n" and "t" in "funtime" and type "good".
5. The above URL should show in the autocomplete list.

Review-Url: https://codereview.chromium.org/2364553004
Cr-Commit-Position: refs/heads/master@{#420721}
parent 3fd37d92
...@@ -387,6 +387,7 @@ Laszlo Gombos <l.gombos@samsung.com> ...@@ -387,6 +387,7 @@ Laszlo Gombos <l.gombos@samsung.com>
Laszlo Radanyi <bekkra@gmail.com> Laszlo Radanyi <bekkra@gmail.com>
Lauren Yeun Kim <lauren.yeun.kim@gmail.com> Lauren Yeun Kim <lauren.yeun.kim@gmail.com>
Lauri Oherd <lauri.oherd@gmail.com> Lauri Oherd <lauri.oherd@gmail.com>
Lavar Askew <open.hyperion@gmail.com>
Legend Lee <guanxian.li@intel.com> Legend Lee <guanxian.li@intel.com>
Leith Bade <leith@leithalweapon.geek.nz> Leith Bade <leith@leithalweapon.geek.nz>
Leo Wolf <jclw@ymail.com> Leo Wolf <jclw@ymail.com>
......
...@@ -57,52 +57,53 @@ struct TestURLInfo { ...@@ -57,52 +57,53 @@ struct TestURLInfo {
int typed_count; int typed_count;
int days_from_now; int days_from_now;
} quick_test_db[] = { } quick_test_db[] = {
{"http://www.google.com/", "Google", 3, 3, 0}, {"http://www.google.com/", "Google", 3, 3, 0},
{"http://slashdot.org/favorite_page.html", "Favorite page", 200, 100, 0}, {"http://slashdot.org/favorite_page.html", "Favorite page", 200, 100, 0},
{"http://kerneltrap.org/not_very_popular.html", "Less popular", 4, 0, 0}, {"http://kerneltrap.org/not_very_popular.html", "Less popular", 4, 0, 0},
{"http://freshmeat.net/unpopular.html", "Unpopular", 1, 1, 0}, {"http://freshmeat.net/unpopular.html", "Unpopular", 1, 1, 0},
{"http://news.google.com/?ned=us&topic=n", "Google News - U.S.", 2, 2, 0}, {"http://news.google.com/?ned=us&topic=n", "Google News - U.S.", 2, 2, 0},
{"http://news.google.com/", "Google News", 1, 1, 0}, {"http://news.google.com/", "Google News", 1, 1, 0},
{"http://foo.com/", "Dir", 200, 100, 0}, {"http://foo.com/", "Dir", 200, 100, 0},
{"http://foo.com/dir/", "Dir", 2, 1, 10}, {"http://foo.com/dir/", "Dir", 2, 1, 10},
{"http://foo.com/dir/another/", "Dir", 10, 5, 0}, {"http://foo.com/dir/another/", "Dir", 10, 5, 0},
{"http://foo.com/dir/another/again/", "Dir", 5, 1, 0}, {"http://foo.com/dir/another/again/", "Dir", 5, 1, 0},
{"http://foo.com/dir/another/again/myfile.html", "File", 3, 1, 0}, {"http://foo.com/dir/another/again/myfile.html", "File", 3, 1, 0},
{"http://visitedest.com/y/a", "VA", 10, 1, 20}, {"http://visitedest.com/y/a", "VA", 10, 1, 20},
{"http://visitedest.com/y/b", "VB", 9, 1, 20}, {"http://visitedest.com/y/b", "VB", 9, 1, 20},
{"http://visitedest.com/x/c", "VC", 8, 1, 20}, {"http://visitedest.com/x/c", "VC", 8, 1, 20},
{"http://visitedest.com/x/d", "VD", 7, 1, 20}, {"http://visitedest.com/x/d", "VD", 7, 1, 20},
{"http://visitedest.com/y/e", "VE", 6, 1, 20}, {"http://visitedest.com/y/e", "VE", 6, 1, 20},
{"http://typeredest.com/y/a", "TA", 5, 5, 0}, {"http://typeredest.com/y/a", "TA", 5, 5, 0},
{"http://typeredest.com/y/b", "TB", 5, 4, 0}, {"http://typeredest.com/y/b", "TB", 5, 4, 0},
{"http://typeredest.com/x/c", "TC", 5, 3, 0}, {"http://typeredest.com/x/c", "TC", 5, 3, 0},
{"http://typeredest.com/x/d", "TD", 5, 2, 0}, {"http://typeredest.com/x/d", "TD", 5, 2, 0},
{"http://typeredest.com/y/e", "TE", 5, 1, 0}, {"http://typeredest.com/y/e", "TE", 5, 1, 0},
{"http://daysagoest.com/y/a", "DA", 1, 1, 0}, {"http://daysagoest.com/y/a", "DA", 1, 1, 0},
{"http://daysagoest.com/y/b", "DB", 1, 1, 1}, {"http://daysagoest.com/y/b", "DB", 1, 1, 1},
{"http://daysagoest.com/x/c", "DC", 1, 1, 2}, {"http://daysagoest.com/x/c", "DC", 1, 1, 2},
{"http://daysagoest.com/x/d", "DD", 1, 1, 3}, {"http://daysagoest.com/x/d", "DD", 1, 1, 3},
{"http://daysagoest.com/y/e", "DE", 1, 1, 4}, {"http://daysagoest.com/y/e", "DE", 1, 1, 4},
{"http://abcdefghixyzjklmnopqrstuvw.com/a", "", 3, 1, 0}, {"http://abcdefghixyzjklmnopqrstuvw.com/a", "", 3, 1, 0},
{"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2, 0}, {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2, 0},
{"http://abcdefghijklxyzmnopqrstuvw.com/a", "", 3, 1, 0}, {"http://abcdefghijklxyzmnopqrstuvw.com/a", "", 3, 1, 0},
{"http://abcdefxyzghijklmnopqrstuvw.com/a", "", 3, 1, 0}, {"http://abcdefxyzghijklmnopqrstuvw.com/a", "", 3, 1, 0},
{"http://abcxyzdefghijklmnopqrstuvw.com/a", "", 3, 1, 0}, {"http://abcxyzdefghijklmnopqrstuvw.com/a", "", 3, 1, 0},
{"http://xyzabcdefghijklmnopqrstuvw.com/a", "", 3, 1, 0}, {"http://xyzabcdefghijklmnopqrstuvw.com/a", "", 3, 1, 0},
{"http://cda.com/Dogs%20Cats%20Gorillas%20Sea%20Slugs%20and%20Mice", {"http://cda.com/Dogs%20Cats%20Gorillas%20Sea%20Slugs%20and%20Mice",
"Dogs & Cats & Mice & Other Animals", 1, 1, 0}, "Dogs & Cats & Mice & Other Animals", 1, 1, 0},
{"https://monkeytrap.org/", "", 3, 1, 0}, {"https://monkeytrap.org/", "", 3, 1, 0},
{"http://popularsitewithpathonly.com/moo", {"http://popularsitewithpathonly.com/moo",
"popularsitewithpathonly.com/moo", 50, 50, 0}, "popularsitewithpathonly.com/moo", 50, 50, 0},
{"http://popularsitewithroot.com/", "popularsitewithroot.com", 50, 50, 0}, {"http://popularsitewithroot.com/", "popularsitewithroot.com", 50, 50, 0},
{"http://testsearch.com/?q=thequery", "Test Search Engine", 10, 10, 0}, {"http://testsearch.com/?q=thequery", "Test Search Engine", 10, 10, 0},
{"http://testsearch.com/", "Test Search Engine", 9, 9, 0}, {"http://testsearch.com/", "Test Search Engine", 9, 9, 0},
{"http://anotherengine.com/?q=thequery", "Another Search Engine", 8, 8, 0}, {"http://anotherengine.com/?q=thequery", "Another Search Engine", 8, 8, 0},
// The encoded stuff between /wiki/ and the # is 第二次世界大戦 // The encoded stuff between /wiki/ and the # is 第二次世界大戦
{"http://ja.wikipedia.org/wiki/%E7%AC%AC%E4%BA%8C%E6%AC%A1%E4%B8%96%E7%95" {"http://ja.wikipedia.org/wiki/%E7%AC%AC%E4%BA%8C%E6%AC%A1%E4%B8%96%E7%95"
"%8C%E5%A4%A7%E6%88%A6#.E3.83.B4.E3.82.A7.E3.83.AB.E3.82.B5.E3.82.A4.E3." "%8C%E5%A4%A7%E6%88%A6#.E3.83.B4.E3.82.A7.E3.83.AB.E3.82.B5.E3.82.A4.E3."
"83.A6.E4.BD.93.E5.88.B6", "Title Unimportant", 2, 2, 0} "83.A6.E4.BD.93.E5.88.B6",
}; "Title Unimportant", 2, 2, 0},
{"https://twitter.com/fungoodtimes", "relatable!", 1, 1, 0}};
// Waits for OnURLsDeletedNotification and when run quits the supplied run loop. // Waits for OnURLsDeletedNotification and when run quits the supplied run loop.
class WaitForURLsDeletedObserver : public history::HistoryServiceObserver { class WaitForURLsDeletedObserver : public history::HistoryServiceObserver {
...@@ -496,6 +497,16 @@ TEST_F(HistoryQuickProviderTest, SingleMatchWithCursor) { ...@@ -496,6 +497,16 @@ TEST_F(HistoryQuickProviderTest, SingleMatchWithCursor) {
base::string16()); base::string16());
} }
TEST_F(HistoryQuickProviderTest, MatchWithAndWithoutCursorWordBreak) {
std::vector<std::string> expected_urls;
expected_urls.push_back("https://twitter.com/fungoodtimes");
// With cursor after "good", we should retrieve the desired result but it
// should not be allowed to be the default match.
RunTestWithCursor(ASCIIToUTF16("fungoodtimes"), 7, false, expected_urls,
false, ASCIIToUTF16("https://twitter.com/fungoodtimes"),
base::string16());
}
TEST_F(HistoryQuickProviderTest, WordBoundariesWithPunctuationMatch) { TEST_F(HistoryQuickProviderTest, WordBoundariesWithPunctuationMatch) {
std::vector<std::string> expected_urls; std::vector<std::string> expected_urls;
expected_urls.push_back("http://popularsitewithpathonly.com/moo"); expected_urls.push_back("http://popularsitewithpathonly.com/moo");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment