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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 int call_count_; | 96 int call_count_; |
97 bool is_fullscreen_; | 97 bool is_fullscreen_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); | 99 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); |
100 }; | 100 }; |
101 | 101 |
102 display::Display GetDisplayNearestWindow(aura::Window* window) { | 102 display::Display GetDisplayNearestWindow(aura::Window* window) { |
103 return display::Screen::GetScreen()->GetDisplayNearestWindow(window); | 103 return display::Screen::GetScreen()->GetDisplayNearestWindow(window); |
104 } | 104 } |
105 | 105 |
| 106 void DisableNewVKMode() { |
| 107 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 108 command_line->AppendSwitch(::switches::kDisableNewVirtualKeyboardBehavior); |
| 109 } |
| 110 |
106 } // namespace | 111 } // namespace |
107 | 112 |
108 using WorkspaceLayoutManagerTest = test::AshTestBase; | 113 using WorkspaceLayoutManagerTest = test::AshTestBase; |
109 | 114 |
110 // Verifies that a window containing a restore coordinate will be restored to | 115 // Verifies that a window containing a restore coordinate will be restored to |
111 // to the size prior to minimize, keeping the restore rectangle in tact (if | 116 // to the size prior to minimize, keeping the restore rectangle in tact (if |
112 // there is one). | 117 // there is one). |
113 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { | 118 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { |
114 // See comment at top of file for why this is needed. | 119 // See comment at top of file for why this is needed. |
115 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; | 120 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 | 1154 |
1150 // Initializes the keyboard bounds using the bottom half of the work area. | 1155 // Initializes the keyboard bounds using the bottom half of the work area. |
1151 void InitKeyboardBounds() { | 1156 void InitKeyboardBounds() { |
1152 gfx::Rect work_area( | 1157 gfx::Rect work_area( |
1153 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1158 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1154 keyboard_bounds_.SetRect(work_area.x(), | 1159 keyboard_bounds_.SetRect(work_area.x(), |
1155 work_area.y() + work_area.height() / 2, | 1160 work_area.y() + work_area.height() / 2, |
1156 work_area.width(), work_area.height() / 2); | 1161 work_area.width(), work_area.height() / 2); |
1157 } | 1162 } |
1158 | 1163 |
1159 void EnableNewVKMode() { | |
1160 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
1161 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) | |
1162 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); | |
1163 } | |
1164 | |
1165 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } | 1164 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } |
1166 | 1165 |
1167 private: | 1166 private: |
1168 gfx::Insets restore_work_area_insets_; | 1167 gfx::Insets restore_work_area_insets_; |
1169 gfx::Rect keyboard_bounds_; | 1168 gfx::Rect keyboard_bounds_; |
1170 WorkspaceLayoutManager* layout_manager_; | 1169 WorkspaceLayoutManager* layout_manager_; |
1171 | 1170 |
1172 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); | 1171 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); |
1173 }; | 1172 }; |
1174 | 1173 |
1175 // Tests that when a child window gains focus the top level window containing it | 1174 // Tests that when a child window gains focus the top level window containing it |
1176 // is resized to fit the remaining workspace area. | 1175 // is resized to fit the remaining workspace area. |
1177 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { | 1176 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { |
| 1177 // Append the flag to cause work area change in non-sticky mode. |
| 1178 DisableNewVKMode(); |
| 1179 |
1178 // See comment at top of file for why this is needed. | 1180 // See comment at top of file for why this is needed. |
1179 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; | 1181 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; |
1180 | 1182 |
1181 InitKeyboardBounds(); | 1183 InitKeyboardBounds(); |
1182 | 1184 |
1183 gfx::Rect work_area( | 1185 gfx::Rect work_area( |
1184 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1186 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1185 | 1187 |
1186 std::unique_ptr<aura::Window> parent_window( | 1188 std::unique_ptr<aura::Window> parent_window( |
1187 CreateToplevelTestWindow(work_area)); | 1189 CreateToplevelTestWindow(work_area)); |
(...skipping 12 matching lines...) Expand all Loading... |
1200 parent_window->bounds().ToString()); | 1202 parent_window->bounds().ToString()); |
1201 ShowKeyboard(); | 1203 ShowKeyboard(); |
1202 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), | 1204 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), |
1203 parent_window->bounds().ToString()); | 1205 parent_window->bounds().ToString()); |
1204 HideKeyboard(); | 1206 HideKeyboard(); |
1205 EXPECT_EQ(initial_window_bounds.ToString(), | 1207 EXPECT_EQ(initial_window_bounds.ToString(), |
1206 parent_window->bounds().ToString()); | 1208 parent_window->bounds().ToString()); |
1207 } | 1209 } |
1208 | 1210 |
1209 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { | 1211 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { |
| 1212 // Append the flag to cause work area change in non-sticky mode. |
| 1213 DisableNewVKMode(); |
| 1214 |
1210 // See comment at top of file for why this is needed. | 1215 // See comment at top of file for why this is needed. |
1211 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; | 1216 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; |
1212 InitKeyboardBounds(); | 1217 InitKeyboardBounds(); |
1213 gfx::Rect work_area( | 1218 gfx::Rect work_area( |
1214 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1219 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1215 | 1220 |
1216 std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area)); | 1221 std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area)); |
1217 // The additional SetBounds() is needed as the aura-mus case uses Widget, | 1222 // The additional SetBounds() is needed as the aura-mus case uses Widget, |
1218 // which alters the supplied bounds. | 1223 // which alters the supplied bounds. |
1219 window->SetBounds(work_area); | 1224 window->SetBounds(work_area); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 EXPECT_EQ( | 1257 EXPECT_EQ( |
1253 gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2, | 1258 gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2, |
1254 occluded_window_bounds.width(), occluded_window_bounds.height()) | 1259 occluded_window_bounds.width(), occluded_window_bounds.height()) |
1255 .ToString(), | 1260 .ToString(), |
1256 window->bounds().ToString()); | 1261 window->bounds().ToString()); |
1257 HideKeyboard(); | 1262 HideKeyboard(); |
1258 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1263 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
1259 } | 1264 } |
1260 | 1265 |
1261 TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) { | 1266 TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) { |
| 1267 // Append the flag to cause work area change in non-sticky mode. |
| 1268 DisableNewVKMode(); |
1262 InitKeyboardBounds(); | 1269 InitKeyboardBounds(); |
1263 | 1270 |
1264 std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds())); | 1271 std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds())); |
1265 // The additional SetBounds() is needed as the aura-mus case uses Widget, | 1272 // The additional SetBounds() is needed as the aura-mus case uses Widget, |
1266 // which alters the supplied bounds. | 1273 // which alters the supplied bounds. |
1267 window->SetBounds(keyboard_bounds()); | 1274 window->SetBounds(keyboard_bounds()); |
1268 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); | 1275 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); |
1269 wm::ActivateWindow(window.get()); | 1276 wm::ActivateWindow(window.get()); |
1270 | 1277 |
1271 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1278 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
1272 ShowKeyboard(); | 1279 ShowKeyboard(); |
1273 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1280 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
1274 } | 1281 } |
1275 | 1282 |
1276 } // namespace ash | 1283 } // namespace ash |
OLD | NEW |