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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 12280014: cc: Don't consider HUD layer for touches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a test Created 7 years, 10 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
« cc/layer_tree_host_common.cc ('K') | « cc/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer_tree_host_common.h" 5 #include "cc/layer_tree_host_common.h"
6 6
7 #include "cc/content_layer.h" 7 #include "cc/content_layer.h"
8 #include "cc/content_layer_client.h" 8 #include "cc/content_layer_client.h"
9 #include "cc/heads_up_display_layer_impl.h"
9 #include "cc/layer.h" 10 #include "cc/layer.h"
10 #include "cc/layer_animation_controller.h" 11 #include "cc/layer_animation_controller.h"
11 #include "cc/layer_impl.h" 12 #include "cc/layer_impl.h"
13 #include "cc/layer_tree_impl.h"
12 #include "cc/math_util.h" 14 #include "cc/math_util.h"
13 #include "cc/proxy.h" 15 #include "cc/proxy.h"
14 #include "cc/single_thread_proxy.h" 16 #include "cc/single_thread_proxy.h"
15 #include "cc/test/animation_test_common.h" 17 #include "cc/test/animation_test_common.h"
16 #include "cc/test/fake_impl_proxy.h" 18 #include "cc/test/fake_impl_proxy.h"
17 #include "cc/test/fake_layer_tree_host_impl.h" 19 #include "cc/test/fake_layer_tree_host_impl.h"
18 #include "cc/test/geometry_test_utils.h" 20 #include "cc/test/geometry_test_utils.h"
19 #include "cc/thread.h" 21 #include "cc/thread.h"
20 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2957 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2956 ASSERT_TRUE(resultLayer); 2958 ASSERT_TRUE(resultLayer);
2957 EXPECT_EQ(12345, resultLayer->id()); 2959 EXPECT_EQ(12345, resultLayer->id());
2958 2960
2959 testPoint = gfx::Point(99, 99); 2961 testPoint = gfx::Point(99, 99);
2960 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2962 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2961 ASSERT_TRUE(resultLayer); 2963 ASSERT_TRUE(resultLayer);
2962 EXPECT_EQ(12345, resultLayer->id()); 2964 EXPECT_EQ(12345, resultLayer->id());
2963 } 2965 }
2964 2966
2967 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud)
2968 {
2969 FakeImplProxy proxy;
2970 FakeLayerTreeHostImpl hostImpl(&proxy);
2971 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2972 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::create(ho stImpl.activeTree(), 11111);
2973
2974 gfx::Transform identityMatrix;
2975 gfx::PointF anchor(0, 0);
danakj 2013/02/19 20:08:12 0.f
2976 gfx::PointF position(0, 0);
danakj 2013/02/19 20:08:12 0.f
2977 gfx::Size bounds(100, 100);
2978 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2979 root->setDrawsContent(true);
2980
2981 // Create hud and add it as a child of root.
2982 gfx::Size hudBounds(200, 200);
2983 hud->setForceRenderSurface(true);
danakj 2013/02/19 20:08:12 why this? the hud doesn't own a surface in product
2984 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch or, position, hudBounds, false);
2985 hud->setDrawsContent(true);
danakj 2013/02/19 20:08:12 not needed for the hud. it always draws content.
2986
2987 hostImpl.activeTree()->set_hud_layer(hud.get());
danakj 2013/02/19 20:08:12 I really dislike that this unit test is now needin
2988 root->addChild(hud.PassAs<LayerImpl>());
2989
2990 std::vector<LayerImpl*> renderSurfaceLayerList;
2991 int dummyMaxTextureSize = 512;
2992 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du mmyMaxTextureSize, false, renderSurfaceLayerList, false);
2993
2994 // Sanity check the scenario we just created.
2995 ASSERT_EQ(2u, renderSurfaceLayerList.size());
2996 ASSERT_EQ(2u, root->renderSurface()->layerList().size());
2997
2998 // Hit testing for a point inside HUD, but outside root should return null
2999 gfx::Point testPoint(101, 101);
3000 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
3001 EXPECT_FALSE(resultLayer);
3002
3003 testPoint = gfx::Point(-1, -1);
3004 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
3005 EXPECT_FALSE(resultLayer);
3006
3007 // Hit testing for a point inside should return the root layer, never the HU D layer.
3008 testPoint = gfx::Point(1, 1);
3009 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
3010 ASSERT_TRUE(resultLayer);
3011 EXPECT_EQ(12345, resultLayer->id());
3012
3013 testPoint = gfx::Point(99, 99);
3014 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
3015 ASSERT_TRUE(resultLayer);
3016 EXPECT_EQ(12345, resultLayer->id());
3017 }
3018
2965 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) 3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
2966 { 3020 {
2967 FakeImplProxy proxy; 3021 FakeImplProxy proxy;
2968 FakeLayerTreeHostImpl hostImpl(&proxy); 3022 FakeLayerTreeHostImpl hostImpl(&proxy);
2969 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ; 3023 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2970 3024
2971 gfx::Transform uninvertibleTransform; 3025 gfx::Transform uninvertibleTransform;
2972 uninvertibleTransform.matrix().setDouble(0, 0, 0); 3026 uninvertibleTransform.matrix().setDouble(0, 0, 0);
2973 uninvertibleTransform.matrix().setDouble(1, 1, 0); 3027 uninvertibleTransform.matrix().setDouble(1, 1, 0);
2974 uninvertibleTransform.matrix().setDouble(2, 2, 0); 3028 uninvertibleTransform.matrix().setDouble(2, 2, 0);
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
5037 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); 5091 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
5038 } 5092 }
5039 5093
5040 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5094 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5041 LCDTextTest, 5095 LCDTextTest,
5042 testing::Combine(testing::Bool(), 5096 testing::Combine(testing::Bool(),
5043 testing::Bool())); 5097 testing::Bool()));
5044 5098
5045 } // namespace 5099 } // namespace
5046 } // namespace cc 5100 } // namespace cc
OLDNEW
« cc/layer_tree_host_common.cc ('K') | « cc/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698