| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_service_unittest.h" | 8 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 9 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 9 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 std::map<int, SkBitmap> results( | 262 std::map<int, SkBitmap> results( |
| 263 BookmarkAppHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes)); | 263 BookmarkAppHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes)); |
| 264 | 264 |
| 265 EXPECT_EQ(3u, results.size()); | 265 EXPECT_EQ(3u, results.size()); |
| 266 ValidateBitmapSizeAndColor(results[16], 16, SK_ColorYELLOW); | 266 ValidateBitmapSizeAndColor(results[16], 16, SK_ColorYELLOW); |
| 267 ValidateBitmapSizeAndColor(results[32], 32, SK_ColorBLUE); | 267 ValidateBitmapSizeAndColor(results[32], 32, SK_ColorBLUE); |
| 268 ValidateBitmapSizeAndColor(results[256], 256, SK_ColorRED); | 268 ValidateBitmapSizeAndColor(results[256], 256, SK_ColorRED); |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST_F(BookmarkAppHelperTest, GenerateIcons) { | |
| 273 { | |
| 274 // The 32x32 icon should be generated from the 16x16 icon. | |
| 275 std::map<int, SkBitmap> bitmaps; | |
| 276 bitmaps[16] = CreateSquareBitmapWithColor(16, SK_ColorRED); | |
| 277 BookmarkAppHelper::GenerateContainerIcon(&bitmaps, 32); | |
| 278 EXPECT_EQ(1u, bitmaps.count(32)); | |
| 279 EXPECT_EQ(32, bitmaps[32].width()); | |
| 280 } | |
| 281 { | |
| 282 // The 32x32 icon should not be generated because no smaller icon exists. | |
| 283 std::map<int, SkBitmap> bitmaps; | |
| 284 bitmaps[48] = CreateSquareBitmapWithColor(48, SK_ColorRED); | |
| 285 BookmarkAppHelper::GenerateContainerIcon(&bitmaps, 32); | |
| 286 EXPECT_EQ(0u, bitmaps.count(32)); | |
| 287 } | |
| 288 { | |
| 289 // The 32x32 icon should not be generated with no base icons. | |
| 290 std::map<int, SkBitmap> bitmaps; | |
| 291 BookmarkAppHelper::GenerateContainerIcon(&bitmaps, 32); | |
| 292 EXPECT_EQ(0u, bitmaps.count(32)); | |
| 293 } | |
| 294 } | |
| 295 | |
| 296 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) { | 272 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) { |
| 297 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org"))); | 273 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org"))); |
| 298 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path"))); | 274 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path"))); |
| 299 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org"))); | 275 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org"))); |
| 300 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags"))); | 276 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags"))); |
| 301 } | 277 } |
| 302 | 278 |
| 303 } // namespace extensions | 279 } // namespace extensions |
| OLD | NEW |