| Index: ui/views/controls/textfield/textfield_unittest.cc
|
| diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
|
| index 027414eb85f3d82ef077ab7b6c5163fb7bcc2431..8db52dfe9d35b06c4372290ee730fc9fd38f7c4c 100644
|
| --- a/ui/views/controls/textfield/textfield_unittest.cc
|
| +++ b/ui/views/controls/textfield/textfield_unittest.cc
|
| @@ -21,6 +21,7 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "build/build_config.h"
|
| #include "ui/accessibility/ax_view_state.h"
|
| +#include "ui/aura/window.h"
|
| #include "ui/base/clipboard/clipboard.h"
|
| #include "ui/base/clipboard/scoped_clipboard_writer.h"
|
| #include "ui/base/dragdrop/drag_drop_types.h"
|
| @@ -2784,6 +2785,44 @@ TEST_F(TextfieldTest, DestroyingTextfieldFromOnKeyEvent) {
|
| EXPECT_FALSE(controller.target());
|
| }
|
|
|
| +// Check that when accessibility virtual keyboard is enabled, windows are
|
| +// shifted up when focused and restored when focus is lost.
|
| +TEST_F(TextfieldTest, VirtualKeyboardFocusEnsureCaretInRect) {
|
| + InitTextfield();
|
| +
|
| + // Enable new virtual keyboard behavior.
|
| + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
| + if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) {
|
| + command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
|
| + }
|
| +
|
| + aura::Window* root_window = widget_->GetNativeView()->GetRootWindow();
|
| + int keyboard_height = 200;
|
| + gfx::Rect root_bounds = root_window->bounds();
|
| + gfx::Rect root_bounds_with_keyboard = gfx::Rect(
|
| + root_bounds.origin(),
|
| + gfx::Size(root_bounds.width(), root_bounds.height() - keyboard_height));
|
| + gfx::Rect orig_widget_bounds = gfx::Rect(0, 300, 400, 200);
|
| + gfx::Rect shifted_widget_bounds = gfx::Rect(0, 200, 400, 200);
|
| +
|
| + // Focus the window.
|
| + widget_->SetBounds(orig_widget_bounds);
|
| + input_method_->SetFocusedTextInputClient(textfield_);
|
| + EXPECT_EQ(widget_->GetNativeView()->bounds(), orig_widget_bounds);
|
| +
|
| + // Simulate virtual keyboard.
|
| + input_method_->SetAvailableBounds(root_bounds_with_keyboard);
|
| +
|
| + // Window should be shifted.
|
| + EXPECT_EQ(widget_->GetNativeView()->bounds(), shifted_widget_bounds);
|
| +
|
| + // Change the focus.
|
| + input_method_->SetFocusedTextInputClient(nullptr);
|
| +
|
| + // Window should be restored.
|
| + EXPECT_EQ(widget_->GetNativeView()->bounds(), orig_widget_bounds);
|
| +}
|
| +
|
| class TextfieldTouchSelectionTest : public TextfieldTest {
|
| protected:
|
| // Simulates a complete tap.
|
|
|