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 "cc/contents_scaling_layer.h" | 5 #include "cc/contents_scaling_layer.h" |
6 | 6 |
7 #include "cc/test/geometry_test_utils.h" | 7 #include "cc/test/geometry_test_utils.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 28 matching lines...) Expand all Loading... | |
39 TEST(ContentsScalingLayerTest, checkContentsBounds) { | 39 TEST(ContentsScalingLayerTest, checkContentsBounds) { |
40 scoped_refptr<MockContentsScalingLayer> testLayer = | 40 scoped_refptr<MockContentsScalingLayer> testLayer = |
41 make_scoped_refptr(new MockContentsScalingLayer()); | 41 make_scoped_refptr(new MockContentsScalingLayer()); |
42 | 42 |
43 testLayer->setBounds(gfx::Size(320, 240)); | 43 testLayer->setBounds(gfx::Size(320, 240)); |
44 EXPECT_FLOAT_EQ(1.0, testLayer->contentsScaleX()); | 44 EXPECT_FLOAT_EQ(1.0, testLayer->contentsScaleX()); |
45 EXPECT_FLOAT_EQ(1.0, testLayer->contentsScaleY()); | 45 EXPECT_FLOAT_EQ(1.0, testLayer->contentsScaleY()); |
46 EXPECT_EQ(320, testLayer->contentBounds().width()); | 46 EXPECT_EQ(320, testLayer->contentBounds().width()); |
47 EXPECT_EQ(240, testLayer->contentBounds().height()); | 47 EXPECT_EQ(240, testLayer->contentBounds().height()); |
48 | 48 |
49 testLayer->setContentsScale(2.0f); | 49 testLayer->updateContentsScale(2.0f); |
danakj
2012/12/14 20:37:23
If you make this method return the scale/bounds it
enne (OOO)
2012/12/14 22:06:05
Added updateContentsScale to FakeTiledLayer as a h
| |
50 EXPECT_EQ(640, testLayer->contentBounds().width()); | 50 EXPECT_EQ(640, testLayer->contentBounds().width()); |
51 EXPECT_EQ(480, testLayer->contentBounds().height()); | 51 EXPECT_EQ(480, testLayer->contentBounds().height()); |
52 | 52 |
53 testLayer->setBounds(gfx::Size(10, 20)); | 53 testLayer->setBounds(gfx::Size(10, 20)); |
54 EXPECT_EQ(20, testLayer->contentBounds().width()); | 54 EXPECT_EQ(20, testLayer->contentBounds().width()); |
55 EXPECT_EQ(40, testLayer->contentBounds().height()); | 55 EXPECT_EQ(40, testLayer->contentBounds().height()); |
56 | 56 |
57 testLayer->setContentsScale(1.33f); | 57 testLayer->updateContentsScale(1.33f); |
58 EXPECT_EQ(14, testLayer->contentBounds().width()); | 58 EXPECT_EQ(14, testLayer->contentBounds().width()); |
59 EXPECT_EQ(27, testLayer->contentBounds().height()); | 59 EXPECT_EQ(27, testLayer->contentBounds().height()); |
60 } | 60 } |
61 | 61 |
62 TEST(ContentsScalingLayerTest, checkContentsScaleChangeTriggersNeedsDisplay) { | |
63 scoped_refptr<MockContentsScalingLayer> testLayer = | |
64 make_scoped_refptr(new MockContentsScalingLayer()); | |
65 | |
66 testLayer->setBounds(gfx::Size(320, 240)); | |
67 | |
68 testLayer->resetNeedsDisplay(); | |
69 EXPECT_FALSE(testLayer->needsDisplay()); | |
70 | |
71 testLayer->setContentsScale(testLayer->contentsScaleX() + 1.f); | |
72 EXPECT_TRUE(testLayer->needsDisplay()); | |
73 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 320, 240), | |
74 testLayer->lastNeedsDisplayRect()); | |
75 } | |
76 | |
77 } // namespace | 62 } // namespace |
78 } // namespace cc | 63 } // namespace cc |
OLD | NEW |