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

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

Issue 2361993003: Draw underlay behind android apps using talkback (Closed)
Patch Set: CL 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 606
604 // There is no shadow when started in maximized state. 607 // There is no shadow when started in maximized state.
605 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); 608 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window));
606 609
607 // Sending a shadow bounds in maximized state won't create a shaodw. 610 // Sending a shadow bounds in maximized state won't create a shaodw.
608 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); 611 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100));
609 surface->Commit(); 612 surface->Commit();
610 613
611 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); 614 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window));
612 // Underlay should be created even without shadow. 615 // Underlay should be created even without shadow.
613 ASSERT_TRUE(shell_surface->shadow_underlay_for_test()); 616 ASSERT_TRUE(shell_surface->shadow_underlay());
614 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible()); 617 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
615 618
616 // Restore the window and make sure the shadow is created, visible and 619 // Restore the window and make sure the shadow is created, visible and
617 // has the latest bounds. 620 // has the latest bounds.
618 widget->Restore(); 621 widget->Restore();
619 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 622 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
620 ASSERT_TRUE(shadow); 623 ASSERT_TRUE(shadow);
621 EXPECT_TRUE(shadow->layer()->visible()); 624 EXPECT_TRUE(shadow->layer()->visible());
622 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); 625 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds());
623 } 626 }
624 627
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 std::unique_ptr<Surface> surface(new Surface); 667 std::unique_ptr<Surface> surface(new Surface);
665 std::unique_ptr<ShellSurface> shell_surface( 668 std::unique_ptr<ShellSurface> shell_surface(
666 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, 669 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true,
667 ash::kShellWindowId_DefaultContainer)); 670 ash::kShellWindowId_DefaultContainer));
668 671
669 surface->Attach(buffer.get()); 672 surface->Attach(buffer.get());
670 673
671 gfx::Rect shadow_bounds(10, 10, 100, 100); 674 gfx::Rect shadow_bounds(10, 10, 100, 100);
672 shell_surface->SetRectangularShadow(shadow_bounds); 675 shell_surface->SetRectangularShadow(shadow_bounds);
673 surface->Commit(); 676 surface->Commit();
674 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds()); 677 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
675 678
676 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); 679 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN);
677 ash::WmWindow* window = 680 ash::WmWindow* window =
678 ash::WmWindowAura::Get(shell_surface->GetWidget()->GetNativeWindow()); 681 ash::WmWindowAura::Get(shell_surface->GetWidget()->GetNativeWindow());
679 682
680 // Enter immersive fullscreen mode. Shadow underlay is fullscreen. 683 // Enter immersive fullscreen mode. Shadow underlay is fullscreen.
681 window->GetWindowState()->OnWMEvent(&event); 684 window->GetWindowState()->OnWMEvent(&event);
682 685
683 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), 686 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
684 shell_surface->shadow_underlay_for_test()->bounds()); 687 shell_surface->shadow_underlay()->bounds());
685 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible()); 688 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
686 EXPECT_EQ(1.f, shell_surface->shadow_underlay_for_test()->layer()->opacity()); 689 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->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()->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()->IsVisible());
693 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds()); 696 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
697 }
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()->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()->bounds());
733 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
734 EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(),
735 shell_surface.shadow_underlay()->bounds());
736
737 // Test event capture
738 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
739 EXPECT_EQ(shell_surface.shadow_underlay(),
740 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
741 shell_window, &ev_out));
742 EXPECT_NE(shell_surface.shadow_underlay(),
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()->bounds());
758
759 // De-activated shell-surface should NOT have fullscreen underlay
760 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->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()->IsVisible());
769 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
770 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
694 } 771 }
695 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