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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 216743004: Prevent system modal dialog from blocking events to the virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move VK window test to root window controller. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include "ash/session_state_delegate.h" 7 #include "ash/session_state_delegate.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1))); 599 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1)));
600 EXPECT_EQ(event_target, 600 EXPECT_EQ(event_target,
601 root->GetEventHandlerForPoint(gfx::Point(size.width() - 1, 0))); 601 root->GetEventHandlerForPoint(gfx::Point(size.width() - 1, 0)));
602 EXPECT_EQ(event_target, 602 EXPECT_EQ(event_target,
603 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1))); 603 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1)));
604 EXPECT_EQ(event_target, 604 EXPECT_EQ(event_target,
605 root->GetEventHandlerForPoint( 605 root->GetEventHandlerForPoint(
606 gfx::Point(size.width() - 1, size.height() - 1))); 606 gfx::Point(size.width() - 1, size.height() - 1)));
607 } 607 }
608 608
609 class VirtualKeyboardRootWindowControllerTest : public test::AshTestBase { 609 class VirtualKeyboardRootWindowControllerTest : public RootWindowControllerTest
610 {
610 public: 611 public:
611 VirtualKeyboardRootWindowControllerTest() {}; 612 VirtualKeyboardRootWindowControllerTest() {};
612 virtual ~VirtualKeyboardRootWindowControllerTest() {}; 613 virtual ~VirtualKeyboardRootWindowControllerTest() {};
613 614
614 virtual void SetUp() OVERRIDE { 615 virtual void SetUp() OVERRIDE {
615 CommandLine::ForCurrentProcess()->AppendSwitch( 616 CommandLine::ForCurrentProcess()->AppendSwitch(
616 keyboard::switches::kEnableVirtualKeyboard); 617 keyboard::switches::kEnableVirtualKeyboard);
617 test::AshTestBase::SetUp(); 618 test::AshTestBase::SetUp();
618 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( 619 Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
619 Shell::GetInstance()->keyboard_controller()); 620 Shell::GetInstance()->keyboard_controller());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 controller->proxy()->GetKeyboardWindow()->bounds()); 722 controller->proxy()->GetKeyboardWindow()->bounds());
722 723
723 gfx::Rect after = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); 724 gfx::Rect after = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area();
724 EXPECT_LT(after, before); 725 EXPECT_LT(after, before);
725 726
726 // Mock a login user profile change to reinitialize the keyboard. 727 // Mock a login user profile change to reinitialize the keyboard.
727 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); 728 ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
728 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(), before); 729 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(), before);
729 } 730 }
730 731
732 // Ensure that system modal dialogs do not block events targeted at the virtual
733 // keyboard.
734 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) {
735 aura::Window* root_window = Shell::GetPrimaryRootWindow();
736 aura::Window* keyboard_container = Shell::GetContainer(root_window,
737 internal::kShellWindowId_VirtualKeyboardContainer);
738 ASSERT_TRUE(keyboard_container);
739 keyboard_container->Show();
740
741 aura::Window* keyboard_window = Shell::GetInstance()->keyboard_controller()->
742 proxy()->GetKeyboardWindow();
743 keyboard_container->AddChild(keyboard_window);
744 keyboard_window->set_owned_by_parent(false);
745 keyboard_window->SetBounds(gfx::Rect());
746 keyboard_window->Show();
747
748 ui::test::TestEventHandler* handler = new ui::test::TestEventHandler;
749 root_window->SetEventFilter(handler);
750 aura::test::EventGenerator root_window_event_generator(root_window);
751 aura::test::EventGenerator keyboard_event_generator(root_window,
752 keyboard_window);
753
754 views::Widget* modal_widget =
755 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
756
757 // Verify that mouse events to the root window are block with a visble modal
758 // dialog.
759 root_window_event_generator.ClickLeftButton();
760 EXPECT_EQ(0, handler->num_mouse_events());
761
762 // Verify that event dispatch to the virtual keyboard is unblocked.
763 keyboard_event_generator.ClickLeftButton();
764 EXPECT_EQ(1, handler->num_mouse_events() / 2);
765
766 modal_widget->Close();
767
768 // Verify that mouse events are now unblocked to the root window.
769 root_window_event_generator.ClickLeftButton();
770 EXPECT_EQ(2, handler->num_mouse_events() / 2);
771 }
772
731 } // namespace test 773 } // namespace test
732 } // namespace ash 774 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell.cc » ('j') | ash/shell.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698