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