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/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" |
11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/wm/system_modal_container_layout_manager.h" | 13 #include "ash/wm/system_modal_container_layout_manager.h" |
14 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
15 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "ui/aura/client/focus_change_observer.h" | 18 #include "ui/aura/client/focus_change_observer.h" |
19 #include "ui/aura/client/focus_client.h" | 19 #include "ui/aura/client/focus_client.h" |
20 #include "ui/aura/client/window_tree_client.h" | 20 #include "ui/aura/client/window_tree_client.h" |
21 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
22 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
23 #include "ui/aura/test/event_generator.h" | 23 #include "ui/aura/test/event_generator.h" |
24 #include "ui/aura/test/test_window_delegate.h" | 24 #include "ui/aura/test/test_window_delegate.h" |
25 #include "ui/aura/test/test_windows.h" | 25 #include "ui/aura/test/test_windows.h" |
26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
27 #include "ui/aura/window_tracker.h" | 27 #include "ui/aura/window_tracker.h" |
28 #include "ui/keyboard/keyboard_controller_proxy.h" | |
28 #include "ui/keyboard/keyboard_switches.h" | 29 #include "ui/keyboard/keyboard_switches.h" |
29 #include "ui/views/controls/menu/menu_controller.h" | 30 #include "ui/views/controls/menu/menu_controller.h" |
30 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
31 #include "ui/views/widget/widget_delegate.h" | 32 #include "ui/views/widget/widget_delegate.h" |
32 | 33 |
33 using aura::Window; | 34 using aura::Window; |
34 using views::Widget; | 35 using views::Widget; |
35 | 36 |
36 namespace ash { | 37 namespace ash { |
37 namespace { | 38 namespace { |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 aura::Window* keyboard_container = Shell::GetContainer(root_window, | 661 aura::Window* keyboard_container = Shell::GetContainer(root_window, |
661 internal::kShellWindowId_VirtualKeyboardContainer); | 662 internal::kShellWindowId_VirtualKeyboardContainer); |
662 ASSERT_TRUE(keyboard_container); | 663 ASSERT_TRUE(keyboard_container); |
663 keyboard_container->Show(); | 664 keyboard_container->Show(); |
664 | 665 |
665 ClickTestWindow* main_delegate = new ClickTestWindow(); | 666 ClickTestWindow* main_delegate = new ClickTestWindow(); |
666 scoped_ptr<aura::Window> keyboard_window( | 667 scoped_ptr<aura::Window> keyboard_window( |
667 main_delegate->CreateTestWindowWithParent(keyboard_container)); | 668 main_delegate->CreateTestWindowWithParent(keyboard_container)); |
668 keyboard_container->layout_manager()->OnWindowResized(); | 669 keyboard_container->layout_manager()->OnWindowResized(); |
669 keyboard_window->Show(); | 670 keyboard_window->Show(); |
671 | |
672 // This test will create 2 sub windows for keyboard container. | |
673 // One is from keyboard controller proxy, and another is from this test | |
674 // itself. For testing purpose, the test window is needed for mouse hit test. | |
675 // But inside keyboard controller, it needs proxy window to calculate the | |
676 // bounds of the hit test mask. Therefore, below code is a hack to make sure | |
677 // the 2 windows have the same bounds. | |
678 Shell::GetInstance()->keyboard_controller()->proxy()->GetKeyboardWindow() | |
679 ->SetBounds(keyboard_window->bounds()); | |
sadrul
2013/12/04 17:35:20
It's not clear to me why you need a new window for
Shu Chen
2013/12/05 05:01:39
Done.
| |
680 | |
670 aura::test::EventGenerator event_generator(root_window, | 681 aura::test::EventGenerator event_generator(root_window, |
671 keyboard_window.get()); | 682 keyboard_window.get()); |
672 event_generator.ClickLeftButton(); | 683 event_generator.ClickLeftButton(); |
673 int expected_mouse_presses = 1; | 684 int expected_mouse_presses = 1; |
674 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); | 685 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); |
675 | 686 |
676 for (int block_reason = FIRST_BLOCK_REASON; | 687 for (int block_reason = FIRST_BLOCK_REASON; |
677 block_reason < NUMBER_OF_BLOCK_REASONS; | 688 block_reason < NUMBER_OF_BLOCK_REASONS; |
678 ++block_reason) { | 689 ++block_reason) { |
679 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 690 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
(...skipping 17 matching lines...) Expand all Loading... | |
697 aura::WindowTracker tracker; | 708 aura::WindowTracker tracker; |
698 tracker.Add(keyboard_container); | 709 tracker.Add(keyboard_container); |
699 // Mock a login user profile change to reinitialize the keyboard. | 710 // Mock a login user profile change to reinitialize the keyboard. |
700 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); | 711 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); |
701 // keyboard_container should no longer be present. | 712 // keyboard_container should no longer be present. |
702 EXPECT_FALSE(tracker.Contains(keyboard_container)); | 713 EXPECT_FALSE(tracker.Contains(keyboard_container)); |
703 } | 714 } |
704 | 715 |
705 } // namespace test | 716 } // namespace test |
706 } // namespace ash | 717 } // namespace ash |
OLD | NEW |