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

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: Remove TextInputClient::OnClientFocusLost() 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 3922 matching lines...) Expand 10 before | Expand all | Expand 10 after
4413 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 4422 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
4414 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 4423 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
4415 4424
4416 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 4425 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
4417 blink::WebGestureDeviceTouchscreen); 4426 blink::WebGestureDeviceTouchscreen);
4418 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 4427 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
4419 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 4428 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
4420 EXPECT_EQ(4U, sink_->message_count()); 4429 EXPECT_EQ(4U, sink_->message_count());
4421 } 4430 }
4422 4431
4432 #if defined(OS_CHROMEOS)
4433 // Check that when accessibility virtual keyboard is enabled, windows are
4434 // shifted up when focused and restored when focus is lost.
4435 TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) {
4436 // TODO (oshima): Test that overscroll occurs.
4437
4438 // Enable new virtual keyboard behavior.
4439 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
4440 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) {
4441 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
4442 }
4443
4444 wm::DefaultScreenPositionClient screen_position_client;
4445 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
4446 &screen_position_client);
4447
4448 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
4449 view_->InitAsChild(parent_view_->GetNativeView());
4450
4451 ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod();
4452 int keyboard_height = 200;
4453 gfx::Rect root_bounds = root_window->bounds();
4454 gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200);
4455 gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200);
4456 gfx::Rect keyboard_view_bounds =
4457 gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(),
4458 keyboard_height);
4459
4460 // Focus the window.
4461 view_->SetBounds(orig_view_bounds);
4462 input_method->SetFocusedTextInputClient(view_);
4463 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
4464
4465 // Simulate virtual keyboard.
4466 input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds);
4467
4468 // Window should be shifted.
4469 EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds);
4470
4471 // Detach the RenderWidgetHostViewAura from the IME.
4472 view_->DetachFromInputMethod();
4473
4474 // Window should be restored.
4475 EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
4476
4477 aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
4478 nullptr);
4479 }
4480 #endif // defined(OS_CHROMEOS)
4481
4423 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted 4482 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted
4424 // before RWH), we clean up properly and don't leak the RWHVGuest. 4483 // before RWH), we clean up properly and don't leak the RWHVGuest.
4425 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { 4484 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) {
4426 view_->InitAsChild(nullptr); 4485 view_->InitAsChild(nullptr);
4427 TearDownEnvironment(); 4486 TearDownEnvironment();
4428 ASSERT_FALSE(guest_view_weak_.get()); 4487 ASSERT_FALSE(guest_view_weak_.get());
4429 } 4488 }
4430 4489
4431 // Tests that invalid touch events are consumed and handled 4490 // Tests that invalid touch events are consumed and handled
4432 // synchronously. 4491 // synchronously.
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 // There is no composition in the beginning. 5284 // There is no composition in the beginning.
5226 EXPECT_FALSE(has_composition_text()); 5285 EXPECT_FALSE(has_composition_text());
5227 SetHasCompositionTextToTrue(); 5286 SetHasCompositionTextToTrue();
5228 view->ImeCancelComposition(); 5287 view->ImeCancelComposition();
5229 // The composition must have been canceled. 5288 // The composition must have been canceled.
5230 EXPECT_FALSE(has_composition_text()); 5289 EXPECT_FALSE(has_composition_text());
5231 } 5290 }
5232 } 5291 }
5233 5292
5234 } // namespace content 5293 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698