| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/bookmark_app_helper.h" | 5 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/banners/app_banner_settings_helper.h" | 9 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 BookmarkAppHelper::BitmapAndSource CreateSquareBitmapAndSourceWithColor( | 99 BookmarkAppHelper::BitmapAndSource CreateSquareBitmapAndSourceWithColor( |
| 100 int size, | 100 int size, |
| 101 SkColor color) { | 101 SkColor color) { |
| 102 return BookmarkAppHelper::BitmapAndSource( | 102 return BookmarkAppHelper::BitmapAndSource( |
| 103 GURL(), CreateSquareBitmapWithColor(size, color)); | 103 GURL(), CreateSquareBitmapWithColor(size, color)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ValidateBitmapSizeAndColor(SkBitmap bitmap, int size, SkColor color) { | 106 void ValidateBitmapSizeAndColor(SkBitmap bitmap, int size, SkColor color) { |
| 107 // Obtain pixel lock to access pixels. | 107 // Obtain pixel lock to access pixels. |
| 108 SkAutoLockPixels lock(bitmap); | |
| 109 EXPECT_EQ(color, bitmap.getColor(0, 0)); | 108 EXPECT_EQ(color, bitmap.getColor(0, 0)); |
| 110 EXPECT_EQ(size, bitmap.width()); | 109 EXPECT_EQ(size, bitmap.width()); |
| 111 EXPECT_EQ(size, bitmap.height()); | 110 EXPECT_EQ(size, bitmap.height()); |
| 112 } | 111 } |
| 113 | 112 |
| 114 WebApplicationInfo::IconInfo CreateIconInfoWithBitmap(int size, SkColor color) { | 113 WebApplicationInfo::IconInfo CreateIconInfoWithBitmap(int size, SkColor color) { |
| 115 WebApplicationInfo::IconInfo icon_info; | 114 WebApplicationInfo::IconInfo icon_info; |
| 116 icon_info.width = size; | 115 icon_info.width = size; |
| 117 icon_info.height = size; | 116 icon_info.height = size; |
| 118 icon_info.data = CreateSquareBitmapWithColor(size, color); | 117 icon_info.data = CreateSquareBitmapWithColor(size, color); |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 TestIconGeneration(kIconSizeTiny, 0, 3); | 772 TestIconGeneration(kIconSizeTiny, 0, 3); |
| 774 } | 773 } |
| 775 | 774 |
| 776 TEST_F(BookmarkAppHelperTest, IconsResizedWhenOnlyAGigantorOneIsProvided) { | 775 TEST_F(BookmarkAppHelperTest, IconsResizedWhenOnlyAGigantorOneIsProvided) { |
| 777 // When an enormous icon is provided, each desired icon size should be resized | 776 // When an enormous icon is provided, each desired icon size should be resized |
| 778 // from it, and no icons should be generated. | 777 // from it, and no icons should be generated. |
| 779 TestIconGeneration(kIconSizeGigantor, 0, 3); | 778 TestIconGeneration(kIconSizeGigantor, 0, 3); |
| 780 } | 779 } |
| 781 | 780 |
| 782 } // namespace extensions | 781 } // namespace extensions |
| OLD | NEW |