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

Unified Diff: chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc

Issue 15458003: Plugs in the new thumbnailing algorithm to ThumbnailTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests. Created 7 years, 7 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
Index: chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc
diff --git a/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc b/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc
index 54d0bcd80f34822e8a5496cdd42ca04ff5fb758f..312540ab48f4645b6a7b918aecfb9d048fbfb9be 100644
--- a/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc
+++ b/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc
@@ -196,3 +196,37 @@ TEST_F(SimpleThumbnailCropTest, GetCanvasCopyInfo) {
EXPECT_EQ(thumbnails::CLIP_RESULT_SOURCE_IS_SMALLER, clip_result);
EXPECT_EQ(thumbnail_size, target_size_result);
}
+
+TEST_F(SimpleThumbnailCropTest, GetClippingRect) {
+ const gfx::Size desired_size(300, 200);
+ thumbnails::ClipResult clip_result;
+ // Try out 'microsource'.
+ gfx::Rect clip_rect = SimpleThumbnailCrop::GetClippingRect(
+ gfx::Size(300, 199), desired_size, &clip_result);
+ EXPECT_EQ(clip_result, thumbnails::CLIP_RESULT_SOURCE_IS_SMALLER);
+ EXPECT_EQ(clip_rect.origin(), gfx::Point(0, 0));
+ EXPECT_EQ(clip_rect.size(), desired_size);
+
+ // Portrait source.
+ clip_rect = SimpleThumbnailCrop::GetClippingRect(
+ gfx::Size(500, 1200), desired_size, &clip_result);
+ EXPECT_EQ(clip_result, thumbnails::CLIP_RESULT_TALLER_THAN_WIDE);
+ EXPECT_EQ(clip_rect.origin(), gfx::Point(0, 0));
+ EXPECT_EQ(clip_rect.width(), 500);
+ EXPECT_LT(clip_rect.height(), 1200);
+
+ clip_rect = SimpleThumbnailCrop::GetClippingRect(
+ gfx::Size(2000, 800), desired_size, &clip_result);
+ EXPECT_TRUE(clip_result == thumbnails::CLIP_RESULT_WIDER_THAN_TALL ||
+ clip_result == thumbnails::CLIP_RESULT_MUCH_WIDER_THAN_TALL);
+ EXPECT_EQ(clip_rect.y(), 0);
+ EXPECT_GT(clip_rect.x(), 0);
+ EXPECT_LT(clip_rect.width(), 2000);
+ EXPECT_EQ(clip_rect.height(), 800);
+
+ clip_rect = SimpleThumbnailCrop::GetClippingRect(
+ gfx::Size(900, 600), desired_size, &clip_result);
+ EXPECT_EQ(clip_result, thumbnails::CLIP_RESULT_NOT_CLIPPED);
+ EXPECT_EQ(clip_rect.origin(), gfx::Point(0, 0));
+ EXPECT_EQ(clip_rect.size(), gfx::Size(900, 600));
+}

Powered by Google App Engine
This is Rietveld 408576698