| OLD | NEW |
| 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 "ash/common/accessibility_delegate.h" | 5 #include "ash/common/accessibility_delegate.h" |
| 6 #include "ash/common/wm/window_state.h" | 6 #include "ash/common/wm/window_state.h" |
| 7 #include "ash/common/wm/wm_event.h" | 7 #include "ash/common/wm/wm_event.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 popup_surface.Commit(); | 497 popup_surface.Commit(); |
| 498 | 498 |
| 499 // Popup position is fixed, and geometry is relative to it. | 499 // Popup position is fixed, and geometry is relative to it. |
| 500 EXPECT_EQ(gfx::Rect(parent_bounds.origin() + | 500 EXPECT_EQ(gfx::Rect(parent_bounds.origin() + |
| 501 popup_bounds.OffsetFromOrigin() + | 501 popup_bounds.OffsetFromOrigin() + |
| 502 geometry.OffsetFromOrigin(), | 502 geometry.OffsetFromOrigin(), |
| 503 geometry.size()), | 503 geometry.size()), |
| 504 popup->GetWidget()->GetWindowBoundsInScreen()); | 504 popup->GetWidget()->GetWindowBoundsInScreen()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 TEST_F(ShellSurfaceTest, Shadow) { | 507 TEST_F(ShellSurfaceTest, SurfaceShadow) { |
| 508 gfx::Size buffer_size(128, 128); | 508 gfx::Size buffer_size(128, 128); |
| 509 std::unique_ptr<Buffer> buffer( | 509 std::unique_ptr<Buffer> buffer( |
| 510 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 510 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 511 std::unique_ptr<Surface> surface(new Surface); | 511 std::unique_ptr<Surface> surface(new Surface); |
| 512 std::unique_ptr<ShellSurface> shell_surface( | 512 std::unique_ptr<ShellSurface> shell_surface( |
| 513 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, false, | 513 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, false, |
| 514 ash::kShellWindowId_DefaultContainer)); | 514 ash::kShellWindowId_DefaultContainer)); |
| 515 surface->Attach(buffer.get()); | 515 surface->Attach(buffer.get()); |
| 516 surface->Commit(); | 516 surface->Commit(); |
| 517 | 517 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 529 std::unique_ptr<Buffer> child_buffer( | 529 std::unique_ptr<Buffer> child_buffer( |
| 530 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 530 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 531 child->Attach(child_buffer.get()); | 531 child->Attach(child_buffer.get()); |
| 532 std::unique_ptr<SubSurface> sub_surface( | 532 std::unique_ptr<SubSurface> sub_surface( |
| 533 display->CreateSubSurface(child.get(), surface.get())); | 533 display->CreateSubSurface(child.get(), surface.get())); |
| 534 surface->Commit(); | 534 surface->Commit(); |
| 535 | 535 |
| 536 EXPECT_FALSE(shadow->layer()->visible()); | 536 EXPECT_FALSE(shadow->layer()->visible()); |
| 537 | 537 |
| 538 // 3) Create a shadow. | 538 // 3) Create a shadow. |
| 539 shell_surface->SetRectangularShadow(true); | 539 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); |
| 540 shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100)); | |
| 541 surface->Commit(); | 540 surface->Commit(); |
| 542 EXPECT_TRUE(shadow->layer()->visible()); | 541 EXPECT_TRUE(shadow->layer()->visible()); |
| 543 | 542 |
| 544 gfx::Rect before = shadow->layer()->bounds(); | 543 gfx::Rect before = shadow->layer()->bounds(); |
| 545 | 544 |
| 546 // 4) Shadow bounds is independent of the sub surface. | 545 // 4) Shadow bounds is independent of the sub surface. |
| 547 gfx::Size new_buffer_size(256, 256); | 546 gfx::Size new_buffer_size(256, 256); |
| 548 std::unique_ptr<Buffer> new_child_buffer( | 547 std::unique_ptr<Buffer> new_child_buffer( |
| 549 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size))); | 548 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size))); |
| 550 child->Attach(new_child_buffer.get()); | 549 child->Attach(new_child_buffer.get()); |
| 551 child->Commit(); | 550 child->Commit(); |
| 552 surface->Commit(); | 551 surface->Commit(); |
| 553 | 552 |
| 554 EXPECT_EQ(before, shadow->layer()->bounds()); | 553 EXPECT_EQ(before, shadow->layer()->bounds()); |
| 555 | 554 |
| 556 // 4) Updating the widget's window bounds should not change the shadow bounds. | 555 // 4) Updating the widget's window bounds should not change the shadow bounds. |
| 557 window->SetBounds(gfx::Rect(10, 10, 100, 100)); | 556 window->SetBounds(gfx::Rect(10, 10, 100, 100)); |
| 558 EXPECT_EQ(before, shadow->layer()->bounds()); | 557 EXPECT_EQ(before, shadow->layer()->bounds()); |
| 559 | 558 |
| 560 // 5) This should disable shadow. | 559 // 5) This should disable shadow. |
| 561 shell_surface->SetRectangularShadow(false); | 560 shell_surface->SetRectangularSurfaceShadow(gfx::Rect()); |
| 562 surface->Commit(); | 561 surface->Commit(); |
| 563 | 562 |
| 564 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); | 563 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); |
| 565 EXPECT_FALSE(shadow->layer()->visible()); | 564 EXPECT_FALSE(shadow->layer()->visible()); |
| 566 | 565 |
| 567 // 6) This should enable shadow. | 566 // 6) This should enable non surface shadow again. |
| 568 shell_surface->SetRectangularShadow(true); | 567 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); |
| 569 surface->Commit(); | 568 surface->Commit(); |
| 570 | 569 |
| 571 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); | 570 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); |
| 572 EXPECT_TRUE(shadow->layer()->visible()); | 571 EXPECT_TRUE(shadow->layer()->visible()); |
| 573 | 572 |
| 573 // For surface shadow, the underlay is placed at the bottom of shell surfaces. |
| 574 EXPECT_EQ(surface->window(), shell_surface->shadow_underlay()->parent()); |
| 575 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent()); |
| 576 |
| 577 EXPECT_EQ(*surface->window()->children().begin(), |
| 578 shell_surface->shadow_underlay()); |
| 579 } |
| 580 |
| 581 TEST_F(ShellSurfaceTest, NonSurfaceShadow) { |
| 582 gfx::Size buffer_size(128, 128); |
| 583 std::unique_ptr<Buffer> buffer( |
| 584 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 585 std::unique_ptr<Surface> surface(new Surface); |
| 586 std::unique_ptr<ShellSurface> shell_surface( |
| 587 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, false, |
| 588 ash::kShellWindowId_DefaultContainer)); |
| 589 surface->Attach(buffer.get()); |
| 590 surface->Commit(); |
| 591 |
| 592 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 593 |
| 594 // 1) Initial state, no shadow. |
| 595 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 596 ASSERT_TRUE(shadow); |
| 597 EXPECT_FALSE(shadow->layer()->visible()); |
| 598 |
| 599 std::unique_ptr<Display> display(new Display); |
| 600 |
| 601 // 2) Just creating a sub surface won't create a shadow. |
| 602 std::unique_ptr<Surface> child = display->CreateSurface(); |
| 603 std::unique_ptr<Buffer> child_buffer( |
| 604 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 605 child->Attach(child_buffer.get()); |
| 606 std::unique_ptr<SubSurface> sub_surface( |
| 607 display->CreateSubSurface(child.get(), surface.get())); |
| 608 surface->Commit(); |
| 609 |
| 610 EXPECT_FALSE(shadow->layer()->visible()); |
| 611 |
| 612 // 3) Enable a shadow. |
| 613 shell_surface->SetRectangularShadowEnabled(true); |
| 614 surface->Commit(); |
| 615 EXPECT_TRUE(shadow->layer()->visible()); |
| 616 |
| 617 gfx::Rect before = shadow->layer()->bounds(); |
| 618 |
| 619 // 4) Shadow bounds is independent of the sub surface. |
| 620 gfx::Size new_buffer_size(256, 256); |
| 621 std::unique_ptr<Buffer> new_child_buffer( |
| 622 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size))); |
| 623 child->Attach(new_child_buffer.get()); |
| 624 child->Commit(); |
| 625 surface->Commit(); |
| 626 |
| 627 EXPECT_EQ(before, shadow->layer()->bounds()); |
| 628 |
| 629 // 4) Updating the widget's window bounds should change the non surface shadow |
| 630 // bounds. |
| 631 const gfx::Rect new_bounds(50, 50, 100, 100); |
| 632 window->SetBounds(new_bounds); |
| 633 EXPECT_NE(before, shadow->layer()->bounds()); |
| 634 EXPECT_NE(new_bounds, shadow->layer()->bounds()); |
| 635 |
| 636 // 5) This should disable shadow. |
| 637 shell_surface->SetRectangularShadowEnabled(false); |
| 638 surface->Commit(); |
| 639 |
| 640 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); |
| 641 EXPECT_FALSE(shadow->layer()->visible()); |
| 642 |
| 643 // 6) This should enable non surface shadow. |
| 644 shell_surface->SetRectangularShadowEnabled(true); |
| 645 surface->Commit(); |
| 646 |
| 647 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); |
| 648 EXPECT_TRUE(shadow->layer()->visible()); |
| 649 |
| 650 // For no surface shadow, both of underlay and overlay should be stacked |
| 651 // below the surface window. |
| 652 EXPECT_EQ(window, shell_surface->shadow_underlay()->parent()); |
| 653 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent()); |
| 654 |
| 574 // Shadow overlay should be stacked just above the shadow underlay. | 655 // Shadow overlay should be stacked just above the shadow underlay. |
| 575 auto underlay_it = | 656 auto underlay_it = |
| 576 std::find(window->children().begin(), window->children().end(), | 657 std::find(window->children().begin(), window->children().end(), |
| 577 shell_surface->shadow_underlay()); | 658 shell_surface->shadow_underlay()); |
| 578 ASSERT_NE(underlay_it, window->children().end()); | 659 ASSERT_NE(underlay_it, window->children().end()); |
| 579 ASSERT_NE(std::next(underlay_it), window->children().end()); | 660 ASSERT_NE(std::next(underlay_it), window->children().end()); |
| 580 EXPECT_EQ(*std::next(underlay_it), shell_surface->shadow_overlay()); | 661 EXPECT_EQ(*std::next(underlay_it), shell_surface->shadow_overlay()); |
| 581 } | 662 } |
| 582 | 663 |
| 583 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { | 664 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 601 const gfx::Rect shadow_bounds(content_size); | 682 const gfx::Rect shadow_bounds(content_size); |
| 602 | 683 |
| 603 // Expected shadow position/bounds in parent coordinates. | 684 // Expected shadow position/bounds in parent coordinates. |
| 604 const gfx::Point expected_shadow_origin(-10, -10); | 685 const gfx::Point expected_shadow_origin(-10, -10); |
| 605 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size); | 686 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size); |
| 606 | 687 |
| 607 views::Widget* widget = shell_surface->GetWidget(); | 688 views::Widget* widget = shell_surface->GetWidget(); |
| 608 aura::Window* window = widget->GetNativeWindow(); | 689 aura::Window* window = widget->GetNativeWindow(); |
| 609 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 690 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 610 | 691 |
| 611 shell_surface->SetRectangularShadow(true); | 692 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 612 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | |
| 613 surface->Commit(); | 693 surface->Commit(); |
| 614 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); | 694 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); |
| 615 | 695 |
| 616 // Shadow overlay bounds. | 696 // Shadow overlay bounds. |
| 617 EXPECT_TRUE(shadow->layer()->visible()); | 697 EXPECT_TRUE(shadow->layer()->visible()); |
| 618 // Origin must be in sync. | 698 // Origin must be in sync. |
| 619 EXPECT_EQ(expected_shadow_origin, | 699 EXPECT_EQ(expected_shadow_origin, |
| 620 shadow->layer()->parent()->bounds().origin()); | 700 shadow->layer()->parent()->bounds().origin()); |
| 621 | 701 |
| 622 const gfx::Rect work_area = | 702 const gfx::Rect work_area = |
| 623 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 703 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 624 // Maximizing window hides the shadow. | 704 // Maximizing window hides the shadow. |
| 625 widget->Maximize(); | 705 widget->Maximize(); |
| 626 ASSERT_TRUE(widget->IsMaximized()); | 706 ASSERT_TRUE(widget->IsMaximized()); |
| 627 EXPECT_FALSE(shadow->layer()->visible()); | 707 EXPECT_FALSE(shadow->layer()->visible()); |
| 628 | 708 |
| 629 shell_surface->SetRectangularShadowContentBounds(work_area); | 709 shell_surface->SetRectangularSurfaceShadow(work_area); |
| 630 surface->Commit(); | 710 surface->Commit(); |
| 631 EXPECT_FALSE(shadow->layer()->visible()); | 711 EXPECT_FALSE(shadow->layer()->visible()); |
| 632 | 712 |
| 633 // Restoring bounds will re-enable shadow. It's content size is set to work | 713 // Restoring bounds will re-enable shadow. It's content size is set to work |
| 634 // area,/ thus not visible until new bounds is committed. | 714 // area,/ thus not visible until new bounds is committed. |
| 635 widget->Restore(); | 715 widget->Restore(); |
| 636 EXPECT_TRUE(shadow->layer()->visible()); | 716 EXPECT_TRUE(shadow->layer()->visible()); |
| 637 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); | 717 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); |
| 638 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); | 718 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); |
| 639 | 719 |
| 640 // The bounds is updated. | 720 // The bounds is updated. |
| 641 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | 721 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 642 surface->Commit(); | 722 surface->Commit(); |
| 643 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); | 723 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); |
| 644 } | 724 } |
| 645 | 725 |
| 646 TEST_F(ShellSurfaceTest, ShadowWithTransform) { | 726 TEST_F(ShellSurfaceTest, ShadowWithTransform) { |
| 647 gfx::Size buffer_size(64, 64); | 727 gfx::Size buffer_size(64, 64); |
| 648 std::unique_ptr<Buffer> buffer( | 728 std::unique_ptr<Buffer> buffer( |
| 649 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 729 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 650 std::unique_ptr<Surface> surface(new Surface); | 730 std::unique_ptr<Surface> surface(new Surface); |
| 651 // Set the bounds to disable auto managed mode. | 731 // Set the bounds to disable auto managed mode. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 663 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); | 743 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 664 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 744 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 665 | 745 |
| 666 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). | 746 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). |
| 667 const gfx::Rect shadow_bounds(content_size); | 747 const gfx::Rect shadow_bounds(content_size); |
| 668 | 748 |
| 669 // Shadow bounds relative to its parent should not be affected by a transform. | 749 // Shadow bounds relative to its parent should not be affected by a transform. |
| 670 gfx::Transform transform; | 750 gfx::Transform transform; |
| 671 transform.Translate(50, 50); | 751 transform.Translate(50, 50); |
| 672 window->SetTransform(transform); | 752 window->SetTransform(transform); |
| 673 shell_surface->SetRectangularShadow(true); | 753 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 674 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | |
| 675 surface->Commit(); | 754 surface->Commit(); |
| 676 EXPECT_TRUE(shadow->layer()->visible()); | 755 EXPECT_TRUE(shadow->layer()->visible()); |
| 677 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); | 756 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); |
| 678 } | 757 } |
| 679 | 758 |
| 680 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { | 759 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { |
| 681 std::unique_ptr<Surface> surface(new Surface); | 760 std::unique_ptr<Surface> surface(new Surface); |
| 682 std::unique_ptr<ShellSurface> shell_surface( | 761 std::unique_ptr<ShellSurface> shell_surface( |
| 683 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false, | 762 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false, |
| 684 ash::kShellWindowId_DefaultContainer)); | 763 ash::kShellWindowId_DefaultContainer)); |
| 685 shell_surface->Maximize(); | 764 shell_surface->Maximize(); |
| 686 views::Widget* widget = shell_surface->GetWidget(); | 765 views::Widget* widget = shell_surface->GetWidget(); |
| 687 aura::Window* window = widget->GetNativeWindow(); | 766 aura::Window* window = widget->GetNativeWindow(); |
| 688 | 767 |
| 689 // There is no shadow when started in maximized state. | 768 // There is no shadow when started in maximized state. |
| 690 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 769 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 691 | 770 |
| 692 // Sending a shadow bounds in maximized state won't create a shaodw. | 771 // Sending a shadow bounds in maximized state won't create a shaodw. |
| 693 shell_surface->SetRectangularShadow(true); | 772 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); |
| 694 shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100)); | |
| 695 surface->Commit(); | 773 surface->Commit(); |
| 696 | 774 |
| 697 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 775 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 698 // Underlay should be created even without shadow. | 776 // Underlay should be created even without shadow. |
| 699 ASSERT_TRUE(shell_surface->shadow_underlay()); | 777 ASSERT_TRUE(shell_surface->shadow_underlay()); |
| 700 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 778 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 701 | 779 |
| 702 // Restore the window and make sure the shadow is created, visible and | 780 // Restore the window and make sure the shadow is created, visible and |
| 703 // has the latest bounds. | 781 // has the latest bounds. |
| 704 widget->Restore(); | 782 widget->Restore(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 815 |
| 738 // Leave fullscreen mode. | 816 // Leave fullscreen mode. |
| 739 window->GetWindowState()->OnWMEvent(&event); | 817 window->GetWindowState()->OnWMEvent(&event); |
| 740 | 818 |
| 741 // Check that shell surface is maximized. | 819 // Check that shell surface is maximized. |
| 742 EXPECT_EQ(CurrentContext()->bounds().width(), | 820 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 743 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); | 821 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| 744 } | 822 } |
| 745 | 823 |
| 746 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { | 824 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { |
| 747 gfx::Size buffer_size(256, 256); | 825 const gfx::Size display_size = |
| 826 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 827 const gfx::Size buffer_size(display_size); |
| 748 std::unique_ptr<Buffer> buffer( | 828 std::unique_ptr<Buffer> buffer( |
| 749 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 829 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 750 std::unique_ptr<Surface> surface(new Surface); | 830 std::unique_ptr<Surface> surface(new Surface); |
| 751 std::unique_ptr<ShellSurface> shell_surface( | 831 std::unique_ptr<ShellSurface> shell_surface( |
| 752 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false, | 832 new ShellSurface(surface.get(), nullptr, gfx::Rect(100, 100), true, false, |
| 753 ash::kShellWindowId_DefaultContainer)); | 833 ash::kShellWindowId_DefaultContainer)); |
| 754 | 834 |
| 755 surface->Attach(buffer.get()); | 835 surface->Attach(buffer.get()); |
| 756 | 836 |
| 757 gfx::Rect shadow_bounds(10, 10, 100, 100); | 837 gfx::Rect shadow_bounds(10, 10, 100, 100); |
| 758 shell_surface->SetRectangularShadow(true); | 838 shell_surface->SetGeometry(shadow_bounds); |
| 759 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | 839 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 760 surface->Commit(); | 840 surface->Commit(); |
| 841 EXPECT_EQ(shadow_bounds, |
| 842 shell_surface->GetWidget()->GetWindowBoundsInScreen()); |
| 761 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); | 843 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 844 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(), |
| 845 shell_surface->surface_for_testing()->window()->bounds().size()); |
| 762 | 846 |
| 763 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); | 847 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 764 ash::WmWindow* window = | 848 ash::WmWindow* window = |
| 765 ash::WmWindow::Get(shell_surface->GetWidget()->GetNativeWindow()); | 849 ash::WmWindow::Get(shell_surface->GetWidget()->GetNativeWindow()); |
| 766 | 850 |
| 767 // Enter immersive fullscreen mode. Shadow underlay is fullscreen. | 851 // Enter immersive fullscreen mode. Shadow underlay is fullscreen. |
| 768 window->GetWindowState()->OnWMEvent(&event); | 852 window->GetWindowState()->OnWMEvent(&event); |
| 769 | 853 |
| 770 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | |
| 771 shell_surface->shadow_underlay()->bounds()); | |
| 772 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 854 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 773 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity()); | 855 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity()); |
| 774 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(), | 856 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(), |
| 775 shell_surface->shadow_underlay()->bounds()); | 857 shell_surface->shadow_underlay()->bounds().size()); |
| 776 | 858 |
| 777 // Leave fullscreen mode. Shadow underlay is restored. | 859 // Leave fullscreen mode. Shadow underlay is restored. |
| 778 window->GetWindowState()->OnWMEvent(&event); | 860 window->GetWindowState()->OnWMEvent(&event); |
| 779 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 861 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 780 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); | 862 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 781 } | 863 } |
| 782 | 864 |
| 783 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { | 865 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { |
| 784 gfx::Size buffer_size(256, 256); | 866 const gfx::Size display_size = |
| 867 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 868 const gfx::Size buffer_size(display_size); |
| 785 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | 869 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); |
| 786 Surface surface; | 870 Surface surface; |
| 787 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true, | 871 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(100, 100), true, |
| 788 false, ash::kShellWindowId_DefaultContainer); | 872 false, ash::kShellWindowId_DefaultContainer); |
| 789 | |
| 790 surface.Attach(&buffer); | 873 surface.Attach(&buffer); |
| 791 | 874 |
| 792 gfx::Rect shadow_bounds(10, 10, 100, 100); | 875 gfx::Rect shadow_bounds(10, 10, 100, 100); |
| 793 shell_surface.SetRectangularShadow(true); | 876 shell_surface.SetGeometry(shadow_bounds); |
| 794 shell_surface.SetRectangularShadowContentBounds(shadow_bounds); | 877 shell_surface.SetRectangularSurfaceShadow(shadow_bounds); |
| 795 surface.Commit(); | 878 surface.Commit(); |
| 879 EXPECT_EQ(shadow_bounds, |
| 880 shell_surface.GetWidget()->GetWindowBoundsInScreen()); |
| 796 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 881 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 797 | 882 |
| 798 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); | 883 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); |
| 799 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( | 884 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( |
| 800 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter()); | 885 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter()); |
| 801 | 886 |
| 802 gfx::Point pt(300, 300); | 887 gfx::Point pt_out(300, 300); |
| 803 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(), | 888 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt_out, pt_out, |
| 804 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 889 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 805 gfx::Point pt2(250, 250); | 890 ui::EF_LEFT_MOUSE_BUTTON); |
| 806 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt2, pt2, ui::EventTimeForNow(), | 891 gfx::Point pt_in(70, 70); |
| 807 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 892 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt_in, pt_in, |
| 893 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 894 ui::EF_LEFT_MOUSE_BUTTON); |
| 808 | 895 |
| 809 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); | 896 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); |
| 810 | 897 |
| 811 // Enable spoken feedback. | 898 // Enable spoken feedback. |
| 812 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 899 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
| 813 ash::A11Y_NOTIFICATION_NONE); | 900 ash::A11Y_NOTIFICATION_NONE); |
| 814 shell_surface.OnAccessibilityModeChanged(); | 901 shell_surface.OnAccessibilityModeChanged(); |
| 815 | 902 |
| 816 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | 903 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), |
| 817 shell_surface.shadow_underlay()->bounds()); | 904 shell_surface.shadow_underlay()->bounds()); |
| 818 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 905 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 819 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(), | 906 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(), |
| 820 shell_surface.shadow_underlay()->bounds()); | 907 shell_surface.shadow_underlay()->bounds()); |
| 821 | 908 |
| 822 // Test event capture | 909 // Test event capture |
| 823 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); | 910 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); |
| 824 EXPECT_EQ(shell_surface.shadow_underlay(), | 911 EXPECT_EQ(shell_surface.shadow_underlay(), |
| 825 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | 912 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( |
| 826 shell_window, &ev_out)); | 913 shell_window, &ev_out)); |
| 827 EXPECT_NE(shell_surface.shadow_underlay(), | 914 EXPECT_NE(shell_surface.shadow_underlay(), |
| 828 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | 915 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( |
| 829 shell_window, &ev_in)); | 916 shell_window, &ev_in)); |
| 830 | 917 |
| 831 // Create a new surface | 918 // Create a new surface |
| 832 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | 919 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); |
| 833 Surface surface2; | 920 Surface surface2; |
| 834 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, | 921 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, |
| 835 false, ash::kShellWindowId_DefaultContainer); | 922 false, ash::kShellWindowId_DefaultContainer); |
| 836 surface2.Attach(&buffer2); | 923 surface2.Attach(&buffer2); |
| 837 shell_surface2.SetRectangularShadow(true); | 924 shell_surface2.SetRectangularSurfaceShadow(shadow_bounds); |
| 838 shell_surface2.SetRectangularShadowContentBounds(shadow_bounds); | |
| 839 surface2.Commit(); | 925 surface2.Commit(); |
| 840 | 926 |
| 841 // spoken-feedback was already on, so underlay should fill screen | 927 // spoken-feedback was already on, so underlay should fill screen |
| 842 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | 928 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), |
| 843 shell_surface2.shadow_underlay()->bounds()); | 929 shell_surface2.shadow_underlay()->bounds()); |
| 844 | 930 |
| 845 // De-activated shell-surface should NOT have fullscreen underlay | 931 // De-activated shell-surface should NOT have fullscreen underlay |
| 846 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 932 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 847 | 933 |
| 848 // Disable spoken feedback. Shadow underlay is restored. | 934 // Disable spoken feedback. Shadow underlay is restored. |
| 849 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 935 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
| 850 ash::A11Y_NOTIFICATION_NONE); | 936 ash::A11Y_NOTIFICATION_NONE); |
| 851 shell_surface.OnAccessibilityModeChanged(); | 937 shell_surface.OnAccessibilityModeChanged(); |
| 852 shell_surface2.OnAccessibilityModeChanged(); | 938 shell_surface2.OnAccessibilityModeChanged(); |
| 853 | 939 |
| 854 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 940 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 855 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 941 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 856 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); | 942 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); |
| 857 } | 943 } |
| 858 | 944 |
| 859 } // namespace | 945 } // namespace |
| 860 } // namespace exo | 946 } // namespace exo |
| OLD | NEW |