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

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

Issue 10086023: Expose array of bitmaps contained by gfx::Image similar to NSImage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes as requested 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 "chrome/browser/extensions/image_loading_tracker.h" 8 #include "chrome/browser/extensions/image_loading_tracker.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_icon_set.h" 12 #include "chrome/common/extensions/extension_icon_set.h"
13 #include "chrome/common/extensions/extension_resource.h" 13 #include "chrome/common/extensions/extension_resource.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/test/test_browser_thread.h" 15 #include "content/test/test_browser_thread.h"
16 #include "grit/component_extension_resources.h" 16 #include "grit/component_extension_resources.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/image/image_skia.h"
20 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
23 24
24 class ImageLoadingTrackerTest : public testing::Test, 25 class ImageLoadingTrackerTest : public testing::Test,
25 public ImageLoadingTracker::Observer { 26 public ImageLoadingTracker::Observer {
26 public: 27 public:
27 ImageLoadingTrackerTest() 28 ImageLoadingTrackerTest()
28 : image_loaded_count_(0), 29 : image_loaded_count_(0),
29 quit_in_image_loaded_(false), 30 quit_in_image_loaded_(false),
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 // The image isn't cached, so we should not have received notification. 212 // The image isn't cached, so we should not have received notification.
212 EXPECT_EQ(0, image_loaded_count()); 213 EXPECT_EQ(0, image_loaded_count());
213 214
214 WaitForImageLoad(); 215 WaitForImageLoad();
215 216
216 // We should have gotten the image. 217 // We should have gotten the image.
217 EXPECT_EQ(1, image_loaded_count()); 218 EXPECT_EQ(1, image_loaded_count());
218 219
219 // Check that all images were loaded. 220 // Check that all images were loaded.
220 ASSERT_EQ(2u, image_.GetNumberOfSkBitmaps()); 221 const std::vector<const SkBitmap*>& bitmaps = image.ToImageSkia().bitmaps();
221 const SkBitmap* bmp1 = image_.GetSkBitmapAtIndex(0); 222 ASSERT_EQ(2u, bitmaps.size());
222 const SkBitmap* bmp2 = image_.GetSkBitmapAtIndex(1); 223 const SkBitmap* bmp1 = bitmaps[0];
224 const SkBitmap* bmp2 = bitmaps[1];
223 if (bmp1->width() > bmp2->width()) { 225 if (bmp1->width() > bmp2->width()) {
224 std::swap(bmp1, bmp2); 226 std::swap(bmp1, bmp2);
225 } 227 }
226 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_BITTY, bmp1->width()); 228 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_BITTY, bmp1->width());
227 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, bmp2->width()); 229 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, bmp2->width());
228 } 230 }
229 231
230 // Tests IsComponentExtensionResource function. 232 // Tests IsComponentExtensionResource function.
231 TEST_F(ImageLoadingTrackerTest, IsComponentExtensionResource) { 233 TEST_F(ImageLoadingTrackerTest, IsComponentExtensionResource) {
232 scoped_refptr<Extension> extension(CreateExtension( 234 scoped_refptr<Extension> extension(CreateExtension(
233 "file_manager", Extension::COMPONENT)); 235 "file_manager", Extension::COMPONENT));
234 ASSERT_TRUE(extension.get() != NULL); 236 ASSERT_TRUE(extension.get() != NULL);
235 237
236 ExtensionResource resource = 238 ExtensionResource resource =
237 extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_BITTY, 239 extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_BITTY,
238 ExtensionIconSet::MATCH_EXACTLY); 240 ExtensionIconSet::MATCH_EXACTLY);
239 241
240 #if defined(FILE_MANAGER_EXTENSION) 242 #if defined(FILE_MANAGER_EXTENSION)
241 ImageLoadingTracker loader(this); 243 ImageLoadingTracker loader(this);
242 int resource_id; 244 int resource_id;
243 ASSERT_EQ(true, 245 ASSERT_EQ(true,
244 loader.IsComponentExtensionResource(extension.get(), 246 loader.IsComponentExtensionResource(extension.get(),
245 resource, 247 resource,
246 resource_id)); 248 resource_id));
247 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); 249 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
248 #endif 250 #endif
249 } 251 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/themes/browser_theme_pack.cc » ('j') | chrome/browser/web_applications/web_app_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698