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

Side by Side Diff: cc/blink/web_layer_impl_fixed_bounds_unittest.cc

Issue 470983004: Move blink<->cc bindings to cc/blink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/blink/web_layer_impl_fixed_bounds.cc ('k') | cc/blink/web_nine_patch_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 5 #include <vector>
6 #include "cc/blink/web_layer_impl_fixed_bounds.h"
6 #include "cc/layers/picture_image_layer.h" 7 #include "cc/layers/picture_image_layer.h"
7 #include "cc/test/fake_layer_tree_host.h" 8 #include "cc/test/fake_layer_tree_host.h"
8 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
9 #include "cc/trees/layer_tree_host_common.h" 10 #include "cc/trees/layer_tree_host_common.h"
10 #include "content/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
13 #include "third_party/WebKit/public/platform/WebSize.h" 13 #include "third_party/WebKit/public/platform/WebSize.h"
14 #include "third_party/skia/include/utils/SkMatrix44.h" 14 #include "third_party/skia/include/utils/SkMatrix44.h"
15 #include "ui/gfx/point3_f.h" 15 #include "ui/gfx/point3_f.h"
16 16
17 using blink::WebFloatPoint; 17 using blink::WebFloatPoint;
18 using blink::WebSize; 18 using blink::WebSize;
19 19
20 namespace content { 20 namespace cc_blink {
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));
26 layer->SetFixedBounds(gfx::Size(100, 100)); 25 layer->SetFixedBounds(gfx::Size(100, 100));
27 layer->setBounds(WebSize(100, 100)); 26 layer->setBounds(WebSize(100, 100));
28 EXPECT_EQ(WebSize(100, 100), layer->bounds()); 27 EXPECT_EQ(WebSize(100, 100), layer->bounds());
29 EXPECT_EQ(gfx::Size(100, 100), layer->layer()->bounds()); 28 EXPECT_EQ(gfx::Size(100, 100), layer->layer()->bounds());
30 EXPECT_EQ(gfx::Transform(), layer->layer()->transform()); 29 EXPECT_EQ(gfx::Transform(), layer->layer()->transform());
31 } 30 }
32 31
33 gfx::Point3F TransformPoint(const gfx::Transform& transform, 32 gfx::Point3F TransformPoint(const gfx::Transform& transform,
34 const gfx::Point3F& point) { 33 const gfx::Point3F& point) {
35 gfx::Point3F result = point; 34 gfx::Point3F result = point;
(...skipping 18 matching lines...) Expand all
54 original_point.y() * bounds.height / fixed_bounds.height(), 53 original_point.y() * bounds.height / fixed_bounds.height(),
55 original_point.z()); 54 original_point.z());
56 // Test if the bounds scale is correctly applied in transform. 55 // Test if the bounds scale is correctly applied in transform.
57 EXPECT_POINT3F_EQ( 56 EXPECT_POINT3F_EQ(
58 scaled_point, 57 scaled_point,
59 TransformPoint(layer->layer()->transform(), original_point)); 58 TransformPoint(layer->layer()->transform(), original_point));
60 } 59 }
61 60
62 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) { 61 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) {
63 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); 62 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds());
64 layer->setAnchorPoint(WebFloatPoint(0, 0));
65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250)); 63 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250));
66 // Change fixed_bounds. 64 // Change fixed_bounds.
67 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100)); 65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100));
68 // Change bounds. 66 // Change bounds.
69 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100)); 67 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100));
70 } 68 }
71 69
72 void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) { 70 void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) {
73 gfx::RectF layer1_rect_in_target(layer1->content_bounds()); 71 gfx::RectF layer1_rect_in_target(layer1->content_bounds());
74 layer1->draw_transform().TransformRect(&layer1_rect_in_target); 72 layer1->draw_transform().TransformRect(&layer1_rect_in_target);
(...skipping 13 matching lines...) Expand all
88 WebSize bounds(150, 200); 86 WebSize bounds(150, 200);
89 WebFloatPoint position(20, 30); 87 WebFloatPoint position(20, 30);
90 gfx::Size fixed_bounds(160, 70); 88 gfx::Size fixed_bounds(160, 70);
91 89
92 scoped_ptr<WebLayerImplFixedBounds> root_layer(new WebLayerImplFixedBounds()); 90 scoped_ptr<WebLayerImplFixedBounds> root_layer(new WebLayerImplFixedBounds());
93 91
94 WebLayerImplFixedBounds* fixed_bounds_layer = 92 WebLayerImplFixedBounds* fixed_bounds_layer =
95 new WebLayerImplFixedBounds(cc::PictureImageLayer::Create()); 93 new WebLayerImplFixedBounds(cc::PictureImageLayer::Create());
96 fixed_bounds_layer->setBounds(bounds); 94 fixed_bounds_layer->setBounds(bounds);
97 fixed_bounds_layer->SetFixedBounds(fixed_bounds); 95 fixed_bounds_layer->SetFixedBounds(fixed_bounds);
98 fixed_bounds_layer->setAnchorPoint(anchor_point);
99 fixed_bounds_layer->setTransform(transform.matrix()); 96 fixed_bounds_layer->setTransform(transform.matrix());
100 fixed_bounds_layer->setPosition(position); 97 fixed_bounds_layer->setPosition(position);
101 root_layer->addChild(fixed_bounds_layer); 98 root_layer->addChild(fixed_bounds_layer);
102 99
103 WebLayerImpl* normal_layer(new WebLayerImpl(cc::PictureImageLayer::Create())); 100 WebLayerImpl* normal_layer(new WebLayerImpl(cc::PictureImageLayer::Create()));
104 101
105 normal_layer->setBounds(bounds); 102 normal_layer->setBounds(bounds);
106 normal_layer->setAnchorPoint(anchor_point);
107 normal_layer->setTransform(transform.matrix()); 103 normal_layer->setTransform(transform.matrix());
108 normal_layer->setPosition(position); 104 normal_layer->setPosition(position);
109 root_layer->addChild(normal_layer); 105 root_layer->addChild(normal_layer);
110 106
111 scoped_ptr<cc::FakeLayerTreeHost> host = cc::FakeLayerTreeHost::Create(); 107 scoped_ptr<cc::FakeLayerTreeHost> host = cc::FakeLayerTreeHost::Create();
112 host->SetRootLayer(root_layer->layer()); 108 host->SetRootLayer(root_layer->layer());
113 109
114 { 110 {
115 cc::RenderSurfaceLayerList render_surface_layer_list; 111 cc::RenderSurfaceLayerList render_surface_layer_list;
116 cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 112 cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 transform.RotateAbout(gfx::Vector3dF(33, 44, 55), 99); 167 transform.RotateAbout(gfx::Vector3dF(33, 44, 55), 99);
172 168
173 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), transform); 169 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), transform);
174 170
175 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to 171 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to
176 // WebLayerImpl. 172 // WebLayerImpl.
177 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), transform); 173 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), transform);
178 } 174 }
179 175
180 } // namespace 176 } // namespace
181 } // namespace content 177 } // namespace cc_blink
OLDNEW
« no previous file with comments | « cc/blink/web_layer_impl_fixed_bounds.cc ('k') | cc/blink/web_nine_patch_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698