summaryrefslogtreecommitdiffstats
path: root/skia/ext/skia_utils_mac_unittest.mm
diff options
context:
space:
mode:
authoravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 21:41:58 +0000
committeravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 21:41:58 +0000
commitac7f222757304095a60909ae7adc3ba22548632e (patch)
treedb53e2c99be4a8a40999c78adcb78965c9a23d47 /skia/ext/skia_utils_mac_unittest.mm
parent2b68c89d7ebca6f0d85d5fb9d7ffe819d3c3a9a8 (diff)
downloadchromium_src-ac7f222757304095a60909ae7adc3ba22548632e.zip
chromium_src-ac7f222757304095a60909ae7adc3ba22548632e.tar.gz
chromium_src-ac7f222757304095a60909ae7adc3ba22548632e.tar.bz2
Reverting r18743.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18755 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/skia_utils_mac_unittest.mm')
-rw-r--r--skia/ext/skia_utils_mac_unittest.mm83
1 files changed, 0 insertions, 83 deletions
diff --git a/skia/ext/skia_utils_mac_unittest.mm b/skia/ext/skia_utils_mac_unittest.mm
deleted file mode 100644
index ce1e7c2..0000000
--- a/skia/ext/skia_utils_mac_unittest.mm
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2009 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.
-
-#import "chrome/browser/cocoa/cocoa_test_helper.h"
-#include "skia/ext/skia_utils_mac.mm"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class SkiaUtilsMacTest : public testing::Test {
- public:
- CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
-
- // If not red, is blue.
- // If not tfbit (twenty-four-bit), is 444.
- // If swap, swap R and B before testing (see TODOs in skia_utils_mac.mm)
- void ShapeHelper(int width, int height, bool isred, bool tfbit, bool swap);
-};
-
-void SkiaUtilsMacTest::ShapeHelper(int width, int height,
- bool isred, bool tfbit, bool swap) {
- SkBitmap thing;
-
- if (tfbit)
- thing.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- else
- thing.setConfig(SkBitmap::kARGB_4444_Config, width, height);
- thing.allocPixels();
-
- if (isred)
- thing.eraseRGB(0xff, 0, 0);
- else
- thing.eraseRGB(0, 0, 0xff);
-
- // Confirm size
- NSImage* image = gfx::SkBitmapToNSImage(thing);
- EXPECT_DOUBLE_EQ([image size].width, (double)width);
- EXPECT_DOUBLE_EQ([image size].height, (double)height);
-
- // Get the color of a pixel and make sure it looks fine
- [image lockFocus];
-
- int x = width > 17 ? 17 : 0;
- int y = height > 17 ? 17 : 0;
- NSColor* color = NSReadPixel(NSMakePoint(x, y));
- CGFloat red = 0, green = 0, blue = 0, alpha = 0;
- [image unlockFocus];
- [color getRed:&red green:&green blue:&blue alpha:&alpha];
-
- if (swap) {
- CGFloat tmp = red;
- red = blue;
- blue = tmp;
- }
-
- // Be tolerant of floating point rounding, gamma, etc.
- if (isred) {
- EXPECT_GT(red, 0.8);
- EXPECT_LT(blue, 0.2);
- } else {
- EXPECT_LT(red, 0.2);
- EXPECT_GT(blue, 0.8);
- }
- EXPECT_LT(green, 0.2);
- EXPECT_GT(alpha, 0.9);
-}
-
-
-TEST_F(SkiaUtilsMacTest, BitmapToNSImage_RedSquare64x64) {
- ShapeHelper(64, 64, true, true, true);
-}
-
-TEST_F(SkiaUtilsMacTest, BitmapToNSImage_BlueRectangle199x19) {
- ShapeHelper(199, 19, false, true, true);
-}
-
-TEST_F(SkiaUtilsMacTest, BitmapToNSImage_BlueRectangle444) {
- ShapeHelper(200, 200, false, false, false);
-}
-
-
-} // namespace