| 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 "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" |
| 6 |
| 5 #include "base/macros.h" | 7 #include "base/macros.h" |
| 6 #include "base/message_loop/message_loop.h" | |
| 7 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 8 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" | |
| 9 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" | 9 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "skia/ext/platform_canvas.h" | 12 #include "skia/ext/platform_canvas.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/scrollbar_size.h" | 16 #include "ui/gfx/scrollbar_size.h" |
| 17 | 17 |
| 18 namespace thumbnails { | 18 namespace thumbnails { |
| 19 | 19 |
| 20 typedef testing::Test ContentBasedThumbnailingAlgorithmTest; | 20 typedef testing::Test ContentBasedThumbnailingAlgorithmTest; |
| 21 | 21 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 canvas.FillRect(gfx::Rect(200, 200, 800, 400), SkColorSetRGB(255, 255, 255)); | 142 canvas.FillRect(gfx::Rect(200, 200, 800, 400), SkColorSetRGB(255, 255, 255)); |
| 143 SkBitmap source = canvas.GetBitmap(); | 143 SkBitmap source = canvas.GetBitmap(); |
| 144 | 144 |
| 145 ConsumerCallbackCatcher catcher; | 145 ConsumerCallbackCatcher catcher; |
| 146 const gfx::Size thumbnail_size(432, 284); | 146 const gfx::Size thumbnail_size(432, 284); |
| 147 scoped_refptr<ThumbnailingContext> context( | 147 scoped_refptr<ThumbnailingContext> context( |
| 148 ThumbnailingContext::CreateThumbnailingContextForTest()); | 148 ThumbnailingContext::CreateThumbnailingContextForTest()); |
| 149 context->requested_copy_size = image_size; | 149 context->requested_copy_size = image_size; |
| 150 context->clip_result = CLIP_RESULT_SOURCE_SAME_AS_TARGET; | 150 context->clip_result = CLIP_RESULT_SOURCE_SAME_AS_TARGET; |
| 151 | 151 |
| 152 base::MessageLoopForUI message_loop; | 152 content::TestBrowserThreadBundle test_browser_thread_bundle; |
| 153 content::TestBrowserThread ui_thread(content::BrowserThread::UI, | |
| 154 &message_loop); | |
| 155 ContentBasedThumbnailingAlgorithm::CreateRetargetedThumbnail( | 153 ContentBasedThumbnailingAlgorithm::CreateRetargetedThumbnail( |
| 156 source, | 154 source, |
| 157 thumbnail_size, | 155 thumbnail_size, |
| 158 context, | 156 context, |
| 159 base::Bind(&ConsumerCallbackCatcher::UiThreadCallback, | 157 base::Bind(&ConsumerCallbackCatcher::UiThreadCallback, |
| 160 base::Unretained(&catcher))); | 158 base::Unretained(&catcher))); |
| 161 base::RunLoop().RunUntilIdle(); | 159 base::RunLoop().RunUntilIdle(); |
| 162 ASSERT_TRUE(catcher.called_back()); | 160 ASSERT_TRUE(catcher.called_back()); |
| 163 EXPECT_TRUE(catcher.score().good_clipping); | 161 EXPECT_TRUE(catcher.score().good_clipping); |
| 164 EXPECT_FALSE(catcher.captured_bitmap().empty()); | 162 EXPECT_FALSE(catcher.captured_bitmap().empty()); |
| 165 EXPECT_LT(catcher.captured_bitmap().width(), source.width()); | 163 EXPECT_LT(catcher.captured_bitmap().width(), source.width()); |
| 166 EXPECT_LT(catcher.captured_bitmap().height(), source.height()); | 164 EXPECT_LT(catcher.captured_bitmap().height(), source.height()); |
| 167 } | 165 } |
| 168 | 166 |
| 169 } // namespace thumbnails | 167 } // namespace thumbnails |
| OLD | NEW |