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

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: minor cleanup 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/common/thumbnail_score.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..43cb96a57fccb0dc85e77a226cea26ea116ed3d4 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, ShouldGenerateThumbnail) {
+ 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(ShouldGenerateThumbnail(score));
+
+ // Make it very interesting, but this is not enough.
+ score.boring_score = 0.0;
+ EXPECT_TRUE(ShouldGenerateThumbnail(score));
+
+ // good_clipping is important, but sill not enough.
+ score.good_clipping = true;
+ EXPECT_TRUE(ShouldGenerateThumbnail(score));
+
+ // at_top is important. Finally, the thumbnail is new and interesting enough.
+ score.at_top = true;
+ EXPECT_FALSE(ShouldGenerateThumbnail(score));
+
+ // Make it old. Then, it's no longer new enough.
+ score.time_at_snapshot -= ThumbnailScore::kUpdateThumbnailTime;
+ EXPECT_TRUE(ShouldGenerateThumbnail(score));
+}
« chrome/common/thumbnail_score.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