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

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

Issue 2871243003: Enable new-virtual-keyboard-behavior flag by default. (Closed)
Patch Set: keep sorted the declarations Created 3 years, 7 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/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/accessibility_delegate.h" 10 #include "ash/accessibility_delegate.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 int call_count_; 109 int call_count_;
110 bool is_fullscreen_; 110 bool is_fullscreen_;
111 111
112 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); 112 DISALLOW_COPY_AND_ASSIGN(TestShellObserver);
113 }; 113 };
114 114
115 display::Display GetDisplayNearestWindow(aura::Window* window) { 115 display::Display GetDisplayNearestWindow(aura::Window* window) {
116 return display::Screen::GetScreen()->GetDisplayNearestWindow(window); 116 return display::Screen::GetScreen()->GetDisplayNearestWindow(window);
117 } 117 }
118 118
119 void DisableNewVKMode() {
120 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
121 command_line->AppendSwitch(::switches::kDisableNewVirtualKeyboardBehavior);
122 }
123
119 } // namespace 124 } // namespace
120 125
121 using WorkspaceLayoutManagerTest = test::AshTestBase; 126 using WorkspaceLayoutManagerTest = test::AshTestBase;
122 127
123 // Verifies that a window containing a restore coordinate will be restored to 128 // Verifies that a window containing a restore coordinate will be restored to
124 // to the size prior to minimize, keeping the restore rectangle in tact (if 129 // to the size prior to minimize, keeping the restore rectangle in tact (if
125 // there is one). 130 // there is one).
126 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { 131 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
127 // See comment at top of file for why this is needed. 132 // See comment at top of file for why this is needed.
128 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; 133 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 1402
1398 // Initializes the keyboard bounds using the bottom half of the work area. 1403 // Initializes the keyboard bounds using the bottom half of the work area.
1399 void InitKeyboardBounds() { 1404 void InitKeyboardBounds() {
1400 gfx::Rect work_area( 1405 gfx::Rect work_area(
1401 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1406 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1402 keyboard_bounds_.SetRect(work_area.x(), 1407 keyboard_bounds_.SetRect(work_area.x(),
1403 work_area.y() + work_area.height() / 2, 1408 work_area.y() + work_area.height() / 2,
1404 work_area.width(), work_area.height() / 2); 1409 work_area.width(), work_area.height() / 2);
1405 } 1410 }
1406 1411
1407 void EnableNewVKMode() {
1408 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
1409 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior))
1410 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
1411 }
1412
1413 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } 1412 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; }
1414 1413
1415 private: 1414 private:
1416 gfx::Insets restore_work_area_insets_; 1415 gfx::Insets restore_work_area_insets_;
1417 gfx::Rect keyboard_bounds_; 1416 gfx::Rect keyboard_bounds_;
1418 WorkspaceLayoutManager* layout_manager_; 1417 WorkspaceLayoutManager* layout_manager_;
1419 1418
1420 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); 1419 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest);
1421 }; 1420 };
1422 1421
1423 // Tests that when a child window gains focus the top level window containing it 1422 // Tests that when a child window gains focus the top level window containing it
1424 // is resized to fit the remaining workspace area. 1423 // is resized to fit the remaining workspace area.
1425 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { 1424 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
1425 // Append the flag to cause work area change in non-sticky mode.
1426 DisableNewVKMode();
1427
1426 // See comment at top of file for why this is needed. 1428 // See comment at top of file for why this is needed.
1427 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; 1429 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
1428 1430
1429 InitKeyboardBounds(); 1431 InitKeyboardBounds();
1430 1432
1431 gfx::Rect work_area( 1433 gfx::Rect work_area(
1432 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1434 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1433 1435
1434 std::unique_ptr<aura::Window> parent_window( 1436 std::unique_ptr<aura::Window> parent_window(
1435 CreateToplevelTestWindow(work_area)); 1437 CreateToplevelTestWindow(work_area));
(...skipping 12 matching lines...) Expand all
1448 parent_window->bounds().ToString()); 1450 parent_window->bounds().ToString());
1449 ShowKeyboard(); 1451 ShowKeyboard();
1450 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), 1452 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
1451 parent_window->bounds().ToString()); 1453 parent_window->bounds().ToString());
1452 HideKeyboard(); 1454 HideKeyboard();
1453 EXPECT_EQ(initial_window_bounds.ToString(), 1455 EXPECT_EQ(initial_window_bounds.ToString(),
1454 parent_window->bounds().ToString()); 1456 parent_window->bounds().ToString());
1455 } 1457 }
1456 1458
1457 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { 1459 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
1460 // Append the flag to cause work area change in non-sticky mode.
1461 DisableNewVKMode();
1462
1458 // See comment at top of file for why this is needed. 1463 // See comment at top of file for why this is needed.
1459 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; 1464 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
1460 InitKeyboardBounds(); 1465 InitKeyboardBounds();
1461 gfx::Rect work_area( 1466 gfx::Rect work_area(
1462 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1467 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1463 1468
1464 std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area)); 1469 std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area));
1465 // The additional SetBounds() is needed as the aura-mus case uses Widget, 1470 // The additional SetBounds() is needed as the aura-mus case uses Widget,
1466 // which alters the supplied bounds. 1471 // which alters the supplied bounds.
1467 window->SetBounds(work_area); 1472 window->SetBounds(work_area);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 EXPECT_EQ( 1505 EXPECT_EQ(
1501 gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2, 1506 gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2,
1502 occluded_window_bounds.width(), occluded_window_bounds.height()) 1507 occluded_window_bounds.width(), occluded_window_bounds.height())
1503 .ToString(), 1508 .ToString(),
1504 window->bounds().ToString()); 1509 window->bounds().ToString());
1505 HideKeyboard(); 1510 HideKeyboard();
1506 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); 1511 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
1507 } 1512 }
1508 1513
1509 TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) { 1514 TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) {
1515 // Append the flag to cause work area change in non-sticky mode.
1516 DisableNewVKMode();
1510 InitKeyboardBounds(); 1517 InitKeyboardBounds();
1511 1518
1512 std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds())); 1519 std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds()));
1513 // The additional SetBounds() is needed as the aura-mus case uses Widget, 1520 // The additional SetBounds() is needed as the aura-mus case uses Widget,
1514 // which alters the supplied bounds. 1521 // which alters the supplied bounds.
1515 window->SetBounds(keyboard_bounds()); 1522 window->SetBounds(keyboard_bounds());
1516 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); 1523 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true);
1517 wm::ActivateWindow(window.get()); 1524 wm::ActivateWindow(window.get());
1518 1525
1519 EXPECT_EQ(keyboard_bounds(), window->bounds()); 1526 EXPECT_EQ(keyboard_bounds(), window->bounds());
1520 ShowKeyboard(); 1527 ShowKeyboard();
1521 EXPECT_EQ(keyboard_bounds(), window->bounds()); 1528 EXPECT_EQ(keyboard_bounds(), window->bounds());
1522 } 1529 }
1523 1530
1524 } // namespace ash 1531 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager_keyboard_unittest.cc ('k') | chrome/browser/about_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698