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/session_state_delegate.h" | 7 #include "ash/session/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/test/event_generator.h" | |
23 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
24 #include "ui/aura/test/test_windows.h" | 23 #include "ui/aura/test/test_windows.h" |
25 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
26 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" |
27 #include "ui/aura/window_tracker.h" | 26 #include "ui/aura/window_tracker.h" |
28 #include "ui/base/ime/dummy_text_input_client.h" | 27 #include "ui/base/ime/dummy_text_input_client.h" |
29 #include "ui/base/ime/input_method.h" | 28 #include "ui/base/ime/input_method.h" |
30 #include "ui/base/ime/text_input_client.h" | 29 #include "ui/base/ime/text_input_client.h" |
31 #include "ui/base/ime/text_input_focus_manager.h" | 30 #include "ui/base/ime/text_input_focus_manager.h" |
32 #include "ui/base/ui_base_switches_util.h" | 31 #include "ui/base/ui_base_switches_util.h" |
| 32 #include "ui/events/test/event_generator.h" |
33 #include "ui/events/test/test_event_handler.h" | 33 #include "ui/events/test/test_event_handler.h" |
34 #include "ui/keyboard/keyboard_controller_proxy.h" | 34 #include "ui/keyboard/keyboard_controller_proxy.h" |
35 #include "ui/keyboard/keyboard_switches.h" | 35 #include "ui/keyboard/keyboard_switches.h" |
36 #include "ui/keyboard/keyboard_util.h" | 36 #include "ui/keyboard/keyboard_util.h" |
37 #include "ui/views/controls/menu/menu_controller.h" | 37 #include "ui/views/controls/menu/menu_controller.h" |
38 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
39 #include "ui/views/widget/widget_delegate.h" | 39 #include "ui/views/widget/widget_delegate.h" |
40 | 40 |
41 using aura::Window; | 41 using aura::Window; |
42 using views::Widget; | 42 using views::Widget; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); | 274 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); |
275 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 275 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
276 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); | 276 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); |
277 | 277 |
278 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); | 278 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); |
279 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); | 279 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); |
280 EXPECT_TRUE(GetModalContainer(root_windows[1])->Contains( | 280 EXPECT_TRUE(GetModalContainer(root_windows[1])->Contains( |
281 modal->GetNativeView())); | 281 modal->GetNativeView())); |
282 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 282 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
283 | 283 |
284 aura::test::EventGenerator generator_1st(root_windows[0]); | 284 ui::test::EventGenerator generator_1st(root_windows[0]); |
285 generator_1st.ClickLeftButton(); | 285 generator_1st.ClickLeftButton(); |
286 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 286 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
287 | 287 |
288 UpdateDisplay("500x500"); | 288 UpdateDisplay("500x500"); |
289 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 289 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
290 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 290 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
291 generator_1st.ClickLeftButton(); | 291 generator_1st.ClickLeftButton(); |
292 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 292 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
293 } | 293 } |
294 | 294 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> | 681 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> |
682 proxy()->GetKeyboardWindow(); | 682 proxy()->GetKeyboardWindow(); |
683 keyboard_container->AddChild(keyboard_window); | 683 keyboard_container->AddChild(keyboard_window); |
684 keyboard_window->set_owned_by_parent(false); | 684 keyboard_window->set_owned_by_parent(false); |
685 keyboard_window->SetBounds(gfx::Rect()); | 685 keyboard_window->SetBounds(gfx::Rect()); |
686 keyboard_window->Show(); | 686 keyboard_window->Show(); |
687 | 687 |
688 ui::test::TestEventHandler handler; | 688 ui::test::TestEventHandler handler; |
689 root_window->AddPreTargetHandler(&handler); | 689 root_window->AddPreTargetHandler(&handler); |
690 | 690 |
691 aura::test::EventGenerator event_generator(root_window, keyboard_window); | 691 ui::test::EventGenerator event_generator(root_window, keyboard_window); |
692 event_generator.ClickLeftButton(); | 692 event_generator.ClickLeftButton(); |
693 int expected_mouse_presses = 1; | 693 int expected_mouse_presses = 1; |
694 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); | 694 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); |
695 | 695 |
696 for (int block_reason = FIRST_BLOCK_REASON; | 696 for (int block_reason = FIRST_BLOCK_REASON; |
697 block_reason < NUMBER_OF_BLOCK_REASONS; | 697 block_reason < NUMBER_OF_BLOCK_REASONS; |
698 ++block_reason) { | 698 ++block_reason) { |
699 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 699 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
700 event_generator.ClickLeftButton(); | 700 event_generator.ClickLeftButton(); |
701 expected_mouse_presses++; | 701 expected_mouse_presses++; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 | 766 |
767 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> | 767 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> |
768 proxy()->GetKeyboardWindow(); | 768 proxy()->GetKeyboardWindow(); |
769 keyboard_container->AddChild(keyboard_window); | 769 keyboard_container->AddChild(keyboard_window); |
770 keyboard_window->set_owned_by_parent(false); | 770 keyboard_window->set_owned_by_parent(false); |
771 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( | 771 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( |
772 keyboard_container->bounds(), 100)); | 772 keyboard_container->bounds(), 100)); |
773 | 773 |
774 ui::test::TestEventHandler handler; | 774 ui::test::TestEventHandler handler; |
775 root_window->AddPreTargetHandler(&handler); | 775 root_window->AddPreTargetHandler(&handler); |
776 aura::test::EventGenerator root_window_event_generator(root_window); | 776 ui::test::EventGenerator root_window_event_generator(root_window); |
777 aura::test::EventGenerator keyboard_event_generator(root_window, | 777 ui::test::EventGenerator keyboard_event_generator(root_window, |
778 keyboard_window); | 778 keyboard_window); |
779 | 779 |
780 views::Widget* modal_widget = | 780 views::Widget* modal_widget = |
781 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 781 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
782 | 782 |
783 // Verify that mouse events to the root window are block with a visble modal | 783 // Verify that mouse events to the root window are block with a visble modal |
784 // dialog. | 784 // dialog. |
785 root_window_event_generator.ClickLeftButton(); | 785 root_window_event_generator.ClickLeftButton(); |
786 EXPECT_EQ(0, handler.num_mouse_events()); | 786 EXPECT_EQ(0, handler.num_mouse_events()); |
787 | 787 |
788 // Verify that event dispatch to the virtual keyboard is unblocked. | 788 // Verify that event dispatch to the virtual keyboard is unblocked. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 if (switches::IsTextInputFocusManagerEnabled()) { | 836 if (switches::IsTextInputFocusManagerEnabled()) { |
837 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( | 837 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( |
838 &text_input_client); | 838 &text_input_client); |
839 } else { | 839 } else { |
840 input_method->SetFocusedTextInputClient(NULL); | 840 input_method->SetFocusedTextInputClient(NULL); |
841 } | 841 } |
842 } | 842 } |
843 | 843 |
844 } // namespace test | 844 } // namespace test |
845 } // namespace ash | 845 } // namespace ash |
OLD | NEW |