| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 std::map<int, SkBitmap> results( | 220 std::map<int, SkBitmap> results( |
| 221 BookmarkAppHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes)); | 221 BookmarkAppHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes)); |
| 222 | 222 |
| 223 EXPECT_EQ(3u, results.size()); | 223 EXPECT_EQ(3u, results.size()); |
| 224 ValidateBitmapSizeAndColor(results[16], 16, SK_ColorYELLOW); | 224 ValidateBitmapSizeAndColor(results[16], 16, SK_ColorYELLOW); |
| 225 ValidateBitmapSizeAndColor(results[32], 32, SK_ColorBLUE); | 225 ValidateBitmapSizeAndColor(results[32], 32, SK_ColorBLUE); |
| 226 ValidateBitmapSizeAndColor(results[256], 256, SK_ColorRED); | 226 ValidateBitmapSizeAndColor(results[256], 256, SK_ColorRED); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 TEST_F(BookmarkAppHelperTest, GenerateIcons) { | |
| 231 { | |
| 232 // The 32x32 icon should be generated from the 16x16 icon. | |
| 233 std::map<int, SkBitmap> bitmaps; | |
| 234 bitmaps[16] = CreateSquareBitmapWithColor(16, SK_ColorRED); | |
| 235 BookmarkAppHelper::GenerateContainerIcon(&bitmaps, 32); | |
| 236 EXPECT_EQ(1u, bitmaps.count(32)); | |
| 237 EXPECT_EQ(32, bitmaps[32].width()); | |
| 238 } | |
| 239 { | |
| 240 // The 32x32 icon should not be generated because no smaller icon exists. | |
| 241 std::map<int, SkBitmap> bitmaps; | |
| 242 bitmaps[48] = CreateSquareBitmapWithColor(48, SK_ColorRED); | |
| 243 BookmarkAppHelper::GenerateContainerIcon(&bitmaps, 32); | |
| 244 EXPECT_EQ(0u, bitmaps.count(32)); | |
| 245 } | |
| 246 { | |
| 247 // The 32x32 icon should not be generated with no base icons. | |
| 248 std::map<int, SkBitmap> bitmaps; | |
| 249 BookmarkAppHelper::GenerateContainerIcon(&bitmaps, 32); | |
| 250 EXPECT_EQ(0u, bitmaps.count(32)); | |
| 251 } | |
| 252 } | |
| 253 | |
| 254 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) { | 230 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) { |
| 255 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org"))); | 231 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org"))); |
| 256 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path"))); | 232 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path"))); |
| 257 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org"))); | 233 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org"))); |
| 258 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags"))); | 234 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags"))); |
| 259 } | 235 } |
| 260 | 236 |
| 261 } // namespace extensions | 237 } // namespace extensions |
| OLD | NEW |