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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/thumbnail_score.h" 5 #include "chrome/common/thumbnail_score.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 // Tests that the different types of thumbnails are compared properly. 8 // Tests that the different types of thumbnails are compared properly.
9 TEST(ThumbnailScoreTest, ShouldReplaceThumbnailWithType) { 9 TEST(ThumbnailScoreTest, ShouldReplaceThumbnailWithType) {
10 base::Time now = base::Time::Now(); 10 base::Time now = base::Time::Now();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 some_redirects.redirect_hops_from_dest = 1; 45 some_redirects.redirect_hops_from_dest = 1;
46 46
47 EXPECT_TRUE(ShouldReplaceThumbnailWith(some_redirects, no_redirects)); 47 EXPECT_TRUE(ShouldReplaceThumbnailWith(some_redirects, no_redirects));
48 48
49 // This one has a lot of redirects but a better score. It should still be 49 // This one has a lot of redirects but a better score. It should still be
50 // rejected. 50 // rejected.
51 ThumbnailScore lotsa_redirects(0.4, true, true, now); 51 ThumbnailScore lotsa_redirects(0.4, true, true, now);
52 lotsa_redirects.redirect_hops_from_dest = 4; 52 lotsa_redirects.redirect_hops_from_dest = 4;
53 EXPECT_FALSE(ShouldReplaceThumbnailWith(no_redirects, lotsa_redirects)); 53 EXPECT_FALSE(ShouldReplaceThumbnailWith(no_redirects, lotsa_redirects));
54 } 54 }
55
56 TEST(ThumbnailScoreTest, ShouldConsiderUpdating) {
57 ThumbnailScore score;
58 // By default, the score is 1.0, meaning very boring, thus we should
59 // generate a new thumbnail.
60 EXPECT_DOUBLE_EQ(1.0, score.boring_score);
61 EXPECT_TRUE(score.ShouldConsiderUpdating());
62
63 // Make it very interesting, but this is not enough.
64 score.boring_score = 0.0;
65 EXPECT_TRUE(score.ShouldConsiderUpdating());
66
67 // good_clipping is important, but sill not enough.
68 score.good_clipping = true;
69 EXPECT_TRUE(score.ShouldConsiderUpdating());
70
71 // at_top is important. Finally, the thumbnail is new and interesting enough.
72 score.at_top = true;
73 EXPECT_FALSE(score.ShouldConsiderUpdating());
74
75 // Make it old. Then, it's no longer new enough.
76 score.time_at_snapshot -= ThumbnailScore::kUpdateThumbnailTime;
77 EXPECT_TRUE(score.ShouldConsiderUpdating());
78 }
OLDNEW
« 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