| OLD | NEW | 
|    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2011 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/file_util.h" |    5 #include "base/file_util.h" | 
|    6 #include "base/files/scoped_temp_dir.h" |    6 #include "base/files/scoped_temp_dir.h" | 
|    7 #include "base/memory/scoped_ptr.h" |    7 #include "base/memory/scoped_ptr.h" | 
|    8 #include "base/path_service.h" |    8 #include "base/path_service.h" | 
|    9 #include "testing/gtest/include/gtest/gtest.h" |    9 #include "testing/gtest/include/gtest/gtest.h" | 
|   10 #include "third_party/skia/include/core/SkBitmap.h" |   10 #include "third_party/skia/include/core/SkBitmap.h" | 
|   11 #include "ui/gfx/gfx_paths.h" |   11 #include "ui/gfx/gfx_paths.h" | 
|   12 #include "ui/gfx/icon_util.h" |   12 #include "ui/gfx/icon_util.h" | 
|   13 #include "ui/gfx/image/image.h" |   13 #include "ui/gfx/image/image.h" | 
|   14 #include "ui/gfx/size.h" |   14 #include "ui/gfx/size.h" | 
 |   15 #include "ui/test/ui_unittests_resource.h" | 
|   15  |   16  | 
|   16 namespace { |   17 namespace { | 
|   17  |   18  | 
|   18 static const char kSmallIconName[] = "icon_util/16_X_16_icon.ico"; |   19 static const char kSmallIconName[] = "icon_util/16_X_16_icon.ico"; | 
|   19 static const char kLargeIconName[] = "icon_util/128_X_128_icon.ico"; |   20 static const char kLargeIconName[] = "icon_util/128_X_128_icon.ico"; | 
|   20 static const char kTempIconFilename[] = "temp_test_icon.ico"; |   21 static const char kTempIconFilename[] = "temp_test_icon.ico"; | 
|   21  |   22  | 
|   22 class IconUtilTest : public testing::Test { |   23 class IconUtilTest : public testing::Test { | 
|   23  public: |   24  public: | 
|   24   IconUtilTest() { |   25   IconUtilTest() { | 
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  286   ASSERT_GE(icon_data.length(), |  287   ASSERT_GE(icon_data.length(), | 
|  287             png_entry->dwImageOffset + png_entry->dwBytesInRes); |  288             png_entry->dwImageOffset + png_entry->dwBytesInRes); | 
|  288   const unsigned char* png_bytes = reinterpret_cast<const unsigned char*>( |  289   const unsigned char* png_bytes = reinterpret_cast<const unsigned char*>( | 
|  289       icon_data.data() + png_entry->dwImageOffset); |  290       icon_data.data() + png_entry->dwImageOffset); | 
|  290   gfx::Image image = gfx::Image::CreateFrom1xPNGBytes(png_bytes, |  291   gfx::Image image = gfx::Image::CreateFrom1xPNGBytes(png_bytes, | 
|  291                                                       png_entry->dwBytesInRes); |  292                                                       png_entry->dwBytesInRes); | 
|  292   SkBitmap bitmap = image.AsBitmap(); |  293   SkBitmap bitmap = image.AsBitmap(); | 
|  293   EXPECT_EQ(256, bitmap.width()); |  294   EXPECT_EQ(256, bitmap.width()); | 
|  294   EXPECT_EQ(256, bitmap.height()); |  295   EXPECT_EQ(256, bitmap.height()); | 
|  295 } |  296 } | 
 |  297  | 
 |  298 TEST_F(IconUtilTest, TestCreateSkBitmapFromIconResource48x48) { | 
 |  299   HMODULE module = GetModuleHandle(NULL); | 
 |  300   scoped_ptr<SkBitmap> bitmap( | 
 |  301       IconUtil::CreateSkBitmapFromIconResource(module, IDR_MAINFRAME, 48)); | 
 |  302   ASSERT_TRUE(bitmap.get()); | 
 |  303   EXPECT_EQ(48, bitmap->width()); | 
 |  304   EXPECT_EQ(48, bitmap->height()); | 
 |  305 } | 
 |  306  | 
 |  307 TEST_F(IconUtilTest, TestCreateSkBitmapFromIconResource256x256) { | 
 |  308   HMODULE module = GetModuleHandle(NULL); | 
 |  309   scoped_ptr<SkBitmap> bitmap( | 
 |  310       IconUtil::CreateSkBitmapFromIconResource(module, IDR_MAINFRAME, 256)); | 
 |  311   ASSERT_TRUE(bitmap.get()); | 
 |  312   EXPECT_EQ(256, bitmap->width()); | 
 |  313   EXPECT_EQ(256, bitmap->height()); | 
 |  314 } | 
| OLD | NEW |