| Index: chrome/browser/autocomplete/scored_history_match_builder_impl_unittest.cc
|
| diff --git a/chrome/browser/autocomplete/scored_history_match_builder_impl_unittest.cc b/chrome/browser/autocomplete/scored_history_match_builder_impl_unittest.cc
|
| index 406beeee81f769ea0131180f20dcee6f713c1202..e9fad3700ae6176855fd101d90eb61bcb6966e16 100644
|
| --- a/chrome/browser/autocomplete/scored_history_match_builder_impl_unittest.cc
|
| +++ b/chrome/browser/autocomplete/scored_history_match_builder_impl_unittest.cc
|
| @@ -19,13 +19,13 @@ using testing::Pair;
|
|
|
| namespace {
|
|
|
| -// Returns a history::VisitInfoVector that includes |num_visits| spread over the
|
| +// Returns a VisitInfoVector that includes |num_visits| spread over the
|
| // last |frequency|*|num_visits| days (relative to |now|). A frequency of
|
| // one means one visit each day, two means every other day, etc.
|
| -history::VisitInfoVector CreateVisitInfoVector(int num_visits,
|
| - int frequency,
|
| - base::Time now) {
|
| - history::VisitInfoVector visits;
|
| +VisitInfoVector CreateVisitInfoVector(int num_visits,
|
| + int frequency,
|
| + base::Time now) {
|
| + VisitInfoVector visits;
|
| for (int i = 0; i < num_visits; ++i) {
|
| visits.push_back(
|
| std::make_pair(now - base::TimeDelta::FromDays(i * frequency),
|
| @@ -50,12 +50,11 @@ class ScoredHistoryMatchBuilderImplTest : public testing::Test {
|
| // Convenience function to set the word starts information from a
|
| // history::URLRow's URL and title.
|
| void PopulateWordStarts(const history::URLRow& url_row,
|
| - history::RowWordStarts* word_starts);
|
| + RowWordStarts* word_starts);
|
|
|
| // Convenience functions for easily creating vectors of search terms.
|
| - history::String16Vector Make1Term(const char* term) const;
|
| - history::String16Vector Make2Terms(const char* term_1,
|
| - const char* term_2) const;
|
| + String16Vector Make1Term(const char* term) const;
|
| + String16Vector Make2Terms(const char* term_1, const char* term_2) const;
|
|
|
| // Convenience function for GetTopicalityScore() that builds the term match
|
| // and word break information automatically that are needed to call
|
| @@ -68,8 +67,8 @@ class ScoredHistoryMatchBuilderImplTest : public testing::Test {
|
| // Registers an URL as bookmarked.
|
| void AddBookmark(const GURL& url);
|
|
|
| - // Returns the history::ScoredHistoryMatch::Builder to use.
|
| - history::ScoredHistoryMatch::Builder* builder() { return builder_.get(); }
|
| + // Returns the ScoredHistoryMatch::Builder to use.
|
| + ScoredHistoryMatch::Builder* builder() { return builder_.get(); }
|
|
|
| private:
|
| // Returns whether an URL is bookmarked, used by
|
| @@ -81,7 +80,7 @@ class ScoredHistoryMatchBuilderImplTest : public testing::Test {
|
| void TearDown() override;
|
|
|
| std::set<GURL> bookmarked_urls_;
|
| - scoped_ptr<history::ScoredHistoryMatch::Builder> builder_;
|
| + scoped_ptr<ScoredHistoryMatch::Builder> builder_;
|
| };
|
|
|
| history::URLRow ScoredHistoryMatchBuilderImplTest::MakeURLRow(
|
| @@ -101,24 +100,23 @@ history::URLRow ScoredHistoryMatchBuilderImplTest::MakeURLRow(
|
|
|
| void ScoredHistoryMatchBuilderImplTest::PopulateWordStarts(
|
| const history::URLRow& url_row,
|
| - history::RowWordStarts* word_starts) {
|
| - history::String16SetFromString16(ASCIIToUTF16(url_row.url().spec()),
|
| - &word_starts->url_word_starts_);
|
| - history::String16SetFromString16(url_row.title(),
|
| - &word_starts->title_word_starts_);
|
| + RowWordStarts* word_starts) {
|
| + String16SetFromString16(ASCIIToUTF16(url_row.url().spec()),
|
| + &word_starts->url_word_starts_);
|
| + String16SetFromString16(url_row.title(), &word_starts->title_word_starts_);
|
| }
|
|
|
| -history::String16Vector ScoredHistoryMatchBuilderImplTest::Make1Term(
|
| +String16Vector ScoredHistoryMatchBuilderImplTest::Make1Term(
|
| const char* term) const {
|
| - history::String16Vector original_terms;
|
| + String16Vector original_terms;
|
| original_terms.push_back(ASCIIToUTF16(term));
|
| return original_terms;
|
| }
|
|
|
| -history::String16Vector ScoredHistoryMatchBuilderImplTest::Make2Terms(
|
| +String16Vector ScoredHistoryMatchBuilderImplTest::Make2Terms(
|
| const char* term_1,
|
| const char* term_2) const {
|
| - history::String16Vector original_terms;
|
| + String16Vector original_terms;
|
| original_terms.push_back(ASCIIToUTF16(term_1));
|
| original_terms.push_back(ASCIIToUTF16(term_2));
|
| return original_terms;
|
| @@ -130,13 +128,13 @@ float ScoredHistoryMatchBuilderImplTest::
|
| const base::string16& title) {
|
| // Make an empty match and simply populate the fields we need in order
|
| // to call GetTopicalityScore().
|
| - history::ScoredHistoryMatch scored_match;
|
| - scored_match.url_matches = history::MatchTermInString(term, url, 0);
|
| - scored_match.title_matches = history::MatchTermInString(term, title, 0);
|
| - history::RowWordStarts word_starts;
|
| - history::String16SetFromString16(url, &word_starts.url_word_starts_);
|
| - history::String16SetFromString16(title, &word_starts.title_word_starts_);
|
| - history::WordStarts one_word_no_offset(1, 0u);
|
| + ScoredHistoryMatch scored_match;
|
| + scored_match.url_matches = MatchTermInString(term, url, 0);
|
| + scored_match.title_matches = MatchTermInString(term, title, 0);
|
| + RowWordStarts word_starts;
|
| + String16SetFromString16(url, &word_starts.url_word_starts_);
|
| + String16SetFromString16(title, &word_starts.title_word_starts_);
|
| + WordStarts one_word_no_offset(1, 0u);
|
| return ScoredHistoryMatchBuilderImpl::GetTopicalityScore(
|
| 1, url, one_word_no_offset, word_starts, &scored_match);
|
| }
|
| @@ -166,47 +164,47 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, Scoring) {
|
| base::Time now = base::Time::NowFromSystemTime();
|
|
|
| history::URLRow row_a(MakeURLRow("http://fedcba", "abcd bcd", 3, 30, 1));
|
| - history::RowWordStarts word_starts_a;
|
| + RowWordStarts word_starts_a;
|
| PopulateWordStarts(row_a, &word_starts_a);
|
| - history::WordStarts one_word_no_offset(1, 0u);
|
| - history::VisitInfoVector visits_a = CreateVisitInfoVector(3, 30, now);
|
| + WordStarts one_word_no_offset(1, 0u);
|
| + VisitInfoVector visits_a = CreateVisitInfoVector(3, 30, now);
|
| // Mark one visit as typed.
|
| visits_a[0].second = ui::PAGE_TRANSITION_TYPED;
|
| - history::ScoredHistoryMatch scored_a = builder()->Build(
|
| + ScoredHistoryMatch scored_a = builder()->Build(
|
| row_a, visits_a, std::string(), ASCIIToUTF16("abc"), Make1Term("abc"),
|
| one_word_no_offset, word_starts_a, now);
|
|
|
| // Test scores based on visit_count.
|
| history::URLRow row_b(MakeURLRow("http://abcdef", "abcd bcd", 10, 30, 1));
|
| - history::RowWordStarts word_starts_b;
|
| + RowWordStarts word_starts_b;
|
| PopulateWordStarts(row_b, &word_starts_b);
|
| - history::VisitInfoVector visits_b = CreateVisitInfoVector(10, 30, now);
|
| + VisitInfoVector visits_b = CreateVisitInfoVector(10, 30, now);
|
| visits_b[0].second = ui::PAGE_TRANSITION_TYPED;
|
| - history::ScoredHistoryMatch scored_b = builder()->Build(
|
| + ScoredHistoryMatch scored_b = builder()->Build(
|
| row_b, visits_b, std::string(), ASCIIToUTF16("abc"), Make1Term("abc"),
|
| one_word_no_offset, word_starts_b, now);
|
| EXPECT_GT(scored_b.raw_score, scored_a.raw_score);
|
|
|
| // Test scores based on last_visit.
|
| history::URLRow row_c(MakeURLRow("http://abcdef", "abcd bcd", 3, 10, 1));
|
| - history::RowWordStarts word_starts_c;
|
| + RowWordStarts word_starts_c;
|
| PopulateWordStarts(row_c, &word_starts_c);
|
| - history::VisitInfoVector visits_c = CreateVisitInfoVector(3, 10, now);
|
| + VisitInfoVector visits_c = CreateVisitInfoVector(3, 10, now);
|
| visits_c[0].second = ui::PAGE_TRANSITION_TYPED;
|
| - history::ScoredHistoryMatch scored_c = builder()->Build(
|
| + ScoredHistoryMatch scored_c = builder()->Build(
|
| row_c, visits_c, std::string(), ASCIIToUTF16("abc"), Make1Term("abc"),
|
| one_word_no_offset, word_starts_c, now);
|
| EXPECT_GT(scored_c.raw_score, scored_a.raw_score);
|
|
|
| // Test scores based on typed_count.
|
| history::URLRow row_d(MakeURLRow("http://abcdef", "abcd bcd", 3, 30, 3));
|
| - history::RowWordStarts word_starts_d;
|
| + RowWordStarts word_starts_d;
|
| PopulateWordStarts(row_d, &word_starts_d);
|
| - history::VisitInfoVector visits_d = CreateVisitInfoVector(3, 30, now);
|
| + VisitInfoVector visits_d = CreateVisitInfoVector(3, 30, now);
|
| visits_d[0].second = ui::PAGE_TRANSITION_TYPED;
|
| visits_d[1].second = ui::PAGE_TRANSITION_TYPED;
|
| visits_d[2].second = ui::PAGE_TRANSITION_TYPED;
|
| - history::ScoredHistoryMatch scored_d = builder()->Build(
|
| + ScoredHistoryMatch scored_d = builder()->Build(
|
| row_d, visits_d, std::string(), ASCIIToUTF16("abc"), Make1Term("abc"),
|
| one_word_no_offset, word_starts_d, now);
|
| EXPECT_GT(scored_d.raw_score, scored_a.raw_score);
|
| @@ -215,17 +213,17 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, Scoring) {
|
| history::URLRow row_e(MakeURLRow(
|
| "http://csi.csi.csi/csi_csi",
|
| "CSI Guide to CSI Las Vegas, CSI New York, CSI Provo", 3, 30, 3));
|
| - history::RowWordStarts word_starts_e;
|
| + RowWordStarts word_starts_e;
|
| PopulateWordStarts(row_e, &word_starts_e);
|
| - const history::VisitInfoVector visits_e = visits_d;
|
| - history::ScoredHistoryMatch scored_e = builder()->Build(
|
| + const VisitInfoVector visits_e = visits_d;
|
| + ScoredHistoryMatch scored_e = builder()->Build(
|
| row_e, visits_e, std::string(), ASCIIToUTF16("csi"), Make1Term("csi"),
|
| one_word_no_offset, word_starts_e, now);
|
| EXPECT_LT(scored_e.raw_score, 1400);
|
|
|
| // Test that a result with only a mid-term match (i.e., not at a word
|
| // boundary) scores 0.
|
| - history::ScoredHistoryMatch scored_f =
|
| + ScoredHistoryMatch scored_f =
|
| builder()->Build(row_a, visits_a, std::string(), ASCIIToUTF16("cd"),
|
| Make1Term("cd"), one_word_no_offset, word_starts_a, now);
|
| EXPECT_EQ(scored_f.raw_score, 0);
|
| @@ -239,18 +237,18 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, ScoringBookmarks) {
|
| std::string url_string("http://fedcba");
|
| const GURL url(url_string);
|
| history::URLRow row(MakeURLRow(url_string.c_str(), "abcd bcd", 8, 3, 1));
|
| - history::RowWordStarts word_starts;
|
| + RowWordStarts word_starts;
|
| PopulateWordStarts(row, &word_starts);
|
| - history::WordStarts one_word_no_offset(1, 0u);
|
| - history::VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
|
| - history::ScoredHistoryMatch scored =
|
| + WordStarts one_word_no_offset(1, 0u);
|
| + VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
|
| + ScoredHistoryMatch scored =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("abc"),
|
| Make1Term("abc"), one_word_no_offset, word_starts, now);
|
| // Now bookmark that URL and make sure its score increases.
|
| base::AutoReset<int> reset(&ScoredHistoryMatchBuilderImpl::bookmark_value_,
|
| 5);
|
| AddBookmark(url);
|
| - history::ScoredHistoryMatch scored_with_bookmark =
|
| + ScoredHistoryMatch scored_with_bookmark =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("abc"),
|
| Make1Term("abc"), one_word_no_offset, word_starts, now);
|
| EXPECT_GT(scored_with_bookmark.raw_score, scored.raw_score);
|
| @@ -265,11 +263,11 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, ScoringTLD) {
|
| std::string url_string("http://fedcba.com/");
|
| const GURL url(url_string);
|
| history::URLRow row(MakeURLRow(url_string.c_str(), "", 8, 3, 1));
|
| - history::RowWordStarts word_starts;
|
| + RowWordStarts word_starts;
|
| PopulateWordStarts(row, &word_starts);
|
| - history::WordStarts two_words_no_offsets(2, 0u);
|
| - history::VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
|
| - history::ScoredHistoryMatch scored = builder()->Build(
|
| + WordStarts two_words_no_offsets(2, 0u);
|
| + VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
|
| + ScoredHistoryMatch scored = builder()->Build(
|
| row, visits, std::string(), ASCIIToUTF16("fed com"),
|
| Make2Terms("fed", "com"), two_words_no_offsets, word_starts, now);
|
| EXPECT_EQ(0, scored.raw_score);
|
| @@ -277,7 +275,7 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, ScoringTLD) {
|
| // Now allow credit for the match in the TLD.
|
| base::AutoReset<bool> reset(
|
| &ScoredHistoryMatchBuilderImpl::allow_tld_matches_, true);
|
| - history::ScoredHistoryMatch scored_with_tld = builder()->Build(
|
| + ScoredHistoryMatch scored_with_tld = builder()->Build(
|
| row, visits, std::string(), ASCIIToUTF16("fed com"),
|
| Make2Terms("fed", "com"), two_words_no_offsets, word_starts, now);
|
| EXPECT_GT(scored_with_tld.raw_score, 0);
|
| @@ -292,11 +290,11 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, ScoringScheme) {
|
| std::string url_string("http://fedcba/");
|
| const GURL url(url_string);
|
| history::URLRow row(MakeURLRow(url_string.c_str(), "", 8, 3, 1));
|
| - history::RowWordStarts word_starts;
|
| + RowWordStarts word_starts;
|
| PopulateWordStarts(row, &word_starts);
|
| - history::WordStarts two_words_no_offsets(2, 0u);
|
| - history::VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
|
| - history::ScoredHistoryMatch scored = builder()->Build(
|
| + WordStarts two_words_no_offsets(2, 0u);
|
| + VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
|
| + ScoredHistoryMatch scored = builder()->Build(
|
| row, visits, std::string(), ASCIIToUTF16("fed http"),
|
| Make2Terms("fed", "http"), two_words_no_offsets, word_starts, now);
|
| EXPECT_EQ(0, scored.raw_score);
|
| @@ -304,7 +302,7 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, ScoringScheme) {
|
| // Now allow credit for the match in the scheme.
|
| base::AutoReset<bool> reset(
|
| &ScoredHistoryMatchBuilderImpl::allow_scheme_matches_, true);
|
| - history::ScoredHistoryMatch scored_with_scheme = builder()->Build(
|
| + ScoredHistoryMatch scored_with_scheme = builder()->Build(
|
| row, visits, std::string(), ASCIIToUTF16("fed http"),
|
| Make2Terms("fed", "http"), two_words_no_offsets, word_starts, now);
|
| EXPECT_GT(scored_with_scheme.raw_score, 0);
|
| @@ -314,30 +312,30 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, Inlining) {
|
| // We use NowFromSystemTime() because MakeURLRow uses the same function
|
| // to calculate last visit time when building a row.
|
| base::Time now = base::Time::NowFromSystemTime();
|
| - history::RowWordStarts word_starts;
|
| - history::WordStarts one_word_no_offset(1, 0u);
|
| - history::VisitInfoVector visits;
|
| + RowWordStarts word_starts;
|
| + WordStarts one_word_no_offset(1, 0u);
|
| + VisitInfoVector visits;
|
|
|
| {
|
| history::URLRow row(
|
| MakeURLRow("http://www.google.com", "abcdef", 3, 30, 1));
|
| PopulateWordStarts(row, &word_starts);
|
| - history::ScoredHistoryMatch scored_a =
|
| + ScoredHistoryMatch scored_a =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("g"),
|
| Make1Term("g"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_a.can_inline);
|
| EXPECT_FALSE(scored_a.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_b =
|
| + ScoredHistoryMatch scored_b =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("w"),
|
| Make1Term("w"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_b.can_inline);
|
| EXPECT_FALSE(scored_b.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_c =
|
| + ScoredHistoryMatch scored_c =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("h"),
|
| Make1Term("h"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_c.can_inline);
|
| EXPECT_TRUE(scored_c.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_d =
|
| + ScoredHistoryMatch scored_d =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("o"),
|
| Make1Term("o"), one_word_no_offset, word_starts, now);
|
| EXPECT_FALSE(scored_d.can_inline);
|
| @@ -347,17 +345,17 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, Inlining) {
|
| {
|
| history::URLRow row(MakeURLRow("http://teams.foo.com", "abcdef", 3, 30, 1));
|
| PopulateWordStarts(row, &word_starts);
|
| - history::ScoredHistoryMatch scored_a =
|
| + ScoredHistoryMatch scored_a =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("t"),
|
| Make1Term("t"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_a.can_inline);
|
| EXPECT_FALSE(scored_a.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_b =
|
| + ScoredHistoryMatch scored_b =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("f"),
|
| Make1Term("f"), one_word_no_offset, word_starts, now);
|
| EXPECT_FALSE(scored_b.can_inline);
|
| EXPECT_FALSE(scored_b.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_c =
|
| + ScoredHistoryMatch scored_c =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("o"),
|
| Make1Term("o"), one_word_no_offset, word_starts, now);
|
| EXPECT_FALSE(scored_c.can_inline);
|
| @@ -368,17 +366,17 @@ TEST_F(ScoredHistoryMatchBuilderImplTest, Inlining) {
|
| history::URLRow row(
|
| MakeURLRow("https://www.testing.com", "abcdef", 3, 30, 1));
|
| PopulateWordStarts(row, &word_starts);
|
| - history::ScoredHistoryMatch scored_a =
|
| + ScoredHistoryMatch scored_a =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("t"),
|
| Make1Term("t"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_a.can_inline);
|
| EXPECT_FALSE(scored_a.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_b =
|
| + ScoredHistoryMatch scored_b =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("h"),
|
| Make1Term("h"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_b.can_inline);
|
| EXPECT_TRUE(scored_b.match_in_scheme);
|
| - history::ScoredHistoryMatch scored_c =
|
| + ScoredHistoryMatch scored_c =
|
| builder()->Build(row, visits, std::string(), ASCIIToUTF16("w"),
|
| Make1Term("w"), one_word_no_offset, word_starts, now);
|
| EXPECT_TRUE(scored_c.can_inline);
|
|
|