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

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

Issue 2402643004: Moves most of WorkspaceLayoutManagerTest into ash/common (Closed)
Patch Set: feedback Created 4 years, 2 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
« no previous file with comments | « ash/common/BUILD.gn ('k') | ash/mus/BUILD.gn » ('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/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"
11 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/shelf/shelf_constants.h" 11 #include "ash/common/shelf/shelf_constants.h"
13 #include "ash/common/shelf/shelf_layout_manager.h" 12 #include "ash/common/shelf/shelf_layout_manager.h"
14 #include "ash/common/shelf/wm_shelf.h" 13 #include "ash/common/shelf/wm_shelf.h"
15 #include "ash/common/shell_observer.h" 14 #include "ash/common/shell_observer.h"
16 #include "ash/common/shell_window_ids.h" 15 #include "ash/common/shell_window_ids.h"
17 #include "ash/common/test/ash_test.h" 16 #include "ash/common/test/ash_test.h"
18 #include "ash/common/test/test_session_state_delegate.h" 17 #include "ash/common/test/test_session_state_delegate.h"
19 #include "ash/common/wm/fullscreen_window_finder.h" 18 #include "ash/common/wm/fullscreen_window_finder.h"
20 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" 19 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h"
21 #include "ash/common/wm/window_state.h" 20 #include "ash/common/wm/window_state.h"
22 #include "ash/common/wm/wm_event.h" 21 #include "ash/common/wm/wm_event.h"
23 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
24 #include "ash/common/wm/workspace/workspace_window_resizer.h" 23 #include "ash/common/wm/workspace/workspace_window_resizer.h"
25 #include "ash/common/wm_lookup.h" 24 #include "ash/common/wm_lookup.h"
26 #include "ash/common/wm_root_window_controller.h" 25 #include "ash/common/wm_root_window_controller.h"
27 #include "ash/common/wm_shell.h" 26 #include "ash/common/wm_shell.h"
28 #include "ash/display/display_manager.h"
29 #include "ash/root_window_controller.h"
30 #include "ash/screen_util.h"
31 #include "ash/shell.h"
32 #include "ash/test/ash_test_base.h"
33 #include "ash/test/display_manager_test_api.h"
34 #include "ash/wm/window_state_aura.h"
35 #include "ash/wm/window_util.h"
36 #include "base/command_line.h" 27 #include "base/command_line.h"
37 #include "base/compiler_specific.h"
38 #include "base/run_loop.h" 28 #include "base/run_loop.h"
39 #include "ui/base/ui_base_switches.h" 29 #include "ui/base/ui_base_switches.h"
40 #include "ui/base/ui_base_types.h" 30 #include "ui/base/ui_base_types.h"
41 #include "ui/display/manager/display_layout.h" 31 #include "ui/display/display.h"
42 #include "ui/display/screen.h" 32 #include "ui/display/screen.h"
43 #include "ui/gfx/geometry/insets.h" 33 #include "ui/gfx/geometry/insets.h"
44 #include "ui/keyboard/keyboard_controller.h"
45 #include "ui/keyboard/keyboard_ui.h"
46 #include "ui/keyboard/keyboard_util.h"
47 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
48 #include "ui/views/widget/widget_delegate.h" 35 #include "ui/views/widget/widget_delegate.h"
49 #include "ui/wm/core/window_util.h"
50 36
51 namespace ash { 37 namespace ash {
52 namespace { 38 namespace {
53 39
54 class MaximizeDelegateView : public views::WidgetDelegateView { 40 class MaximizeDelegateView : public views::WidgetDelegateView {
55 public: 41 public:
56 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) 42 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds)
57 : initial_bounds_(initial_bounds) {} 43 : initial_bounds_(initial_bounds) {}
58 ~MaximizeDelegateView() override {} 44 ~MaximizeDelegateView() override {}
59 45
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 CreateTestWindow(keyboard_bounds())); 1208 CreateTestWindow(keyboard_bounds()));
1223 WmWindow* window = window_owner->window(); 1209 WmWindow* window = window_owner->window();
1224 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); 1210 window->GetWindowState()->set_ignore_keyboard_bounds_change(true);
1225 window->Activate(); 1211 window->Activate();
1226 1212
1227 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); 1213 EXPECT_EQ(keyboard_bounds(), window->GetBounds());
1228 ShowKeyboard(); 1214 ShowKeyboard();
1229 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); 1215 EXPECT_EQ(keyboard_bounds(), window->GetBounds());
1230 } 1216 }
1231 1217
1232 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChangeWorkAreaInNonStickyMode) {
1233 keyboard::SetAccessibilityKeyboardEnabled(true);
1234 InitKeyboardBounds();
1235 Shell::GetInstance()->CreateKeyboard();
1236 keyboard::KeyboardController* kb_controller =
1237 keyboard::KeyboardController::GetInstance();
1238
1239 gfx::Rect work_area(
1240 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1241
1242 gfx::Rect orig_window_bounds(0, 100, work_area.width(),
1243 work_area.height() - 100);
1244 std::unique_ptr<WindowOwner> window_owner(
1245 CreateToplevelTestWindow(orig_window_bounds));
1246 WmWindow* window = window_owner->window();
1247
1248 window->Activate();
1249 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1250
1251 // Open keyboard in non-sticky mode.
1252 kb_controller->ShowKeyboard(false);
1253 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
1254 keyboard::FullWidthKeyboardBoundsFromRootBounds(
1255 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
1256
1257 int shift =
1258 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
1259 gfx::Rect changed_window_bounds(orig_window_bounds);
1260 changed_window_bounds.Offset(0, -shift);
1261 // Window should be shifted up.
1262 EXPECT_EQ(changed_window_bounds, window->GetBounds());
1263
1264 kb_controller->HideKeyboard(
1265 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1266 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1267
1268 // Open keyboard in sticky mode.
1269 kb_controller->ShowKeyboard(true);
1270
1271 // Window should be shifted up.
1272 EXPECT_EQ(changed_window_bounds, window->GetBounds());
1273
1274 kb_controller->HideKeyboard(
1275 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1276 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1277 }
1278
1279 // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility
1280 // keyboard work area in non-sticky mode.
1281 TEST_F(WorkspaceLayoutManagerKeyboardTest,
1282 IgnoreWorkAreaChangeinNonStickyMode) {
1283 // Append flag to ignore work area change in non-sticky mode.
1284 EnableNewVKMode();
1285
1286 keyboard::SetAccessibilityKeyboardEnabled(true);
1287 InitKeyboardBounds();
1288 Shell::GetInstance()->CreateKeyboard();
1289 keyboard::KeyboardController* kb_controller =
1290 keyboard::KeyboardController::GetInstance();
1291
1292 gfx::Rect work_area(
1293 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1294
1295 gfx::Rect orig_window_bounds(0, 100, work_area.width(),
1296 work_area.height() - 100);
1297 std::unique_ptr<WindowOwner> window_owner(
1298 CreateToplevelTestWindow(orig_window_bounds));
1299 WmWindow* window = window_owner->window();
1300
1301 window->Activate();
1302 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1303
1304 // Open keyboard in non-sticky mode.
1305 kb_controller->ShowKeyboard(false);
1306 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
1307 keyboard::FullWidthKeyboardBoundsFromRootBounds(
1308 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
1309
1310 // Window should not be shifted up.
1311 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1312
1313 kb_controller->HideKeyboard(
1314 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1315 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1316
1317 // Open keyboard in sticky mode.
1318 kb_controller->ShowKeyboard(true);
1319
1320 int shift =
1321 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
1322 gfx::Rect changed_window_bounds(orig_window_bounds);
1323 changed_window_bounds.Offset(0, -shift);
1324 // Window should be shifted up.
1325 EXPECT_EQ(changed_window_bounds, window->GetBounds());
1326
1327 kb_controller->HideKeyboard(
1328 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
1329 EXPECT_EQ(orig_window_bounds, window->GetBounds());
1330 }
1331
1332 } // namespace ash 1218 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/BUILD.gn ('k') | ash/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698