| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |
| 543 // For surface shadow, the underlay is placed at the bottom of shell surfaces. |
| 544 EXPECT_EQ(surface->window(), shell_surface->shadow_underlay()->parent()); |
| 545 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent()); |
| 546 |
| 547 EXPECT_EQ(*surface->window()->children().begin(), |
| 548 shell_surface->shadow_underlay()); |
| 549 |
| 544 gfx::Rect before = shadow->layer()->bounds(); | 550 gfx::Rect before = shadow->layer()->bounds(); |
| 545 | 551 |
| 546 // 4) Shadow bounds is independent of the sub surface. | 552 // 4) Shadow bounds is independent of the sub surface. |
| 547 gfx::Size new_buffer_size(256, 256); | 553 gfx::Size new_buffer_size(256, 256); |
| 548 std::unique_ptr<Buffer> new_child_buffer( | 554 std::unique_ptr<Buffer> new_child_buffer( |
| 549 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size))); | 555 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size))); |
| 550 child->Attach(new_child_buffer.get()); | 556 child->Attach(new_child_buffer.get()); |
| 551 child->Commit(); | 557 child->Commit(); |
| 552 surface->Commit(); | 558 surface->Commit(); |
| 553 | 559 |
| 554 EXPECT_EQ(before, shadow->layer()->bounds()); | 560 EXPECT_EQ(before, shadow->layer()->bounds()); |
| 555 | 561 |
| 556 // 4) Updating the widget's window bounds should not change the shadow bounds. | 562 // 4) Updating the widget's window bounds should not change the shadow bounds. |
| 557 window->SetBounds(gfx::Rect(10, 10, 100, 100)); | 563 window->SetBounds(gfx::Rect(10, 10, 100, 100)); |
| 558 EXPECT_EQ(before, shadow->layer()->bounds()); | 564 EXPECT_EQ(before, shadow->layer()->bounds()); |
| 559 | 565 |
| 560 // 5) This should disable shadow. | 566 // 5) This should disable shadow. |
| 561 shell_surface->SetRectangularShadow(false); | 567 shell_surface->SetEnableRectangularShadow(false); |
| 562 surface->Commit(); | 568 surface->Commit(); |
| 563 | 569 |
| 564 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); | 570 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); |
| 565 EXPECT_FALSE(shadow->layer()->visible()); | 571 EXPECT_FALSE(shadow->layer()->visible()); |
| 566 | 572 |
| 567 // 6) This should enable shadow. | 573 // 6) This should enable non surface shadow. |
| 568 shell_surface->SetRectangularShadow(true); | 574 shell_surface->SetEnableRectangularShadow(true); |
| 569 surface->Commit(); | 575 surface->Commit(); |
| 570 | 576 |
| 571 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); | 577 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); |
| 572 EXPECT_TRUE(shadow->layer()->visible()); | 578 EXPECT_TRUE(shadow->layer()->visible()); |
| 573 | 579 |
| 580 // For no surface shadow, both of underlay and overlay should be stacked |
| 581 // below the surface window. |
| 582 EXPECT_EQ(window, shell_surface->shadow_underlay()->parent()); |
| 583 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent()); |
| 584 |
| 574 // Shadow overlay should be stacked just above the shadow underlay. | 585 // Shadow overlay should be stacked just above the shadow underlay. |
| 575 auto underlay_it = | 586 auto underlay_it = |
| 576 std::find(window->children().begin(), window->children().end(), | 587 std::find(window->children().begin(), window->children().end(), |
| 577 shell_surface->shadow_underlay()); | 588 shell_surface->shadow_underlay()); |
| 578 ASSERT_NE(underlay_it, window->children().end()); | 589 ASSERT_NE(underlay_it, window->children().end()); |
| 579 ASSERT_NE(std::next(underlay_it), window->children().end()); | 590 ASSERT_NE(std::next(underlay_it), window->children().end()); |
| 580 EXPECT_EQ(*std::next(underlay_it), shell_surface->shadow_overlay()); | 591 EXPECT_EQ(*std::next(underlay_it), shell_surface->shadow_overlay()); |
| 581 } | 592 } |
| 582 | 593 |
| 583 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { | 594 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 601 const gfx::Rect shadow_bounds(content_size); | 612 const gfx::Rect shadow_bounds(content_size); |
| 602 | 613 |
| 603 // Expected shadow position/bounds in parent coordinates. | 614 // Expected shadow position/bounds in parent coordinates. |
| 604 const gfx::Point expected_shadow_origin(-10, -10); | 615 const gfx::Point expected_shadow_origin(-10, -10); |
| 605 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size); | 616 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size); |
| 606 | 617 |
| 607 views::Widget* widget = shell_surface->GetWidget(); | 618 views::Widget* widget = shell_surface->GetWidget(); |
| 608 aura::Window* window = widget->GetNativeWindow(); | 619 aura::Window* window = widget->GetNativeWindow(); |
| 609 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 620 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 610 | 621 |
| 611 shell_surface->SetRectangularShadow(true); | 622 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 612 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | |
| 613 surface->Commit(); | 623 surface->Commit(); |
| 614 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); | 624 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); |
| 615 | 625 |
| 616 // Shadow overlay bounds. | 626 // Shadow overlay bounds. |
| 617 EXPECT_TRUE(shadow->layer()->visible()); | 627 EXPECT_TRUE(shadow->layer()->visible()); |
| 618 // Origin must be in sync. | 628 // Origin must be in sync. |
| 619 EXPECT_EQ(expected_shadow_origin, | 629 EXPECT_EQ(expected_shadow_origin, |
| 620 shadow->layer()->parent()->bounds().origin()); | 630 shadow->layer()->parent()->bounds().origin()); |
| 621 | 631 |
| 622 const gfx::Rect work_area = | 632 const gfx::Rect work_area = |
| 623 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 633 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 624 // Maximizing window hides the shadow. | 634 // Maximizing window hides the shadow. |
| 625 widget->Maximize(); | 635 widget->Maximize(); |
| 626 ASSERT_TRUE(widget->IsMaximized()); | 636 ASSERT_TRUE(widget->IsMaximized()); |
| 627 EXPECT_FALSE(shadow->layer()->visible()); | 637 EXPECT_FALSE(shadow->layer()->visible()); |
| 628 | 638 |
| 629 shell_surface->SetRectangularShadowContentBounds(work_area); | 639 shell_surface->SetRectangularSurfaceShadow(work_area); |
| 630 surface->Commit(); | 640 surface->Commit(); |
| 631 EXPECT_FALSE(shadow->layer()->visible()); | 641 EXPECT_FALSE(shadow->layer()->visible()); |
| 632 | 642 |
| 633 // Restoring bounds will re-enable shadow. It's content size is set to work | 643 // Restoring bounds will re-enable shadow. It's content size is set to work |
| 634 // area,/ thus not visible until new bounds is committed. | 644 // area,/ thus not visible until new bounds is committed. |
| 635 widget->Restore(); | 645 widget->Restore(); |
| 636 EXPECT_TRUE(shadow->layer()->visible()); | 646 EXPECT_TRUE(shadow->layer()->visible()); |
| 637 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); | 647 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); |
| 638 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); | 648 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); |
| 639 | 649 |
| 640 // The bounds is updated. | 650 // The bounds is updated. |
| 641 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | 651 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 642 surface->Commit(); | 652 surface->Commit(); |
| 643 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); | 653 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); |
| 644 } | 654 } |
| 645 | 655 |
| 646 TEST_F(ShellSurfaceTest, ShadowWithTransform) { | 656 TEST_F(ShellSurfaceTest, ShadowWithTransform) { |
| 647 gfx::Size buffer_size(64, 64); | 657 gfx::Size buffer_size(64, 64); |
| 648 std::unique_ptr<Buffer> buffer( | 658 std::unique_ptr<Buffer> buffer( |
| 649 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 659 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 650 std::unique_ptr<Surface> surface(new Surface); | 660 std::unique_ptr<Surface> surface(new Surface); |
| 651 // Set the bounds to disable auto managed mode. | 661 // Set the bounds to disable auto managed mode. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 663 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); | 673 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 664 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 674 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 665 | 675 |
| 666 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). | 676 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). |
| 667 const gfx::Rect shadow_bounds(content_size); | 677 const gfx::Rect shadow_bounds(content_size); |
| 668 | 678 |
| 669 // Shadow bounds relative to its parent should not be affected by a transform. | 679 // Shadow bounds relative to its parent should not be affected by a transform. |
| 670 gfx::Transform transform; | 680 gfx::Transform transform; |
| 671 transform.Translate(50, 50); | 681 transform.Translate(50, 50); |
| 672 window->SetTransform(transform); | 682 window->SetTransform(transform); |
| 673 shell_surface->SetRectangularShadow(true); | 683 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 674 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | |
| 675 surface->Commit(); | 684 surface->Commit(); |
| 676 EXPECT_TRUE(shadow->layer()->visible()); | 685 EXPECT_TRUE(shadow->layer()->visible()); |
| 677 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); | 686 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); |
| 678 } | 687 } |
| 679 | 688 |
| 680 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { | 689 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { |
| 681 std::unique_ptr<Surface> surface(new Surface); | 690 std::unique_ptr<Surface> surface(new Surface); |
| 682 std::unique_ptr<ShellSurface> shell_surface( | 691 std::unique_ptr<ShellSurface> shell_surface( |
| 683 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false, | 692 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false, |
| 684 ash::kShellWindowId_DefaultContainer)); | 693 ash::kShellWindowId_DefaultContainer)); |
| 685 shell_surface->Maximize(); | 694 shell_surface->Maximize(); |
| 686 views::Widget* widget = shell_surface->GetWidget(); | 695 views::Widget* widget = shell_surface->GetWidget(); |
| 687 aura::Window* window = widget->GetNativeWindow(); | 696 aura::Window* window = widget->GetNativeWindow(); |
| 688 | 697 |
| 689 // There is no shadow when started in maximized state. | 698 // There is no shadow when started in maximized state. |
| 690 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 699 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 691 | 700 |
| 692 // Sending a shadow bounds in maximized state won't create a shaodw. | 701 // Sending a shadow bounds in maximized state won't create a shaodw. |
| 693 shell_surface->SetRectangularShadow(true); | 702 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); |
| 694 shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100)); | |
| 695 surface->Commit(); | 703 surface->Commit(); |
| 696 | 704 |
| 697 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 705 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 698 // Underlay should be created even without shadow. | 706 // Underlay should be created even without shadow. |
| 699 ASSERT_TRUE(shell_surface->shadow_underlay()); | 707 ASSERT_TRUE(shell_surface->shadow_underlay()); |
| 700 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 708 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 701 | 709 |
| 702 // Restore the window and make sure the shadow is created, visible and | 710 // Restore the window and make sure the shadow is created, visible and |
| 703 // has the latest bounds. | 711 // has the latest bounds. |
| 704 widget->Restore(); | 712 widget->Restore(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 745 |
| 738 // Leave fullscreen mode. | 746 // Leave fullscreen mode. |
| 739 window->GetWindowState()->OnWMEvent(&event); | 747 window->GetWindowState()->OnWMEvent(&event); |
| 740 | 748 |
| 741 // Check that shell surface is maximized. | 749 // Check that shell surface is maximized. |
| 742 EXPECT_EQ(CurrentContext()->bounds().width(), | 750 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 743 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); | 751 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| 744 } | 752 } |
| 745 | 753 |
| 746 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { | 754 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { |
| 747 gfx::Size buffer_size(256, 256); | 755 const gfx::Size display_size = |
| 756 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 757 const gfx::Size buffer_size(display_size); |
| 748 std::unique_ptr<Buffer> buffer( | 758 std::unique_ptr<Buffer> buffer( |
| 749 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 759 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 750 std::unique_ptr<Surface> surface(new Surface); | 760 std::unique_ptr<Surface> surface(new Surface); |
| 751 std::unique_ptr<ShellSurface> shell_surface( | 761 std::unique_ptr<ShellSurface> shell_surface( |
| 752 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false, | 762 new ShellSurface(surface.get(), nullptr, gfx::Rect(100, 100), true, false, |
| 753 ash::kShellWindowId_DefaultContainer)); | 763 ash::kShellWindowId_DefaultContainer)); |
| 754 | 764 |
| 755 surface->Attach(buffer.get()); | 765 surface->Attach(buffer.get()); |
| 756 | 766 |
| 757 gfx::Rect shadow_bounds(10, 10, 100, 100); | 767 gfx::Rect shadow_bounds(10, 10, 100, 100); |
| 758 shell_surface->SetRectangularShadow(true); | 768 shell_surface->SetGeometry(shadow_bounds); |
| 759 shell_surface->SetRectangularShadowContentBounds(shadow_bounds); | 769 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); |
| 760 surface->Commit(); | 770 surface->Commit(); |
| 771 EXPECT_EQ(shadow_bounds, |
| 772 shell_surface->GetWidget()->GetWindowBoundsInScreen()); |
| 761 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); | 773 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 774 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(), |
| 775 shell_surface->surface()->window()->bounds().size()); |
| 762 | 776 |
| 763 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); | 777 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 764 ash::WmWindow* window = | 778 ash::WmWindow* window = |
| 765 ash::WmWindow::Get(shell_surface->GetWidget()->GetNativeWindow()); | 779 ash::WmWindow::Get(shell_surface->GetWidget()->GetNativeWindow()); |
| 766 | 780 |
| 767 // Enter immersive fullscreen mode. Shadow underlay is fullscreen. | 781 // Enter immersive fullscreen mode. Shadow underlay is fullscreen. |
| 768 window->GetWindowState()->OnWMEvent(&event); | 782 window->GetWindowState()->OnWMEvent(&event); |
| 769 | 783 |
| 770 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | |
| 771 shell_surface->shadow_underlay()->bounds()); | |
| 772 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 784 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 773 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity()); | 785 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity()); |
| 774 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(), | 786 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(), |
| 775 shell_surface->shadow_underlay()->bounds()); | 787 shell_surface->shadow_underlay()->bounds().size()); |
| 776 | 788 |
| 777 // Leave fullscreen mode. Shadow underlay is restored. | 789 // Leave fullscreen mode. Shadow underlay is restored. |
| 778 window->GetWindowState()->OnWMEvent(&event); | 790 window->GetWindowState()->OnWMEvent(&event); |
| 779 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 791 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 780 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); | 792 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 781 } | 793 } |
| 782 | 794 |
| 783 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { | 795 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { |
| 784 gfx::Size buffer_size(256, 256); | 796 const gfx::Size display_size = |
| 797 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 798 const gfx::Size buffer_size(display_size); |
| 785 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | 799 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); |
| 786 Surface surface; | 800 Surface surface; |
| 787 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true, | 801 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(100, 100), true, |
| 788 false, ash::kShellWindowId_DefaultContainer); | 802 false, ash::kShellWindowId_DefaultContainer); |
| 789 | |
| 790 surface.Attach(&buffer); | 803 surface.Attach(&buffer); |
| 791 | 804 |
| 792 gfx::Rect shadow_bounds(10, 10, 100, 100); | 805 gfx::Rect shadow_bounds(10, 10, 100, 100); |
| 793 shell_surface.SetRectangularShadow(true); | 806 shell_surface.SetGeometry(shadow_bounds); |
| 794 shell_surface.SetRectangularShadowContentBounds(shadow_bounds); | 807 shell_surface.SetRectangularSurfaceShadow(shadow_bounds); |
| 795 surface.Commit(); | 808 surface.Commit(); |
| 809 EXPECT_EQ(shadow_bounds, |
| 810 shell_surface.GetWidget()->GetWindowBoundsInScreen()); |
| 796 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 811 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 797 | 812 |
| 798 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); | 813 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); |
| 799 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( | 814 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( |
| 800 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter()); | 815 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter()); |
| 801 | 816 |
| 802 gfx::Point pt(300, 300); | 817 gfx::Point pt_out(300, 300); |
| 803 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(), | 818 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt_out, pt_out, |
| 804 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 819 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 805 gfx::Point pt2(250, 250); | 820 ui::EF_LEFT_MOUSE_BUTTON); |
| 806 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt2, pt2, ui::EventTimeForNow(), | 821 gfx::Point pt_in(70, 70); |
| 807 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 822 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt_in, pt_in, |
| 823 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 824 ui::EF_LEFT_MOUSE_BUTTON); |
| 808 | 825 |
| 809 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); | 826 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); |
| 810 | 827 |
| 811 // Enable spoken feedback. | 828 // Enable spoken feedback. |
| 812 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 829 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
| 813 ash::A11Y_NOTIFICATION_NONE); | 830 ash::A11Y_NOTIFICATION_NONE); |
| 814 shell_surface.OnAccessibilityModeChanged(); | 831 shell_surface.OnAccessibilityModeChanged(); |
| 815 | 832 |
| 816 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | 833 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), |
| 817 shell_surface.shadow_underlay()->bounds()); | 834 shell_surface.shadow_underlay()->bounds()); |
| 818 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 835 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 819 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(), | 836 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(), |
| 820 shell_surface.shadow_underlay()->bounds()); | 837 shell_surface.shadow_underlay()->bounds()); |
| 821 | 838 |
| 822 // Test event capture | 839 // Test event capture |
| 823 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); | 840 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); |
| 824 EXPECT_EQ(shell_surface.shadow_underlay(), | 841 EXPECT_EQ(shell_surface.shadow_underlay(), |
| 825 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | 842 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( |
| 826 shell_window, &ev_out)); | 843 shell_window, &ev_out)); |
| 827 EXPECT_NE(shell_surface.shadow_underlay(), | 844 EXPECT_NE(shell_surface.shadow_underlay(), |
| 828 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | 845 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( |
| 829 shell_window, &ev_in)); | 846 shell_window, &ev_in)); |
| 830 | 847 |
| 831 // Create a new surface | 848 // Create a new surface |
| 832 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | 849 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); |
| 833 Surface surface2; | 850 Surface surface2; |
| 834 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, | 851 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, |
| 835 false, ash::kShellWindowId_DefaultContainer); | 852 false, ash::kShellWindowId_DefaultContainer); |
| 836 surface2.Attach(&buffer2); | 853 surface2.Attach(&buffer2); |
| 837 shell_surface2.SetRectangularShadow(true); | 854 shell_surface2.SetRectangularSurfaceShadow(shadow_bounds); |
| 838 shell_surface2.SetRectangularShadowContentBounds(shadow_bounds); | |
| 839 surface2.Commit(); | 855 surface2.Commit(); |
| 840 | 856 |
| 841 // spoken-feedback was already on, so underlay should fill screen | 857 // spoken-feedback was already on, so underlay should fill screen |
| 842 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | 858 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), |
| 843 shell_surface2.shadow_underlay()->bounds()); | 859 shell_surface2.shadow_underlay()->bounds()); |
| 844 | 860 |
| 845 // De-activated shell-surface should NOT have fullscreen underlay | 861 // De-activated shell-surface should NOT have fullscreen underlay |
| 846 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 862 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 847 | 863 |
| 848 // Disable spoken feedback. Shadow underlay is restored. | 864 // Disable spoken feedback. Shadow underlay is restored. |
| 849 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 865 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
| 850 ash::A11Y_NOTIFICATION_NONE); | 866 ash::A11Y_NOTIFICATION_NONE); |
| 851 shell_surface.OnAccessibilityModeChanged(); | 867 shell_surface.OnAccessibilityModeChanged(); |
| 852 shell_surface2.OnAccessibilityModeChanged(); | 868 shell_surface2.OnAccessibilityModeChanged(); |
| 853 | 869 |
| 854 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 870 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 855 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 871 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 856 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); | 872 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); |
| 857 } | 873 } |
| 858 | 874 |
| 859 } // namespace | 875 } // namespace |
| 860 } // namespace exo | 876 } // namespace exo |
| OLD | NEW |