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

Side by Side Diff: cc/trees/layer_tree_impl_unittest.cc

Issue 328753002: Clean up PointIsClippedBySurfaceOrClipRect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 | Annotate | Revision Log
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 "cc/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "cc/layers/heads_up_display_layer_impl.h" 7 #include "cc/layers/heads_up_display_layer_impl.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1110
1111 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to 1111 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to
1112 // be on top. 1112 // be on top.
1113 test_point = gfx::Point(20, 51); 1113 test_point = gfx::Point(20, 51);
1114 result_layer = 1114 result_layer =
1115 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 1115 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1116 ASSERT_TRUE(result_layer); 1116 ASSERT_TRUE(result_layer);
1117 EXPECT_EQ(4, result_layer->id()); 1117 EXPECT_EQ(4, result_layer->id());
1118 } 1118 }
1119 1119
1120 TEST_F(LayerTreeImplTest, HitTestingNotDrawnClippedLayersWithHandlers) {
1121 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
1122 gfx::Transform identity_matrix;
1123 gfx::Point3F transform_origin;
1124 gfx::PointF position;
1125 gfx::Size bounds(100, 100);
1126 SetLayerPropertiesForTesting(root.get(),
1127 identity_matrix,
1128 transform_origin,
1129 position,
1130 bounds,
1131 true,
1132 false);
1133 root->SetDrawsContent(true);
1134 {
1135 scoped_ptr<LayerImpl> child1 =
1136 LayerImpl::Create(host_impl().active_tree(), 2);
1137 scoped_ptr<LayerImpl> grand_child1 =
1138 LayerImpl::Create(host_impl().active_tree(), 4);
1139
1140 position = gfx::PointF(10.f, 10.f);
1141 bounds = gfx::Size(50, 50);
1142 SetLayerPropertiesForTesting(child1.get(),
1143 identity_matrix,
1144 transform_origin,
1145 position,
1146 bounds,
1147 true,
1148 false);
1149 child1->SetDrawsContent(true);
1150 child1->SetMasksToBounds(true);
1151
1152 position = gfx::PointF(0.f, 40.f);
1153 bounds = gfx::Size(100, 50);
1154 SetLayerPropertiesForTesting(grand_child1.get(),
1155 identity_matrix,
1156 transform_origin,
1157 position,
1158 bounds,
1159 true,
1160 false);
1161 grand_child1->SetDrawsContent(true);
1162 grand_child1->SetForceRenderSurface(true);
1163
1164 child1->AddChild(grand_child1.Pass());
1165 root->AddChild(child1.Pass());
1166 }
1167
1168 LayerImpl* child1 = root->children()[0];
1169 LayerImpl* grand_child1 = child1->children()[0];
1170
1171 child1->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
1172 grand_child1->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
1173
1174 host_impl().SetViewportSize(root->bounds());
1175 host_impl().active_tree()->SetRootLayer(root.Pass());
1176 host_impl().active_tree()->UpdateDrawProperties();
1177
1178 // This is meant to simulate the destruction of the render target. In
1179 // reality this would leave a stale pointer, but to ensure that the test
1180 // crashes without the appropriate guards, we force it to be NULL here.
1181 child1->draw_properties().render_target = NULL;
1182 child1->SetHideLayerAndSubtree(true);
1183 host_impl().active_tree()->UpdateDrawProperties();
1184
1185 gfx::Point test_point = gfx::Point(11, 51);
1186 LayerImpl* result_layer =
1187 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1188 ASSERT_TRUE(result_layer);
1189 EXPECT_EQ(4, result_layer->id());
danakj 2014/06/11 22:15:06 Mmh, you're touch-interacting with grandchild1, bu
Ian Vollick 2014/06/11 23:50:37 It is weird, but yeah, it was intentional. We stil
danakj 2014/06/12 00:21:23 Well, hm. Isn't the invariant that you have a vali
1190 }
1191
1120 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { 1192 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
1121 // 1193 //
1122 // The geometry is set up similarly to the previous case, but 1194 // The geometry is set up similarly to the previous case, but
1123 // all layers are forced to be render surfaces now. 1195 // all layers are forced to be render surfaces now.
1124 // 1196 //
1125 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); 1197 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
1126 1198
1127 gfx::Transform identity_matrix; 1199 gfx::Transform identity_matrix;
1128 gfx::Point3F transform_origin; 1200 gfx::Point3F transform_origin;
1129 gfx::PointF position; 1201 gfx::PointF position;
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 1999
1928 test_point = gfx::Point(35, 65); 2000 test_point = gfx::Point(35, 65);
1929 result_layer = 2001 result_layer =
1930 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 2002 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1931 test_point); 2003 test_point);
1932 EXPECT_FALSE(result_layer); 2004 EXPECT_FALSE(result_layer);
1933 } 2005 }
1934 2006
1935 } // namespace 2007 } // namespace
1936 } // namespace cc 2008 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_common_unittest.cc ('K') | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698