| 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/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ash/wm/window_state_aura.h" | 24 #include "ash/wm/window_state_aura.h" |
| 25 #include "ash/wm/window_util.h" | 25 #include "ash/wm/window_util.h" |
| 26 #include "ash/wm/workspace/workspace_window_resizer.h" | 26 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 27 #include "base/compiler_specific.h" | 27 #include "base/compiler_specific.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 28 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/test/test_windows.h" | 29 #include "ui/aura/test/test_windows.h" |
| 30 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/base/ui_base_types.h" | 32 #include "ui/base/ui_base_types.h" |
| 33 #include "ui/display/manager/display_layout.h" | 33 #include "ui/display/manager/display_layout.h" |
| 34 #include "ui/display/screen.h" |
| 34 #include "ui/gfx/geometry/insets.h" | 35 #include "ui/gfx/geometry/insets.h" |
| 35 #include "ui/gfx/screen.h" | |
| 36 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 37 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
| 38 #include "ui/wm/core/window_util.h" | 38 #include "ui/wm/core/window_util.h" |
| 39 | 39 |
| 40 namespace ash { | 40 namespace ash { |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 class MaximizeDelegateView : public views::WidgetDelegateView { | 43 class MaximizeDelegateView : public views::WidgetDelegateView { |
| 44 public: | 44 public: |
| 45 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) | 45 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 // bounds. | 381 // bounds. |
| 382 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { | 382 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { |
| 383 std::unique_ptr<aura::Window> window( | 383 std::unique_ptr<aura::Window> window( |
| 384 aura::test::CreateTestWindowWithBounds(gfx::Rect(0, 0, 0, 0), nullptr)); | 384 aura::test::CreateTestWindowWithBounds(gfx::Rect(0, 0, 0, 0), nullptr)); |
| 385 wm::GetWindowState(window.get())->Maximize(); | 385 wm::GetWindowState(window.get())->Maximize(); |
| 386 aura::Window* default_container = Shell::GetContainer( | 386 aura::Window* default_container = Shell::GetContainer( |
| 387 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); | 387 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); |
| 388 default_container->AddChild(window.get()); | 388 default_container->AddChild(window.get()); |
| 389 window->Show(); | 389 window->Show(); |
| 390 gfx::Rect work_area( | 390 gfx::Rect work_area( |
| 391 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 391 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 392 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 392 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { | 395 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { |
| 396 // Normal window bounds shouldn't be changed. | 396 // Normal window bounds shouldn't be changed. |
| 397 gfx::Rect window_bounds(100, 100, 200, 200); | 397 gfx::Rect window_bounds(100, 100, 200, 200); |
| 398 std::unique_ptr<aura::Window> window( | 398 std::unique_ptr<aura::Window> window( |
| 399 CreateTestWindowInShellWithBounds(window_bounds)); | 399 CreateTestWindowInShellWithBounds(window_bounds)); |
| 400 EXPECT_EQ(window_bounds, window->bounds()); | 400 EXPECT_EQ(window_bounds, window->bounds()); |
| 401 | 401 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 bounds = window_bigger_than_display->bounds(); | 456 bounds = window_bigger_than_display->bounds(); |
| 457 bounds.Intersect(root_window_bounds); | 457 bounds.Intersect(root_window_bounds); |
| 458 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); | 458 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); |
| 459 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); | 459 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); |
| 460 } | 460 } |
| 461 | 461 |
| 462 // Verifies the size of a window is enforced to be smaller than the work area. | 462 // Verifies the size of a window is enforced to be smaller than the work area. |
| 463 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) { | 463 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) { |
| 464 // Normal window bounds shouldn't be changed. | 464 // Normal window bounds shouldn't be changed. |
| 465 gfx::Size work_area( | 465 gfx::Size work_area( |
| 466 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); | 466 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); |
| 467 const gfx::Rect window_bounds( | 467 const gfx::Rect window_bounds( |
| 468 100, 101, work_area.width() + 1, work_area.height() + 2); | 468 100, 101, work_area.width() + 1, work_area.height() + 2); |
| 469 std::unique_ptr<aura::Window> window( | 469 std::unique_ptr<aura::Window> window( |
| 470 CreateTestWindowInShellWithBounds(window_bounds)); | 470 CreateTestWindowInShellWithBounds(window_bounds)); |
| 471 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 471 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 472 window->bounds().ToString()); | 472 window->bounds().ToString()); |
| 473 | 473 |
| 474 // Directly setting the bounds triggers a slightly different code path. Verify | 474 // Directly setting the bounds triggers a slightly different code path. Verify |
| 475 // that too. | 475 // that too. |
| 476 window->SetBounds(window_bounds); | 476 window->SetBounds(window_bounds); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 initial_work_area_bounds.ToString(), | 631 initial_work_area_bounds.ToString(), |
| 632 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString()); | 632 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString()); |
| 633 } | 633 } |
| 634 | 634 |
| 635 // Tests normal->fullscreen->normal. | 635 // Tests normal->fullscreen->normal. |
| 636 TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) { | 636 TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) { |
| 637 gfx::Rect bounds(100, 100, 200, 200); | 637 gfx::Rect bounds(100, 100, 200, 200); |
| 638 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 638 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 639 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 639 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 640 // Fullscreen window fills the whole display. | 640 // Fullscreen window fills the whole display. |
| 641 EXPECT_EQ(gfx::Screen::GetScreen() | 641 EXPECT_EQ(display::Screen::GetScreen() |
| 642 ->GetDisplayNearestWindow(window.get()) | 642 ->GetDisplayNearestWindow(window.get()) |
| 643 .bounds() | 643 .bounds() |
| 644 .ToString(), | 644 .ToString(), |
| 645 window->bounds().ToString()); | 645 window->bounds().ToString()); |
| 646 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 646 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 647 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 647 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
| 648 } | 648 } |
| 649 | 649 |
| 650 // Tests that fullscreen window causes always_on_top windows to stack below. | 650 // Tests that fullscreen window causes always_on_top windows to stack below. |
| 651 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) { | 651 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 674 EXPECT_EQ(nullptr, GetRootWindowController(fullscreen_window->GetRootWindow()) | 674 EXPECT_EQ(nullptr, GetRootWindowController(fullscreen_window->GetRootWindow()) |
| 675 ->GetWindowForFullscreenMode()); | 675 ->GetWindowForFullscreenMode()); |
| 676 } | 676 } |
| 677 | 677 |
| 678 // Tests fullscreen window size during root window resize. | 678 // Tests fullscreen window size during root window resize. |
| 679 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) { | 679 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) { |
| 680 gfx::Rect bounds(100, 100, 200, 200); | 680 gfx::Rect bounds(100, 100, 200, 200); |
| 681 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 681 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 682 // Fullscreen window fills the whole display. | 682 // Fullscreen window fills the whole display. |
| 683 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 683 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 684 EXPECT_EQ(gfx::Screen::GetScreen() | 684 EXPECT_EQ(display::Screen::GetScreen() |
| 685 ->GetDisplayNearestWindow(window.get()) | 685 ->GetDisplayNearestWindow(window.get()) |
| 686 .bounds() | 686 .bounds() |
| 687 .ToString(), | 687 .ToString(), |
| 688 window->bounds().ToString()); | 688 window->bounds().ToString()); |
| 689 // Enlarge the root window. We should still match the display size. | 689 // Enlarge the root window. We should still match the display size. |
| 690 UpdateDisplay("800x600"); | 690 UpdateDisplay("800x600"); |
| 691 EXPECT_EQ(gfx::Screen::GetScreen() | 691 EXPECT_EQ(display::Screen::GetScreen() |
| 692 ->GetDisplayNearestWindow(window.get()) | 692 ->GetDisplayNearestWindow(window.get()) |
| 693 .bounds() | 693 .bounds() |
| 694 .ToString(), | 694 .ToString(), |
| 695 window->bounds().ToString()); | 695 window->bounds().ToString()); |
| 696 } | 696 } |
| 697 | 697 |
| 698 // Tests that when the screen gets smaller the windows aren't bigger than | 698 // Tests that when the screen gets smaller the windows aren't bigger than |
| 699 // the screen. | 699 // the screen. |
| 700 TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) { | 700 TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) { |
| 701 std::unique_ptr<aura::Window> window( | 701 std::unique_ptr<aura::Window> window( |
| 702 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); | 702 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); |
| 703 gfx::Rect work_area = gfx::Screen::GetScreen() | 703 gfx::Rect work_area = display::Screen::GetScreen() |
| 704 ->GetDisplayNearestWindow(window.get()) | 704 ->GetDisplayNearestWindow(window.get()) |
| 705 .work_area(); | 705 .work_area(); |
| 706 // Invariant: Window is smaller than work area. | 706 // Invariant: Window is smaller than work area. |
| 707 EXPECT_LE(window->bounds().width(), work_area.width()); | 707 EXPECT_LE(window->bounds().width(), work_area.width()); |
| 708 EXPECT_LE(window->bounds().height(), work_area.height()); | 708 EXPECT_LE(window->bounds().height(), work_area.height()); |
| 709 | 709 |
| 710 // Make the root window narrower than our window. | 710 // Make the root window narrower than our window. |
| 711 UpdateDisplay("300x400"); | 711 UpdateDisplay("300x400"); |
| 712 work_area = gfx::Screen::GetScreen() | 712 work_area = display::Screen::GetScreen() |
| 713 ->GetDisplayNearestWindow(window.get()) | 713 ->GetDisplayNearestWindow(window.get()) |
| 714 .work_area(); | 714 .work_area(); |
| 715 EXPECT_LE(window->bounds().width(), work_area.width()); | 715 EXPECT_LE(window->bounds().width(), work_area.width()); |
| 716 EXPECT_LE(window->bounds().height(), work_area.height()); | 716 EXPECT_LE(window->bounds().height(), work_area.height()); |
| 717 | 717 |
| 718 // Make the root window shorter than our window. | 718 // Make the root window shorter than our window. |
| 719 UpdateDisplay("300x200"); | 719 UpdateDisplay("300x200"); |
| 720 work_area = gfx::Screen::GetScreen() | 720 work_area = display::Screen::GetScreen() |
| 721 ->GetDisplayNearestWindow(window.get()) | 721 ->GetDisplayNearestWindow(window.get()) |
| 722 .work_area(); | 722 .work_area(); |
| 723 EXPECT_LE(window->bounds().width(), work_area.width()); | 723 EXPECT_LE(window->bounds().width(), work_area.width()); |
| 724 EXPECT_LE(window->bounds().height(), work_area.height()); | 724 EXPECT_LE(window->bounds().height(), work_area.height()); |
| 725 | 725 |
| 726 // Enlarging the root window does not change the window bounds. | 726 // Enlarging the root window does not change the window bounds. |
| 727 gfx::Rect old_bounds = window->bounds(); | 727 gfx::Rect old_bounds = window->bounds(); |
| 728 UpdateDisplay("800x600"); | 728 UpdateDisplay("800x600"); |
| 729 EXPECT_EQ(old_bounds.width(), window->bounds().width()); | 729 EXPECT_EQ(old_bounds.width(), window->bounds().width()); |
| 730 EXPECT_EQ(old_bounds.height(), window->bounds().height()); | 730 EXPECT_EQ(old_bounds.height(), window->bounds().height()); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 default_container->layout_manager()); | 1030 default_container->layout_manager()); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 1033 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
| 1034 return CreateTestWindowInShellWithBounds(bounds); | 1034 return CreateTestWindowInShellWithBounds(bounds); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 void ShowKeyboard() { | 1037 void ShowKeyboard() { |
| 1038 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); | 1038 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); |
| 1039 restore_work_area_insets_ = | 1039 restore_work_area_insets_ = |
| 1040 gfx::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); | 1040 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); |
| 1041 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 1041 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 1042 Shell::GetPrimaryRootWindow(), | 1042 Shell::GetPrimaryRootWindow(), |
| 1043 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); | 1043 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 void HideKeyboard() { | 1046 void HideKeyboard() { |
| 1047 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 1047 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 1048 Shell::GetPrimaryRootWindow(), | 1048 Shell::GetPrimaryRootWindow(), |
| 1049 restore_work_area_insets_); | 1049 restore_work_area_insets_); |
| 1050 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); | 1050 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 void SetKeyboardBounds(const gfx::Rect& bounds) { | 1053 void SetKeyboardBounds(const gfx::Rect& bounds) { |
| 1054 keyboard_bounds_ = bounds; | 1054 keyboard_bounds_ = bounds; |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 private: | 1057 private: |
| 1058 gfx::Insets restore_work_area_insets_; | 1058 gfx::Insets restore_work_area_insets_; |
| 1059 gfx::Rect keyboard_bounds_; | 1059 gfx::Rect keyboard_bounds_; |
| 1060 WorkspaceLayoutManager* layout_manager_; | 1060 WorkspaceLayoutManager* layout_manager_; |
| 1061 | 1061 |
| 1062 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); | 1062 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); |
| 1063 }; | 1063 }; |
| 1064 | 1064 |
| 1065 // Tests that when a child window gains focus the top level window containing it | 1065 // Tests that when a child window gains focus the top level window containing it |
| 1066 // is resized to fit the remaining workspace area. | 1066 // is resized to fit the remaining workspace area. |
| 1067 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { | 1067 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { |
| 1068 gfx::Rect work_area( | 1068 gfx::Rect work_area( |
| 1069 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1069 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1070 gfx::Rect keyboard_bounds(work_area.x(), | 1070 gfx::Rect keyboard_bounds(work_area.x(), |
| 1071 work_area.y() + work_area.height() / 2, | 1071 work_area.y() + work_area.height() / 2, |
| 1072 work_area.width(), | 1072 work_area.width(), |
| 1073 work_area.height() / 2); | 1073 work_area.height() / 2); |
| 1074 | 1074 |
| 1075 SetKeyboardBounds(keyboard_bounds); | 1075 SetKeyboardBounds(keyboard_bounds); |
| 1076 | 1076 |
| 1077 aura::test::TestWindowDelegate delegate1; | 1077 aura::test::TestWindowDelegate delegate1; |
| 1078 std::unique_ptr<aura::Window> parent_window( | 1078 std::unique_ptr<aura::Window> parent_window( |
| 1079 CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area)); | 1079 CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area)); |
| 1080 aura::test::TestWindowDelegate delegate2; | 1080 aura::test::TestWindowDelegate delegate2; |
| 1081 std::unique_ptr<aura::Window> window( | 1081 std::unique_ptr<aura::Window> window( |
| 1082 CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area)); | 1082 CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area)); |
| 1083 parent_window->AddChild(window.get()); | 1083 parent_window->AddChild(window.get()); |
| 1084 | 1084 |
| 1085 wm::ActivateWindow(window.get()); | 1085 wm::ActivateWindow(window.get()); |
| 1086 | 1086 |
| 1087 int available_height = | 1087 int available_height = |
| 1088 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - | 1088 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - |
| 1089 keyboard_bounds.height(); | 1089 keyboard_bounds.height(); |
| 1090 | 1090 |
| 1091 gfx::Rect initial_window_bounds(50, 50, 100, 500); | 1091 gfx::Rect initial_window_bounds(50, 50, 100, 500); |
| 1092 parent_window->SetBounds(initial_window_bounds); | 1092 parent_window->SetBounds(initial_window_bounds); |
| 1093 EXPECT_EQ(initial_window_bounds.ToString(), | 1093 EXPECT_EQ(initial_window_bounds.ToString(), |
| 1094 parent_window->bounds().ToString()); | 1094 parent_window->bounds().ToString()); |
| 1095 ShowKeyboard(); | 1095 ShowKeyboard(); |
| 1096 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), | 1096 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), |
| 1097 parent_window->bounds().ToString()); | 1097 parent_window->bounds().ToString()); |
| 1098 HideKeyboard(); | 1098 HideKeyboard(); |
| 1099 EXPECT_EQ(initial_window_bounds.ToString(), | 1099 EXPECT_EQ(initial_window_bounds.ToString(), |
| 1100 parent_window->bounds().ToString()); | 1100 parent_window->bounds().ToString()); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { | 1103 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { |
| 1104 gfx::Rect work_area( | 1104 gfx::Rect work_area( |
| 1105 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1105 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1106 gfx::Rect keyboard_bounds(work_area.x(), | 1106 gfx::Rect keyboard_bounds(work_area.x(), |
| 1107 work_area.y() + work_area.height() / 2, | 1107 work_area.y() + work_area.height() / 2, |
| 1108 work_area.width(), | 1108 work_area.width(), |
| 1109 work_area.height() / 2); | 1109 work_area.height() / 2); |
| 1110 | 1110 |
| 1111 SetKeyboardBounds(keyboard_bounds); | 1111 SetKeyboardBounds(keyboard_bounds); |
| 1112 | 1112 |
| 1113 aura::test::TestWindowDelegate delegate; | 1113 aura::test::TestWindowDelegate delegate; |
| 1114 std::unique_ptr<aura::Window> window( | 1114 std::unique_ptr<aura::Window> window( |
| 1115 CreateTestWindowInShellWithDelegate(&delegate, -1, work_area)); | 1115 CreateTestWindowInShellWithDelegate(&delegate, -1, work_area)); |
| 1116 | 1116 |
| 1117 int available_height = | 1117 int available_height = |
| 1118 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - | 1118 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - |
| 1119 keyboard_bounds.height(); | 1119 keyboard_bounds.height(); |
| 1120 | 1120 |
| 1121 wm::ActivateWindow(window.get()); | 1121 wm::ActivateWindow(window.get()); |
| 1122 | 1122 |
| 1123 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); | 1123 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); |
| 1124 ShowKeyboard(); | 1124 ShowKeyboard(); |
| 1125 EXPECT_EQ(gfx::Rect(work_area.origin(), | 1125 EXPECT_EQ(gfx::Rect(work_area.origin(), |
| 1126 gfx::Size(work_area.width(), available_height)).ToString(), | 1126 gfx::Size(work_area.width(), available_height)).ToString(), |
| 1127 window->bounds().ToString()); | 1127 window->bounds().ToString()); |
| 1128 HideKeyboard(); | 1128 HideKeyboard(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1147 EXPECT_EQ(gfx::Rect(50, | 1147 EXPECT_EQ(gfx::Rect(50, |
| 1148 keyboard_bounds.y() - keyboard_bounds.height()/2, | 1148 keyboard_bounds.y() - keyboard_bounds.height()/2, |
| 1149 occluded_window_bounds.width(), | 1149 occluded_window_bounds.width(), |
| 1150 occluded_window_bounds.height()).ToString(), | 1150 occluded_window_bounds.height()).ToString(), |
| 1151 window->bounds().ToString()); | 1151 window->bounds().ToString()); |
| 1152 HideKeyboard(); | 1152 HideKeyboard(); |
| 1153 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1153 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 } // namespace ash | 1156 } // namespace ash |
| OLD | NEW |