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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 bool compositor_locked() const { | 494 bool compositor_locked() const { |
490 return delegated_frame_host_client_->compositor_locked(); | 495 return delegated_frame_host_client_->compositor_locked(); |
491 } | 496 } |
492 | 497 |
493 gfx::Size last_frame_size_; | 498 gfx::Size last_frame_size_; |
494 std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; | 499 std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; |
495 FakeWindowEventDispatcher* dispatcher_; | 500 FakeWindowEventDispatcher* dispatcher_; |
496 std::unique_ptr<FakeRendererCompositorFrameSink> | 501 std::unique_ptr<FakeRendererCompositorFrameSink> |
497 renderer_compositor_frame_sink_; | 502 renderer_compositor_frame_sink_; |
498 | 503 |
504 protected: | |
505 // In this unit test, |window_| is directly added to the root and is toplevel. | |
506 aura::Window* GetToplevelWindow() override { return window(); } | |
sadrul
2017/05/08 15:47:26
Do you need this override? Because Window::GetTopl
yhanada
2017/05/09 03:19:14
I removed this override. It was needed because I i
| |
507 | |
499 private: | 508 private: |
500 FakeDelegatedFrameHostClientAura* delegated_frame_host_client_; | 509 FakeDelegatedFrameHostClientAura* delegated_frame_host_client_; |
501 cc::mojom::MojoCompositorFrameSinkClientPtr | 510 cc::mojom::MojoCompositorFrameSinkClientPtr |
502 renderer_compositor_frame_sink_ptr_; | 511 renderer_compositor_frame_sink_ptr_; |
503 | 512 |
504 DISALLOW_COPY_AND_ASSIGN(FakeRenderWidgetHostViewAura); | 513 DISALLOW_COPY_AND_ASSIGN(FakeRenderWidgetHostViewAura); |
505 }; | 514 }; |
506 | 515 |
507 // A layout manager that always resizes a child to the root window size. | 516 // A layout manager that always resizes a child to the root window size. |
508 class FullscreenLayoutManager : public aura::LayoutManager { | 517 class FullscreenLayoutManager : public aura::LayoutManager { |
(...skipping 4171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4680 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 4689 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
4681 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 4690 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
4682 | 4691 |
4683 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, | 4692 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, |
4684 blink::kWebGestureDeviceTouchscreen); | 4693 blink::kWebGestureDeviceTouchscreen); |
4685 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 4694 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
4686 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 4695 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
4687 EXPECT_EQ(4U, sink_->message_count()); | 4696 EXPECT_EQ(4U, sink_->message_count()); |
4688 } | 4697 } |
4689 | 4698 |
4699 #if defined(OS_CHROMEOS) | |
4700 // Check that when accessibility virtual keyboard is enabled, windows are | |
4701 // shifted up when focused and restored when focus is lost. | |
4702 TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) { | |
4703 // TODO (oshima): Test that overscroll occurs. | |
4704 | |
4705 // Enable new virtual keyboard behavior. | |
4706 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
4707 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) | |
4708 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); | |
4709 | |
4710 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); | |
4711 view_->InitAsChild(parent_view_->GetNativeView()); | |
4712 wm::DefaultScreenPositionClient screen_position_client; | |
4713 aura::client::SetScreenPositionClient(root_window, &screen_position_client); | |
4714 | |
4715 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod(); | |
4716 int keyboard_height = 200; | |
4717 gfx::Rect root_bounds = root_window->bounds(); | |
4718 gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200); | |
4719 gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200); | |
4720 gfx::Rect keyboard_view_bounds = | |
4721 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(), | |
4722 keyboard_height); | |
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 |