| 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 71d3ad8ca556465e47b116b7506401dc885914d7..893f62a3de8f2629003b2de668d86047613226e5 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_node_data.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"
|
| @@ -48,6 +49,7 @@
|
| #include "ui/views/test/views_test_base.h"
|
| #include "ui/views/test/widget_test.h"
|
| #include "ui/views/widget/widget.h"
|
| +#include "ui/wm/core/ime_util.h"
|
| #include "url/gurl.h"
|
|
|
| #if defined(OS_WIN)
|
| @@ -2947,6 +2949,48 @@ TEST_F(TextfieldTest, CursorBlinkRestartsOnInsertOrReplace) {
|
| EXPECT_TRUE(test_api_->IsCursorBlinkTimerRunning());
|
| }
|
|
|
| +#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(TextfieldTest, VirtualKeyboardFocusEnsureCaretNotInRect) {
|
| + 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 orig_widget_bounds = gfx::Rect(0, 300, 400, 200);
|
| + gfx::Rect shifted_widget_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.
|
| + widget_->SetBounds(orig_widget_bounds);
|
| + input_method_->SetFocusedTextInputClient(textfield_);
|
| + EXPECT_EQ(widget_->GetNativeView()->bounds(), orig_widget_bounds);
|
| +
|
| + // Simulate virtual keyboard.
|
| + input_method_->SetOnScreenKeyboardBounds(keyboard_view_bounds);
|
| +
|
| + // Window should be shifted.
|
| + EXPECT_EQ(widget_->GetNativeView()->bounds(), shifted_widget_bounds);
|
| +
|
| + // Detach the textfield from the IME
|
| + input_method_->DetachTextInputClient(textfield_);
|
| + wm::RestoreWindowBoundsOnClientFocusLost(
|
| + widget_->GetNativeView()->GetToplevelWindow());
|
| +
|
| + // Window should be restored.
|
| + EXPECT_EQ(widget_->GetNativeView()->bounds(), orig_widget_bounds);
|
| +}
|
| +#endif // defined(OS_CHROMEOS)
|
| +
|
| class TextfieldTouchSelectionTest : public TextfieldTest {
|
| protected:
|
| // Simulates a complete tap.
|
|
|