summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-25 13:10:27 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-25 13:10:27 +0000
commit61b86fbd9ea4e2bb6c125dcf995526031bde6eda (patch)
tree53c0944b8a07a169a0680d04056e668629f6fbd6
parent867ba4b6c9c68a567382289e154ce08918a320a6 (diff)
downloadchromium_src-61b86fbd9ea4e2bb6c125dcf995526031bde6eda.zip
chromium_src-61b86fbd9ea4e2bb6c125dcf995526031bde6eda.tar.gz
chromium_src-61b86fbd9ea4e2bb6c125dcf995526031bde6eda.tar.bz2
Revert 82841 - Adding missing files from r82838
TBR=sail@chromium.org Review URL: http://codereview.chromium.org/6895049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82855 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/gfx/image_mac_unittest.mm110
-rw-r--r--ui/gfx/image_unittest_util.cc55
-rw-r--r--ui/gfx/image_unittest_util.h33
3 files changed, 0 insertions, 198 deletions
diff --git a/ui/gfx/image_mac_unittest.mm b/ui/gfx/image_mac_unittest.mm
deleted file mode 100644
index 1c333db..0000000
--- a/ui/gfx/image_mac_unittest.mm
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <Cocoa/Cocoa.h>
-
-#include "base/logging.h"
-#include "base/memory/scoped_nsobject.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/image.h"
-#include "ui/gfx/image_unittest_util.h"
-
-namespace {
-
-class ImageMacTest : public testing::Test {
- public:
- void CreateBitmapImageRep(int width, int height, NSImageRep** image_rep) {
- scoped_nsobject<NSImage> image([[NSImage alloc]
- initWithSize:NSMakeSize(width, height)]);
- [image lockFocus];
- [[NSColor redColor] set];
- NSRectFill(NSMakeRect(0, 0, width, height));
- [image unlockFocus];
- EXPECT_TRUE([[[image representations] lastObject]
- isKindOfClass:[NSImageRep class]]);
- *image_rep = [[image representations] lastObject];
- }
-};
-
-namespace gt = gfx::test;
-
-TEST_F(ImageMacTest, MultiResolutionNSImageToSkBitmap) {
- const int width1 = 10;
- const int height1 = 12;
- const int width2 = 20;
- const int height2 = 24;
-
- NSImageRep* image_rep_1;
- CreateBitmapImageRep(width1, height1, &image_rep_1);
- NSImageRep* image_rep_2;
- CreateBitmapImageRep(width2, height2, &image_rep_2);
- scoped_nsobject<NSImage> ns_image([[NSImage alloc]
- initWithSize:NSMakeSize(width1, height1)]);
- [ns_image addRepresentation:image_rep_1];
- [ns_image addRepresentation:image_rep_2];
-
- gfx::Image image(ns_image.release());
-
- EXPECT_EQ(1u, image.RepresentationCount());
- EXPECT_EQ(2u, image.GetNumberOfSkBitmaps());
-
- const SkBitmap* bitmap1 = image.GetSkBitmapAtIndex(0);
- EXPECT_TRUE(bitmap1);
- const SkBitmap* bitmap2 = image.GetSkBitmapAtIndex(1);
- EXPECT_TRUE(bitmap2);
-
- if (bitmap1->width() == width1) {
- EXPECT_EQ(bitmap1->height(), height1);
- EXPECT_EQ(bitmap2->width(), width2);
- EXPECT_EQ(bitmap2->height(), height2);
- } else {
- EXPECT_EQ(bitmap1->width(), width2);
- EXPECT_EQ(bitmap1->height(), height2);
- EXPECT_EQ(bitmap2->width(), width1);
- EXPECT_EQ(bitmap2->height(), height1);
- }
-
- // GetNumberOfSkBitmaps and GetSkBitmapAtIndex should create a second
- // representation.
- EXPECT_EQ(2u, image.RepresentationCount());
-}
-
-TEST_F(ImageMacTest, MultiResolutionSkBitmapToNSImage) {
- const int width1 = 10;
- const int height1 = 12;
- const int width2 = 20;
- const int height2 = 24;
-
- std::vector<const SkBitmap*> bitmaps;
- bitmaps.push_back(gt::CreateBitmap(width1, height1));
- bitmaps.push_back(gt::CreateBitmap(width2, height2));
- gfx::Image image(bitmaps);
-
- EXPECT_EQ(1u, image.RepresentationCount());
- EXPECT_EQ(2u, image.GetNumberOfSkBitmaps());
-
- NSImage* ns_image = image;
- EXPECT_TRUE(ns_image);
-
- EXPECT_EQ(2u, [[image representations] count]);
- NSImageRep* image_rep_1 = [[image representations] objectAtIndex:0];
- NSImageRep* image_rep_2 = [[image representations] objectAtIndex:1];
-
- if ([image_rep_1 size].width == width1) {
- EXPECT_EQ([image_rep_1 size].height, height1);
- EXPECT_EQ([image_rep_2 size].width, width2);
- EXPECT_EQ([image_rep_2 size].height, height2);
- } else {
- EXPECT_EQ([image_rep_1 size].width, width2);
- EXPECT_EQ([image_rep_1 size].height, height2);
- EXPECT_EQ([image_rep_2 size].width, width1);
- EXPECT_EQ([image_rep_2 size].height, height1);
- }
-
- // Cast to NSImage* should create a second representation.
- EXPECT_EQ(2u, image.RepresentationCount());
-}
-
-} // namespace
diff --git a/ui/gfx/image_unittest_util.cc b/ui/gfx/image_unittest_util.cc
deleted file mode 100644
index b996a86..0000000
--- a/ui/gfx/image_unittest_util.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Because the unit tests for gfx::Image are spread across multiple
-// implementation files, this header contains the reusable components.
-
-#include "base/memory/scoped_ptr.h"
-#include "ui/gfx/image_unittest_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-#if defined(OS_LINUX)
-#include "ui/gfx/gtk_util.h"
-#elif defined(OS_MACOSX)
-#include "base/mac/mac_util.h"
-#include "skia/ext/skia_utils_mac.h"
-#endif
-
-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);
- return bitmap;
-}
-
-PlatformImage CreatePlatformImage() {
- scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25));
-#if defined(OS_MACOSX)
- NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get()));
- base::mac::NSObjectRetain(image);
- return image;
-#elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
- return gfx::GdkPixbufFromSkBitmap(bitmap.get());
-#else
- return bitmap.release();
-#endif
-}
-
-gfx::Image::RepresentationType GetPlatformRepresentationType() {
-#if defined(OS_MACOSX)
- return gfx::Image::kNSImageRep;
-#elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
- return gfx::Image::kGdkPixbufRep;
-#else
- return gfx::Image::kSkBitmapRep;
-#endif
-}
-
-} // namespace test
-} // namespace gfx
diff --git a/ui/gfx/image_unittest_util.h b/ui/gfx/image_unittest_util.h
deleted file mode 100644
index f087f90..0000000
--- a/ui/gfx/image_unittest_util.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Because the unit tests for gfx::Image are spread across multiple
-// implementation files, this header contains the reusable components.
-
-#ifndef UI_GFX_IMAGE_UNITTEST_UTIL_H_
-#define UI_GFX_IMAGE_UNITTEST_UTIL_H_
-
-#include "ui/gfx/image.h"
-
-namespace gfx {
-namespace test {
-
-#if defined(OS_MACOSX)
-typedef NSImage* PlatformImage;
-#elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
-typedef GdkPixbuf* PlatformImage;
-#else
-typedef const SkBitmap* PlatformImage;
-#endif
-
-SkBitmap* CreateBitmap(int width, int height);
-
-PlatformImage CreatePlatformImage();
-
-gfx::Image::RepresentationType GetPlatformRepresentationType();
-
-} // namespace test
-} // namespace gfx
-
-#endif // UI_GFX_IMAGE_UNITTEST_UTIL_H_