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

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: Nicer diff 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
« no previous file with comments | « no previous file | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
19 #include "ui/gfx/image/image_skia.h"
19 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 23
23 class ImageLoadingTrackerTest : public testing::Test, 24 class ImageLoadingTrackerTest : public testing::Test,
24 public ImageLoadingTracker::Observer { 25 public ImageLoadingTracker::Observer {
25 public: 26 public:
26 ImageLoadingTrackerTest() 27 ImageLoadingTrackerTest()
27 : image_loaded_count_(0), 28 : image_loaded_count_(0),
28 quit_in_image_loaded_(false), 29 quit_in_image_loaded_(false),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 206
206 // The image isn't cached, so we should not have received notification. 207 // The image isn't cached, so we should not have received notification.
207 EXPECT_EQ(0, image_loaded_count()); 208 EXPECT_EQ(0, image_loaded_count());
208 209
209 WaitForImageLoad(); 210 WaitForImageLoad();
210 211
211 // We should have gotten the image. 212 // We should have gotten the image.
212 EXPECT_EQ(1, image_loaded_count()); 213 EXPECT_EQ(1, image_loaded_count());
213 214
214 // Check that all images were loaded. 215 // Check that all images were loaded.
215 ASSERT_EQ(2u, image_.GetNumberOfSkBitmaps()); 216 const std::vector<const SkBitmap*>& bitmaps =
216 const SkBitmap* bmp1 = image_.GetSkBitmapAtIndex(0); 217 image_.ToImageSkia()->bitmaps();
217 const SkBitmap* bmp2 = image_.GetSkBitmapAtIndex(1); 218 ASSERT_EQ(2u, bitmaps.size());
219 const SkBitmap* bmp1 = bitmaps[0];
220 const SkBitmap* bmp2 = bitmaps[1];
218 if (bmp1->width() > bmp2->width()) { 221 if (bmp1->width() > bmp2->width()) {
219 std::swap(bmp1, bmp2); 222 std::swap(bmp1, bmp2);
220 } 223 }
221 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_BITTY, bmp1->width()); 224 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_BITTY, bmp1->width());
222 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, bmp2->width()); 225 EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, bmp2->width());
223 } 226 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698