summaryrefslogtreecommitdiffstats
path: root/ui/gfx/image/image_unittest_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/image/image_unittest_util.cc')
-rw-r--r--ui/gfx/image/image_unittest_util.cc36
1 files changed, 26 insertions, 10 deletions
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 6a72869..141db84 100644
--- a/ui/gfx/image/image_unittest_util.cc
+++ b/ui/gfx/image/image_unittest_util.cc
@@ -20,11 +20,11 @@
namespace gfx {
namespace test {
-SkBitmap* CreateBitmap(int width, int height) {
- SkBitmap* bitmap = new SkBitmap();
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap->allocPixels();
- bitmap->eraseRGB(255, 0, 0);
+const SkBitmap CreateBitmap(int width, int height) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.allocPixels();
+ bitmap.eraseRGB(255, 0, 0);
return bitmap;
}
@@ -65,15 +65,15 @@ bool IsEmpty(const gfx::Image& image) {
}
PlatformImage CreatePlatformImage() {
- scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25));
+ const SkBitmap bitmap(CreateBitmap(25, 25));
#if defined(OS_MACOSX)
- NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get()));
+ NSImage* image = gfx::SkBitmapToNSImage(bitmap);
base::mac::NSObjectRetain(image);
return image;
#elif defined(TOOLKIT_GTK)
- return gfx::GdkPixbufFromSkBitmap(bitmap.get());
+ return gfx::GdkPixbufFromSkBitmap(&bitmap);
#else
- return bitmap.release();
+ return bitmap;
#endif
}
@@ -93,7 +93,23 @@ PlatformImage ToPlatformType(const gfx::Image& image) {
#elif defined(TOOLKIT_GTK)
return image.ToGdkPixbuf();
#else
- return image.ToSkBitmap();
+ return *image.ToSkBitmap();
+#endif
+}
+
+bool IsPlatformImageValid(PlatformImage image) {
+#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+ return image != NULL;
+#else
+ return !image.isNull();
+#endif
+}
+
+bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) {
+#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+ return image1 == image2;
+#else
+ return image1.getPixels() == image2.getPixels();
#endif
}