summaryrefslogtreecommitdiffstats
path: root/chromium/ui/gfx/icon_util_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/gfx/icon_util_unittest.cc')
-rw-r--r--chromium/ui/gfx/icon_util_unittest.cc34
1 files changed, 15 insertions, 19 deletions
diff --git a/chromium/ui/gfx/icon_util_unittest.cc b/chromium/ui/gfx/icon_util_unittest.cc
index 641422a24ef..1e2e96297c2 100644
--- a/chromium/ui/gfx/icon_util_unittest.cc
+++ b/chromium/ui/gfx/icon_util_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/gfx/icon_util.h"
+
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
@@ -9,11 +11,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/gfx_paths.h"
-#include "ui/gfx/icon_util.h"
+#include "ui/gfx/icon_util_unittests_resource.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_family.h"
#include "ui/gfx/size.h"
-#include "ui/test/ui_unittests_resource.h"
namespace {
@@ -50,9 +51,8 @@ class IconUtilTest : public testing::Test {
SkBitmap CreateBlackSkBitmap(int width, int height) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap.allocPixels();
- // Setting the pixels to black.
+ bitmap.allocN32Pixels(width, height);
+ // Setting the pixels to transparent-black.
memset(bitmap.getPixels(), 0, width * height * 4);
return bitmap;
}
@@ -172,23 +172,22 @@ TEST_F(IconUtilTest, TestBitmapToIconInvalidParameters) {
// Wrong bitmap format.
bitmap.reset(new SkBitmap);
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
- bitmap->setConfig(SkBitmap::kA8_Config, kSmallIconWidth, kSmallIconHeight);
+ bitmap->setInfo(SkImageInfo::MakeA8(kSmallIconWidth, kSmallIconHeight));
icon = IconUtil::CreateHICONFromSkBitmap(*bitmap);
EXPECT_EQ(icon, static_cast<HICON>(NULL));
// Invalid bitmap size.
bitmap.reset(new SkBitmap);
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, 0, 0);
+ bitmap->setInfo(SkImageInfo::MakeN32Premul(0, 0));
icon = IconUtil::CreateHICONFromSkBitmap(*bitmap);
EXPECT_EQ(icon, static_cast<HICON>(NULL));
// Valid bitmap configuration but no pixels allocated.
bitmap.reset(new SkBitmap);
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
- bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- kSmallIconWidth,
- kSmallIconHeight);
+ bitmap->setInfo(SkImageInfo::MakeN32Premul(kSmallIconWidth,
+ kSmallIconHeight));
icon = IconUtil::CreateHICONFromSkBitmap(*bitmap);
EXPECT_TRUE(icon == NULL);
}
@@ -206,10 +205,9 @@ TEST_F(IconUtilTest, TestCreateIconFileInvalidParameters) {
// Wrong bitmap format.
bitmap.reset(new SkBitmap);
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
- bitmap->setConfig(SkBitmap::kA8_Config, kSmallIconWidth, kSmallIconHeight);
// Must allocate pixels or else ImageSkia will ignore the bitmap and just
// return an empty image.
- bitmap->allocPixels();
+ bitmap->allocPixels(SkImageInfo::MakeA8(kSmallIconWidth, kSmallIconHeight));
memset(bitmap->getPixels(), 0, bitmap->width() * bitmap->height());
image_family.Add(gfx::Image::CreateFrom1xBitmap(*bitmap));
EXPECT_FALSE(IconUtil::CreateIconFileFromImageFamily(image_family,
@@ -220,8 +218,7 @@ TEST_F(IconUtilTest, TestCreateIconFileInvalidParameters) {
image_family.clear();
bitmap.reset(new SkBitmap);
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, 0, 0);
- bitmap->allocPixels();
+ bitmap->allocPixels(SkImageInfo::MakeN32Premul(0, 0));
image_family.Add(gfx::Image::CreateFrom1xBitmap(*bitmap));
EXPECT_FALSE(IconUtil::CreateIconFileFromImageFamily(image_family,
valid_icon_filename));
@@ -231,9 +228,8 @@ TEST_F(IconUtilTest, TestCreateIconFileInvalidParameters) {
image_family.clear();
bitmap.reset(new SkBitmap);
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
- bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- kSmallIconWidth,
- kSmallIconHeight);
+ bitmap->setInfo(SkImageInfo::MakeN32Premul(kSmallIconWidth,
+ kSmallIconHeight));
image_family.Add(gfx::Image::CreateFrom1xBitmap(*bitmap));
EXPECT_FALSE(IconUtil::CreateIconFileFromImageFamily(image_family,
valid_icon_filename));
@@ -284,7 +280,7 @@ TEST_F(IconUtilTest, TestCreateSkBitmapFromHICON) {
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
EXPECT_EQ(bitmap->width(), small_icon_size.width());
EXPECT_EQ(bitmap->height(), small_icon_size.height());
- EXPECT_EQ(bitmap->config(), SkBitmap::kARGB_8888_Config);
+ EXPECT_EQ(bitmap->colorType(), kPMColor_SkColorType);
::DestroyIcon(small_icon);
base::FilePath large_icon_filename = test_data_directory_.AppendASCII(
@@ -298,7 +294,7 @@ TEST_F(IconUtilTest, TestCreateSkBitmapFromHICON) {
ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL));
EXPECT_EQ(bitmap->width(), large_icon_size.width());
EXPECT_EQ(bitmap->height(), large_icon_size.height());
- EXPECT_EQ(bitmap->config(), SkBitmap::kARGB_8888_Config);
+ EXPECT_EQ(bitmap->colorType(), kPMColor_SkColorType);
::DestroyIcon(large_icon);
}