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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/extension_icon_manager.h" | 8 #include "chrome/browser/extensions/extension_icon_manager.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 FilePath test_dir; | 102 FilePath test_dir; |
103 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 103 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
104 FilePath manifest_path = test_dir.AppendASCII( | 104 FilePath manifest_path = test_dir.AppendASCII( |
105 "extensions/image_loading_tracker/app.json"); | 105 "extensions/image_loading_tracker/app.json"); |
106 | 106 |
107 JSONFileValueSerializer serializer(manifest_path); | 107 JSONFileValueSerializer serializer(manifest_path); |
108 scoped_ptr<DictionaryValue> manifest( | 108 scoped_ptr<DictionaryValue> manifest( |
109 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); | 109 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); |
110 ASSERT_TRUE(manifest.get() != NULL); | 110 ASSERT_TRUE(manifest.get() != NULL); |
111 | 111 |
| 112 std::string error; |
112 scoped_refptr<Extension> extension(Extension::Create( | 113 scoped_refptr<Extension> extension(Extension::Create( |
113 manifest_path.DirName(), Extension::INVALID, *manifest.get(), | 114 manifest_path.DirName(), Extension::INVALID, *manifest.get(), |
114 Extension::STRICT_ERROR_CHECKS, NULL)); | 115 Extension::STRICT_ERROR_CHECKS, &error)); |
115 ASSERT_TRUE(extension.get()); | 116 ASSERT_TRUE(extension.get()); |
116 TestIconManager icon_manager(this); | 117 TestIconManager icon_manager(this); |
117 | 118 |
118 // Load the icon and grab the bitmap. | 119 // Load the icon and grab the bitmap. |
119 icon_manager.LoadIcon(extension.get()); | 120 icon_manager.LoadIcon(extension.get()); |
120 WaitForImageLoad(); | 121 WaitForImageLoad(); |
121 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); | 122 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); |
122 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); | 123 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); |
123 | 124 |
124 // Remove the icon from the manager. | 125 // Remove the icon from the manager. |
125 icon_manager.RemoveIcon(extension->id()); | 126 icon_manager.RemoveIcon(extension->id()); |
126 | 127 |
127 // Now re-load the icon - we should get the same result bitmap (and not the | 128 // Now re-load the icon - we should get the same result bitmap (and not the |
128 // default icon). | 129 // default icon). |
129 icon_manager.LoadIcon(extension.get()); | 130 icon_manager.LoadIcon(extension.get()); |
130 WaitForImageLoad(); | 131 WaitForImageLoad(); |
131 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); | 132 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); |
132 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); | 133 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); |
133 | 134 |
134 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); | 135 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); |
135 } | 136 } |
OLD | NEW |