OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 6 |
7 #include "cc/solid_color_layer_impl.h" | 7 #include "cc/solid_color_layer_impl.h" |
8 | 8 |
9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
10 #include "cc/single_thread_proxy.h" | 10 #include "cc/single_thread_proxy.h" |
11 #include "cc/solid_color_draw_quad.h" | 11 #include "cc/solid_color_draw_quad.h" |
12 #include "cc/test/layer_test_common.h" | 12 #include "cc/test/layer_test_common.h" |
13 #include "cc/test/mock_quad_culler.h" | 13 #include "cc/test/mock_quad_culler.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using namespace cc; | 17 using namespace cc; |
18 using namespace LayerTestCommon; | 18 using namespace LayerTestCommon; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) | 22 TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) |
23 { | 23 { |
24 MockQuadCuller quadCuller; | 24 MockQuadCuller quadCuller; |
25 IntSize layerSize = IntSize(800, 600); | 25 gfx::Size layerSize = gfx::Size(800, 600); |
26 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); | 26 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); |
27 | 27 |
28 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); | 28 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); |
29 layer->setVisibleContentRect(visibleContentRect); | 29 layer->setVisibleContentRect(visibleContentRect); |
30 layer->setBounds(layerSize); | 30 layer->setBounds(layerSize); |
31 layer->setContentBounds(layerSize); | 31 layer->setContentBounds(layerSize); |
32 layer->createRenderSurface(); | 32 layer->createRenderSurface(); |
33 layer->setRenderTarget(layer.get()); | 33 layer->setRenderTarget(layer.get()); |
34 | 34 |
35 AppendQuadsData data; | 35 AppendQuadsData data; |
36 layer->appendQuads(quadCuller, data); | 36 layer->appendQuads(quadCuller, data); |
37 | 37 |
38 verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect); | 38 verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect); |
39 } | 39 } |
40 | 40 |
41 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) | 41 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) |
42 { | 42 { |
43 SkColor testColor = 0xFFA55AFF; | 43 SkColor testColor = 0xFFA55AFF; |
44 | 44 |
45 MockQuadCuller quadCuller; | 45 MockQuadCuller quadCuller; |
46 IntSize layerSize = IntSize(100, 100); | 46 gfx::Size layerSize = gfx::Size(100, 100); |
47 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); | 47 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); |
48 | 48 |
49 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); | 49 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); |
50 layer->setVisibleContentRect(visibleContentRect); | 50 layer->setVisibleContentRect(visibleContentRect); |
51 layer->setBounds(layerSize); | 51 layer->setBounds(layerSize); |
52 layer->setContentBounds(layerSize); | 52 layer->setContentBounds(layerSize); |
53 layer->setBackgroundColor(testColor); | 53 layer->setBackgroundColor(testColor); |
54 layer->createRenderSurface(); | 54 layer->createRenderSurface(); |
55 layer->setRenderTarget(layer.get()); | 55 layer->setRenderTarget(layer.get()); |
56 | 56 |
57 AppendQuadsData data; | 57 AppendQuadsData data; |
58 layer->appendQuads(quadCuller, data); | 58 layer->appendQuads(quadCuller, data); |
59 | 59 |
60 ASSERT_EQ(quadCuller.quadList().size(), 1U); | 60 ASSERT_EQ(quadCuller.quadList().size(), 1U); |
61 EXPECT_EQ(SolidColorDrawQuad::materialCast(quadCuller.quadList()[0])->color(
), testColor); | 61 EXPECT_EQ(SolidColorDrawQuad::materialCast(quadCuller.quadList()[0])->color(
), testColor); |
62 } | 62 } |
63 | 63 |
64 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) | 64 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) |
65 { | 65 { |
66 const float opacity = 0.5f; | 66 const float opacity = 0.5f; |
67 | 67 |
68 MockQuadCuller quadCuller; | 68 MockQuadCuller quadCuller; |
69 IntSize layerSize = IntSize(100, 100); | 69 gfx::Size layerSize = gfx::Size(100, 100); |
70 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); | 70 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); |
71 | 71 |
72 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); | 72 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); |
73 layer->setVisibleContentRect(visibleContentRect); | 73 layer->setVisibleContentRect(visibleContentRect); |
74 layer->setBounds(layerSize); | 74 layer->setBounds(layerSize); |
75 layer->setContentBounds(layerSize); | 75 layer->setContentBounds(layerSize); |
76 layer->setDrawOpacity(opacity); | 76 layer->setDrawOpacity(opacity); |
77 layer->createRenderSurface(); | 77 layer->createRenderSurface(); |
78 layer->setRenderTarget(layer.get()); | 78 layer->setRenderTarget(layer.get()); |
79 | 79 |
80 AppendQuadsData data; | 80 AppendQuadsData data; |
81 layer->appendQuads(quadCuller, data); | 81 layer->appendQuads(quadCuller, data); |
82 | 82 |
83 ASSERT_EQ(quadCuller.quadList().size(), 1U); | 83 ASSERT_EQ(quadCuller.quadList().size(), 1U); |
84 EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0]
)->opacity()); | 84 EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0]
)->opacity()); |
85 } | 85 } |
86 | 86 |
87 } // namespace | 87 } // namespace |
OLD | NEW |