Chromium Code Reviews| Index: chrome/browser/history/scored_history_match_unittest.cc |
| diff --git a/chrome/browser/history/scored_history_match_unittest.cc b/chrome/browser/history/scored_history_match_unittest.cc |
| index 229d28ed3af9ccf7516914ca15586e336e60f5b5..db5dcaeca465a7d55579a1cf4a21109abd81a92c 100644 |
| --- a/chrome/browser/history/scored_history_match_unittest.cc |
| +++ b/chrome/browser/history/scored_history_match_unittest.cc |
| @@ -13,7 +13,7 @@ |
| namespace history { |
| // Returns a VisitInfoVector that includes |num_visits| spread over the |
| -// last |frecency|*|num_visits| days (relative to |now|). A frequency of |
| +// last |frequency|*|num_visits| days (relative to |now|). A frequency of |
| // one means one visit each day, two means every other day, etc. |
| VisitInfoVector CreateVisitInfoVector(int num_visits, |
| int frequency, |
| @@ -175,6 +175,56 @@ TEST_F(ScoredHistoryMatchTest, Scoring) { |
| EXPECT_EQ(scored_f.raw_score(), 0); |
| } |
| +class BookmarkServiceMock : public BookmarkService { |
|
Peter Kasting
2013/11/26 02:33:48
Nit: I tend to prefer classes to all be at the top
Mark P
2013/11/26 19:31:57
Because there is only one test using this Mock, I
|
| + public: |
| + explicit BookmarkServiceMock(const GURL& url); |
| + virtual ~BookmarkServiceMock() {} |
| + |
| + // Returns true if the given |url| is the same as |url_|. |
| + virtual bool IsBookmarked(const GURL& url) OVERRIDE; |
| + |
| + // Required but unused. |
| + virtual void GetBookmarks(std::vector<URLAndTitle>* bookmarks) OVERRIDE {} |
| + virtual void BlockTillLoaded() OVERRIDE {} |
| + |
| + private: |
| + const GURL url_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BookmarkServiceMock); |
| +}; |
| + |
| +BookmarkServiceMock::BookmarkServiceMock(const GURL& url) |
| + : BookmarkService(), |
| + url_(url) { |
| +} |
| + |
| +bool BookmarkServiceMock::IsBookmarked(const GURL& url) { |
| + return url == url_; |
| +} |
| + |
| +TEST_F(ScoredHistoryMatchTest, ScoringBookmarks) { |
| + // We use NowFromSystemTime() because MakeURLRow uses the same function |
| + // to calculate last visit time when building a row. |
| + base::Time now = base::Time::NowFromSystemTime(); |
| + |
| + std::string url_string("http://fedcba"); |
| + const GURL url(url_string); |
| + URLRow row(MakeURLRow(url_string.c_str(), "abcd bcd", 8, 3, 1)); |
| + RowWordStarts word_starts; |
| + PopulateWordStarts(row, &word_starts); |
| + VisitInfoVector visits = CreateVisitInfoVector(8, 3, now); |
| + ScoredHistoryMatch scored(row, visits, std::string(), |
| + ASCIIToUTF16("abc"), Make1Term("abc"), |
| + word_starts, now, NULL); |
| + // Now bookmark that URL and make sure its score increases. |
| + ScoredHistoryMatch::bookmark_value_ = 5; |
| + BookmarkServiceMock bookmark_model_mock(url); |
| + ScoredHistoryMatch scored_with_bookmark( |
| + row, visits, std::string(), ASCIIToUTF16("abc"), Make1Term("abc"), |
| + word_starts, now, &bookmark_model_mock); |
| + EXPECT_GT(scored_with_bookmark.raw_score_, scored.raw_score_); |
| +} |
| + |
| TEST_F(ScoredHistoryMatchTest, Inlining) { |
| // We use NowFromSystemTime() because MakeURLRow uses the same function |
| // to calculate last visit time when building a row. |