| 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" | 
| 11 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" | 
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" | 
| 13 #include "ash/wm/coordinate_conversion.h" | 13 #include "ash/wm/coordinate_conversion.h" | 
| 14 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" | 
| 15 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" | 
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" | 
|  | 17 #include "base/strings/utf_string_conversions.h" | 
| 17 #include "ui/aura/client/activation_client.h" | 18 #include "ui/aura/client/activation_client.h" | 
| 18 #include "ui/aura/client/capture_client.h" | 19 #include "ui/aura/client/capture_client.h" | 
| 19 #include "ui/aura/client/focus_client.h" | 20 #include "ui/aura/client/focus_client.h" | 
| 20 #include "ui/aura/test/event_generator.h" | 21 #include "ui/aura/test/event_generator.h" | 
| 21 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" | 
| 22 #include "ui/aura/test/window_test_api.h" | 23 #include "ui/aura/test/window_test_api.h" | 
| 23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" | 
| 24 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" | 
| 25 #include "ui/base/cursor/cursor.h" | 26 #include "ui/base/cursor/cursor.h" | 
| 26 #include "ui/events/event_handler.h" | 27 #include "ui/events/event_handler.h" | 
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 733       aura::client::GetFocusClient(root_windows[0]); | 734       aura::client::GetFocusClient(root_windows[0]); | 
| 734   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 735   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 
| 735 | 736 | 
| 736   // The lock window should get events on both root windows. | 737   // The lock window should get events on both root windows. | 
| 737   aura::test::EventGenerator& event_generator(GetEventGenerator()); | 738   aura::test::EventGenerator& event_generator(GetEventGenerator()); | 
| 738 | 739 | 
| 739   event_generator.set_current_host(root_windows[0]->GetHost()); | 740   event_generator.set_current_host(root_windows[0]->GetHost()); | 
| 740   event_generator.PressKey(ui::VKEY_A, 0); | 741   event_generator.PressKey(ui::VKEY_A, 0); | 
| 741   event_generator.ReleaseKey(ui::VKEY_A, 0); | 742   event_generator.ReleaseKey(ui::VKEY_A, 0); | 
| 742   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 743   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 
| 743   EXPECT_EQ("a", UTF16ToASCII(textfield->text())); | 744   EXPECT_EQ("a", base::UTF16ToASCII(textfield->text())); | 
| 744 | 745 | 
| 745   event_generator.set_current_host(root_windows[1]->GetHost()); | 746   event_generator.set_current_host(root_windows[1]->GetHost()); | 
| 746   event_generator.PressKey(ui::VKEY_B, 0); | 747   event_generator.PressKey(ui::VKEY_B, 0); | 
| 747   event_generator.ReleaseKey(ui::VKEY_B, 0); | 748   event_generator.ReleaseKey(ui::VKEY_B, 0); | 
| 748   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 749   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 
| 749   EXPECT_EQ("ab", UTF16ToASCII(textfield->text())); | 750   EXPECT_EQ("ab", base::UTF16ToASCII(textfield->text())); | 
| 750 | 751 | 
| 751   // Deleting 2nd display. The lock window still should get the events. | 752   // Deleting 2nd display. The lock window still should get the events. | 
| 752   UpdateDisplay("100x100"); | 753   UpdateDisplay("100x100"); | 
| 753   event_generator.PressKey(ui::VKEY_C, 0); | 754   event_generator.PressKey(ui::VKEY_C, 0); | 
| 754   event_generator.ReleaseKey(ui::VKEY_C, 0); | 755   event_generator.ReleaseKey(ui::VKEY_C, 0); | 
| 755   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 756   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 
| 756   EXPECT_EQ("abc", UTF16ToASCII(textfield->text())); | 757   EXPECT_EQ("abc", base::UTF16ToASCII(textfield->text())); | 
| 757 | 758 | 
| 758   // Creating 2nd display again, and lock window still should get events | 759   // Creating 2nd display again, and lock window still should get events | 
| 759   // on both root windows. | 760   // on both root windows. | 
| 760   UpdateDisplay("100x100,200x200"); | 761   UpdateDisplay("100x100,200x200"); | 
| 761   root_windows = Shell::GetAllRootWindows(); | 762   root_windows = Shell::GetAllRootWindows(); | 
| 762   event_generator.set_current_host(root_windows[0]->GetHost()); | 763   event_generator.set_current_host(root_windows[0]->GetHost()); | 
| 763   event_generator.PressKey(ui::VKEY_D, 0); | 764   event_generator.PressKey(ui::VKEY_D, 0); | 
| 764   event_generator.ReleaseKey(ui::VKEY_D, 0); | 765   event_generator.ReleaseKey(ui::VKEY_D, 0); | 
| 765   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 766   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 
| 766   EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); | 767   EXPECT_EQ("abcd", base::UTF16ToASCII(textfield->text())); | 
| 767 | 768 | 
| 768   event_generator.set_current_host(root_windows[1]->GetHost()); | 769   event_generator.set_current_host(root_windows[1]->GetHost()); | 
| 769   event_generator.PressKey(ui::VKEY_E, 0); | 770   event_generator.PressKey(ui::VKEY_E, 0); | 
| 770   event_generator.ReleaseKey(ui::VKEY_E, 0); | 771   event_generator.ReleaseKey(ui::VKEY_E, 0); | 
| 771   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 772   EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 
| 772   EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); | 773   EXPECT_EQ("abcde", base::UTF16ToASCII(textfield->text())); | 
| 773 } | 774 } | 
| 774 | 775 | 
| 775 TEST_F(ExtendedDesktopTest, PassiveGrab) { | 776 TEST_F(ExtendedDesktopTest, PassiveGrab) { | 
| 776   if (!SupportsMultipleDisplays()) | 777   if (!SupportsMultipleDisplays()) | 
| 777     return; | 778     return; | 
| 778 | 779 | 
| 779   EventLocationRecordingEventHandler event_handler; | 780   EventLocationRecordingEventHandler event_handler; | 
| 780   ash::Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 781   ash::Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 
| 781 | 782 | 
| 782   UpdateDisplay("300x300,200x200"); | 783   UpdateDisplay("300x300,200x200"); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 797   generator.ReleaseLeftButton(); | 798   generator.ReleaseLeftButton(); | 
| 798   EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 799   EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 
| 799 | 800 | 
| 800   generator.MoveMouseTo(400, 150); | 801   generator.MoveMouseTo(400, 150); | 
| 801   EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 802   EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 
| 802 | 803 | 
| 803   ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 804   ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 
| 804 } | 805 } | 
| 805 | 806 | 
| 806 }  // namespace ash | 807 }  // namespace ash | 
| OLD | NEW | 
|---|