Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2553603002: New accessibility virtual keyboard behavior in non-sticky mode. (Closed)
Patch Set: Fix the build error on Linux and Windows Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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(); }
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 4172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4681 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 4690 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
4682 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 4691 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
4683 4692
4684 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd, 4693 SimulateGestureEvent(WebInputEvent::kGestureScrollEnd,
4685 blink::kWebGestureDeviceTouchscreen); 4694 blink::kWebGestureDeviceTouchscreen);
4686 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 4695 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
4687 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 4696 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
4688 EXPECT_EQ(4U, sink_->message_count()); 4697 EXPECT_EQ(4U, sink_->message_count());
4689 } 4698 }
4690 4699
4700 #if defined(OS_CHROMEOS)
4701 // Check that when accessibility virtual keyboard is enabled, windows are
4702 // shifted up when focused and restored when focus is lost.
4703 TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) {
4704 // TODO (oshima): Test that overscroll occurs.
4705
4706 // Enable new virtual keyboard behavior.
4707 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
4708 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) {
4709 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
4710 }
4711
4712 wm::DefaultScreenPositionClient screen_position_client;
4713 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
4714 &screen_position_client);
4715
4716 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
4717 view_->InitAsChild(parent_view_->GetNativeView());
4718
4719 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod();
4720 int keyboard_height = 200;
4721 gfx::Rect root_bounds = root_window->bounds();
4722 gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200);
4723 gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200);
4724 gfx::Rect keyboard_view_bounds =
4725 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(),
4726 keyboard_height);
4727
4728 // Focus the window.
4729 view_->SetBounds(orig_view_bounds);
4730 input_method->SetFocusedTextInputClient(view_);
4731 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
4732
4733 // Simulate virtual keyboard.
4734 input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds);
4735
4736 // Window should be shifted.
4737 EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds);
4738
4739 // Detach the RenderWidgetHostViewAura from the IME.
4740 view_->DetachFromInputMethod();
4741
4742 // Window should be restored.
4743 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
4744
4745 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
4746 nullptr);
4747 }
4748 #endif // defined(OS_CHROMEOS)
4749
4691 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted 4750 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted
4692 // before RWH), we clean up properly and don't leak the RWHVGuest. 4751 // before RWH), we clean up properly and don't leak the RWHVGuest.
4693 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { 4752 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) {
4694 view_->InitAsChild(nullptr); 4753 view_->InitAsChild(nullptr);
4695 TearDownEnvironment(); 4754 TearDownEnvironment();
4696 ASSERT_FALSE(guest_view_weak_.get()); 4755 ASSERT_FALSE(guest_view_weak_.get());
4697 } 4756 }
4698 4757
4699 // Tests that invalid touch events are consumed and handled 4758 // Tests that invalid touch events are consumed and handled
4700 // synchronously. 4759 // synchronously.
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
5493 // There is no composition in the beginning. 5552 // There is no composition in the beginning.
5494 EXPECT_FALSE(has_composition_text()); 5553 EXPECT_FALSE(has_composition_text());
5495 SetHasCompositionTextToTrue(); 5554 SetHasCompositionTextToTrue();
5496 view->ImeCancelComposition(); 5555 view->ImeCancelComposition();
5497 // The composition must have been canceled. 5556 // The composition must have been canceled.
5498 EXPECT_FALSE(has_composition_text()); 5557 EXPECT_FALSE(has_composition_text());
5499 } 5558 }
5500 } 5559 }
5501 5560
5502 } // namespace content 5561 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698