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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "ui/aura/layout_manager.h" | 76 #include "ui/aura/layout_manager.h" |
77 #include "ui/aura/test/aura_test_helper.h" | 77 #include "ui/aura/test/aura_test_helper.h" |
78 #include "ui/aura/test/aura_test_utils.h" | 78 #include "ui/aura/test/aura_test_utils.h" |
79 #include "ui/aura/test/test_cursor_client.h" | 79 #include "ui/aura/test/test_cursor_client.h" |
80 #include "ui/aura/test/test_screen.h" | 80 #include "ui/aura/test/test_screen.h" |
81 #include "ui/aura/test/test_window_delegate.h" | 81 #include "ui/aura/test/test_window_delegate.h" |
82 #include "ui/aura/window.h" | 82 #include "ui/aura/window.h" |
83 #include "ui/aura/window_event_dispatcher.h" | 83 #include "ui/aura/window_event_dispatcher.h" |
84 #include "ui/aura/window_observer.h" | 84 #include "ui/aura/window_observer.h" |
85 #include "ui/base/clipboard/clipboard.h" | 85 #include "ui/base/clipboard/clipboard.h" |
| 86 #include "ui/base/ui_base_switches.h" |
86 #include "ui/base/ui_base_types.h" | 87 #include "ui/base/ui_base_types.h" |
87 #include "ui/compositor/compositor.h" | 88 #include "ui/compositor/compositor.h" |
88 #include "ui/compositor/layer_tree_owner.h" | 89 #include "ui/compositor/layer_tree_owner.h" |
89 #include "ui/compositor/test/draw_waiter_for_test.h" | 90 #include "ui/compositor/test/draw_waiter_for_test.h" |
90 #include "ui/events/blink/blink_event_util.h" | 91 #include "ui/events/blink/blink_event_util.h" |
91 #include "ui/events/blink/web_input_event_traits.h" | 92 #include "ui/events/blink/web_input_event_traits.h" |
92 #include "ui/events/event.h" | 93 #include "ui/events/event.h" |
93 #include "ui/events/event_utils.h" | 94 #include "ui/events/event_utils.h" |
94 #include "ui/events/gesture_detection/gesture_configuration.h" | 95 #include "ui/events/gesture_detection/gesture_configuration.h" |
95 #include "ui/events/gestures/motion_event_aura.h" | 96 #include "ui/events/gestures/motion_event_aura.h" |
96 #include "ui/events/keycodes/dom/dom_code.h" | 97 #include "ui/events/keycodes/dom/dom_code.h" |
97 #include "ui/events/keycodes/dom/keycode_converter.h" | 98 #include "ui/events/keycodes/dom/keycode_converter.h" |
98 #include "ui/events/test/event_generator.h" | 99 #include "ui/events/test/event_generator.h" |
99 #include "ui/gfx/geometry/rect.h" | 100 #include "ui/gfx/geometry/rect.h" |
100 #include "ui/gfx/selection_bound.h" | 101 #include "ui/gfx/selection_bound.h" |
101 #include "ui/wm/core/default_activation_client.h" | 102 #include "ui/wm/core/default_activation_client.h" |
102 #include "ui/wm/core/default_screen_position_client.h" | 103 #include "ui/wm/core/default_screen_position_client.h" |
103 #include "ui/wm/core/window_util.h" | 104 #include "ui/wm/core/window_util.h" |
104 | 105 |
| 106 #if defined(OS_CHROMEOS) |
| 107 #include "ui/base/ime/input_method.h" |
| 108 #endif |
| 109 |
105 using testing::_; | 110 using testing::_; |
106 | 111 |
107 using blink::WebGestureEvent; | 112 using blink::WebGestureEvent; |
108 using blink::WebInputEvent; | 113 using blink::WebInputEvent; |
109 using blink::WebMouseEvent; | 114 using blink::WebMouseEvent; |
110 using blink::WebMouseWheelEvent; | 115 using blink::WebMouseWheelEvent; |
111 using blink::WebTouchEvent; | 116 using blink::WebTouchEvent; |
112 using blink::WebTouchPoint; | 117 using blink::WebTouchPoint; |
113 using ui::WebInputEventTraits; | 118 using ui::WebInputEventTraits; |
114 using viz::FrameEvictionManager; | 119 using viz::FrameEvictionManager; |
(...skipping 4565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4680 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 4685 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
4681 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 4686 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
4682 | 4687 |
4683 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, | 4688 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, |
4684 blink::kWebGestureDeviceTouchscreen); | 4689 blink::kWebGestureDeviceTouchscreen); |
4685 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 4690 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
4686 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 4691 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
4687 EXPECT_EQ(4U, sink_->message_count()); | 4692 EXPECT_EQ(4U, sink_->message_count()); |
4688 } | 4693 } |
4689 | 4694 |
| 4695 #if defined(OS_CHROMEOS) |
| 4696 // Check that when accessibility virtual keyboard is enabled, windows are |
| 4697 // shifted up when focused and restored when focus is lost. |
| 4698 TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) { |
| 4699 // TODO (oshima): Test that overscroll occurs. |
| 4700 |
| 4701 // Enable new virtual keyboard behavior. |
| 4702 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 4703 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) |
| 4704 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); |
| 4705 |
| 4706 view_->InitAsChild(nullptr); |
| 4707 aura::client::ParentWindowWithContext( |
| 4708 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 4709 gfx::Rect()); |
| 4710 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); |
| 4711 wm::DefaultScreenPositionClient screen_position_client; |
| 4712 aura::client::SetScreenPositionClient(root_window, &screen_position_client); |
| 4713 |
| 4714 const gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200); |
| 4715 const gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200); |
| 4716 const gfx::Rect root_bounds = root_window->bounds(); |
| 4717 const int keyboard_height = 200; |
| 4718 const gfx::Rect keyboard_view_bounds = |
| 4719 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(), |
| 4720 keyboard_height); |
| 4721 |
| 4722 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod(); |
| 4723 |
| 4724 // Focus the window. |
| 4725 view_->SetBounds(orig_view_bounds); |
| 4726 input_method->SetFocusedTextInputClient(view_); |
| 4727 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds); |
| 4728 |
| 4729 // Simulate virtual keyboard. |
| 4730 input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds); |
| 4731 |
| 4732 // Window should be shifted. |
| 4733 EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds); |
| 4734 |
| 4735 // Detach the RenderWidgetHostViewAura from the IME. |
| 4736 view_->DetachFromInputMethod(); |
| 4737 |
| 4738 // Window should be restored. |
| 4739 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds); |
| 4740 |
| 4741 aura::client::SetScreenPositionClient(root_window, nullptr); |
| 4742 } |
| 4743 #endif // defined(OS_CHROMEOS) |
| 4744 |
4690 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 4745 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
4691 // before RWH), we clean up properly and don't leak the RWHVGuest. | 4746 // before RWH), we clean up properly and don't leak the RWHVGuest. |
4692 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 4747 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
4693 view_->InitAsChild(nullptr); | 4748 view_->InitAsChild(nullptr); |
4694 TearDownEnvironment(); | 4749 TearDownEnvironment(); |
4695 ASSERT_FALSE(guest_view_weak_.get()); | 4750 ASSERT_FALSE(guest_view_weak_.get()); |
4696 } | 4751 } |
4697 | 4752 |
4698 // Tests that invalid touch events are consumed and handled | 4753 // Tests that invalid touch events are consumed and handled |
4699 // synchronously. | 4754 // synchronously. |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5492 // There is no composition in the beginning. | 5547 // There is no composition in the beginning. |
5493 EXPECT_FALSE(has_composition_text()); | 5548 EXPECT_FALSE(has_composition_text()); |
5494 SetHasCompositionTextToTrue(); | 5549 SetHasCompositionTextToTrue(); |
5495 view->ImeCancelComposition(); | 5550 view->ImeCancelComposition(); |
5496 // The composition must have been canceled. | 5551 // The composition must have been canceled. |
5497 EXPECT_FALSE(has_composition_text()); | 5552 EXPECT_FALSE(has_composition_text()); |
5498 } | 5553 } |
5499 } | 5554 } |
5500 | 5555 |
5501 } // namespace content | 5556 } // namespace content |
OLD | NEW |