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

Side by Side Diff: cc/surfaces/surface_hittest_unittest.cc

Issue 1663433002: Adds an interface to SurfaceHittestDelegate in order to override (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « cc/surfaces/surface_hittest_delegate.h ('k') | cc/test/surface_hittest_test_helpers.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_factory.h" 9 #include "cc/surfaces/surface_factory.h"
10 #include "cc/surfaces/surface_factory_client.h" 10 #include "cc/surfaces/surface_factory_client.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 factory.Create(root_surface_id); 498 factory.Create(root_surface_id);
499 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), 499 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
500 SurfaceFactory::DrawCallback()); 500 SurfaceFactory::DrawCallback());
501 501
502 // Creates a child surface. 502 // Creates a child surface.
503 RenderPass* child_pass = nullptr; 503 RenderPass* child_pass = nullptr;
504 scoped_ptr<CompositorFrame> child_frame = 504 scoped_ptr<CompositorFrame> child_frame =
505 CreateCompositorFrame(child_rect, &child_pass); 505 CreateCompositorFrame(child_rect, &child_pass);
506 506
507 // Add a solid quad in the child surface. 507 // Add a solid quad in the child surface.
508 gfx::Rect child_solid_quad_rect(200, 200); 508 gfx::Rect child_solid_quad_rect(190, 190);
509 CreateSolidColorDrawQuad( 509 CreateSolidColorDrawQuad(
510 child_pass, 510 child_pass,
511 gfx::Transform(), 511 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f,
512 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
512 root_rect, child_solid_quad_rect); 513 root_rect, child_solid_quad_rect);
513 514
514 // Submit the frame. 515 // Submit the frame.
515 factory.Create(child_surface_id); 516 factory.Create(child_surface_id);
516 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), 517 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
517 SurfaceFactory::DrawCallback()); 518 SurfaceFactory::DrawCallback());
518 519
519 TestCase test_expectations_without_insets[] = { 520 TestCase test_expectations_without_insets[] = {
520 { 521 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
521 root_surface_id, 522 {root_surface_id, gfx::Point(60, 60), child_surface_id,
522 gfx::Point(50, 50), 523 gfx::Point(10, 10)},
523 child_surface_id, 524 {root_surface_id, gfx::Point(239, 239), child_surface_id,
524 gfx::Point(0, 0) 525 gfx::Point(189, 189)},
525 }, 526 {root_surface_id, gfx::Point(244, 244), child_surface_id,
526 { 527 gfx::Point(194, 194)},
527 root_surface_id, 528 {root_surface_id, gfx::Point(50, 50), root_surface_id,
528 gfx::Point(60, 60), 529 gfx::Point(50, 50)},
529 child_surface_id, 530 {root_surface_id, gfx::Point(249, 249), root_surface_id,
530 gfx::Point(10, 10) 531 gfx::Point(249, 249)},
531 },
532 {
533 root_surface_id,
534 gfx::Point(239, 239),
535 child_surface_id,
536 gfx::Point(189, 189)
537 },
538 {
539 root_surface_id,
540 gfx::Point(249, 249),
541 child_surface_id,
542 gfx::Point(199, 199)
543 },
544 }; 532 };
545 533
546 TestSurfaceHittestDelegate delegate; 534 TestSurfaceHittestDelegate empty_delegate;
547 RunTests(&delegate, &manager, test_expectations_without_insets, 535 RunTests(&empty_delegate, &manager, test_expectations_without_insets,
548 arraysize(test_expectations_without_insets)); 536 arraysize(test_expectations_without_insets));
549 537
550 // Verify that insets have NOT affected hit targeting. 538 // Verify that insets have NOT affected hit targeting.
551 EXPECT_EQ(0, delegate.target_overrides()); 539 EXPECT_EQ(0, empty_delegate.reject_target_overrides());
540 EXPECT_EQ(0, empty_delegate.accept_target_overrides());
552 541
553 delegate.AddInsetsForSurface(child_surface_id, gfx::Insets(10, 10, 10, 10)); 542 TestCase test_expectations_with_reject_insets[] = {
554 543 // Point (55, 55) falls outside the child surface due to the insets
555 TestCase test_expectations_with_insets[] = { 544 // introduced above.
556 // Point (50, 50) falls outside the child surface due to the insets 545 {root_surface_id, gfx::Point(55, 55), root_surface_id,
557 // introduced above. 546 gfx::Point(55, 55)},
558 { 547 // These two points still fall within the child surface.
559 root_surface_id, 548 {root_surface_id, gfx::Point(60, 60), child_surface_id,
560 gfx::Point(50, 50), 549 gfx::Point(10, 10)},
561 root_surface_id, 550 {root_surface_id, gfx::Point(239, 239), child_surface_id,
562 gfx::Point(50, 50) 551 gfx::Point(189, 189)},
563 }, 552 // Point (244, 244) falls outside the child surface due to the insets
564 // These two points still fall within the child surface. 553 // introduced above.
565 { 554 {root_surface_id, gfx::Point(244, 244), root_surface_id,
566 root_surface_id, 555 gfx::Point(244, 244)},
567 gfx::Point(60, 60), 556 // Next two points also fall within within the insets indroduced above.
568 child_surface_id, 557 {root_surface_id, gfx::Point(50, 50), root_surface_id,
569 gfx::Point(10, 10) 558 gfx::Point(50, 50)},
570 }, 559 {root_surface_id, gfx::Point(249, 249), root_surface_id,
571 { 560 gfx::Point(249, 249)},
572 root_surface_id,
573 gfx::Point(239, 239),
574 child_surface_id,
575 gfx::Point(189, 189)
576 },
577 // Point (249, 249) falls outside the child surface due to the insets
578 // introduced above.
579 {
580 root_surface_id,
581 gfx::Point(249, 249),
582 root_surface_id,
583 gfx::Point(249, 249)
584 },
585 }; 561 };
586 562
587 RunTests(&delegate, &manager, test_expectations_with_insets, 563 TestSurfaceHittestDelegate reject_delegate;
588 arraysize(test_expectations_with_insets)); 564 reject_delegate.AddInsetsForRejectSurface(child_surface_id,
565 gfx::Insets(10, 10, 10, 10));
566 RunTests(&reject_delegate, &manager, test_expectations_with_reject_insets,
567 arraysize(test_expectations_with_reject_insets));
589 568
590 // Verify that insets have affected hit targeting. 569 // Verify that insets have affected hit targeting.
591 EXPECT_EQ(2, delegate.target_overrides()); 570 EXPECT_EQ(4, reject_delegate.reject_target_overrides());
571 EXPECT_EQ(0, reject_delegate.accept_target_overrides());
572
573 TestCase test_expectations_with_accept_insets[] = {
574 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
575 {root_surface_id, gfx::Point(60, 60), child_surface_id,
576 gfx::Point(10, 10)},
577 {root_surface_id, gfx::Point(239, 239), child_surface_id,
578 gfx::Point(189, 189)},
579 {root_surface_id, gfx::Point(244, 244), child_surface_id,
580 gfx::Point(194, 194)},
581 // Next two points fall within within the insets indroduced above.
582 {root_surface_id, gfx::Point(50, 50), child_surface_id, gfx::Point(0, 0)},
583 {root_surface_id, gfx::Point(249, 249), child_surface_id,
584 gfx::Point(199, 199)},
585 };
586
587 TestSurfaceHittestDelegate accept_delegate;
588 accept_delegate.AddInsetsForAcceptSurface(child_surface_id,
589 gfx::Insets(5, 5, 5, 5));
590 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets,
591 arraysize(test_expectations_with_accept_insets));
592
593 // Verify that insets have affected hit targeting.
594 EXPECT_EQ(0, accept_delegate.reject_target_overrides());
595 EXPECT_EQ(2, accept_delegate.accept_target_overrides());
592 596
593 factory.Destroy(root_surface_id); 597 factory.Destroy(root_surface_id);
594 } 598 }
595 599
596 } // namespace cc 600 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_hittest_delegate.h ('k') | cc/test/surface_hittest_test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698