| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" | 6 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" |
| 7 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" | 7 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 EXPECT_GE(result.width(), copy_size.width()); | 127 EXPECT_GE(result.width(), copy_size.width()); |
| 128 EXPECT_GE(result.height(), copy_size.height()); | 128 EXPECT_GE(result.height(), copy_size.height()); |
| 129 EXPECT_LT(result.width(), source.width()); | 129 EXPECT_LT(result.width(), source.width()); |
| 130 EXPECT_LT(result.height(), source.height()); | 130 EXPECT_LT(result.height(), source.height()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 TEST_F(ContentBasedThumbnailingAlgorithmTest, CreateRetargetedThumbnail) { | 133 TEST_F(ContentBasedThumbnailingAlgorithmTest, CreateRetargetedThumbnail) { |
| 134 // This tests the invocation of the main thumbnail-making apparatus. | 134 // This tests the invocation of the main thumbnail-making apparatus. |
| 135 // The actual content is not really of concern here, just check the plumbing. | 135 // The actual content is not really of concern here, just check the plumbing. |
| 136 const gfx::Size image_size(1200, 800); | 136 const gfx::Size image_size(1200, 800); |
| 137 gfx::Canvas canvas(image_size, ui::SCALE_FACTOR_100P, true); | 137 gfx::Canvas canvas(image_size, 1.0f, true); |
| 138 | 138 |
| 139 // The image consists of vertical non-overlapping stripes 150 pixels wide. | 139 // The image consists of vertical non-overlapping stripes 150 pixels wide. |
| 140 canvas.FillRect(gfx::Rect(200, 200, 800, 400), SkColorSetRGB(255, 255, 255)); | 140 canvas.FillRect(gfx::Rect(200, 200, 800, 400), SkColorSetRGB(255, 255, 255)); |
| 141 SkBitmap source = | 141 SkBitmap source = |
| 142 skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); | 142 skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); |
| 143 | 143 |
| 144 ConsumerCallbackCatcher catcher; | 144 ConsumerCallbackCatcher catcher; |
| 145 const gfx::Size thumbnail_size(432, 284); | 145 const gfx::Size thumbnail_size(432, 284); |
| 146 scoped_refptr<ThumbnailingContext> context( | 146 scoped_refptr<ThumbnailingContext> context( |
| 147 ThumbnailingContext::CreateThumbnailingContextForTest()); | 147 ThumbnailingContext::CreateThumbnailingContextForTest()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 159 base::Unretained(&catcher))); | 159 base::Unretained(&catcher))); |
| 160 message_loop.RunUntilIdle(); | 160 message_loop.RunUntilIdle(); |
| 161 ASSERT_TRUE(catcher.called_back()); | 161 ASSERT_TRUE(catcher.called_back()); |
| 162 EXPECT_TRUE(catcher.score().good_clipping); | 162 EXPECT_TRUE(catcher.score().good_clipping); |
| 163 EXPECT_FALSE(catcher.captured_bitmap().empty()); | 163 EXPECT_FALSE(catcher.captured_bitmap().empty()); |
| 164 EXPECT_LT(catcher.captured_bitmap().width(), source.width()); | 164 EXPECT_LT(catcher.captured_bitmap().width(), source.width()); |
| 165 EXPECT_LT(catcher.captured_bitmap().height(), source.height()); | 165 EXPECT_LT(catcher.captured_bitmap().height(), source.height()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace thumbnails | 168 } // namespace thumbnails |
| OLD | NEW |