| Index: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
|
| index aea4d89025e6b06fc57be800cfeceb2ba60a7039..4f7c3ec7ad24472603e8dfc2cffcd5acfaf141ce 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
|
| @@ -83,6 +83,7 @@
|
| #include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/aura/window_observer.h"
|
| #include "ui/base/clipboard/clipboard.h"
|
| +#include "ui/base/ui_base_switches.h"
|
| #include "ui/base/ui_base_types.h"
|
| #include "ui/compositor/compositor.h"
|
| #include "ui/compositor/layer_tree_owner.h"
|
| @@ -102,6 +103,10 @@
|
| #include "ui/wm/core/default_screen_position_client.h"
|
| #include "ui/wm/core/window_util.h"
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +#include "ui/base/ime/input_method.h"
|
| +#endif
|
| +
|
| using testing::_;
|
|
|
| using blink::WebGestureEvent;
|
| @@ -496,6 +501,10 @@ class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
|
| std::unique_ptr<FakeRendererCompositorFrameSink>
|
| renderer_compositor_frame_sink_;
|
|
|
| + protected:
|
| + // In this unit test, |window_| is directly added to the root and is toplevel.
|
| + aura::Window* GetToplevelWindow() override { return window(); }
|
| +
|
| private:
|
| FakeDelegatedFrameHostClientAura* delegated_frame_host_client_;
|
| cc::mojom::MojoCompositorFrameSinkClientPtr
|
| @@ -4688,6 +4697,56 @@ TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) {
|
| EXPECT_EQ(4U, sink_->message_count());
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +// Check that when accessibility virtual keyboard is enabled, windows are
|
| +// shifted up when focused and restored when focus is lost.
|
| +TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) {
|
| + // TODO (oshima): Test that overscroll occurs.
|
| +
|
| + // Enable new virtual keyboard behavior.
|
| + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
| + if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) {
|
| + command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
|
| + }
|
| +
|
| + wm::DefaultScreenPositionClient screen_position_client;
|
| + aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
|
| + &screen_position_client);
|
| +
|
| + aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
|
| + view_->InitAsChild(parent_view_->GetNativeView());
|
| +
|
| + ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod();
|
| + int keyboard_height = 200;
|
| + gfx::Rect root_bounds = root_window->bounds();
|
| + gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200);
|
| + gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200);
|
| + gfx::Rect keyboard_view_bounds =
|
| + gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(),
|
| + keyboard_height);
|
| +
|
| + // Focus the window.
|
| + view_->SetBounds(orig_view_bounds);
|
| + input_method->SetFocusedTextInputClient(view_);
|
| + EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
|
| +
|
| + // Simulate virtual keyboard.
|
| + input_method->SetOnScreenKeyboardBounds(keyboard_view_bounds);
|
| +
|
| + // Window should be shifted.
|
| + EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds);
|
| +
|
| + // Detach the RenderWidgetHostViewAura from the IME.
|
| + view_->DetachFromInputMethod();
|
| +
|
| + // Window should be restored.
|
| + EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
|
| +
|
| + aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
|
| + nullptr);
|
| +}
|
| +#endif // defined(OS_CHROMEOS)
|
| +
|
| // Tests that when view initiated shutdown happens (i.e. RWHView is deleted
|
| // before RWH), we clean up properly and don't leak the RWHVGuest.
|
| TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) {
|
|
|