Instrumented libraries: fix libpci3 build on Trusty.
[chromium-blink-merge.git] / skia / ext / bitmap_platform_device_mac_unittest.cc
blob7265bc4cfb3a2d7148337de2c7f6a2c6ec34d5c1
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "skia/ext/bitmap_platform_device_mac.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "skia/ext/skia_utils_mac.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkMatrix.h"
11 #include "third_party/skia/include/core/SkRegion.h"
12 #include "third_party/skia/include/core/SkClipStack.h"
14 namespace skia {
16 const int kWidth = 400;
17 const int kHeight = 300;
19 class BitmapPlatformDeviceMacTest : public testing::Test {
20 public:
21 BitmapPlatformDeviceMacTest() {
22 bitmap_.reset(BitmapPlatformDevice::Create(
23 NULL, kWidth, kHeight, /*is_opaque=*/true));
26 scoped_ptr<BitmapPlatformDevice> bitmap_;
29 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) {
30 SkMatrix transform;
31 transform.setTranslate(50, 140);
33 SkClipStack ignore;
34 SkRegion clip_region;
35 SkIRect rect;
36 rect.set(0, 0, kWidth, kHeight);
37 clip_region.setRect(rect);
38 bitmap_->setMatrixClip(transform, clip_region, ignore);
40 CGContextRef context = bitmap_->GetBitmapContext();
41 SkRect clip_rect = gfx::CGRectToSkRect(CGContextGetClipBoundingBox(context));
42 transform.mapRect(&clip_rect);
43 EXPECT_EQ(0, clip_rect.fLeft);
44 EXPECT_EQ(0, clip_rect.fTop);
45 EXPECT_EQ(kWidth, clip_rect.width());
46 EXPECT_EQ(kHeight, clip_rect.height());
49 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) {
50 SkMatrix transform;
51 transform.setScale(0.5, 0.5);
53 SkClipStack unused;
54 SkRegion clip_region;
55 SkIRect rect;
56 rect.set(0, 0, kWidth, kHeight);
57 clip_region.setRect(rect);
58 bitmap_->setMatrixClip(transform, clip_region, unused);
60 CGContextRef context = bitmap_->GetBitmapContext();
61 SkRect clip_rect = gfx::CGRectToSkRect(CGContextGetClipBoundingBox(context));
62 transform.mapRect(&clip_rect);
63 EXPECT_EQ(0, clip_rect.fLeft);
64 EXPECT_EQ(0, clip_rect.fTop);
65 EXPECT_EQ(kWidth, clip_rect.width());
66 EXPECT_EQ(kHeight, clip_rect.height());
69 } // namespace skia