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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "ui/aura/layout_manager.h" | 75 #include "ui/aura/layout_manager.h" |
76 #include "ui/aura/test/aura_test_helper.h" | 76 #include "ui/aura/test/aura_test_helper.h" |
77 #include "ui/aura/test/aura_test_utils.h" | 77 #include "ui/aura/test/aura_test_utils.h" |
78 #include "ui/aura/test/test_cursor_client.h" | 78 #include "ui/aura/test/test_cursor_client.h" |
79 #include "ui/aura/test/test_screen.h" | 79 #include "ui/aura/test/test_screen.h" |
80 #include "ui/aura/test/test_window_delegate.h" | 80 #include "ui/aura/test/test_window_delegate.h" |
81 #include "ui/aura/window.h" | 81 #include "ui/aura/window.h" |
82 #include "ui/aura/window_event_dispatcher.h" | 82 #include "ui/aura/window_event_dispatcher.h" |
83 #include "ui/aura/window_observer.h" | 83 #include "ui/aura/window_observer.h" |
84 #include "ui/base/clipboard/clipboard.h" | 84 #include "ui/base/clipboard/clipboard.h" |
| 85 #include "ui/base/ui_base_switches.h" |
85 #include "ui/base/ui_base_types.h" | 86 #include "ui/base/ui_base_types.h" |
86 #include "ui/compositor/compositor.h" | 87 #include "ui/compositor/compositor.h" |
87 #include "ui/compositor/layer_tree_owner.h" | 88 #include "ui/compositor/layer_tree_owner.h" |
88 #include "ui/compositor/test/draw_waiter_for_test.h" | 89 #include "ui/compositor/test/draw_waiter_for_test.h" |
89 #include "ui/events/blink/blink_event_util.h" | 90 #include "ui/events/blink/blink_event_util.h" |
90 #include "ui/events/blink/web_input_event_traits.h" | 91 #include "ui/events/blink/web_input_event_traits.h" |
91 #include "ui/events/event.h" | 92 #include "ui/events/event.h" |
92 #include "ui/events/event_utils.h" | 93 #include "ui/events/event_utils.h" |
93 #include "ui/events/gesture_detection/gesture_configuration.h" | 94 #include "ui/events/gesture_detection/gesture_configuration.h" |
94 #include "ui/events/gestures/motion_event_aura.h" | 95 #include "ui/events/gestures/motion_event_aura.h" |
95 #include "ui/events/keycodes/dom/dom_code.h" | 96 #include "ui/events/keycodes/dom/dom_code.h" |
96 #include "ui/events/keycodes/dom/keycode_converter.h" | 97 #include "ui/events/keycodes/dom/keycode_converter.h" |
97 #include "ui/events/test/event_generator.h" | 98 #include "ui/events/test/event_generator.h" |
98 #include "ui/gfx/geometry/rect.h" | 99 #include "ui/gfx/geometry/rect.h" |
99 #include "ui/gfx/selection_bound.h" | 100 #include "ui/gfx/selection_bound.h" |
100 #include "ui/wm/core/default_activation_client.h" | 101 #include "ui/wm/core/default_activation_client.h" |
101 #include "ui/wm/core/default_screen_position_client.h" | 102 #include "ui/wm/core/default_screen_position_client.h" |
102 #include "ui/wm/core/window_util.h" | 103 #include "ui/wm/core/window_util.h" |
103 | 104 |
| 105 #if defined(OS_CHROMEOS) |
| 106 #include "ui/base/ime/input_method.h" |
| 107 #endif |
| 108 |
104 using testing::_; | 109 using testing::_; |
105 | 110 |
106 using blink::WebGestureEvent; | 111 using blink::WebGestureEvent; |
107 using blink::WebInputEvent; | 112 using blink::WebInputEvent; |
108 using blink::WebMouseEvent; | 113 using blink::WebMouseEvent; |
109 using blink::WebMouseWheelEvent; | 114 using blink::WebMouseWheelEvent; |
110 using blink::WebTouchEvent; | 115 using blink::WebTouchEvent; |
111 using blink::WebTouchPoint; | 116 using blink::WebTouchPoint; |
112 using ui::WebInputEventTraits; | 117 using ui::WebInputEventTraits; |
113 | 118 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 return delegated_frame_host_client_->resize_locked(); | 476 return delegated_frame_host_client_->resize_locked(); |
472 } | 477 } |
473 bool compositor_locked() const { | 478 bool compositor_locked() const { |
474 return delegated_frame_host_client_->compositor_locked(); | 479 return delegated_frame_host_client_->compositor_locked(); |
475 } | 480 } |
476 | 481 |
477 gfx::Size last_frame_size_; | 482 gfx::Size last_frame_size_; |
478 std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; | 483 std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; |
479 FakeWindowEventDispatcher* dispatcher_; | 484 FakeWindowEventDispatcher* dispatcher_; |
480 | 485 |
| 486 protected: |
| 487 // In this unit test, |window_| is directly added to the root and is toplevel. |
| 488 aura::Window* GetToplevelWindow() override { return window(); } |
| 489 |
481 private: | 490 private: |
482 FakeDelegatedFrameHostClientAura* delegated_frame_host_client_; | 491 FakeDelegatedFrameHostClientAura* delegated_frame_host_client_; |
483 | 492 |
484 DISALLOW_COPY_AND_ASSIGN(FakeRenderWidgetHostViewAura); | 493 DISALLOW_COPY_AND_ASSIGN(FakeRenderWidgetHostViewAura); |
485 }; | 494 }; |
486 | 495 |
487 // A layout manager that always resizes a child to the root window size. | 496 // A layout manager that always resizes a child to the root window size. |
488 class FullscreenLayoutManager : public aura::LayoutManager { | 497 class FullscreenLayoutManager : public aura::LayoutManager { |
489 public: | 498 public: |
490 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} | 499 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} |
(...skipping 4129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4620 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 4629 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
4621 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 4630 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
4622 | 4631 |
4623 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, | 4632 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, |
4624 blink::kWebGestureDeviceTouchscreen); | 4633 blink::kWebGestureDeviceTouchscreen); |
4625 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 4634 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
4626 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 4635 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
4627 EXPECT_EQ(4U, sink_->message_count()); | 4636 EXPECT_EQ(4U, sink_->message_count()); |
4628 } | 4637 } |
4629 | 4638 |
| 4639 #if defined(OS_CHROMEOS) |
| 4640 // Check that when accessibility virtual keyboard is enabled, windows are |
| 4641 // shifted up when focused and restored when focus is lost. |
| 4642 TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) { |
| 4643 // TODO (oshima): Test that overscroll occurs. |
| 4644 |
| 4645 // Enable new virtual keyboard behavior. |
| 4646 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 4647 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) { |
| 4648 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); |
| 4649 } |
| 4650 |
| 4651 wm::DefaultScreenPositionClient screen_position_client; |
| 4652 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(), |
| 4653 &screen_position_client); |
| 4654 |
| 4655 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); |
| 4656 view_->InitAsChild(parent_view_->GetNativeView()); |
| 4657 |
| 4658 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod(); |
| 4659 int keyboard_height = 200; |
| 4660 gfx::Rect root_bounds = root_window->bounds(); |
| 4661 gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200); |
| 4662 gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200); |
| 4663 gfx::Rect keyboard_view_bounds = |
| 4664 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(), |
| 4665 keyboard_height); |
| 4666 |
| 4667 // Focus the window. |
| 4668 view_->SetBounds(orig_view_bounds); |
| 4669 input_method->SetFocusedTextInputClient(view_); |
| 4670 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds); |
| 4671 |
| 4672 // Simulate virtual keyboard. |
| 4673 input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds); |
| 4674 |
| 4675 // Window should be shifted. |
| 4676 EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds); |
| 4677 |
| 4678 // Detach the RenderWidgetHostViewAura from the IME. |
| 4679 view_->DetachFromInputMethod(); |
| 4680 |
| 4681 // Window should be restored. |
| 4682 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds); |
| 4683 |
| 4684 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(), |
| 4685 nullptr); |
| 4686 } |
| 4687 #endif // defined(OS_CHROMEOS) |
| 4688 |
4630 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 4689 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
4631 // before RWH), we clean up properly and don't leak the RWHVGuest. | 4690 // before RWH), we clean up properly and don't leak the RWHVGuest. |
4632 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 4691 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
4633 view_->InitAsChild(nullptr); | 4692 view_->InitAsChild(nullptr); |
4634 TearDownEnvironment(); | 4693 TearDownEnvironment(); |
4635 ASSERT_FALSE(guest_view_weak_.get()); | 4694 ASSERT_FALSE(guest_view_weak_.get()); |
4636 } | 4695 } |
4637 | 4696 |
4638 // Tests that invalid touch events are consumed and handled | 4697 // Tests that invalid touch events are consumed and handled |
4639 // synchronously. | 4698 // synchronously. |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5432 // There is no composition in the beginning. | 5491 // There is no composition in the beginning. |
5433 EXPECT_FALSE(has_composition_text()); | 5492 EXPECT_FALSE(has_composition_text()); |
5434 SetHasCompositionTextToTrue(); | 5493 SetHasCompositionTextToTrue(); |
5435 view->ImeCancelComposition(); | 5494 view->ImeCancelComposition(); |
5436 // The composition must have been canceled. | 5495 // The composition must have been canceled. |
5437 EXPECT_FALSE(has_composition_text()); | 5496 EXPECT_FALSE(has_composition_text()); |
5438 } | 5497 } |
5439 } | 5498 } |
5440 | 5499 |
5441 } // namespace content | 5500 } // namespace content |
OLD | NEW |