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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11402002: Add API for hit testing layer_impl touchEventHandlerRegions from the host (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added tests and fixed parameters on static call Created 8 years, 1 month 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/layer_tree_host_common.cc ('k') | cc/layer_tree_host_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 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_tree_host_common.h" 7 #include "cc/layer_tree_host_common.h"
8 8
9 #include "cc/content_layer.h" 9 #include "cc/content_layer.h"
10 #include "cc/content_layer_client.h" 10 #include "cc/content_layer_client.h"
(...skipping 3091 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 3102
3103 { 3103 {
3104 scoped_ptr<LayerImpl> child = LayerImpl::create(456); 3104 scoped_ptr<LayerImpl> child = LayerImpl::create(456);
3105 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); 3105 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789);
3106 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); 3106 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468);
3107 3107
3108 position = gfx::PointF(10, 10); 3108 position = gfx::PointF(10, 10);
3109 bounds = gfx::Size(80, 80); 3109 bounds = gfx::Size(80, 80);
3110 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3110 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3111 child->setMasksToBounds(true); 3111 child->setMasksToBounds(true);
3112 3112
3113 WebTransformationMatrix rotation45DegreesAboutCorner; 3113 WebTransformationMatrix rotation45DegreesAboutCorner;
3114 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); 3114 rotation45DegreesAboutCorner.rotate3d(0, 0, 45);
3115 3115
3116 position = gfx::PointF(0, 0); // remember, positioned with respect to it s parent which is already at 10, 10 3116 position = gfx::PointF(0, 0); // remember, positioned with respect to it s parent which is already at 10, 10
3117 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. 3117 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100.
3118 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor ner, identityMatrix, anchor, position, bounds, false); 3118 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor ner, identityMatrix, anchor, position, bounds, false);
3119 grandChild->setMasksToBounds(true); 3119 grandChild->setMasksToBounds(true);
3120 3120
3121 // Rotates about the center of the layer 3121 // Rotates about the center of the layer
3122 WebTransformationMatrix rotatedLeafTransform; 3122 WebTransformationMatrix rotatedLeafTransform;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 ASSERT_TRUE(resultLayer); 3456 ASSERT_TRUE(resultLayer);
3457 EXPECT_EQ(3, resultLayer->id()); 3457 EXPECT_EQ(3, resultLayer->id());
3458 3458
3459 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b e on top. 3459 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b e on top.
3460 testPoint = gfx::Point(20, 51); 3460 testPoint = gfx::Point(20, 51);
3461 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 3461 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
3462 ASSERT_TRUE(resultLayer); 3462 ASSERT_TRUE(resultLayer);
3463 EXPECT_EQ(4, resultLayer->id()); 3463 EXPECT_EQ(4, resultLayer->id());
3464 } 3464 }
3465 3465
3466 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForEmptyLayerL ist)
3467 {
3468 // Hit checking on an empty renderSurfaceLayerList should return a null poin ter.
3469 DebugScopedSetImplThread thisScopeIsOnImplThread;
3470
3471 std::vector<LayerImpl*> renderSurfaceLayerList;
3472
3473 gfx::Point testPoint(0, 0);
3474 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3475 EXPECT_FALSE(resultLayer);
3476
3477 testPoint = gfx::Point(10, 20);
3478 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3479 EXPECT_FALSE(resultLayer);
3480 }
3481
3482 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer )
3483 {
3484 DebugScopedSetImplThread thisScopeIsOnImplThread;
3485
3486 scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
3487
3488 WebTransformationMatrix identityMatrix;
3489 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3490 gfx::PointF anchor(0, 0);
3491 gfx::PointF position(0, 0);
3492 gfx::Size bounds(100, 100);
3493 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3494 root->setDrawsContent(true);
3495
3496 std::vector<LayerImpl*> renderSurfaceLayerList;
3497 int dummyMaxTextureSize = 512;
3498 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
3499
3500 // Sanity check the scenario we just created.
3501 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3502 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3503
3504 // Hit checking for any point should return a null pointer for a layer witho ut any touch event handler regions.
3505 gfx::Point testPoint(11, 11);
3506 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3507 EXPECT_FALSE(resultLayer);
3508
3509 root->setTouchEventHandlerRegion(touchHandlerRegion);
3510 // Hit checking for a point outside the layer should return a null pointer.
3511 testPoint = gfx::Point(101, 101);
3512 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3513 EXPECT_FALSE(resultLayer);
3514
3515 testPoint = gfx::Point(-1, -1);
3516 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3517 EXPECT_FALSE(resultLayer);
3518
3519 // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer.
3520 testPoint = gfx::Point(1, 1);
3521 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3522 EXPECT_FALSE(resultLayer);
3523
3524 testPoint = gfx::Point(99, 99);
3525 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3526 EXPECT_FALSE(resultLayer);
3527
3528 // Hit checking for a point inside the touch event handler region should ret urn the root layer.
3529 testPoint = gfx::Point(11, 11);
3530 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3531 ASSERT_TRUE(resultLayer);
3532 EXPECT_EQ(12345, resultLayer->id());
3533
3534 testPoint = gfx::Point(59, 59);
3535 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3536 ASSERT_TRUE(resultLayer);
3537 EXPECT_EQ(12345, resultLayer->id());
3538 }
3539
3540 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform)
3541 {
3542 DebugScopedSetImplThread thisScopeIsOnImplThread;
3543
3544 scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
3545
3546 WebTransformationMatrix uninvertibleTransform;
3547 uninvertibleTransform.setM11(0);
3548 uninvertibleTransform.setM22(0);
3549 uninvertibleTransform.setM33(0);
3550 uninvertibleTransform.setM44(0);
3551 ASSERT_FALSE(uninvertibleTransform.isInvertible());
3552
3553 WebTransformationMatrix identityMatrix;
3554 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3555 gfx::PointF anchor(0, 0);
3556 gfx::PointF position(0, 0);
3557 gfx::Size bounds(100, 100);
3558 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false);
3559 root->setDrawsContent(true);
3560 root->setTouchEventHandlerRegion(touchHandlerRegion);
3561
3562 std::vector<LayerImpl*> renderSurfaceLayerList;
3563 int dummyMaxTextureSize = 512;
3564 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
3565
3566 // Sanity check the scenario we just created.
3567 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3568 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3569 ASSERT_FALSE(root->screenSpaceTransform().isInvertible());
3570
3571 // Hit checking any point should not hit the touch handler region on the lay er. If the invertible matrix is
3572 // accidentally ignored and treated like an identity, then the hit testing w ill
3573 // incorrectly hit the layer when it shouldn't.
3574 gfx::Point testPoint(1, 1);
3575 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3576 EXPECT_FALSE(resultLayer);
3577
3578 testPoint = gfx::Point(10, 10);
3579 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3580 EXPECT_FALSE(resultLayer);
3581
3582 testPoint = gfx::Point(10, 30);
3583 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3584 EXPECT_FALSE(resultLayer);
3585
3586 testPoint = gfx::Point(50, 50);
3587 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3588 EXPECT_FALSE(resultLayer);
3589
3590 testPoint = gfx::Point(67, 48);
3591 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3592 EXPECT_FALSE(resultLayer);
3593
3594 testPoint = gfx::Point(99, 99);
3595 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3596 EXPECT_FALSE(resultLayer);
3597
3598 testPoint = gfx::Point(-1, -1);
3599 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3600 EXPECT_FALSE(resultLayer);
3601 }
3602
3603 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer)
3604 {
3605 DebugScopedSetImplThread thisScopeIsOnImplThread;
3606
3607 scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
3608
3609 WebTransformationMatrix identityMatrix;
3610 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3611 gfx::PointF anchor(0, 0);
3612 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located.
3613 gfx::Size bounds(100, 100);
3614 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3615 root->setDrawsContent(true);
3616 root->setTouchEventHandlerRegion(touchHandlerRegion);
3617
3618 std::vector<LayerImpl*> renderSurfaceLayerList;
3619 int dummyMaxTextureSize = 512;
3620 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
3621
3622 // Sanity check the scenario we just created.
3623 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3624 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3625
3626 // Hit checking for a point outside the layer should return a null pointer.
3627 gfx::Point testPoint(49, 49);
3628 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3629 EXPECT_FALSE(resultLayer);
3630
3631 // Even though the layer has a touch handler region containing (101, 101), i t should not be visible there since the root renderSurface would clamp it.
3632 testPoint = gfx::Point(101, 101);
3633 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3634 EXPECT_FALSE(resultLayer);
3635
3636 // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer.
3637 testPoint = gfx::Point(51, 51);
3638 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3639 EXPECT_FALSE(resultLayer);
3640
3641 // Hit checking for a point inside the touch event handler region should ret urn the root layer.
3642 testPoint = gfx::Point(61, 61);
3643 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3644 ASSERT_TRUE(resultLayer);
3645 EXPECT_EQ(12345, resultLayer->id());
3646
3647 testPoint = gfx::Point(99, 99);
3648 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3649 ASSERT_TRUE(resultLayer);
3650 EXPECT_EQ(12345, resultLayer->id());
3651 }
3652
3653 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithScaledContents)
3654 {
3655 // A layer's visibleContentRect is actually in the layer's content space. Th e
3656 // screenSpaceTransform converts from the layer's origin space to screen spa ce. This
3657 // test makes sure that hit testing works correctly accounts for the content s scale.
3658 // A contentsScale that is not 1 effectively forces a non-identity transform between
3659 // layer's content space and layer's origin space. The hit testing code must take this into account.
3660 //
3661 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If
3662 // contentsScale is ignored, then hit checking will mis-interpret the visibl eContentRect
3663 // as being larger than the actual bounds of the layer.
3664 //
3665 DebugScopedSetImplThread thisScopeIsOnImplThread;
3666
3667 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3668
3669 WebTransformationMatrix identityMatrix;
3670 gfx::PointF anchor(0, 0);
3671
3672 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3673
3674 {
3675 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30));
3676 gfx::PointF position(25, 25);
3677 gfx::Size bounds(50, 50);
3678 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345);
3679 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3680
3681 // override contentBounds and contentsScale
3682 testLayer->setContentBounds(gfx::Size(100, 100));
3683 testLayer->setContentsScale(2, 2);
3684
3685 testLayer->setDrawsContent(true);
3686 testLayer->setTouchEventHandlerRegion(touchHandlerRegion);
3687 root->addChild(testLayer.Pass());
3688 }
3689
3690 std::vector<LayerImpl*> renderSurfaceLayerList;
3691 int dummyMaxTextureSize = 512;
3692 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
danakj 2012/11/09 17:02:58 Can you repeat this test but pass something non-1,
Yusuf 2012/11/12 23:57:33 Done.
3693
3694 // Sanity check the scenario we just created.
3695 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
3696 LayerImpl* testLayer = root->children()[0];
3697 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi bleContentRect());
3698 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3699 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3700
3701 // Hit checking for a point outside the layer should return a null pointer ( the root layer does not draw content, so it will not be tested either).
3702 gfx::Point testPoint(76, 76);
3703 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3704 EXPECT_FALSE(resultLayer);
3705
3706 // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer.
3707 testPoint = gfx::Point(26, 26);
danakj 2012/11/09 17:02:58 does this also work at 34,34?
Yusuf 2012/11/12 23:57:33 Done.
3708 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3709 EXPECT_FALSE(resultLayer);
3710
3711 testPoint = gfx::Point(74, 74);
danakj 2012/11/09 17:02:58 does this also work at 65,65?
Yusuf 2012/11/12 23:57:33 Done.
3712 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3713 EXPECT_FALSE(resultLayer);
3714
3715 // Hit checking for a point inside the touch event handler region should ret urn the root layer.
3716 testPoint = gfx::Point(36, 36);
danakj 2012/11/09 17:02:58 does this also work at 35,35?
Yusuf 2012/11/12 23:57:33 Done.
3717 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3718 ASSERT_TRUE(resultLayer);
3719 EXPECT_EQ(12345, resultLayer->id());
3720
3721 testPoint = gfx::Point(64, 64);
3722 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3723 ASSERT_TRUE(resultLayer);
3724 EXPECT_EQ(12345, resultLayer->id());
3725 }
3726
3727 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer)
3728 {
3729 // Test that hit-checking will only work for the visible portion of a layer, and not
3730 // the entire layer bounds. Here we just test the simple axis-aligned case.
3731 DebugScopedSetImplThread thisScopeIsOnImplThread;
3732
3733 WebTransformationMatrix identityMatrix;
3734 gfx::PointF anchor(0, 0);
3735
3736 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3737 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3738
3739 {
3740 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123);
3741 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located.
3742 gfx::Size bounds(50, 50);
3743 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false);
3744 clippingLayer->setMasksToBounds(true);
3745
3746 scoped_ptr<LayerImpl> child = LayerImpl::create(456);
3747 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3748 position = gfx::PointF(-50, -50);
3749 bounds = gfx::Size(300, 300);
3750 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3751 child->setDrawsContent(true);
3752 child->setTouchEventHandlerRegion(touchHandlerRegion);
3753 clippingLayer->addChild(child.Pass());
3754 root->addChild(clippingLayer.Pass());
3755 }
3756
3757 std::vector<LayerImpl*> renderSurfaceLayerList;
3758 int dummyMaxTextureSize = 512;
3759 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
3760
3761 // Sanity check the scenario we just created.
3762 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3763 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3764 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id());
3765
3766 // Hit checking for a point outside the layer should return a null pointer.
3767 // Despite the child layer being very large, it should be clipped to the roo t layer's bounds.
3768 gfx::Point testPoint(24, 24);
3769 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3770 EXPECT_FALSE(resultLayer);
3771
3772 // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer.
3773 testPoint = gfx::Point(36, 36);
danakj 2012/11/09 17:02:58 how about 35,35?
Yusuf 2012/11/12 23:57:33 Done.
3774 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3775 EXPECT_FALSE(resultLayer);
3776
3777 testPoint = gfx::Point(74, 74);
3778 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3779 EXPECT_FALSE(resultLayer);
3780
3781 // Hit checking for a point inside the touch event handler region should ret urn the root layer.
3782 testPoint = gfx::Point(26, 26);
danakj 2012/11/09 17:02:58 how about 25,25?
Yusuf 2012/11/12 23:57:33 Done.
3783 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3784 ASSERT_TRUE(resultLayer);
3785 EXPECT_EQ(456, resultLayer->id());
3786
3787 testPoint = gfx::Point(34, 34);
3788 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3789 ASSERT_TRUE(resultLayer);
3790 EXPECT_EQ(456, resultLayer->id());
3791 }
3792
3466 class NoScaleContentLayer : public ContentLayer 3793 class NoScaleContentLayer : public ContentLayer
3467 { 3794 {
3468 public: 3795 public:
3469 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client) { return make_scoped_refptr(new NoScaleContentLayer(client)); } 3796 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client) { return make_scoped_refptr(new NoScaleContentLayer(client)); }
3470 3797
3471 virtual gfx::Size contentBounds() const OVERRIDE { return bounds(); } 3798 virtual gfx::Size contentBounds() const OVERRIDE { return bounds(); }
3472 virtual float contentsScaleX() const OVERRIDE { return 1.0; } 3799 virtual float contentsScaleX() const OVERRIDE { return 1.0; }
3473 virtual float contentsScaleY() const OVERRIDE { return 1.0; } 3800 virtual float contentsScaleY() const OVERRIDE { return 1.0; }
3474 3801
3475 protected: 3802 protected:
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 int nonexistentId = -1; 4366 int nonexistentId = -1;
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); 4367 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ()));
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); 4368 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id()));
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); 4369 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id()));
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); 4370 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id()));
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); 4371 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id()));
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); 4372 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id));
4046 } 4373 }
4047 4374
4048 } // namespace 4375 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698