OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/json/json_file_value_serializer.h" | 5 #include "base/json/json_file_value_serializer.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_icon_manager.h" | 9 #include "chrome/browser/extensions/extension_icon_manager.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // Now re-load the icon - we should get the same result bitmap (and not the | 131 // Now re-load the icon - we should get the same result bitmap (and not the |
132 // default icon). | 132 // default icon). |
133 icon_manager.LoadIcon(extension.get()); | 133 icon_manager.LoadIcon(extension.get()); |
134 WaitForImageLoad(); | 134 WaitForImageLoad(); |
135 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); | 135 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); |
136 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); | 136 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); |
137 | 137 |
138 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); | 138 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); |
139 } | 139 } |
| 140 |
| 141 #if defined(FILE_MANAGER_EXTENSION) |
| 142 // Tests loading an icon for a component extension. |
| 143 TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) { |
| 144 SkBitmap default_icon = GetDefaultIcon(); |
| 145 |
| 146 FilePath test_dir; |
| 147 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 148 FilePath manifest_path = test_dir.AppendASCII( |
| 149 "extensions/file_manager/app.json"); |
| 150 |
| 151 JSONFileValueSerializer serializer(manifest_path); |
| 152 scoped_ptr<DictionaryValue> manifest( |
| 153 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); |
| 154 ASSERT_TRUE(manifest.get() != NULL); |
| 155 |
| 156 std::string error; |
| 157 scoped_refptr<Extension> extension(Extension::Create( |
| 158 manifest_path.DirName(), Extension::COMPONENT, *manifest.get(), |
| 159 Extension::STRICT_ERROR_CHECKS, &error)); |
| 160 ASSERT_TRUE(extension.get()); |
| 161 |
| 162 TestIconManager icon_manager(this); |
| 163 // Load the icon and grab the bitmap. |
| 164 icon_manager.LoadIcon(extension.get()); |
| 165 WaitForImageLoad(); |
| 166 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); |
| 167 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); |
| 168 |
| 169 // Remove the icon from the manager. |
| 170 icon_manager.RemoveIcon(extension->id()); |
| 171 |
| 172 // Now re-load the icon - we should get the same result bitmap (and not the |
| 173 // default icon). |
| 174 icon_manager.LoadIcon(extension.get()); |
| 175 WaitForImageLoad(); |
| 176 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); |
| 177 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); |
| 178 |
| 179 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); |
| 180 } |
| 181 #endif |
OLD | NEW |