Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chrome/browser/extensions/extension_icon_manager_unittest.cc

Issue 9979001: Attempt to load component extension favicon from the resources first. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 // Tests loading an icon for a component extension.
142 TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) {
dgozman 2012/04/11 16:53:53 Note: this is similar to the test above, but for c
143 SkBitmap default_icon = GetDefaultIcon();
144
145 FilePath test_dir;
146 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
147 FilePath manifest_path = test_dir.AppendASCII(
148 "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,
149
150 JSONFileValueSerializer serializer(manifest_path);
151 scoped_ptr<DictionaryValue> manifest(
152 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL)));
153 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.
154
155 std::string error;
156 scoped_refptr<Extension> extension(Extension::Create(
157 manifest_path.DirName(), Extension::COMPONENT, *manifest.get(),
158 Extension::STRICT_ERROR_CHECKS, &error));
159 ASSERT_TRUE(extension.get());
160 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.
161
162 // Load the icon and grab the bitmap.
163 icon_manager.LoadIcon(extension.get());
164 WaitForImageLoad();
165 SkBitmap first_icon = icon_manager.GetIcon(extension->id());
166 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon));
167
168 // Remove the icon from the manager.
169 icon_manager.RemoveIcon(extension->id());
170
171 // Now re-load the icon - we should get the same result bitmap (and not the
172 // default icon).
173 icon_manager.LoadIcon(extension.get());
174 WaitForImageLoad();
175 SkBitmap second_icon = icon_manager.GetIcon(extension->id());
176 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon));
177
178 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon));
179 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/image_loading_tracker.h » ('j') | chrome/browser/extensions/image_loading_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698