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

Side by Side Diff: chrome/browser/tab_contents/thumbnail_generator_unittest.cc

Issue 9021046: Pass const gfx::Rect& as the first parameter to FillRect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more fix Created 8 years, 10 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
« no previous file with comments | « chrome/browser/ntp_background_util.cc ('k') | chrome/browser/ui/gtk/gtk_theme_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "chrome/browser/history/top_sites.h" 7 #include "chrome/browser/history/top_sites.h"
8 #include "chrome/browser/tab_contents/thumbnail_generator.h" 8 #include "chrome/browser/tab_contents/thumbnail_generator.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_Empty) { 205 TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_Empty) {
206 SkBitmap bitmap; 206 SkBitmap bitmap;
207 EXPECT_DOUBLE_EQ(1.0, ThumbnailGenerator::CalculateBoringScore(&bitmap)); 207 EXPECT_DOUBLE_EQ(1.0, ThumbnailGenerator::CalculateBoringScore(&bitmap));
208 } 208 }
209 209
210 TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_SingleColor) { 210 TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_SingleColor) {
211 const SkColor kBlack = SkColorSetRGB(0, 0, 0); 211 const SkColor kBlack = SkColorSetRGB(0, 0, 0);
212 const gfx::Size kSize(20, 10); 212 const gfx::Size kSize(20, 10);
213 gfx::CanvasSkia canvas(kSize, true); 213 gfx::CanvasSkia canvas(kSize, true);
214 // Fill all pixesl in black. 214 // Fill all pixesl in black.
215 canvas.FillRect(kBlack, gfx::Rect(gfx::Point(), kSize)); 215 canvas.FillRect(gfx::Rect(gfx::Point(), kSize), kBlack);
216 216
217 SkBitmap bitmap = 217 SkBitmap bitmap =
218 skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); 218 skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false);
219 // The thumbnail should deserve the highest boring score. 219 // The thumbnail should deserve the highest boring score.
220 EXPECT_DOUBLE_EQ(1.0, ThumbnailGenerator::CalculateBoringScore(&bitmap)); 220 EXPECT_DOUBLE_EQ(1.0, ThumbnailGenerator::CalculateBoringScore(&bitmap));
221 } 221 }
222 222
223 TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_TwoColors) { 223 TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_TwoColors) {
224 const SkColor kBlack = SkColorSetRGB(0, 0, 0); 224 const SkColor kBlack = SkColorSetRGB(0, 0, 0);
225 const SkColor kWhite = SkColorSetRGB(0xFF, 0xFF, 0xFF); 225 const SkColor kWhite = SkColorSetRGB(0xFF, 0xFF, 0xFF);
226 const gfx::Size kSize(20, 10); 226 const gfx::Size kSize(20, 10);
227 227
228 gfx::CanvasSkia canvas(kSize, true); 228 gfx::CanvasSkia canvas(kSize, true);
229 // Fill all pixesl in black. 229 // Fill all pixesl in black.
230 canvas.FillRect(kBlack, gfx::Rect(gfx::Point(), kSize)); 230 canvas.FillRect(gfx::Rect(gfx::Point(), kSize), kBlack);
231 // Fill the left half pixels in white. 231 // Fill the left half pixels in white.
232 canvas.FillRect(kWhite, gfx::Rect(0, 0, kSize.width() / 2, kSize.height())); 232 canvas.FillRect(gfx::Rect(0, 0, kSize.width() / 2, kSize.height()), kWhite);
233 233
234 SkBitmap bitmap = 234 SkBitmap bitmap =
235 skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); 235 skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false);
236 ASSERT_EQ(kSize.width(), bitmap.width()); 236 ASSERT_EQ(kSize.width(), bitmap.width());
237 ASSERT_EQ(kSize.height(), bitmap.height()); 237 ASSERT_EQ(kSize.height(), bitmap.height());
238 // The thumbnail should be less boring because two colors are used. 238 // The thumbnail should be less boring because two colors are used.
239 EXPECT_DOUBLE_EQ(0.5, ThumbnailGenerator::CalculateBoringScore(&bitmap)); 239 EXPECT_DOUBLE_EQ(0.5, ThumbnailGenerator::CalculateBoringScore(&bitmap));
240 } 240 }
241 241
242 TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_TallerThanWide) { 242 TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_TallerThanWide) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 good_score.good_clipping = true; 397 good_score.good_clipping = true;
398 good_score.boring_score = 0.0; 398 good_score.boring_score = 0.0;
399 good_score.load_completed = true; 399 good_score.load_completed = true;
400 top_sites->AddKnownURL(kGoodURL, good_score); 400 top_sites->AddKnownURL(kGoodURL, good_score);
401 401
402 // Should be false, as the existing thumbnail is good enough (i.e. don't 402 // Should be false, as the existing thumbnail is good enough (i.e. don't
403 // need to replace the existing thumbnail which is new and good). 403 // need to replace the existing thumbnail which is new and good).
404 EXPECT_FALSE(ThumbnailGenerator::ShouldUpdateThumbnail( 404 EXPECT_FALSE(ThumbnailGenerator::ShouldUpdateThumbnail(
405 &profile, top_sites.get(), kGoodURL)); 405 &profile, top_sites.get(), kGoodURL));
406 } 406 }
OLDNEW
« no previous file with comments | « chrome/browser/ntp_background_util.cc ('k') | chrome/browser/ui/gtk/gtk_theme_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698