OLD | NEW |
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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 #include "ash/display/display_manager.h" | 6 #include "ash/display/display_manager.h" |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 lock_widget->Show(); | 781 lock_widget->Show(); |
782 textfield->RequestFocus(); | 782 textfield->RequestFocus(); |
783 | 783 |
784 aura::client::FocusClient* focus_client = | 784 aura::client::FocusClient* focus_client = |
785 aura::client::GetFocusClient(root_windows[0]); | 785 aura::client::GetFocusClient(root_windows[0]); |
786 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 786 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
787 | 787 |
788 // The lock window should get events on both root windows. | 788 // The lock window should get events on both root windows. |
789 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 789 aura::test::EventGenerator& event_generator(GetEventGenerator()); |
790 | 790 |
791 event_generator.set_current_dispatcher( | 791 event_generator.set_current_host(root_windows[0]->GetHost()); |
792 root_windows[0]->GetHost()->dispatcher()); | |
793 event_generator.PressKey(ui::VKEY_A, 0); | 792 event_generator.PressKey(ui::VKEY_A, 0); |
794 event_generator.ReleaseKey(ui::VKEY_A, 0); | 793 event_generator.ReleaseKey(ui::VKEY_A, 0); |
795 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 794 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
796 EXPECT_EQ("a", UTF16ToASCII(textfield->text())); | 795 EXPECT_EQ("a", UTF16ToASCII(textfield->text())); |
797 | 796 |
798 event_generator.set_current_dispatcher( | 797 event_generator.set_current_host(root_windows[1]->GetHost()); |
799 root_windows[1]->GetHost()->dispatcher()); | |
800 event_generator.PressKey(ui::VKEY_B, 0); | 798 event_generator.PressKey(ui::VKEY_B, 0); |
801 event_generator.ReleaseKey(ui::VKEY_B, 0); | 799 event_generator.ReleaseKey(ui::VKEY_B, 0); |
802 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 800 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
803 EXPECT_EQ("ab", UTF16ToASCII(textfield->text())); | 801 EXPECT_EQ("ab", UTF16ToASCII(textfield->text())); |
804 | 802 |
805 // Deleting 2nd display. The lock window still should get the events. | 803 // Deleting 2nd display. The lock window still should get the events. |
806 UpdateDisplay("100x100"); | 804 UpdateDisplay("100x100"); |
807 event_generator.PressKey(ui::VKEY_C, 0); | 805 event_generator.PressKey(ui::VKEY_C, 0); |
808 event_generator.ReleaseKey(ui::VKEY_C, 0); | 806 event_generator.ReleaseKey(ui::VKEY_C, 0); |
809 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 807 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
810 EXPECT_EQ("abc", UTF16ToASCII(textfield->text())); | 808 EXPECT_EQ("abc", UTF16ToASCII(textfield->text())); |
811 | 809 |
812 // Creating 2nd display again, and lock window still should get events | 810 // Creating 2nd display again, and lock window still should get events |
813 // on both root windows. | 811 // on both root windows. |
814 UpdateDisplay("100x100,200x200"); | 812 UpdateDisplay("100x100,200x200"); |
815 root_windows = Shell::GetAllRootWindows(); | 813 root_windows = Shell::GetAllRootWindows(); |
816 event_generator.set_current_dispatcher( | 814 event_generator.set_current_host(root_windows[0]->GetHost()); |
817 root_windows[0]->GetHost()->dispatcher()); | |
818 event_generator.PressKey(ui::VKEY_D, 0); | 815 event_generator.PressKey(ui::VKEY_D, 0); |
819 event_generator.ReleaseKey(ui::VKEY_D, 0); | 816 event_generator.ReleaseKey(ui::VKEY_D, 0); |
820 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 817 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
821 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); | 818 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); |
822 | 819 |
823 event_generator.set_current_dispatcher( | 820 event_generator.set_current_host(root_windows[1]->GetHost()); |
824 root_windows[1]->GetHost()->dispatcher()); | |
825 event_generator.PressKey(ui::VKEY_E, 0); | 821 event_generator.PressKey(ui::VKEY_E, 0); |
826 event_generator.ReleaseKey(ui::VKEY_E, 0); | 822 event_generator.ReleaseKey(ui::VKEY_E, 0); |
827 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 823 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
828 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); | 824 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); |
829 } | 825 } |
830 | 826 |
831 TEST_F(ExtendedDesktopTest, PassiveGrab) { | 827 TEST_F(ExtendedDesktopTest, PassiveGrab) { |
832 if (!SupportsMultipleDisplays()) | 828 if (!SupportsMultipleDisplays()) |
833 return; | 829 return; |
834 | 830 |
(...skipping 18 matching lines...) Expand all Loading... |
853 generator.ReleaseLeftButton(); | 849 generator.ReleaseLeftButton(); |
854 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 850 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
855 | 851 |
856 generator.MoveMouseTo(400, 150); | 852 generator.MoveMouseTo(400, 150); |
857 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 853 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
858 | 854 |
859 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 855 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
860 } | 856 } |
861 | 857 |
862 } // namespace ash | 858 } // namespace ash |
OLD | NEW |