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

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

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 "chrome/browser/extensions/image_loader.h" 5 #include "chrome/browser/extensions/image_loader.h"
6 6
7 #include "base/json/json_file_value_serializer.h" 7 #include "base/json/json_file_value_serializer.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 content::TestBrowserThread io_thread_; 111 content::TestBrowserThread io_thread_;
112 }; 112 };
113 113
114 // Tests loading an image works correctly. 114 // Tests loading an image works correctly.
115 TEST_F(ImageLoaderTest, LoadImage) { 115 TEST_F(ImageLoaderTest, LoadImage) {
116 scoped_refptr<Extension> extension(CreateExtension( 116 scoped_refptr<Extension> extension(CreateExtension(
117 "image_loading_tracker", Manifest::INVALID_LOCATION)); 117 "image_loading_tracker", Manifest::INVALID_LOCATION));
118 ASSERT_TRUE(extension.get() != NULL); 118 ASSERT_TRUE(extension.get() != NULL);
119 119
120 ExtensionResource image_resource = extensions::IconsInfo::GetIconResource( 120 ExtensionResource image_resource = extensions::IconsInfo::GetIconResource(
121 extension, 121 extension.get(),
122 extension_misc::EXTENSION_ICON_SMALLISH, 122 extension_misc::EXTENSION_ICON_SMALLISH,
123 ExtensionIconSet::MATCH_EXACTLY); 123 ExtensionIconSet::MATCH_EXACTLY);
124 gfx::Size max_size(extension_misc::EXTENSION_ICON_SMALLISH, 124 gfx::Size max_size(extension_misc::EXTENSION_ICON_SMALLISH,
125 extension_misc::EXTENSION_ICON_SMALLISH); 125 extension_misc::EXTENSION_ICON_SMALLISH);
126 ImageLoader loader; 126 ImageLoader loader;
127 loader.LoadImageAsync(extension.get(), 127 loader.LoadImageAsync(extension.get(),
128 image_resource, 128 image_resource,
129 max_size, 129 max_size,
130 base::Bind(&ImageLoaderTest::OnImageLoaded, 130 base::Bind(&ImageLoaderTest::OnImageLoaded,
131 base::Unretained(this))); 131 base::Unretained(this)));
(...skipping 12 matching lines...) Expand all
144 } 144 }
145 145
146 // Tests deleting an extension while waiting for the image to load doesn't cause 146 // Tests deleting an extension while waiting for the image to load doesn't cause
147 // problems. 147 // problems.
148 TEST_F(ImageLoaderTest, DeleteExtensionWhileWaitingForCache) { 148 TEST_F(ImageLoaderTest, DeleteExtensionWhileWaitingForCache) {
149 scoped_refptr<Extension> extension(CreateExtension( 149 scoped_refptr<Extension> extension(CreateExtension(
150 "image_loading_tracker", Manifest::INVALID_LOCATION)); 150 "image_loading_tracker", Manifest::INVALID_LOCATION));
151 ASSERT_TRUE(extension.get() != NULL); 151 ASSERT_TRUE(extension.get() != NULL);
152 152
153 ExtensionResource image_resource = extensions::IconsInfo::GetIconResource( 153 ExtensionResource image_resource = extensions::IconsInfo::GetIconResource(
154 extension, 154 extension.get(),
155 extension_misc::EXTENSION_ICON_SMALLISH, 155 extension_misc::EXTENSION_ICON_SMALLISH,
156 ExtensionIconSet::MATCH_EXACTLY); 156 ExtensionIconSet::MATCH_EXACTLY);
157 gfx::Size max_size(extension_misc::EXTENSION_ICON_SMALLISH, 157 gfx::Size max_size(extension_misc::EXTENSION_ICON_SMALLISH,
158 extension_misc::EXTENSION_ICON_SMALLISH); 158 extension_misc::EXTENSION_ICON_SMALLISH);
159 ImageLoader loader; 159 ImageLoader loader;
160 std::set<int> sizes; 160 std::set<int> sizes;
161 sizes.insert(extension_misc::EXTENSION_ICON_SMALLISH); 161 sizes.insert(extension_misc::EXTENSION_ICON_SMALLISH);
162 loader.LoadImageAsync(extension.get(), 162 loader.LoadImageAsync(extension.get(),
163 image_resource, 163 image_resource,
164 max_size, 164 max_size,
(...skipping 30 matching lines...) Expand all
195 TEST_F(ImageLoaderTest, MultipleImages) { 195 TEST_F(ImageLoaderTest, MultipleImages) {
196 scoped_refptr<Extension> extension(CreateExtension( 196 scoped_refptr<Extension> extension(CreateExtension(
197 "image_loading_tracker", Manifest::INVALID_LOCATION)); 197 "image_loading_tracker", Manifest::INVALID_LOCATION));
198 ASSERT_TRUE(extension.get() != NULL); 198 ASSERT_TRUE(extension.get() != NULL);
199 199
200 std::vector<ImageLoader::ImageRepresentation> info_list; 200 std::vector<ImageLoader::ImageRepresentation> info_list;
201 int sizes[] = {extension_misc::EXTENSION_ICON_SMALLISH, 201 int sizes[] = {extension_misc::EXTENSION_ICON_SMALLISH,
202 extension_misc::EXTENSION_ICON_BITTY}; 202 extension_misc::EXTENSION_ICON_BITTY};
203 for (size_t i = 0; i < arraysize(sizes); ++i) { 203 for (size_t i = 0; i < arraysize(sizes); ++i) {
204 ExtensionResource resource = extensions::IconsInfo::GetIconResource( 204 ExtensionResource resource = extensions::IconsInfo::GetIconResource(
205 extension, sizes[i], ExtensionIconSet::MATCH_EXACTLY); 205 extension.get(), sizes[i], ExtensionIconSet::MATCH_EXACTLY);
206 info_list.push_back(ImageLoader::ImageRepresentation( 206 info_list.push_back(ImageLoader::ImageRepresentation(
207 resource, 207 resource,
208 ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, 208 ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER,
209 gfx::Size(sizes[i], sizes[i]), 209 gfx::Size(sizes[i], sizes[i]),
210 ui::SCALE_FACTOR_NONE)); 210 ui::SCALE_FACTOR_NONE));
211 } 211 }
212 212
213 ImageLoader loader; 213 ImageLoader loader;
214 loader.LoadImagesAsync(extension.get(), info_list, 214 loader.LoadImagesAsync(extension.get(), info_list,
215 base::Bind(&ImageLoaderTest::OnImageLoaded, 215 base::Bind(&ImageLoaderTest::OnImageLoaded,
(...skipping 22 matching lines...) Expand all
238 img_rep2->pixel_width()); 238 img_rep2->pixel_width());
239 } 239 }
240 240
241 // Tests IsComponentExtensionResource function. 241 // Tests IsComponentExtensionResource function.
242 TEST_F(ImageLoaderTest, IsComponentExtensionResource) { 242 TEST_F(ImageLoaderTest, IsComponentExtensionResource) {
243 scoped_refptr<Extension> extension(CreateExtension( 243 scoped_refptr<Extension> extension(CreateExtension(
244 "file_manager", Manifest::COMPONENT)); 244 "file_manager", Manifest::COMPONENT));
245 ASSERT_TRUE(extension.get() != NULL); 245 ASSERT_TRUE(extension.get() != NULL);
246 246
247 ExtensionResource resource = extensions::IconsInfo::GetIconResource( 247 ExtensionResource resource = extensions::IconsInfo::GetIconResource(
248 extension, 248 extension.get(),
249 extension_misc::EXTENSION_ICON_BITTY, 249 extension_misc::EXTENSION_ICON_BITTY,
250 ExtensionIconSet::MATCH_EXACTLY); 250 ExtensionIconSet::MATCH_EXACTLY);
251 251
252 #if defined(FILE_MANAGER_EXTENSION) 252 #if defined(FILE_MANAGER_EXTENSION)
253 int resource_id; 253 int resource_id;
254 ASSERT_EQ(true, 254 ASSERT_EQ(true,
255 ImageLoader::IsComponentExtensionResource(extension->path(), 255 ImageLoader::IsComponentExtensionResource(extension->path(),
256 resource.relative_path(), 256 resource.relative_path(),
257 &resource_id)); 257 &resource_id));
258 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); 258 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
259 #endif 259 #endif
260 } 260 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_quota_service_unittest.cc ('k') | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698