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

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

Issue 2180603002: Virtual keyboard - do not change work area of screen if in non-sticky mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Virtual keyboard - do not change work area of screen if in non-sticky mode Created 4 years, 4 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
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/common/wm/workspace/workspace_layout_manager.h" 5 #include "ash/common/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/aura/wm_window_aura.h" 10 #include "ash/aura/wm_window_aura.h"
11 #include "ash/common/ash_switches.h"
11 #include "ash/common/session/session_state_delegate.h" 12 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/shelf/shelf_constants.h" 13 #include "ash/common/shelf/shelf_constants.h"
13 #include "ash/common/shell_observer.h" 14 #include "ash/common/shell_observer.h"
14 #include "ash/common/shell_window_ids.h" 15 #include "ash/common/shell_window_ids.h"
15 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" 16 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h"
16 #include "ash/common/wm/window_state.h" 17 #include "ash/common/wm/window_state.h"
17 #include "ash/common/wm/wm_event.h" 18 #include "ash/common/wm/wm_event.h"
18 #include "ash/common/wm/workspace/workspace_window_resizer.h" 19 #include "ash/common/wm/workspace/workspace_window_resizer.h"
19 #include "ash/common/wm_shell.h" 20 #include "ash/common/wm_shell.h"
20 #include "ash/display/display_manager.h" 21 #include "ash/display/display_manager.h"
21 #include "ash/root_window_controller.h" 22 #include "ash/root_window_controller.h"
22 #include "ash/screen_util.h" 23 #include "ash/screen_util.h"
23 #include "ash/shelf/shelf.h" 24 #include "ash/shelf/shelf.h"
24 #include "ash/shelf/shelf_layout_manager.h" 25 #include "ash/shelf/shelf_layout_manager.h"
25 #include "ash/shell.h" 26 #include "ash/shell.h"
26 #include "ash/test/ash_test_base.h" 27 #include "ash/test/ash_test_base.h"
27 #include "ash/test/display_manager_test_api.h" 28 #include "ash/test/display_manager_test_api.h"
28 #include "ash/wm/window_state_aura.h" 29 #include "ash/wm/window_state_aura.h"
29 #include "ash/wm/window_util.h" 30 #include "ash/wm/window_util.h"
31 #include "base/command_line.h"
30 #include "base/compiler_specific.h" 32 #include "base/compiler_specific.h"
31 #include "base/run_loop.h" 33 #include "base/run_loop.h"
32 #include "ui/aura/client/aura_constants.h" 34 #include "ui/aura/client/aura_constants.h"
33 #include "ui/aura/test/test_windows.h" 35 #include "ui/aura/test/test_windows.h"
34 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
35 #include "ui/aura/window_event_dispatcher.h" 37 #include "ui/aura/window_event_dispatcher.h"
36 #include "ui/base/ui_base_types.h" 38 #include "ui/base/ui_base_types.h"
37 #include "ui/display/manager/display_layout.h" 39 #include "ui/display/manager/display_layout.h"
38 #include "ui/display/screen.h" 40 #include "ui/display/screen.h"
39 #include "ui/gfx/geometry/insets.h" 41 #include "ui/gfx/geometry/insets.h"
42 #include "ui/keyboard/keyboard_controller.h"
43 #include "ui/keyboard/keyboard_ui.h"
44 #include "ui/keyboard/keyboard_util.h"
40 #include "ui/views/widget/widget.h" 45 #include "ui/views/widget/widget.h"
41 #include "ui/views/widget/widget_delegate.h" 46 #include "ui/views/widget/widget_delegate.h"
42 #include "ui/wm/core/window_util.h" 47 #include "ui/wm/core/window_util.h"
43 48
44 namespace ash { 49 namespace ash {
45 namespace { 50 namespace {
46 51
47 class MaximizeDelegateView : public views::WidgetDelegateView { 52 class MaximizeDelegateView : public views::WidgetDelegateView {
48 public: 53 public:
49 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) 54 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds)
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1094
1090 // Initializes the keyboard bounds using the bottom half of the work area. 1095 // Initializes the keyboard bounds using the bottom half of the work area.
1091 void InitKeyboardBounds() { 1096 void InitKeyboardBounds() {
1092 gfx::Rect work_area( 1097 gfx::Rect work_area(
1093 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1098 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1094 keyboard_bounds_.SetRect(work_area.x(), 1099 keyboard_bounds_.SetRect(work_area.x(),
1095 work_area.y() + work_area.height() / 2, 1100 work_area.y() + work_area.height() / 2,
1096 work_area.width(), work_area.height() / 2); 1101 work_area.width(), work_area.height() / 2);
1097 } 1102 }
1098 1103
1104 void EnableNewVKMode() {
1105 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
1106 if (!command_line->HasSwitch(switches::kAshUseNewVKWindowBehavior)) {
1107 command_line->AppendSwitch(switches::kAshUseNewVKWindowBehavior);
1108 }
1109 }
1110
1099 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } 1111 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; }
1100 1112
1101 private: 1113 private:
1102 gfx::Insets restore_work_area_insets_; 1114 gfx::Insets restore_work_area_insets_;
1103 gfx::Rect keyboard_bounds_; 1115 gfx::Rect keyboard_bounds_;
1104 WorkspaceLayoutManager* layout_manager_; 1116 WorkspaceLayoutManager* layout_manager_;
1105 1117
1106 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); 1118 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest);
1107 }; 1119 };
1108 1120
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 std::unique_ptr<aura::Window> window( 1208 std::unique_ptr<aura::Window> window(
1197 CreateTestWindowInShellWithDelegate(&delegate2, -1, keyboard_bounds())); 1209 CreateTestWindowInShellWithDelegate(&delegate2, -1, keyboard_bounds()));
1198 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); 1210 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true);
1199 wm::ActivateWindow(window.get()); 1211 wm::ActivateWindow(window.get());
1200 1212
1201 EXPECT_EQ(keyboard_bounds(), window->bounds()); 1213 EXPECT_EQ(keyboard_bounds(), window->bounds());
1202 ShowKeyboard(); 1214 ShowKeyboard();
1203 EXPECT_EQ(keyboard_bounds(), window->bounds()); 1215 EXPECT_EQ(keyboard_bounds(), window->bounds());
1204 } 1216 }
1205 1217
1218 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChangeWorkAreaInNonStickyMode) {
1219 keyboard::SetAccessibilityKeyboardEnabled(true);
1220 InitKeyboardBounds();
1221 Shell::GetInstance()->CreateKeyboard();
1222 keyboard::KeyboardController* kb_controller =
1223 keyboard::KeyboardController::GetInstance();
1224
1225 gfx::Rect work_area(
1226 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1227
1228 aura::test::TestWindowDelegate delegate;
1229 gfx::Rect orig_window_bounds(0, 100, work_area.width(),
1230 work_area.height() - 100);
1231 std::unique_ptr<aura::Window> window(
1232 CreateTestWindowInShellWithDelegate(&delegate, -1, orig_window_bounds));
1233
1234 wm::ActivateWindow(window.get());
1235 EXPECT_EQ(orig_window_bounds, window->bounds());
1236
1237 // Open keyboard in non-sticky mode.
1238 kb_controller->ShowKeyboard(false);
1239 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
1240 keyboard::FullWidthKeyboardBoundsFromRootBounds(
1241 Shell::GetPrimaryRootWindow()->bounds(), 100));
1242
1243 int shift =
1244 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
1245 gfx::Rect changed_window_bounds(orig_window_bounds);
1246 changed_window_bounds.Offset(0, -shift);
1247 // Window should be shifted up.
1248 EXPECT_EQ(changed_window_bounds, window->bounds());
1249
1250 kb_controller->HideKeyboard(
1251 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1252 EXPECT_EQ(orig_window_bounds, window->bounds());
1253
1254 // Open keyboard in sticky mode.
1255 kb_controller->ShowKeyboard(true);
1256
1257 // Window should be shifted up.
1258 EXPECT_EQ(changed_window_bounds, window->bounds());
1259
1260 kb_controller->HideKeyboard(
1261 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1262 EXPECT_EQ(orig_window_bounds, window->bounds());
1263 }
1264
1265 // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility
1266 // keyboard work area in non-sticky mode.
1267 TEST_F(WorkspaceLayoutManagerKeyboardTest,
1268 IgnoreWorkAreaChangeinNonStickyMode) {
1269 // Append flag to ignore work area change in non-sticky mode.
1270 EnableNewVKMode();
1271
1272 keyboard::SetAccessibilityKeyboardEnabled(true);
1273 InitKeyboardBounds();
1274 Shell::GetInstance()->CreateKeyboard();
1275 keyboard::KeyboardController* kb_controller =
1276 keyboard::KeyboardController::GetInstance();
1277
1278 gfx::Rect work_area(
1279 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1280
1281 aura::test::TestWindowDelegate delegate;
1282 gfx::Rect orig_window_bounds(0, 100, work_area.width(),
1283 work_area.height() - 100);
1284 std::unique_ptr<aura::Window> window(
1285 CreateTestWindowInShellWithDelegate(&delegate, -1, orig_window_bounds));
1286
1287 wm::ActivateWindow(window.get());
1288 EXPECT_EQ(orig_window_bounds, window->bounds());
1289
1290 // Open keyboard in non-sticky mode.
1291 kb_controller->ShowKeyboard(false);
1292 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
1293 keyboard::FullWidthKeyboardBoundsFromRootBounds(
1294 Shell::GetPrimaryRootWindow()->bounds(), 100));
1295
1296 // Window should not be shifted up.
1297 EXPECT_EQ(orig_window_bounds, window->bounds());
1298
1299 kb_controller->HideKeyboard(
1300 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1301 EXPECT_EQ(orig_window_bounds, window->bounds());
1302
1303 // Open keyboard in sticky mode.
1304 kb_controller->ShowKeyboard(true);
1305
1306 int shift =
1307 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
1308 gfx::Rect changed_window_bounds(orig_window_bounds);
1309 changed_window_bounds.Offset(0, -shift);
1310 // Window should be shifted up.
1311 EXPECT_EQ(changed_window_bounds, window->bounds());
1312
1313 kb_controller->HideKeyboard(
1314 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1315 EXPECT_EQ(orig_window_bounds, window->bounds());
1316 }
1317
1206 } // namespace ash 1318 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/workspace/workspace_layout_manager.cc ('k') | chrome/browser/chromeos/login/chrome_restart_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698