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" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 // First, use the Windows API to load the icon, a basic validity test. | 86 // First, use the Windows API to load the icon, a basic validity test. |
87 HICON icon = LoadIconFromFile(icon_filename, kSmallIconWidth, | 87 HICON icon = LoadIconFromFile(icon_filename, kSmallIconWidth, |
88 kSmallIconHeight); | 88 kSmallIconHeight); |
89 EXPECT_NE(static_cast<HICON>(NULL), icon); | 89 EXPECT_NE(static_cast<HICON>(NULL), icon); |
90 if (icon != NULL) | 90 if (icon != NULL) |
91 ::DestroyIcon(icon); | 91 ::DestroyIcon(icon); |
92 | 92 |
93 // Read the file completely into memory. | 93 // Read the file completely into memory. |
94 std::string icon_data; | 94 std::string icon_data; |
95 ASSERT_TRUE(file_util::ReadFileToString(icon_filename, &icon_data)); | 95 ASSERT_TRUE(base::ReadFileToString(icon_filename, &icon_data)); |
96 ASSERT_GE(icon_data.length(), sizeof(IconUtil::ICONDIR)); | 96 ASSERT_GE(icon_data.length(), sizeof(IconUtil::ICONDIR)); |
97 | 97 |
98 // Ensure that it has exactly the expected number and sizes of icons, in the | 98 // Ensure that it has exactly the expected number and sizes of icons, in the |
99 // expected order. This matches each entry of the loaded file's icon directory | 99 // expected order. This matches each entry of the loaded file's icon directory |
100 // with the corresponding element of kIconDimensions. | 100 // with the corresponding element of kIconDimensions. |
101 // Also extracts the 256x256 entry as png_entry. | 101 // Also extracts the 256x256 entry as png_entry. |
102 const IconUtil::ICONDIR* icon_dir = | 102 const IconUtil::ICONDIR* icon_dir = |
103 reinterpret_cast<const IconUtil::ICONDIR*>(icon_data.data()); | 103 reinterpret_cast<const IconUtil::ICONDIR*>(icon_data.data()); |
104 EXPECT_EQ(expected_num_icons, icon_dir->idCount); | 104 EXPECT_EQ(expected_num_icons, icon_dir->idCount); |
105 ASSERT_GE(IconUtil::kNumIconDimensions, icon_dir->idCount); | 105 ASSERT_GE(IconUtil::kNumIconDimensions, icon_dir->idCount); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } | 426 } |
427 | 427 |
428 // This tests that kNumIconDimensionsUpToMediumSize has the correct value. | 428 // This tests that kNumIconDimensionsUpToMediumSize has the correct value. |
429 TEST_F(IconUtilTest, TestNumIconDimensionsUpToMediumSize) { | 429 TEST_F(IconUtilTest, TestNumIconDimensionsUpToMediumSize) { |
430 ASSERT_LE(IconUtil::kNumIconDimensionsUpToMediumSize, | 430 ASSERT_LE(IconUtil::kNumIconDimensionsUpToMediumSize, |
431 IconUtil::kNumIconDimensions); | 431 IconUtil::kNumIconDimensions); |
432 EXPECT_EQ(IconUtil::kMediumIconSize, | 432 EXPECT_EQ(IconUtil::kMediumIconSize, |
433 IconUtil::kIconDimensions[ | 433 IconUtil::kIconDimensions[ |
434 IconUtil::kNumIconDimensionsUpToMediumSize - 1]); | 434 IconUtil::kNumIconDimensionsUpToMediumSize - 1]); |
435 } | 435 } |
OLD | NEW |