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

Unified Diff: skia/ext/bitmap_platform_device_mac_unittest.cc

Issue 3030003: Mac: unit test for setting a clip rect with a scale transform (Closed)
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/bitmap_platform_device_mac_unittest.cc
diff --git a/skia/ext/bitmap_platform_device_mac_unittest.cc b/skia/ext/bitmap_platform_device_mac_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3ca6a8f68762eb80a2a8adc9cf68433b6c86244d
--- /dev/null
+++ b/skia/ext/bitmap_platform_device_mac_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 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 "skia/ext/bitmap_platform_device_mac.h"
+
+#include "base/scoped_ptr.h"
+#include "skia/ext/skia_utils_mac.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/core/SkRegion.h"
+
+namespace skia {
+
+class BitmapPlatformDeviceMacTest : public testing::Test {
+ public:
+ BitmapPlatformDeviceMacTest() {
+ bitmap_.reset(
+ BitmapPlatformDevice::Create(NULL, 400, 300, /*is_opaque=*/true));
jeremy 2010/07/18 11:24:07 Could you make the dimensions, constants
Nico 2010/07/19 15:14:51 Done.
+ }
+
+ scoped_ptr<BitmapPlatformDevice> bitmap_;
+};
+
+TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) {
+ SkMatrix transform;
+ transform.setTranslate(50, 140);
+
+ SkRegion clip_region;
+ SkIRect rect;
+ rect.set(0, 0, 400, 300);
+ clip_region.setRect(rect);
+ bitmap_->setMatrixClip(transform, clip_region);
+
+ CGContextRef context = bitmap_->GetBitmapContext();
+ SkRect clip_rect = gfx::CGRectToSkRect(CGContextGetClipBoundingBox(context));
+ transform.mapRect(&clip_rect);
+ EXPECT_EQ(0, clip_rect.fLeft);
+ EXPECT_EQ(0, clip_rect.fTop);
+ EXPECT_EQ(400, clip_rect.width());
+ EXPECT_EQ(300, clip_rect.height());
+}
+
+TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) {
+ SkMatrix transform;
+ transform.setScale(0.5, 0.5);
+
+ SkRegion clip_region;
+ SkIRect rect;
+ rect.set(0, 0, 400, 300);
+ clip_region.setRect(rect);
+ bitmap_->setMatrixClip(transform, clip_region);
+
+ CGContextRef context = bitmap_->GetBitmapContext();
+ SkRect clip_rect = gfx::CGRectToSkRect(CGContextGetClipBoundingBox(context));
+ transform.mapRect(&clip_rect);
+ EXPECT_EQ(0, clip_rect.fLeft);
+ EXPECT_EQ(0, clip_rect.fTop);
+ EXPECT_EQ(400, clip_rect.width());
+ EXPECT_EQ(300, clip_rect.height());
+}
+
+} // namespace skia
« no previous file with comments | « no previous file | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698