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

Side by Side Diff: chrome/browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 5 #include "base/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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ThumbnailingContext::CreateThumbnailingContextForTest()); 102 ThumbnailingContext::CreateThumbnailingContextForTest());
103 context->requested_copy_size = copy_size; 103 context->requested_copy_size = copy_size;
104 104
105 // This calls for exercising two distinct paths: with prior clipping and 105 // This calls for exercising two distinct paths: with prior clipping and
106 // without. 106 // without.
107 SkBitmap source; 107 SkBitmap source;
108 source.setConfig(SkBitmap::kARGB_8888_Config, 800, 600); 108 source.setConfig(SkBitmap::kARGB_8888_Config, 800, 600);
109 source.allocPixels(); 109 source.allocPixels();
110 source.eraseRGB(50, 150, 200); 110 source.eraseRGB(50, 150, 200);
111 SkBitmap result = ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap( 111 SkBitmap result = ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap(
112 source, thumbnail_size, context); 112 source, thumbnail_size, context.get());
113 EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, context->clip_result); 113 EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, context->clip_result);
114 EXPECT_GE(result.width(), copy_size.width()); 114 EXPECT_GE(result.width(), copy_size.width());
115 EXPECT_GE(result.height(), copy_size.height()); 115 EXPECT_GE(result.height(), copy_size.height());
116 EXPECT_LT(result.width(), source.width()); 116 EXPECT_LT(result.width(), source.width());
117 EXPECT_LT(result.height(), source.height()); 117 EXPECT_LT(result.height(), source.height());
118 // The check below is a bit of a side effect: since the image was clipped 118 // The check below is a bit of a side effect: since the image was clipped
119 // by scrollbar_size, it cannot be shrunk and thus what we get below is 119 // by scrollbar_size, it cannot be shrunk and thus what we get below is
120 // true. 120 // true.
121 EXPECT_NEAR(result.width(), source.width(), gfx::scrollbar_size()); 121 EXPECT_NEAR(result.width(), source.width(), gfx::scrollbar_size());
122 EXPECT_NEAR(result.height(), source.height(), gfx::scrollbar_size()); 122 EXPECT_NEAR(result.height(), source.height(), gfx::scrollbar_size());
123 123
124 result = ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap( 124 result = ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap(
125 source, thumbnail_size, context); 125 source, thumbnail_size, context.get());
126 EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, context->clip_result); 126 EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, context->clip_result);
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.
(...skipping 23 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/content_based_thumbnailing_algorithm.cc ('k') | chrome/browser/thumbnails/simple_thumbnail_crop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698