Index: chrome/browser/extensions/extension_icon_manager_unittest.cc |
=================================================================== |
--- chrome/browser/extensions/extension_icon_manager_unittest.cc (revision 131549) |
+++ chrome/browser/extensions/extension_icon_manager_unittest.cc (working copy) |
@@ -137,3 +137,43 @@ |
EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); |
} |
+ |
+// Tests loading an icon for a component extension. |
+TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) { |
dgozman
2012/04/11 16:53:53
Note: this is similar to the test above, but for c
|
+ SkBitmap default_icon = GetDefaultIcon(); |
+ |
+ FilePath test_dir; |
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
+ FilePath manifest_path = test_dir.AppendASCII( |
+ "extensions/file_manager/app.json"); |
Finnur
2012/04/11 17:38:13
nit: it might make sense, for future-proofing, to
dgozman
2012/04/12 11:47:24
Not quite understood you. There are some other fil
Finnur
2012/04/12 12:53:01
Ah, right. Never mind. :)
On 2012/04/12 11:47:24,
|
+ |
+ JSONFileValueSerializer serializer(manifest_path); |
+ scoped_ptr<DictionaryValue> manifest( |
+ static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); |
+ ASSERT_TRUE(manifest.get() != NULL); |
Finnur
2012/04/11 17:38:13
nit: ASSERT_NE() ?
dgozman
2012/04/12 11:47:24
This doesn't compile for pointers.
|
+ |
+ std::string error; |
+ scoped_refptr<Extension> extension(Extension::Create( |
+ manifest_path.DirName(), Extension::COMPONENT, *manifest.get(), |
+ Extension::STRICT_ERROR_CHECKS, &error)); |
+ ASSERT_TRUE(extension.get()); |
+ TestIconManager icon_manager(this); |
Finnur
2012/04/11 17:38:13
nit: This feels like more a part of the next parag
dgozman
2012/04/12 11:47:24
Done.
|
+ |
+ // Load the icon and grab the bitmap. |
+ icon_manager.LoadIcon(extension.get()); |
+ WaitForImageLoad(); |
+ SkBitmap first_icon = icon_manager.GetIcon(extension->id()); |
+ EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); |
+ |
+ // Remove the icon from the manager. |
+ icon_manager.RemoveIcon(extension->id()); |
+ |
+ // Now re-load the icon - we should get the same result bitmap (and not the |
+ // default icon). |
+ icon_manager.LoadIcon(extension.get()); |
+ WaitForImageLoad(); |
+ SkBitmap second_icon = icon_manager.GetIcon(extension->id()); |
+ EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); |
+ |
+ EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); |
+} |