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

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

Issue 2361993003: Draw underlay behind android apps using talkback (Closed)
Patch Set: Draw underlay behind android apps using talkback Created 4 years, 3 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::unique_ptr<Buffer> buffer(
692 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
693 std::unique_ptr<Surface> surface(new Surface);
694 std::unique_ptr<ShellSurface> shell_surface(
695 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true,
696 ash::kShellWindowId_DefaultContainer));
697
698 surface->Attach(buffer.get());
699
700 gfx::Rect shadow_bounds(10, 10, 100, 100);
701 shell_surface->SetRectangularShadow(shadow_bounds);
702 surface->Commit();
703 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds());
704
705 aura::Window* shell_window = shell_surface->GetWidget()->GetNativeWindow();
706 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>(
707 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter());
708
709 gfx::Point pt(300, 300);
710 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(),
711 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
712 pt = gfx::Point(250, 250);
713 ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(),
714 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
715
716 EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
717
718 // Enable spoken feedback.
719 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
720 ash::A11Y_NOTIFICATION_NONE);
721 shell_surface->OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE);
722
723 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
724 shell_surface->shadow_underlay_for_test()->bounds());
725 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible());
726 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(),
727 shell_surface->shadow_underlay_for_test()->bounds());
728
729 // Test event capture
730 EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
731 EXPECT_EQ(shell_surface->shadow_underlay_for_test(),
732 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
733 shell_window, &ev_out));
734 EXPECT_NE(shell_surface->shadow_underlay_for_test(),
735 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
736 shell_window, &ev_in));
737
738 // Disable spoken feedback. Shadow underlay is restored.
739 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
740 ash::A11Y_NOTIFICATION_SHOW);
741 shell_surface->OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE);
742
743 EXPECT_TRUE(shell_surface->shadow_underlay_for_test()->IsVisible());
744 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay_for_test()->bounds());
745 }
746
686 } // namespace 747 } // namespace
687 } // namespace exo 748 } // 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