OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/thumbnails/simple_thumbnail_crop.h" | 5 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/thumbnails/thumbnailing_context.h" | 9 #include "chrome/browser/thumbnails/thumbnailing_context.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 EXPECT_NEAR(desired_aspect, clip_aspect, 0.01); | 189 EXPECT_NEAR(desired_aspect, clip_aspect, 0.01); |
190 | 190 |
191 clip_result = algorithm->GetCanvasCopyInfo( | 191 clip_result = algorithm->GetCanvasCopyInfo( |
192 gfx::Size(200, 100), | 192 gfx::Size(200, 100), |
193 ui::SCALE_FACTOR_200P, | 193 ui::SCALE_FACTOR_200P, |
194 &clipping_rect_result, | 194 &clipping_rect_result, |
195 &target_size_result); | 195 &target_size_result); |
196 EXPECT_EQ(thumbnails::CLIP_RESULT_SOURCE_IS_SMALLER, clip_result); | 196 EXPECT_EQ(thumbnails::CLIP_RESULT_SOURCE_IS_SMALLER, clip_result); |
197 EXPECT_EQ(thumbnail_size, target_size_result); | 197 EXPECT_EQ(thumbnail_size, target_size_result); |
198 } | 198 } |
199 | |
200 TEST_F(SimpleThumbnailCropTest, GetClippingRect) { | |
201 const gfx::Size desired_size(300, 200); | |
202 thumbnails::ClipResult clip_result; | |
203 // Try out 'microsource'. | |
204 gfx::Rect clip_rect = SimpleThumbnailCrop::GetClippingRect( | |
205 gfx::Size(300, 199), desired_size, &clip_result); | |
206 EXPECT_EQ(clip_result, thumbnails::CLIP_RESULT_SOURCE_IS_SMALLER); | |
mazda
2013/05/29 21:50:27
The expectation is first.
Same applies to all the
motek.
2013/05/30 15:00:03
Done.
| |
207 EXPECT_EQ(clip_rect.origin(), gfx::Point(0, 0)); | |
208 EXPECT_EQ(clip_rect.size(), desired_size); | |
209 | |
210 // Portrait source. | |
211 clip_rect = SimpleThumbnailCrop::GetClippingRect( | |
212 gfx::Size(500, 1200), desired_size, &clip_result); | |
213 EXPECT_EQ(clip_result, thumbnails::CLIP_RESULT_TALLER_THAN_WIDE); | |
214 EXPECT_EQ(clip_rect.origin(), gfx::Point(0, 0)); | |
215 EXPECT_EQ(clip_rect.width(), 500); | |
216 EXPECT_LT(clip_rect.height(), 1200); | |
217 | |
218 clip_rect = SimpleThumbnailCrop::GetClippingRect( | |
219 gfx::Size(2000, 800), desired_size, &clip_result); | |
220 EXPECT_TRUE(clip_result == thumbnails::CLIP_RESULT_WIDER_THAN_TALL || | |
221 clip_result == thumbnails::CLIP_RESULT_MUCH_WIDER_THAN_TALL); | |
222 EXPECT_EQ(clip_rect.y(), 0); | |
223 EXPECT_GT(clip_rect.x(), 0); | |
224 EXPECT_LT(clip_rect.width(), 2000); | |
225 EXPECT_EQ(clip_rect.height(), 800); | |
226 | |
227 clip_rect = SimpleThumbnailCrop::GetClippingRect( | |
228 gfx::Size(900, 600), desired_size, &clip_result); | |
229 EXPECT_EQ(clip_result, thumbnails::CLIP_RESULT_NOT_CLIPPED); | |
230 EXPECT_EQ(clip_rect.origin(), gfx::Point(0, 0)); | |
231 EXPECT_EQ(clip_rect.size(), gfx::Size(900, 600)); | |
232 } | |
OLD | NEW |