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

Unified Diff: chrome/common/thumbnail_score_unittest.cc

Issue 6389001: Add heuristics to skip thumbnail generation when it's unnecessary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix debug unit tests Created 9 years, 11 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
« chrome/browser/history/top_sites.cc ('K') | « chrome/common/thumbnail_score.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/thumbnail_score_unittest.cc
diff --git a/chrome/common/thumbnail_score_unittest.cc b/chrome/common/thumbnail_score_unittest.cc
index 14d79dd9d7af9081608bb21eef19ead3de526b38..1defee3128b4f131b6761bfe73014734d753c994 100644
--- a/chrome/common/thumbnail_score_unittest.cc
+++ b/chrome/common/thumbnail_score_unittest.cc
@@ -52,3 +52,27 @@ TEST(ThumbnailScoreTest, RedirectCount) {
lotsa_redirects.redirect_hops_from_dest = 4;
EXPECT_FALSE(ShouldReplaceThumbnailWith(no_redirects, lotsa_redirects));
}
+
+TEST(ThumbnailScoreTest, ShouldConsiderUpdating) {
+ ThumbnailScore score;
+ // By default, the score is 1.0, meaning very boring, thus we should
+ // generate a new thumbnail.
+ EXPECT_DOUBLE_EQ(1.0, score.boring_score);
+ EXPECT_TRUE(score.ShouldConsiderUpdating());
+
+ // Make it very interesting, but this is not enough.
+ score.boring_score = 0.0;
+ EXPECT_TRUE(score.ShouldConsiderUpdating());
+
+ // good_clipping is important, but sill not enough.
+ score.good_clipping = true;
+ EXPECT_TRUE(score.ShouldConsiderUpdating());
+
+ // at_top is important. Finally, the thumbnail is new and interesting enough.
+ score.at_top = true;
+ EXPECT_FALSE(score.ShouldConsiderUpdating());
+
+ // Make it old. Then, it's no longer new enough.
+ score.time_at_snapshot -= ThumbnailScore::kUpdateThumbnailTime;
+ EXPECT_TRUE(score.ShouldConsiderUpdating());
+}
« chrome/browser/history/top_sites.cc ('K') | « chrome/common/thumbnail_score.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698