Chromium Code Reviews| 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/aura/wm_window_aura.h" | 5 #include "ash/aura/wm_window_aura.h" |
| 6 #include "ash/common/accessibility_delegate.h" | |
| 6 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
| 7 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm/wm_event.h" | 9 #include "ash/common/wm/wm_event.h" |
| 9 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| 10 #include "ash/wm/window_state_aura.h" | 11 #include "ash/wm/window_state_aura.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/exo/buffer.h" | 14 #include "components/exo/buffer.h" |
| 14 #include "components/exo/display.h" | 15 #include "components/exo/display.h" |
| 15 #include "components/exo/shell_surface.h" | 16 #include "components/exo/shell_surface.h" |
| 16 #include "components/exo/sub_surface.h" | 17 #include "components/exo/sub_surface.h" |
| 17 #include "components/exo/surface.h" | 18 #include "components/exo/surface.h" |
| 18 #include "components/exo/test/exo_test_base.h" | 19 #include "components/exo/test/exo_test_base.h" |
| 19 #include "components/exo/test/exo_test_helper.h" | 20 #include "components/exo/test/exo_test_helper.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 24 #include "ui/aura/window_targeter.h" | |
| 23 #include "ui/base/hit_test.h" | 25 #include "ui/base/hit_test.h" |
| 24 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
| 25 #include "ui/display/screen.h" | 27 #include "ui/display/screen.h" |
| 28 #include "ui/events/base_event_utils.h" | |
| 26 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 27 #include "ui/wm/core/shadow.h" | 30 #include "ui/wm/core/shadow.h" |
| 28 #include "ui/wm/core/shadow_controller.h" | 31 #include "ui/wm/core/shadow_controller.h" |
| 29 #include "ui/wm/core/shadow_types.h" | 32 #include "ui/wm/core/shadow_types.h" |
| 30 #include "ui/wm/core/window_util.h" | 33 #include "ui/wm/core/window_util.h" |
| 31 | 34 |
| 32 namespace exo { | 35 namespace exo { |
| 33 namespace { | 36 namespace { |
| 34 | 37 |
| 35 using ShellSurfaceTest = test::ExoTestBase; | 38 using ShellSurfaceTest = test::ExoTestBase; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 EXPECT_EQ(1.f, shell_surface->shadow_underlay_for_test()->layer()->opacity()); | 679 EXPECT_EQ(1.f, shell_surface->shadow_underlay_for_test()->layer()->opacity()); |
| 677 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(), | 680 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(), |
| 678 shell_surface->shadow_underlay_for_test()->bounds()); | 681 shell_surface->shadow_underlay_for_test()->bounds()); |
| 679 | 682 |
| 680 // Leave fullscreen mode. Shadow underlay is restored. | 683 // Leave fullscreen mode. Shadow underlay is restored. |
| 681 window->GetWindowState()->OnWMEvent(&event); | 684 window->GetWindowState()->OnWMEvent(&event); |
| 682 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible()); | 685 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible()); |
| 683 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds()); | 686 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds()); |
| 684 } | 687 } |
| 685 | 688 |
| 689 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { | |
| 690 gfx::Size buffer_size(256, 256); | |
| 691 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | |
| 692 Surface surface; | |
| 693 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true, | |
| 694 ash::kShellWindowId_DefaultContainer); | |
| 695 | |
| 696 surface.Attach(&buffer); | |
| 697 | |
| 698 gfx::Rect shadow_bounds(10, 10, 100, 100); | |
| 699 shell_surface.SetRectangularShadow(shadow_bounds); | |
| 700 surface.Commit(); | |
| 701 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay_for_test()->bounds()); | |
| 702 | |
| 703 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); | |
| 704 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( | |
| 705 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter()); | |
| 706 | |
| 707 gfx::Point pt(300, 300); | |
| 708 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(), | |
| 709 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | |
| 710 pt = gfx::Point(250, 250); | |
|
Mr4D (OOO till 08-26)
2016/09/27 06:40:59
You might want to create a new point "pt2" here.
erosky
2016/09/28 19:21:13
Done.
| |
| 711 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(), | |
| 712 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | |
| 713 | |
| 714 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); | |
| 715 | |
| 716 // Enable spoken feedback. | |
| 717 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 718 ash::A11Y_NOTIFICATION_NONE); | |
| 719 shell_surface.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); | |
| 720 | |
| 721 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | |
| 722 shell_surface.shadow_underlay_for_test()->bounds()); | |
| 723 EXPECT_TRUE(shell_surface.shadow_underlay_for_test()->IsVisible()); | |
| 724 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(), | |
| 725 shell_surface.shadow_underlay_for_test()->bounds()); | |
| 726 | |
| 727 // Test event capture | |
| 728 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out)); | |
| 729 EXPECT_EQ(shell_surface.shadow_underlay_for_test(), | |
| 730 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | |
| 731 shell_window, &ev_out)); | |
| 732 EXPECT_NE(shell_surface.shadow_underlay_for_test(), | |
| 733 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | |
| 734 shell_window, &ev_in)); | |
| 735 | |
| 736 // Create a new surface | |
| 737 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | |
| 738 Surface surface2; | |
| 739 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, | |
| 740 ash::kShellWindowId_DefaultContainer); | |
| 741 surface2.Attach(&buffer2); | |
| 742 shell_surface2.SetRectangularShadow(shadow_bounds); | |
| 743 surface2.Commit(); | |
| 744 | |
| 745 // spoken-feedback was already on, so underlay should fill screen | |
| 746 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | |
| 747 shell_surface2.shadow_underlay_for_test()->bounds()); | |
| 748 | |
| 749 // De-activated shell-surface should NOT have fullscreen underlay | |
| 750 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay_for_test()->bounds()); | |
| 751 | |
| 752 // Disable spoken feedback. Shadow underlay is restored. | |
| 753 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 754 ash::A11Y_NOTIFICATION_NONE); | |
| 755 shell_surface.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); | |
| 756 shell_surface2.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); | |
| 757 | |
| 758 EXPECT_TRUE(shell_surface.shadow_underlay_for_test()->IsVisible()); | |
| 759 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay_for_test()->bounds()); | |
| 760 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay_for_test()->bounds()); | |
| 761 } | |
| 762 | |
| 686 } // namespace | 763 } // namespace |
| 687 } // namespace exo | 764 } // namespace exo |
| OLD | NEW |