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

Unified Diff: components/omnibox/browser/scored_history_match_unittest.cc

Issue 2355053003: Omnibox - Allow Matching in Port Number (Closed)
Patch Set: Created 4 years, 3 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: components/omnibox/browser/scored_history_match_unittest.cc
diff --git a/components/omnibox/browser/scored_history_match_unittest.cc b/components/omnibox/browser/scored_history_match_unittest.cc
index d0ad21a618d99e26f48809a02c33a242631fa74c..8c430f0085d3717cbdef4337b2afcb106e15d65b 100644
--- a/components/omnibox/browser/scored_history_match_unittest.cc
+++ b/components/omnibox/browser/scored_history_match_unittest.cc
@@ -244,6 +244,39 @@ TEST_F(ScoredHistoryMatchTest, ScoringTLD) {
EXPECT_GT(scored_with_tld.raw_score, 0);
}
+TEST_F(ScoredHistoryMatchTest, ScoringPort) {
+ // Reset the topicality threshold to 0, otherwise the port matches will not
+ // score above the minimum to be returned.
+ base::AutoReset<float> reset(&ScoredHistoryMatch::topicality_threshold_, 0.0);
+
+ // We use NowFromSystemTime() because MakeURLRow uses the same function
+ // to calculate last visit time when building a row.
+ base::Time now = base::Time::NowFromSystemTime();
+
+ // The URL should be returned with a positive score for a query that includes
+ // "8000".
+ std::string url_string("http://fedcba.com:8000/");
+ GURL url(url_string);
+ history::URLRow row(MakeURLRow(url_string.c_str(), "", 8, 3, 1));
+ RowWordStarts word_starts;
+ PopulateWordStarts(row, &word_starts);
+ WordStarts one_word_no_offsets(1, 0u);
+ VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
+ ScoredHistoryMatch scored(row, visits, ASCIIToUTF16("8000"),
+ Make1Term("8000"), one_word_no_offsets,
+ word_starts, false, nullptr, now);
+ EXPECT_GT(scored.raw_score, 0);
+
+ // Ditto for intranet URLs.
+ url_string = "http://fedcba:8000/";
+ url = GURL(url_string);
+ row = MakeURLRow(url_string.c_str(), "", 8, 3, 1);
+ scored = ScoredHistoryMatch(row, visits, ASCIIToUTF16("8000"),
+ Make1Term("8000"), one_word_no_offsets,
+ word_starts, false, nullptr, now);
+ EXPECT_GT(scored.raw_score, 0);
+}
+
TEST_F(ScoredHistoryMatchTest, ScoringScheme) {
// We use NowFromSystemTime() because MakeURLRow uses the same function
// to calculate last visit time when building a row.

Powered by Google App Engine
This is Rietveld 408576698