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

Side by Side Diff: components/exo/shell_surface_unittest.cc

Issue 2361993003: Draw underlay behind android apps using talkback (Closed)
Patch Set: Addressed some CL comments and added some comments Created 4 years, 2 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
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 "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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 EXPECT_EQ(1.f, shell_surface->shadow_underlay_for_test()->layer()->opacity()); 689 EXPECT_EQ(1.f, shell_surface->shadow_underlay_for_test()->layer()->opacity());
687 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(), 690 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(),
688 shell_surface->shadow_underlay_for_test()->bounds()); 691 shell_surface->shadow_underlay_for_test()->bounds());
689 692
690 // Leave fullscreen mode. Shadow underlay is restored. 693 // Leave fullscreen mode. Shadow underlay is restored.
691 window->GetWindowState()->OnWMEvent(&event); 694 window->GetWindowState()->OnWMEvent(&event);
692 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible()); 695 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible());
693 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds()); 696 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds());
694 } 697 }
695 698
699 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
700 gfx::Size buffer_size(256, 256);
701 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
702 Surface surface;
703 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true,
704 ash::kShellWindowId_DefaultContainer);
705
706 surface.Attach(&buffer);
707
708 gfx::Rect shadow_bounds(10, 10, 100, 100);
709 shell_surface.SetRectangularShadow(shadow_bounds);
710 surface.Commit();
711 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay_for_test()->bounds());
712
713 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow();
714 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>(
715 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter());
716
717 gfx::Point pt(300, 300);
718 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(),
719 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
720 gfx::Point pt2(250, 250);
721 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt2, pt2, ui::EventTimeForNow(),
722 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
723
724 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
725
726 // Enable spoken feedback.
727 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
728 ash::A11Y_NOTIFICATION_NONE);
729 shell_surface.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE);
730
731 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
732 shell_surface.shadow_underlay_for_test()->bounds());
733 EXPECT_TRUE(shell_surface.shadow_underlay_for_test()->IsVisible());
734 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(),
735 shell_surface.shadow_underlay_for_test()->bounds());
736
737 // Test event capture
738 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
739 EXPECT_EQ(shell_surface.shadow_underlay_for_test(),
740 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
741 shell_window, &ev_out));
742 EXPECT_NE(shell_surface.shadow_underlay_for_test(),
743 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
744 shell_window, &ev_in));
745
746 // Create a new surface
747 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
748 Surface surface2;
749 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true,
750 ash::kShellWindowId_DefaultContainer);
751 surface2.Attach(&buffer2);
752 shell_surface2.SetRectangularShadow(shadow_bounds);
753 surface2.Commit();
754
755 // spoken-feedback was already on, so underlay should fill screen
756 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
757 shell_surface2.shadow_underlay_for_test()->bounds());
758
759 // De-activated shell-surface should NOT have fullscreen underlay
760 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay_for_test()->bounds());
761
762 // Disable spoken feedback. Shadow underlay is restored.
763 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
764 ash::A11Y_NOTIFICATION_NONE);
765 shell_surface.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE);
766 shell_surface2.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE);
767
768 EXPECT_TRUE(shell_surface.shadow_underlay_for_test()->IsVisible());
769 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay_for_test()->bounds());
770 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay_for_test()->bounds());
771 }
772
696 } // namespace 773 } // namespace
697 } // namespace exo 774 } // namespace exo
OLDNEW
« components/exo/shell_surface.cc ('K') | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698