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

Side by Side Diff: content/renderer/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc

Issue 317163002: Moving compositor_bindings from webkit to content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing dependencies due to failing ios bots Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 #include "cc/layers/picture_image_layer.h" 6 #include "cc/layers/picture_image_layer.h"
7 #include "cc/test/fake_layer_tree_host.h" 7 #include "cc/test/fake_layer_tree_host.h"
8 #include "cc/test/geometry_test_utils.h" 8 #include "cc/test/geometry_test_utils.h"
9 #include "cc/trees/layer_tree_host_common.h" 9 #include "cc/trees/layer_tree_host_common.h"
10 #include "content/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
12 #include "third_party/WebKit/public/platform/WebSize.h" 13 #include "third_party/WebKit/public/platform/WebSize.h"
13 #include "third_party/skia/include/utils/SkMatrix44.h" 14 #include "third_party/skia/include/utils/SkMatrix44.h"
14 #include "ui/gfx/point3_f.h" 15 #include "ui/gfx/point3_f.h"
15 #include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
16 16
17 using blink::WebFloatPoint; 17 using blink::WebFloatPoint;
18 using blink::WebSize; 18 using blink::WebSize;
19 19
20 namespace webkit { 20 namespace content {
21 namespace { 21 namespace {
22 22
23 TEST(WebLayerImplFixedBoundsTest, IdentityBounds) { 23 TEST(WebLayerImplFixedBoundsTest, IdentityBounds) {
24 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); 24 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds());
25 layer->setAnchorPoint(WebFloatPoint(0, 0)); 25 layer->setAnchorPoint(WebFloatPoint(0, 0));
26 layer->SetFixedBounds(gfx::Size(100, 100)); 26 layer->SetFixedBounds(gfx::Size(100, 100));
27 layer->setBounds(WebSize(100, 100)); 27 layer->setBounds(WebSize(100, 100));
28 EXPECT_EQ(WebSize(100, 100), layer->bounds()); 28 EXPECT_EQ(WebSize(100, 100), layer->bounds());
29 EXPECT_EQ(gfx::Size(100, 100), layer->layer()->bounds()); 29 EXPECT_EQ(gfx::Size(100, 100), layer->layer()->bounds());
30 EXPECT_EQ(gfx::Transform(), layer->layer()->transform()); 30 EXPECT_EQ(gfx::Transform(), layer->layer()->transform());
(...skipping 16 matching lines...) Expand all
47 EXPECT_EQ(fixed_bounds, layer->layer()->bounds()); 47 EXPECT_EQ(fixed_bounds, layer->layer()->bounds());
48 EXPECT_TRUE(layer->transform().isIdentity()); 48 EXPECT_TRUE(layer->transform().isIdentity());
49 49
50 // An arbitrary point to check the scale and transforms. 50 // An arbitrary point to check the scale and transforms.
51 gfx::Point3F original_point(10, 20, 1); 51 gfx::Point3F original_point(10, 20, 1);
52 gfx::Point3F scaled_point( 52 gfx::Point3F scaled_point(
53 original_point.x() * bounds.width / fixed_bounds.width(), 53 original_point.x() * bounds.width / fixed_bounds.width(),
54 original_point.y() * bounds.height / fixed_bounds.height(), 54 original_point.y() * bounds.height / fixed_bounds.height(),
55 original_point.z()); 55 original_point.z());
56 // Test if the bounds scale is correctly applied in transform. 56 // Test if the bounds scale is correctly applied in transform.
57 EXPECT_POINT3F_EQ(scaled_point, 57 EXPECT_POINT3F_EQ(
58 TransformPoint(layer->layer()->transform(), 58 scaled_point,
59 original_point)); 59 TransformPoint(layer->layer()->transform(), original_point));
60 } 60 }
61 61
62 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) { 62 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) {
63 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); 63 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds());
64 layer->setAnchorPoint(WebFloatPoint(0, 0)); 64 layer->setAnchorPoint(WebFloatPoint(0, 0));
65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250)); 65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250));
66 // Change fixed_bounds. 66 // Change fixed_bounds.
67 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100)); 67 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100));
68 // Change bounds. 68 // Change bounds.
69 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100)); 69 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 inputs.device_scale_factor = kDeviceScaleFactor; 118 inputs.device_scale_factor = kDeviceScaleFactor;
119 inputs.page_scale_factor = kPageScaleFactor; 119 inputs.page_scale_factor = kPageScaleFactor;
120 inputs.page_scale_application_layer = root_layer->layer(), 120 inputs.page_scale_application_layer = root_layer->layer(),
121 cc::LayerTreeHostCommon::CalculateDrawProperties(&inputs); 121 cc::LayerTreeHostCommon::CalculateDrawProperties(&inputs);
122 122
123 ExpectEqualLayerRectsInTarget(normal_layer->layer(), 123 ExpectEqualLayerRectsInTarget(normal_layer->layer(),
124 fixed_bounds_layer->layer()); 124 fixed_bounds_layer->layer());
125 } 125 }
126 126
127 // Change of fixed bounds should not affect the target geometries. 127 // Change of fixed bounds should not affect the target geometries.
128 fixed_bounds_layer->SetFixedBounds(gfx::Size(fixed_bounds.width() / 2, 128 fixed_bounds_layer->SetFixedBounds(
129 fixed_bounds.height() * 2)); 129 gfx::Size(fixed_bounds.width() / 2, fixed_bounds.height() * 2));
130 130
131 { 131 {
132 cc::RenderSurfaceLayerList render_surface_layer_list; 132 cc::RenderSurfaceLayerList render_surface_layer_list;
133 cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 133 cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
134 root_layer->layer(), kDeviceViewportSize, &render_surface_layer_list); 134 root_layer->layer(), kDeviceViewportSize, &render_surface_layer_list);
135 inputs.device_scale_factor = kDeviceScaleFactor; 135 inputs.device_scale_factor = kDeviceScaleFactor;
136 inputs.page_scale_factor = kPageScaleFactor; 136 inputs.page_scale_factor = kPageScaleFactor;
137 inputs.page_scale_application_layer = root_layer->layer(), 137 inputs.page_scale_application_layer = root_layer->layer(),
138 cc::LayerTreeHostCommon::CalculateDrawProperties(&inputs); 138 cc::LayerTreeHostCommon::CalculateDrawProperties(&inputs);
139 139
140 ExpectEqualLayerRectsInTarget(normal_layer->layer(), 140 ExpectEqualLayerRectsInTarget(normal_layer->layer(),
141 fixed_bounds_layer->layer()); 141 fixed_bounds_layer->layer());
142 } 142 }
143 } 143 }
144 144
145 // A black box test that ensures WebLayerImplFixedBounds won't change target 145 // A black box test that ensures WebLayerImplFixedBounds won't change target
146 // geometries. Simple case: identity transforms and zero anchor point. 146 // geometries. Simple case: identity transforms and zero anchor point.
147 TEST(WebLayerImplFixedBoundsTest, CompareToWebLayerImplSimple) { 147 TEST(WebLayerImplFixedBoundsTest, CompareToWebLayerImplSimple) {
148 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), 148 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), gfx::Transform());
149 gfx::Transform());
150 } 149 }
151 150
152 // A black box test that ensures WebLayerImplFixedBounds won't change target 151 // A black box test that ensures WebLayerImplFixedBounds won't change target
153 // geometries. Complex case: complex transforms and non-zero anchor point. 152 // geometries. Complex case: complex transforms and non-zero anchor point.
154 TEST(WebLayerImplFixedBoundsTest, CompareToWebLayerImplComplex) { 153 TEST(WebLayerImplFixedBoundsTest, CompareToWebLayerImplComplex) {
155 gfx::Transform transform; 154 gfx::Transform transform;
156 // These are arbitrary values that should not affect the results. 155 // These are arbitrary values that should not affect the results.
157 transform.Translate3d(50, 60, 70); 156 transform.Translate3d(50, 60, 70);
158 transform.Scale3d(2, 3, 4); 157 transform.Scale3d(2, 3, 4);
159 transform.RotateAbout(gfx::Vector3dF(33, 44, 55), 99); 158 transform.RotateAbout(gfx::Vector3dF(33, 44, 55), 99);
160 159
161 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), transform); 160 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), transform);
162 161
163 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to 162 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to
164 // WebLayerImpl. 163 // WebLayerImpl.
165 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), transform); 164 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), transform);
166 } 165 }
167 166
168 } // namespace 167 } // namespace
169 } // namespace webkit 168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698