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 "chrome/browser/extensions/image_loading_tracker.h" |
| 6 |
5 #include "base/json/json_file_value_serializer.h" | 7 #include "base/json/json_file_value_serializer.h" |
6 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 9 #include "base/path_service.h" |
8 #include "chrome/browser/extensions/image_loading_tracker.h" | |
9 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/extensions/extension_icon_set.h" | 13 #include "chrome/common/extensions/extension_icon_set.h" |
13 #include "chrome/common/extensions/extension_resource.h" | 14 #include "chrome/common/extensions/extension_resource.h" |
14 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
15 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
16 #include "grit/component_extension_resources.h" | 17 #include "grit/component_extension_resources.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, | 191 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, |
191 image_.ToSkBitmap()->width()); | 192 image_.ToSkBitmap()->width()); |
192 } | 193 } |
193 | 194 |
194 // Tests loading multiple dimensions of the same image. | 195 // Tests loading multiple dimensions of the same image. |
195 TEST_F(ImageLoadingTrackerTest, MultipleImages) { | 196 TEST_F(ImageLoadingTrackerTest, MultipleImages) { |
196 scoped_refptr<Extension> extension(CreateExtension( | 197 scoped_refptr<Extension> extension(CreateExtension( |
197 "image_loading_tracker", Extension::INVALID)); | 198 "image_loading_tracker", Extension::INVALID)); |
198 ASSERT_TRUE(extension.get() != NULL); | 199 ASSERT_TRUE(extension.get() != NULL); |
199 | 200 |
200 std::vector<ImageLoadingTracker::ImageInfo> info_list; | 201 std::vector<ImageLoadingTracker::ImageRepInfo> info_list; |
201 int sizes[] = {ExtensionIconSet::EXTENSION_ICON_SMALLISH, | 202 int sizes[] = {ExtensionIconSet::EXTENSION_ICON_SMALLISH, |
202 ExtensionIconSet::EXTENSION_ICON_BITTY}; | 203 ExtensionIconSet::EXTENSION_ICON_BITTY}; |
203 for (size_t i = 0; i < arraysize(sizes); ++i) { | 204 for (size_t i = 0; i < arraysize(sizes); ++i) { |
204 ExtensionResource resource = | 205 ExtensionResource resource = |
205 extension->GetIconResource(sizes[i], ExtensionIconSet::MATCH_EXACTLY); | 206 extension->GetIconResource(sizes[i], ExtensionIconSet::MATCH_EXACTLY); |
206 info_list.push_back(ImageLoadingTracker::ImageInfo( | 207 info_list.push_back(ImageLoadingTracker::ImageRepInfo( |
207 resource, gfx::Size(sizes[i], sizes[i]))); | 208 resource, |
| 209 ImageLoadingTracker::ImageRepInfo::RESIZE_WHEN_LARGER, |
| 210 gfx::Size(sizes[i], sizes[i]), |
| 211 ui::SCALE_FACTOR_NONE)); |
208 } | 212 } |
209 | 213 |
210 ImageLoadingTracker loader(this); | 214 ImageLoadingTracker loader(this); |
211 loader.LoadImages(extension.get(), info_list, ImageLoadingTracker::CACHE); | 215 loader.LoadImages(extension.get(), info_list, ImageLoadingTracker::CACHE); |
212 | 216 |
213 // The image isn't cached, so we should not have received notification. | 217 // The image isn't cached, so we should not have received notification. |
214 EXPECT_EQ(0, image_loaded_count()); | 218 EXPECT_EQ(0, image_loaded_count()); |
215 | 219 |
216 WaitForImageLoad(); | 220 WaitForImageLoad(); |
217 | 221 |
(...skipping 28 matching lines...) Expand all Loading... |
246 #if defined(FILE_MANAGER_EXTENSION) | 250 #if defined(FILE_MANAGER_EXTENSION) |
247 ImageLoadingTracker loader(this); | 251 ImageLoadingTracker loader(this); |
248 int resource_id; | 252 int resource_id; |
249 ASSERT_EQ(true, | 253 ASSERT_EQ(true, |
250 loader.IsComponentExtensionResource(extension.get(), | 254 loader.IsComponentExtensionResource(extension.get(), |
251 resource, | 255 resource, |
252 resource_id)); | 256 resource_id)); |
253 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); | 257 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); |
254 #endif | 258 #endif |
255 } | 259 } |
OLD | NEW |