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

Unified Diff: components/history/core/browser/url_database_unittest.cc

Issue 2864103003: Limit the number of history urls indexed for omnibox suggestions. (Closed)
Patch Set: Fixes. Created 3 years, 7 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/history/core/browser/url_database_unittest.cc
diff --git a/components/history/core/browser/url_database_unittest.cc b/components/history/core/browser/url_database_unittest.cc
index c9466aed55d0c186c39d52880b17472915ffe5af..ac400cb1676a8181ba75832ffc9ef6a052f358e7 100644
--- a/components/history/core/browser/url_database_unittest.cc
+++ b/components/history/core/browser/url_database_unittest.cc
@@ -235,26 +235,44 @@ TEST_F(URLDatabaseTest, DeleteURLDeletesKeywordSearchTermVisit) {
}
TEST_F(URLDatabaseTest, EnumeratorForSignificant) {
Mark P 2017/05/08 22:39:17 Please restructure this test a bit. Right now, fo
ssid 2017/05/10 01:01:35 good point. Done.
- std::set<std::string> good_urls;
+ // Vector contains urls in order of significance.
+ std::vector<std::string> good_urls;
+
// Add URLs which do and don't meet the criteria.
URLRow url_no_match(GURL("http://www.url_no_match.com/"));
EXPECT_TRUE(AddURL(url_no_match));
- std::string url_string2("http://www.url_match_visit_count.com/");
- good_urls.insert("http://www.url_match_visit_count.com/");
- URLRow url_match_visit_count(GURL("http://www.url_match_visit_count.com/"));
- url_match_visit_count.set_visit_count(kLowQualityMatchVisitLimit);
- EXPECT_TRUE(AddURL(url_match_visit_count));
-
- good_urls.insert("http://www.url_match_typed_count.com/");
- URLRow url_match_typed_count(GURL("http://www.url_match_typed_count.com/"));
- url_match_typed_count.set_typed_count(kLowQualityMatchTypedLimit);
- EXPECT_TRUE(AddURL(url_match_typed_count));
-
- good_urls.insert("http://www.url_match_last_visit.com/");
- URLRow url_match_last_visit(GURL("http://www.url_match_last_visit.com/"));
- url_match_last_visit.set_last_visit(Time::Now() - TimeDelta::FromDays(1));
- EXPECT_TRUE(AddURL(url_match_last_visit));
+ good_urls.push_back("http://www.url_match_higher_typed_count.com/");
+ URLRow url_match_typed_count1(
+ GURL("http://www.url_match_higher_typed_count.com/"));
+ url_match_typed_count1.set_typed_count(kLowQualityMatchTypedLimit + 1);
+ EXPECT_TRUE(AddURL(url_match_typed_count1));
+
+ good_urls.push_back("http://www.url_match_typed_count.com/");
+ URLRow url_match_typed_count2(GURL("http://www.url_match_typed_count.com/"));
+ url_match_typed_count2.set_typed_count(kLowQualityMatchTypedLimit);
+ EXPECT_TRUE(AddURL(url_match_typed_count2));
+
+ good_urls.push_back("http://www.url_match_last_visit.com/");
+ URLRow url_match_last_visit1(GURL("http://www.url_match_last_visit.com/"));
+ url_match_last_visit1.set_last_visit(Time::Now() - TimeDelta::FromDays(1));
+ EXPECT_TRUE(AddURL(url_match_last_visit1));
+
+ good_urls.push_back("http://www.url_match_last_visit2.com/");
+ URLRow url_match_last_visit2(GURL("http://www.url_match_last_visit2.com/"));
+ url_match_last_visit2.set_last_visit(Time::Now() - TimeDelta::FromDays(2));
+ EXPECT_TRUE(AddURL(url_match_last_visit2));
+
+ good_urls.push_back("http://www.url_match_higher_visit_count.com/");
+ URLRow url_match_visit_count1(
+ GURL("http://www.url_match_higher_visit_count.com/"));
+ url_match_visit_count1.set_visit_count(kLowQualityMatchVisitLimit + 1);
+ EXPECT_TRUE(AddURL(url_match_visit_count1));
+
+ good_urls.push_back("http://www.url_match_visit_count.com/");
+ URLRow url_match_visit_count2(GURL("http://www.url_match_visit_count.com/"));
+ url_match_visit_count2.set_visit_count(kLowQualityMatchVisitLimit);
+ EXPECT_TRUE(AddURL(url_match_visit_count2));
URLRow url_no_match_last_visit(GURL(
"http://www.url_no_match_last_visit.com/"));
@@ -267,8 +285,8 @@ TEST_F(URLDatabaseTest, EnumeratorForSignificant) {
URLRow row;
int row_count = 0;
for (; history_enum.GetNextURL(&row); ++row_count)
- EXPECT_EQ(1U, good_urls.count(row.url().spec()));
- EXPECT_EQ(3, row_count);
+ EXPECT_EQ(good_urls[row_count], row.url().spec());
+ EXPECT_EQ(6, row_count);
}
// Test GetKeywordSearchTermRows and DeleteSearchTerm

Powered by Google App Engine
This is Rietveld 408576698