| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "ui/aura/layout_manager.h" | 73 #include "ui/aura/layout_manager.h" |
| 74 #include "ui/aura/test/aura_test_helper.h" | 74 #include "ui/aura/test/aura_test_helper.h" |
| 75 #include "ui/aura/test/aura_test_utils.h" | 75 #include "ui/aura/test/aura_test_utils.h" |
| 76 #include "ui/aura/test/test_cursor_client.h" | 76 #include "ui/aura/test/test_cursor_client.h" |
| 77 #include "ui/aura/test/test_screen.h" | 77 #include "ui/aura/test/test_screen.h" |
| 78 #include "ui/aura/test/test_window_delegate.h" | 78 #include "ui/aura/test/test_window_delegate.h" |
| 79 #include "ui/aura/window.h" | 79 #include "ui/aura/window.h" |
| 80 #include "ui/aura/window_event_dispatcher.h" | 80 #include "ui/aura/window_event_dispatcher.h" |
| 81 #include "ui/aura/window_observer.h" | 81 #include "ui/aura/window_observer.h" |
| 82 #include "ui/base/clipboard/clipboard.h" | 82 #include "ui/base/clipboard/clipboard.h" |
| 83 #include "ui/base/ui_base_switches.h" |
| 83 #include "ui/base/ui_base_types.h" | 84 #include "ui/base/ui_base_types.h" |
| 84 #include "ui/compositor/compositor.h" | 85 #include "ui/compositor/compositor.h" |
| 85 #include "ui/compositor/layer_tree_owner.h" | 86 #include "ui/compositor/layer_tree_owner.h" |
| 86 #include "ui/compositor/test/draw_waiter_for_test.h" | 87 #include "ui/compositor/test/draw_waiter_for_test.h" |
| 87 #include "ui/events/blink/blink_event_util.h" | 88 #include "ui/events/blink/blink_event_util.h" |
| 88 #include "ui/events/blink/web_input_event_traits.h" | 89 #include "ui/events/blink/web_input_event_traits.h" |
| 89 #include "ui/events/event.h" | 90 #include "ui/events/event.h" |
| 90 #include "ui/events/event_utils.h" | 91 #include "ui/events/event_utils.h" |
| 91 #include "ui/events/gesture_detection/gesture_configuration.h" | 92 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 92 #include "ui/events/gestures/motion_event_aura.h" | 93 #include "ui/events/gestures/motion_event_aura.h" |
| 93 #include "ui/events/keycodes/dom/dom_code.h" | 94 #include "ui/events/keycodes/dom/dom_code.h" |
| 94 #include "ui/events/keycodes/dom/keycode_converter.h" | 95 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 95 #include "ui/events/test/event_generator.h" | 96 #include "ui/events/test/event_generator.h" |
| 96 #include "ui/gfx/geometry/rect.h" | 97 #include "ui/gfx/geometry/rect.h" |
| 97 #include "ui/gfx/selection_bound.h" | 98 #include "ui/gfx/selection_bound.h" |
| 98 #include "ui/wm/core/default_activation_client.h" | 99 #include "ui/wm/core/default_activation_client.h" |
| 99 #include "ui/wm/core/default_screen_position_client.h" | 100 #include "ui/wm/core/default_screen_position_client.h" |
| 100 #include "ui/wm/core/window_util.h" | 101 #include "ui/wm/core/window_util.h" |
| 101 | 102 |
| 103 #if defined(OS_CHROMEOS) |
| 104 #include "ui/base/ime/input_method.h" |
| 105 #endif |
| 106 |
| 102 using testing::_; | 107 using testing::_; |
| 103 | 108 |
| 104 using blink::WebGestureEvent; | 109 using blink::WebGestureEvent; |
| 105 using blink::WebInputEvent; | 110 using blink::WebInputEvent; |
| 106 using blink::WebMouseEvent; | 111 using blink::WebMouseEvent; |
| 107 using blink::WebMouseWheelEvent; | 112 using blink::WebMouseWheelEvent; |
| 108 using blink::WebTouchEvent; | 113 using blink::WebTouchEvent; |
| 109 using blink::WebTouchPoint; | 114 using blink::WebTouchPoint; |
| 110 using ui::WebInputEventTraits; | 115 using ui::WebInputEventTraits; |
| 111 | 116 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 void ResetCompositor() { GetDelegatedFrameHost()->ResetCompositor(); } | 441 void ResetCompositor() { GetDelegatedFrameHost()->ResetCompositor(); } |
| 437 | 442 |
| 438 const ui::MotionEventAura& pointer_state_for_test() { | 443 const ui::MotionEventAura& pointer_state_for_test() { |
| 439 return event_handler()->pointer_state(); | 444 return event_handler()->pointer_state(); |
| 440 } | 445 } |
| 441 | 446 |
| 442 gfx::Size last_frame_size_; | 447 gfx::Size last_frame_size_; |
| 443 std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; | 448 std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; |
| 444 FakeWindowEventDispatcher* dispatcher_; | 449 FakeWindowEventDispatcher* dispatcher_; |
| 445 | 450 |
| 451 protected: |
| 452 // In this unit test, |window_| is directly added to the root and is toplevel. |
| 453 aura::Window* GetToplevelWindow() override { return window(); } |
| 454 |
| 446 private: | 455 private: |
| 447 FakeDelegatedFrameHostClientAura* delegated_frame_host_client_; | 456 FakeDelegatedFrameHostClientAura* delegated_frame_host_client_; |
| 448 | 457 |
| 449 DISALLOW_COPY_AND_ASSIGN(FakeRenderWidgetHostViewAura); | 458 DISALLOW_COPY_AND_ASSIGN(FakeRenderWidgetHostViewAura); |
| 450 }; | 459 }; |
| 451 | 460 |
| 452 // A layout manager that always resizes a child to the root window size. | 461 // A layout manager that always resizes a child to the root window size. |
| 453 class FullscreenLayoutManager : public aura::LayoutManager { | 462 class FullscreenLayoutManager : public aura::LayoutManager { |
| 454 public: | 463 public: |
| 455 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} | 464 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} |
| (...skipping 3565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4021 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 4030 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 4022 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 4031 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 4023 | 4032 |
| 4024 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 4033 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 4025 blink::WebGestureDeviceTouchscreen); | 4034 blink::WebGestureDeviceTouchscreen); |
| 4026 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 4035 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 4027 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 4036 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 4028 EXPECT_EQ(4U, sink_->message_count()); | 4037 EXPECT_EQ(4U, sink_->message_count()); |
| 4029 } | 4038 } |
| 4030 | 4039 |
| 4040 #if defined(OS_CHROMEOS) |
| 4041 // Check that when accessibility virtual keyboard is enabled, windows are |
| 4042 // shifted up when focused and restored when focus is lost. |
| 4043 TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) { |
| 4044 // TODO (oshima): Test that overscroll occurs. |
| 4045 |
| 4046 // Enable new virtual keyboard behavior. |
| 4047 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 4048 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) { |
| 4049 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); |
| 4050 } |
| 4051 |
| 4052 wm::DefaultScreenPositionClient screen_position_client; |
| 4053 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(), |
| 4054 &screen_position_client); |
| 4055 |
| 4056 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); |
| 4057 view_->InitAsChild(parent_view_->GetNativeView()); |
| 4058 |
| 4059 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod(); |
| 4060 int keyboard_height = 200; |
| 4061 gfx::Rect root_bounds = root_window->bounds(); |
| 4062 gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200); |
| 4063 gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200); |
| 4064 gfx::Rect keyboard_view_bounds = |
| 4065 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(), |
| 4066 keyboard_height); |
| 4067 |
| 4068 // Focus the window. |
| 4069 view_->SetBounds(orig_view_bounds); |
| 4070 input_method->SetFocusedTextInputClient(view_); |
| 4071 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds); |
| 4072 |
| 4073 // Simulate virtual keyboard. |
| 4074 input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds); |
| 4075 |
| 4076 // Window should be shifted. |
| 4077 EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds); |
| 4078 |
| 4079 // Change the focus. |
| 4080 input_method->SetFocusedTextInputClient(nullptr); |
| 4081 |
| 4082 // Window should be restored. |
| 4083 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds); |
| 4084 |
| 4085 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(), |
| 4086 nullptr); |
| 4087 } |
| 4088 #endif // defined(OS_CHROMEOS) |
| 4089 |
| 4031 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 4090 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
| 4032 // before RWH), we clean up properly and don't leak the RWHVGuest. | 4091 // before RWH), we clean up properly and don't leak the RWHVGuest. |
| 4033 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 4092 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
| 4034 view_->InitAsChild(nullptr); | 4093 view_->InitAsChild(nullptr); |
| 4035 TearDownEnvironment(); | 4094 TearDownEnvironment(); |
| 4036 ASSERT_FALSE(guest_view_weak_.get()); | 4095 ASSERT_FALSE(guest_view_weak_.get()); |
| 4037 } | 4096 } |
| 4038 | 4097 |
| 4039 // Tests that invalid touch events are consumed and handled | 4098 // Tests that invalid touch events are consumed and handled |
| 4040 // synchronously. | 4099 // synchronously. |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4813 // There is no composition in the beginning. | 4872 // There is no composition in the beginning. |
| 4814 EXPECT_FALSE(has_composition_text()); | 4873 EXPECT_FALSE(has_composition_text()); |
| 4815 SetHasCompositionTextToTrue(); | 4874 SetHasCompositionTextToTrue(); |
| 4816 view->ImeCancelComposition(); | 4875 view->ImeCancelComposition(); |
| 4817 // The composition must have been canceled. | 4876 // The composition must have been canceled. |
| 4818 EXPECT_FALSE(has_composition_text()); | 4877 EXPECT_FALSE(has_composition_text()); |
| 4819 } | 4878 } |
| 4820 } | 4879 } |
| 4821 | 4880 |
| 4822 } // namespace content | 4881 } // namespace content |
| OLD | NEW |