This source file includes following definitions.
- TEST
- TEST
- TEST
- TEST
#include "chrome/common/thumbnail_score.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(ThumbnailScoreTest, ShouldReplaceThumbnailWithType) {
base::Time now = base::Time::Now();
ThumbnailScore nothing_good(0.5, false, false, now);
ThumbnailScore not_at_top(0.5, false, true, now);
ThumbnailScore bad_clipping(0.5, true, false, now);
ThumbnailScore life_is_awesome(0.5, true, true, now);
EXPECT_TRUE(ShouldReplaceThumbnailWith(nothing_good, not_at_top));
EXPECT_TRUE(ShouldReplaceThumbnailWith(nothing_good, bad_clipping));
EXPECT_TRUE(ShouldReplaceThumbnailWith(nothing_good, life_is_awesome));
EXPECT_TRUE(ShouldReplaceThumbnailWith(not_at_top, bad_clipping));
EXPECT_TRUE(ShouldReplaceThumbnailWith(not_at_top, life_is_awesome));
EXPECT_TRUE(ShouldReplaceThumbnailWith(bad_clipping, life_is_awesome));
}
TEST(ThumbnailScoreTest, ShouldReplaceThumbnailWithTime) {
base::Time now = base::Time::Now();
base::Time last_year = now - base::TimeDelta::FromDays(365);
ThumbnailScore oldie_but_goodie(0.1, true, true, last_year);
ThumbnailScore newie_but_crappie(0.9, true, true, now);
EXPECT_TRUE(ShouldReplaceThumbnailWith(oldie_but_goodie, newie_but_crappie));
}
TEST(ThumbnailScoreTest, RedirectCount) {
base::Time now = base::Time::Now();
ThumbnailScore no_redirects(0.5, true, true, now);
no_redirects.redirect_hops_from_dest = 0;
ThumbnailScore some_redirects(0.5, true, true, now);
some_redirects.redirect_hops_from_dest = 1;
EXPECT_TRUE(ShouldReplaceThumbnailWith(some_redirects, no_redirects));
ThumbnailScore lotsa_redirects(0.4, true, true, now);
lotsa_redirects.redirect_hops_from_dest = 4;
EXPECT_FALSE(ShouldReplaceThumbnailWith(no_redirects, lotsa_redirects));
}
TEST(ThumbnailScoreTest, ShouldConsiderUpdating) {
ThumbnailScore score;
EXPECT_TRUE(score.ShouldConsiderUpdating());
score.boring_score = 0.0;
EXPECT_TRUE(score.ShouldConsiderUpdating());
score.good_clipping = true;
EXPECT_TRUE(score.ShouldConsiderUpdating());
score.at_top = true;
EXPECT_TRUE(score.ShouldConsiderUpdating());
score.load_completed = true;
EXPECT_FALSE(score.ShouldConsiderUpdating());
score.boring_score = 1.0;
EXPECT_FALSE(score.ShouldConsiderUpdating());
score.time_at_snapshot -=
base::TimeDelta::FromDays(ThumbnailScore::kUpdateThumbnailTimeDays);
EXPECT_TRUE(score.ShouldConsiderUpdating());
}