OLD | NEW |
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/display/display_layout.h" | 9 #include "ash/display/display_layout.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); | 985 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); |
986 layout_manager_ = static_cast<WorkspaceLayoutManager*>( | 986 layout_manager_ = static_cast<WorkspaceLayoutManager*>( |
987 default_container->layout_manager()); | 987 default_container->layout_manager()); |
988 } | 988 } |
989 | 989 |
990 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 990 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
991 return CreateTestWindowInShellWithBounds(bounds); | 991 return CreateTestWindowInShellWithBounds(bounds); |
992 } | 992 } |
993 | 993 |
994 void ShowKeyboard() { | 994 void ShowKeyboard() { |
| 995 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); |
995 restore_work_area_insets_ = Shell::GetScreen()->GetPrimaryDisplay(). | 996 restore_work_area_insets_ = Shell::GetScreen()->GetPrimaryDisplay(). |
996 GetWorkAreaInsets(); | 997 GetWorkAreaInsets(); |
997 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 998 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
998 Shell::GetPrimaryRootWindow(), | 999 Shell::GetPrimaryRootWindow(), |
999 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); | 1000 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); |
1000 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); | |
1001 } | 1001 } |
1002 | 1002 |
1003 void HideKeyboard() { | 1003 void HideKeyboard() { |
1004 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 1004 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
1005 Shell::GetPrimaryRootWindow(), | 1005 Shell::GetPrimaryRootWindow(), |
1006 restore_work_area_insets_); | 1006 restore_work_area_insets_); |
1007 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); | 1007 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); |
1008 } | 1008 } |
1009 | 1009 |
1010 void SetKeyboardBounds(const gfx::Rect& bounds) { | 1010 void SetKeyboardBounds(const gfx::Rect& bounds) { |
(...skipping 25 matching lines...) Expand all Loading... |
1036 | 1036 |
1037 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { | 1037 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { |
1038 gfx::Rect work_area( | 1038 gfx::Rect work_area( |
1039 Shell::GetScreen()->GetPrimaryDisplay().work_area()); | 1039 Shell::GetScreen()->GetPrimaryDisplay().work_area()); |
1040 gfx::Rect keyboard_bounds(work_area.x(), | 1040 gfx::Rect keyboard_bounds(work_area.x(), |
1041 work_area.y() + work_area.height() / 2, | 1041 work_area.y() + work_area.height() / 2, |
1042 work_area.width(), | 1042 work_area.width(), |
1043 work_area.height() / 2); | 1043 work_area.height() / 2); |
1044 | 1044 |
1045 SetKeyboardBounds(keyboard_bounds); | 1045 SetKeyboardBounds(keyboard_bounds); |
1046 scoped_ptr<aura::Window> window( | 1046 |
1047 CreateTestWindowInShellWithBounds(work_area)); | 1047 aura::test::TestWindowDelegate delegate; |
| 1048 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| 1049 &delegate, -1, work_area)); |
1048 | 1050 |
1049 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | 1051 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
1050 FakeTextInputClient text_input_client(window.get()); | 1052 FakeTextInputClient text_input_client(window.get()); |
1051 ui::InputMethod* input_method = | 1053 ui::InputMethod* input_method = |
1052 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 1054 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
1053 if (switches::IsTextInputFocusManagerEnabled()) { | 1055 if (switches::IsTextInputFocusManagerEnabled()) { |
1054 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient( | 1056 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient( |
1055 &text_input_client); | 1057 &text_input_client); |
1056 } else { | 1058 } else { |
1057 input_method->SetFocusedTextInputClient(&text_input_client); | 1059 input_method->SetFocusedTextInputClient(&text_input_client); |
1058 } | 1060 } |
1059 | 1061 |
1060 int available_height = | 1062 int available_height = |
1061 Shell::GetScreen()->GetPrimaryDisplay().bounds().height() - | 1063 Shell::GetScreen()->GetPrimaryDisplay().bounds().height() - |
1062 keyboard_bounds.height(); | 1064 keyboard_bounds.height(); |
1063 | 1065 |
1064 EXPECT_EQ(gfx::Rect(work_area).ToString(), | 1066 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); |
1065 window->bounds().ToString()); | |
1066 ShowKeyboard(); | 1067 ShowKeyboard(); |
1067 EXPECT_EQ(gfx::Rect(work_area.origin(), | 1068 EXPECT_EQ(gfx::Rect(work_area.origin(), |
1068 gfx::Size(work_area.width(), available_height)).ToString(), | 1069 gfx::Size(work_area.width(), available_height)).ToString(), |
1069 window->bounds().ToString()); | 1070 window->bounds().ToString()); |
1070 HideKeyboard(); | 1071 HideKeyboard(); |
| 1072 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); |
1071 | 1073 |
1072 window->SetBounds(gfx::Rect(50, 50, 100, 500)); | 1074 gfx::Rect small_window_bound(50, 50, 100, 500); |
1073 EXPECT_EQ("50,50 100x500", window->bounds().ToString()); | 1075 window->SetBounds(small_window_bound); |
| 1076 EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString()); |
1074 ShowKeyboard(); | 1077 ShowKeyboard(); |
1075 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), | 1078 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), |
1076 window->bounds().ToString()); | 1079 window->bounds().ToString()); |
1077 HideKeyboard(); | 1080 HideKeyboard(); |
| 1081 EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString()); |
| 1082 |
1078 if (switches::IsTextInputFocusManagerEnabled()) { | 1083 if (switches::IsTextInputFocusManagerEnabled()) { |
1079 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( | 1084 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( |
1080 &text_input_client); | 1085 &text_input_client); |
1081 } else { | 1086 } else { |
1082 input_method->SetFocusedTextInputClient(NULL); | 1087 input_method->SetFocusedTextInputClient(NULL); |
1083 } | 1088 } |
1084 } | 1089 } |
1085 | 1090 |
1086 } // namespace ash | 1091 } // namespace ash |
OLD | NEW |