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

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: address the comments Created 3 years, 11 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "ui/aura/layout_manager.h" 71 #include "ui/aura/layout_manager.h"
72 #include "ui/aura/test/aura_test_helper.h" 72 #include "ui/aura/test/aura_test_helper.h"
73 #include "ui/aura/test/aura_test_utils.h" 73 #include "ui/aura/test/aura_test_utils.h"
74 #include "ui/aura/test/test_cursor_client.h" 74 #include "ui/aura/test/test_cursor_client.h"
75 #include "ui/aura/test/test_screen.h" 75 #include "ui/aura/test/test_screen.h"
76 #include "ui/aura/test/test_window_delegate.h" 76 #include "ui/aura/test/test_window_delegate.h"
77 #include "ui/aura/window.h" 77 #include "ui/aura/window.h"
78 #include "ui/aura/window_event_dispatcher.h" 78 #include "ui/aura/window_event_dispatcher.h"
79 #include "ui/aura/window_observer.h" 79 #include "ui/aura/window_observer.h"
80 #include "ui/base/clipboard/clipboard.h" 80 #include "ui/base/clipboard/clipboard.h"
81 #include "ui/base/ui_base_switches.h"
81 #include "ui/base/ui_base_types.h" 82 #include "ui/base/ui_base_types.h"
82 #include "ui/compositor/compositor.h" 83 #include "ui/compositor/compositor.h"
83 #include "ui/compositor/layer_tree_owner.h" 84 #include "ui/compositor/layer_tree_owner.h"
84 #include "ui/compositor/test/draw_waiter_for_test.h" 85 #include "ui/compositor/test/draw_waiter_for_test.h"
85 #include "ui/events/blink/blink_event_util.h" 86 #include "ui/events/blink/blink_event_util.h"
86 #include "ui/events/blink/web_input_event_traits.h" 87 #include "ui/events/blink/web_input_event_traits.h"
87 #include "ui/events/event.h" 88 #include "ui/events/event.h"
88 #include "ui/events/event_utils.h" 89 #include "ui/events/event_utils.h"
89 #include "ui/events/gesture_detection/gesture_configuration.h" 90 #include "ui/events/gesture_detection/gesture_configuration.h"
90 #include "ui/events/gestures/motion_event_aura.h" 91 #include "ui/events/gestures/motion_event_aura.h"
91 #include "ui/events/keycodes/dom/dom_code.h" 92 #include "ui/events/keycodes/dom/dom_code.h"
92 #include "ui/events/keycodes/dom/keycode_converter.h" 93 #include "ui/events/keycodes/dom/keycode_converter.h"
93 #include "ui/events/test/event_generator.h" 94 #include "ui/events/test/event_generator.h"
94 #include "ui/gfx/geometry/rect.h" 95 #include "ui/gfx/geometry/rect.h"
95 #include "ui/gfx/selection_bound.h" 96 #include "ui/gfx/selection_bound.h"
96 #include "ui/wm/core/default_activation_client.h" 97 #include "ui/wm/core/default_activation_client.h"
97 #include "ui/wm/core/default_screen_position_client.h" 98 #include "ui/wm/core/default_screen_position_client.h"
98 #include "ui/wm/core/window_util.h" 99 #include "ui/wm/core/window_util.h"
99 100
101 #if defined(OS_CHROMEOS)
102 #include "ui/base/ime/input_method.h"
103 #endif
104
100 using testing::_; 105 using testing::_;
101 106
102 using blink::WebGestureEvent; 107 using blink::WebGestureEvent;
103 using blink::WebInputEvent; 108 using blink::WebInputEvent;
104 using blink::WebMouseEvent; 109 using blink::WebMouseEvent;
105 using blink::WebMouseWheelEvent; 110 using blink::WebMouseWheelEvent;
106 using blink::WebTouchEvent; 111 using blink::WebTouchEvent;
107 using blink::WebTouchPoint; 112 using blink::WebTouchPoint;
108 using ui::WebInputEventTraits; 113 using ui::WebInputEventTraits;
109 114
(...skipping 3857 matching lines...) Expand 10 before | Expand all | Expand 10 after
3967 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 3972 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3968 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 3973 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
3969 3974
3970 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3975 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3971 blink::WebGestureDeviceTouchscreen); 3976 blink::WebGestureDeviceTouchscreen);
3972 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 3977 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3973 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 3978 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
3974 EXPECT_EQ(3U, sink_->message_count()); 3979 EXPECT_EQ(3U, sink_->message_count());
3975 } 3980 }
3976 3981
3982 #if defined(OS_CHROMEOS)
3983 // Check that when accessibility virtual keyboard is enabled, windows are
3984 // shifted up when focused and restored when focus is lost.
3985 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3986 VirtualKeyboardFocusEnsureCaretInRect) {
3987 SetUpOverscrollEnvironment();
3988 // TODO (oshima): Test that overscroll occurs.
3989
3990 // Enable new virtual keyboard behavior.
3991 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
3992 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) {
3993 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
3994 }
3995
3996 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
3997 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod();
3998 int keyboard_height = 200;
3999 gfx::Rect root_bounds = root_window->bounds();
4000 gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200);
4001 gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200);
4002 gfx::Rect keyboard_view_bounds =
4003 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(),
4004 keyboard_height);
4005
4006 // Focus the window.
4007 view_->SetBounds(orig_view_bounds);
4008 input_method->SetFocusedTextInputClient(view_);
4009 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
4010
4011 // Simulate virtual keyboard.
4012 input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds);
4013
4014 // Window should be shifted.
4015 EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds);
4016
4017 // Change the focus.
4018 input_method->SetFocusedTextInputClient(nullptr);
4019
4020 // Window should be restored.
4021 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
4022 }
4023 #endif // defined(OS_CHROMEOS)
4024
3977 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted 4025 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted
3978 // before RWH), we clean up properly and don't leak the RWHVGuest. 4026 // before RWH), we clean up properly and don't leak the RWHVGuest.
3979 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { 4027 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) {
3980 view_->InitAsChild(nullptr); 4028 view_->InitAsChild(nullptr);
3981 TearDownEnvironment(); 4029 TearDownEnvironment();
3982 ASSERT_FALSE(guest_view_weak_.get()); 4030 ASSERT_FALSE(guest_view_weak_.get());
3983 } 4031 }
3984 4032
3985 // Tests that invalid touch events are consumed and handled 4033 // Tests that invalid touch events are consumed and handled
3986 // synchronously. 4034 // synchronously.
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
4744 4792
4745 // Retrieve the selected text from clipboard and verify it is as expected. 4793 // Retrieve the selected text from clipboard and verify it is as expected.
4746 base::string16 result_text; 4794 base::string16 result_text;
4747 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); 4795 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text);
4748 EXPECT_EQ(expected_text, result_text); 4796 EXPECT_EQ(expected_text, result_text);
4749 } 4797 }
4750 } 4798 }
4751 #endif 4799 #endif
4752 4800
4753 } // namespace content 4801 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698