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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager_unittest.cc

Issue 313463002: Prevent a11y on-screen keyboard from occluding active text field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add early return. Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.cc ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/display/display_layout.h" 7 #include "ash/display/display_layout.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
11 #include "ash/session/session_state_delegate.h" 11 #include "ash/session/session_state_delegate.h"
12 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_observer.h" 14 #include "ash/shell_observer.h"
15 #include "ash/shell_window_ids.h" 15 #include "ash/shell_window_ids.h"
16 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
17 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" 17 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h"
18 #include "ash/wm/window_state.h" 18 #include "ash/wm/window_state.h"
19 #include "ash/wm/window_util.h" 19 #include "ash/wm/window_util.h"
20 #include "ash/wm/wm_event.h" 20 #include "ash/wm/wm_event.h"
21 #include "ash/wm/workspace/workspace_window_resizer.h" 21 #include "ash/wm/workspace/workspace_window_resizer.h"
22 #include "base/basictypes.h" 22 #include "base/basictypes.h"
23 #include "base/compiler_specific.h" 23 #include "base/compiler_specific.h"
24 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/test/test_windows.h" 25 #include "ui/aura/test/test_windows.h"
26 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
27 #include "ui/aura/window_event_dispatcher.h" 27 #include "ui/aura/window_event_dispatcher.h"
28 #include "ui/base/ime/dummy_text_input_client.h"
29 #include "ui/base/ime/input_method.h"
28 #include "ui/base/ui_base_types.h" 30 #include "ui/base/ui_base_types.h"
29 #include "ui/gfx/insets.h" 31 #include "ui/gfx/insets.h"
30 #include "ui/gfx/screen.h" 32 #include "ui/gfx/screen.h"
31 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
32 #include "ui/views/widget/widget_delegate.h" 34 #include "ui/views/widget/widget_delegate.h"
33 #include "ui/wm/core/window_util.h" 35 #include "ui/wm/core/window_util.h"
34 36
35 namespace ash { 37 namespace ash {
36 namespace { 38 namespace {
37 39
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 window3.reset(); 935 window3.reset();
934 EXPECT_EQ("b,x", 936 EXPECT_EQ("b,x",
935 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 937 GetWindowOrderAsString(backdrop, window1.get(), window2.get(),
936 window3.get())); 938 window3.get()));
937 ShowTopWindowBackdrop(false); 939 ShowTopWindowBackdrop(false);
938 EXPECT_EQ("b", 940 EXPECT_EQ("b",
939 GetWindowOrderAsString(NULL, window1.get(), window2.get(), 941 GetWindowOrderAsString(NULL, window1.get(), window2.get(),
940 window3.get())); 942 window3.get()));
941 } 943 }
942 944
945 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase {
946 public:
947 WorkspaceLayoutManagerKeyboardTest() {}
948 virtual ~WorkspaceLayoutManagerKeyboardTest() {}
949
950 virtual void SetUp() OVERRIDE {
951 test::AshTestBase::SetUp();
952 UpdateDisplay("800x600");
953 aura::Window* default_container = Shell::GetContainer(
954 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer);
955 layout_manager_ = new WorkspaceLayoutManager(Shell::GetPrimaryRootWindow());
956 default_container->SetLayoutManager(layout_manager_);
957 }
958
959 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
960 return CreateTestWindowInShellWithBounds(bounds);
961 }
962
963 void ShowKeyboard() {
964 restore_work_area_insets_ = Shell::GetScreen()->GetPrimaryDisplay().
965 GetWorkAreaInsets();
966 Shell::GetInstance()->SetDisplayWorkAreaInsets(
967 Shell::GetPrimaryRootWindow(),
968 gfx::Insets(0, 0, keyboard_bounds_.height(), 0));
969 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_);
970 }
971
972 void HideKeyboard() {
973 Shell::GetInstance()->SetDisplayWorkAreaInsets(
974 Shell::GetPrimaryRootWindow(),
975 restore_work_area_insets_);
976 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect());
977 }
978
979 void SetKeyboardBounds(const gfx::Rect& bounds) {
980 keyboard_bounds_ = bounds;
981 }
982
983 private:
984 gfx::Insets restore_work_area_insets_;
985 gfx::Rect keyboard_bounds_;
986 WorkspaceLayoutManager *layout_manager_;
987
988 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest);
989 };
990
991 class FakeTextInputClient : public ui::DummyTextInputClient {
992 public:
993 FakeTextInputClient(gfx::NativeWindow window) : window_(window) {}
994 virtual ~FakeTextInputClient() {}
995
996 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE {
997 return window_;
998 }
999
1000 private:
1001 gfx::NativeWindow window_;
1002
1003 DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient);
1004 };
1005
1006 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
1007 gfx::Rect work_area(
1008 Shell::GetScreen()->GetPrimaryDisplay().work_area());
1009 gfx::Rect keyboard_bounds(work_area.x(),
1010 work_area.y() + work_area.height() / 2,
1011 work_area.width(),
1012 work_area.height() / 2);
1013
1014 SetKeyboardBounds(keyboard_bounds);
1015 scoped_ptr<aura::Window> window(
1016 CreateTestWindowInShellWithBounds(work_area));
1017
1018 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow();
1019 FakeTextInputClient text_input_client(window.get());
1020 ui::InputMethod* input_method =
1021 root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
1022 input_method->SetFocusedTextInputClient(&text_input_client);
1023
1024 int available_height =
1025 Shell::GetScreen()->GetPrimaryDisplay().bounds().height() -
1026 keyboard_bounds.height();
1027
1028 EXPECT_EQ(gfx::Rect(work_area).ToString(),
1029 window->bounds().ToString());
1030 ShowKeyboard();
1031 EXPECT_EQ(gfx::Rect(work_area.origin(),
1032 gfx::Size(work_area.width(), available_height)).ToString(),
1033 window->bounds().ToString());
1034 HideKeyboard();
1035
1036 window->SetBounds(gfx::Rect(50, 50, 100, 500));
1037 EXPECT_EQ("50,50 100x500", window->bounds().ToString());
1038 ShowKeyboard();
1039 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
1040 window->bounds().ToString());
1041 HideKeyboard();
1042 input_method->SetFocusedTextInputClient(NULL);
1043 }
1044
943 } // namespace ash 1045 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.cc ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698