OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/paint/PaintInfo.h" | 6 #include "core/paint/PaintInfo.h" |
7 | 7 |
| 8 #include "platform/graphics/paint/PaintController.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace blink { | 11 namespace blink { |
11 | 12 |
12 class PaintInfoTest : public testing::Test { | 13 class PaintInfoTest : public testing::Test { |
| 14 protected: |
| 15 PaintInfoTest() |
| 16 : m_paintController(PaintController::create()) |
| 17 , m_context(*m_paintController) |
| 18 { } |
| 19 |
| 20 OwnPtr<PaintController> m_paintController; |
| 21 GraphicsContext m_context; |
13 }; | 22 }; |
14 | 23 |
15 TEST_F(PaintInfoTest, intersectsCullRect) | 24 TEST_F(PaintInfoTest, intersectsCullRect) |
16 { | 25 { |
17 PaintInfo paintInfo(nullptr, IntRect(0, 0, 50, 50), PaintPhaseBlockBackgroun
d, GlobalPaintNormalPhase, PaintLayerNoFlag); | 26 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseBlockBackgro
und, GlobalPaintNormalPhase, PaintLayerNoFlag); |
18 | 27 |
19 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); | 28 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); |
20 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; | 29 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; |
21 } | 30 } |
22 | 31 |
23 TEST_F(PaintInfoTest, intersectsCullRectWithLayoutRect) | 32 TEST_F(PaintInfoTest, intersectsCullRectWithLayoutRect) |
24 { | 33 { |
25 PaintInfo paintInfo(nullptr, IntRect(0, 0, 50, 50), PaintPhaseBlockBackgroun
d, GlobalPaintNormalPhase, PaintLayerNoFlag); | 34 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseBlockBackgro
und, GlobalPaintNormalPhase, PaintLayerNoFlag); |
26 | 35 |
27 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0, 0, 1, 1)))
; | 36 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0, 0, 1, 1)))
; |
28 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0.1, 0.1, 0.1
, 0.1))); | 37 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0.1, 0.1, 0.1
, 0.1))); |
29 } | 38 } |
30 | 39 |
31 TEST_F(PaintInfoTest, intersectsCullRectWithTransform) | 40 TEST_F(PaintInfoTest, intersectsCullRectWithTransform) |
32 { | 41 { |
33 PaintInfo paintInfo(nullptr, IntRect(0, 0, 50, 50), PaintPhaseBlockBackgroun
d, GlobalPaintNormalPhase, PaintLayerNoFlag); | 42 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseBlockBackgro
und, GlobalPaintNormalPhase, PaintLayerNoFlag); |
34 AffineTransform transform; | 43 AffineTransform transform; |
35 transform.translate(-2, -2); | 44 transform.translate(-2, -2); |
36 | 45 |
37 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(transform, IntRect(51, 5
1, 1, 1))); | 46 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(transform, IntRect(51, 5
1, 1, 1))); |
38 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(52, 52, 1, 1)))
; | 47 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(52, 52, 1, 1)))
; |
39 } | 48 } |
40 | 49 |
41 TEST_F(PaintInfoTest, updateCullRect) | 50 TEST_F(PaintInfoTest, updateCullRect) |
42 { | 51 { |
43 PaintInfo paintInfo(nullptr, IntRect(1, 1, 50, 50), PaintPhaseBlockBackgroun
d, GlobalPaintNormalPhase, PaintLayerNoFlag); | 52 PaintInfo paintInfo(m_context, IntRect(1, 1, 50, 50), PaintPhaseBlockBackgro
und, GlobalPaintNormalPhase, PaintLayerNoFlag); |
44 AffineTransform transform; | 53 AffineTransform transform; |
45 transform.translate(1, 1); | 54 transform.translate(1, 1); |
46 paintInfo.updateCullRect(transform); | 55 paintInfo.updateCullRect(transform); |
47 | 56 |
48 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); | 57 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); |
49 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; | 58 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; |
50 } | 59 } |
51 | 60 |
52 TEST_F(PaintInfoTest, intersectsVerticalRange) | 61 TEST_F(PaintInfoTest, intersectsVerticalRange) |
53 { | 62 { |
54 PaintInfo paintInfo(nullptr, IntRect(0, 0, 50, 100), PaintPhaseBlockBackgrou
nd, GlobalPaintNormalPhase, PaintLayerNoFlag); | 63 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 100), PaintPhaseBlockBackgr
ound, GlobalPaintNormalPhase, PaintLayerNoFlag); |
55 | 64 |
56 EXPECT_TRUE(paintInfo.cullRect().intersectsVerticalRange(0, 1)); | 65 EXPECT_TRUE(paintInfo.cullRect().intersectsVerticalRange(0, 1)); |
57 EXPECT_FALSE(paintInfo.cullRect().intersectsVerticalRange(100, 101)); | 66 EXPECT_FALSE(paintInfo.cullRect().intersectsVerticalRange(100, 101)); |
58 } | 67 } |
59 | 68 |
60 TEST_F(PaintInfoTest, intersectsHorizontalRange) | 69 TEST_F(PaintInfoTest, intersectsHorizontalRange) |
61 { | 70 { |
62 PaintInfo paintInfo(nullptr, IntRect(0, 0, 50, 100), PaintPhaseBlockBackgrou
nd, GlobalPaintNormalPhase, PaintLayerNoFlag); | 71 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 100), PaintPhaseBlockBackgr
ound, GlobalPaintNormalPhase, PaintLayerNoFlag); |
63 | 72 |
64 EXPECT_TRUE(paintInfo.cullRect().intersectsHorizontalRange(0, 1)); | 73 EXPECT_TRUE(paintInfo.cullRect().intersectsHorizontalRange(0, 1)); |
65 EXPECT_FALSE(paintInfo.cullRect().intersectsHorizontalRange(50, 51)); | 74 EXPECT_FALSE(paintInfo.cullRect().intersectsHorizontalRange(50, 51)); |
66 } | 75 } |
67 | 76 |
68 } // namespace blink | 77 } // namespace blink |
OLD | NEW |