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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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"
(...skipping 28 matching lines...) Expand all
39 #include "ui/views/widget/widget.h" 39 #include "ui/views/widget/widget.h"
40 #include "ui/views/widget/widget_delegate.h" 40 #include "ui/views/widget/widget_delegate.h"
41 #include "ui/wm/core/window_util.h" 41 #include "ui/wm/core/window_util.h"
42 42
43 namespace ash { 43 namespace ash {
44 namespace { 44 namespace {
45 45
46 class MaximizeDelegateView : public views::WidgetDelegateView { 46 class MaximizeDelegateView : public views::WidgetDelegateView {
47 public: 47 public:
48 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) 48 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds)
49 : initial_bounds_(initial_bounds) { 49 : initial_bounds_(initial_bounds) {}
50 }
51 ~MaximizeDelegateView() override {} 50 ~MaximizeDelegateView() override {}
52 51
53 bool GetSavedWindowPlacement(const views::Widget* widget, 52 bool GetSavedWindowPlacement(const views::Widget* widget,
54 gfx::Rect* bounds, 53 gfx::Rect* bounds,
55 ui::WindowShowState* show_state) const override { 54 ui::WindowShowState* show_state) const override {
56 *bounds = initial_bounds_; 55 *bounds = initial_bounds_;
57 *show_state = ui::SHOW_STATE_MAXIMIZED; 56 *show_state = ui::SHOW_STATE_MAXIMIZED;
58 return true; 57 return true;
59 } 58 }
60 59
61 private: 60 private:
62 const gfx::Rect initial_bounds_; 61 const gfx::Rect initial_bounds_;
63 62
64 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); 63 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView);
65 }; 64 };
66 65
67 class TestShellObserver : public ShellObserver { 66 class TestShellObserver : public ShellObserver {
68 public: 67 public:
69 TestShellObserver() : call_count_(0), 68 TestShellObserver() : call_count_(0), is_fullscreen_(false) {
70 is_fullscreen_(false) {
71 WmShell::Get()->AddShellObserver(this); 69 WmShell::Get()->AddShellObserver(this);
72 } 70 }
73 71
74 ~TestShellObserver() override { WmShell::Get()->RemoveShellObserver(this); } 72 ~TestShellObserver() override { WmShell::Get()->RemoveShellObserver(this); }
75 73
76 void OnFullscreenStateChanged(bool is_fullscreen, 74 void OnFullscreenStateChanged(bool is_fullscreen,
77 WmWindow* root_window) override { 75 WmWindow* root_window) override {
78 call_count_++; 76 call_count_++;
79 is_fullscreen_ = is_fullscreen; 77 is_fullscreen_ = is_fullscreen;
80 } 78 }
81 79
82 int call_count() const { 80 int call_count() const { return call_count_; }
83 return call_count_;
84 }
85 81
86 bool is_fullscreen() const { 82 bool is_fullscreen() const { return is_fullscreen_; }
87 return is_fullscreen_;
88 }
89 83
90 private: 84 private:
91 int call_count_; 85 int call_count_;
92 bool is_fullscreen_; 86 bool is_fullscreen_;
93 87
94 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); 88 DISALLOW_COPY_AND_ASSIGN(TestShellObserver);
95 }; 89 };
96 90
97 } // namespace 91 } // namespace
98 92
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 264 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
271 265
272 std::unique_ptr<aura::Window> window( 266 std::unique_ptr<aura::Window> window(
273 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 267 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
274 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 268 EXPECT_EQ(root_windows[0], window->GetRootWindow());
275 269
276 wm::WindowState* window_state = wm::GetWindowState(window.get()); 270 wm::WindowState* window_state = wm::GetWindowState(window.get());
277 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); 271 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
278 // Maximize the window in 2nd display as the restore bounds 272 // Maximize the window in 2nd display as the restore bounds
279 // is inside 2nd display. 273 // is inside 2nd display.
280 window->SetProperty(aura::client::kShowStateKey, 274 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
281 ui::SHOW_STATE_FULLSCREEN);
282 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 275 EXPECT_EQ(root_windows[1], window->GetRootWindow());
283 EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString()); 276 EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
284 277
285 window_state->Restore(); 278 window_state->Restore();
286 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 279 EXPECT_EQ(root_windows[1], window->GetRootWindow());
287 EXPECT_EQ("400,0 30x40", window->GetBoundsInScreen().ToString()); 280 EXPECT_EQ("400,0 30x40", window->GetBoundsInScreen().ToString());
288 281
289 // If the restore bounds intersects with the current display, 282 // If the restore bounds intersects with the current display,
290 // don't move. 283 // don't move.
291 window_state->SetRestoreBoundsInScreen(gfx::Rect(295, 0, 30, 40)); 284 window_state->SetRestoreBoundsInScreen(gfx::Rect(295, 0, 30, 40));
292 window->SetProperty(aura::client::kShowStateKey, 285 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
293 ui::SHOW_STATE_FULLSCREEN);
294 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 286 EXPECT_EQ(root_windows[1], window->GetRootWindow());
295 EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString()); 287 EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
296 288
297 window_state->Restore(); 289 window_state->Restore();
298 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 290 EXPECT_EQ(root_windows[1], window->GetRootWindow());
299 EXPECT_EQ("295,0 30x40", window->GetBoundsInScreen().ToString()); 291 EXPECT_EQ("295,0 30x40", window->GetBoundsInScreen().ToString());
300 } 292 }
301 293
302 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. 294 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver.
303 // This code mirrors what BrowserFrameAsh does. In particular when this code 295 // This code mirrors what BrowserFrameAsh does. In particular when this code
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 wm::WindowState* window_state = wm::GetWindowState(window.get()); 343 wm::WindowState* window_state = wm::GetWindowState(window.get());
352 window_state->Activate(); 344 window_state->Activate();
353 345
354 std::unique_ptr<aura::Window> window2( 346 std::unique_ptr<aura::Window> window2(
355 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40))); 347 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40)));
356 ::wm::AddTransientChild(window.get(), window2.get()); 348 ::wm::AddTransientChild(window.get(), window2.get());
357 window2->Show(); 349 window2->Show();
358 350
359 window_observer.set_window(window2.get()); 351 window_observer.set_window(window2.get());
360 window_state->Maximize(); 352 window_state->Maximize();
361 EXPECT_EQ("10,20 30x40", 353 EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInScreen().ToString());
362 window_state->GetRestoreBoundsInScreen().ToString());
363 window->RemoveObserver(&window_observer); 354 window->RemoveObserver(&window_observer);
364 } 355 }
365 356
366 // Verifies when a window is maximized all descendant windows have a size. 357 // Verifies when a window is maximized all descendant windows have a size.
367 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) { 358 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) {
368 std::unique_ptr<aura::Window> window( 359 std::unique_ptr<aura::Window> window(
369 CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 30, 40))); 360 CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 30, 40)));
370 window->Show(); 361 window->Show();
371 wm::WindowState* window_state = wm::GetWindowState(window.get()); 362 wm::WindowState* window_state = wm::GetWindowState(window.get());
372 window_state->Activate(); 363 window_state->Activate();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 bounds.Intersect(root_window_bounds); 449 bounds.Intersect(root_window_bounds);
459 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); 450 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
460 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); 451 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
461 } 452 }
462 453
463 // Verifies the size of a window is enforced to be smaller than the work area. 454 // Verifies the size of a window is enforced to be smaller than the work area.
464 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) { 455 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) {
465 // Normal window bounds shouldn't be changed. 456 // Normal window bounds shouldn't be changed.
466 gfx::Size work_area( 457 gfx::Size work_area(
467 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); 458 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size());
468 const gfx::Rect window_bounds( 459 const gfx::Rect window_bounds(100, 101, work_area.width() + 1,
469 100, 101, work_area.width() + 1, work_area.height() + 2); 460 work_area.height() + 2);
470 std::unique_ptr<aura::Window> window( 461 std::unique_ptr<aura::Window> window(
471 CreateTestWindowInShellWithBounds(window_bounds)); 462 CreateTestWindowInShellWithBounds(window_bounds));
472 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 463 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
473 window->bounds().ToString()); 464 window->bounds().ToString());
474 465
475 // Directly setting the bounds triggers a slightly different code path. Verify 466 // Directly setting the bounds triggers a slightly different code path. Verify
476 // that too. 467 // that too.
477 window->SetBounds(window_bounds); 468 window->SetBounds(window_bounds);
478 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 469 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
479 window->bounds().ToString()); 470 window->bounds().ToString());
480 } 471 }
481 472
482 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { 473 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
483 TestShellObserver observer; 474 TestShellObserver observer;
484 std::unique_ptr<aura::Window> window1( 475 std::unique_ptr<aura::Window> window1(
485 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 476 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
486 std::unique_ptr<aura::Window> window2( 477 std::unique_ptr<aura::Window> window2(
487 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 478 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
488 wm::WindowState* window_state1 = wm::GetWindowState(window1.get()); 479 wm::WindowState* window_state1 = wm::GetWindowState(window1.get());
489 wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); 480 wm::WindowState* window_state2 = wm::GetWindowState(window2.get());
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 // Return the order of windows (top most first) as they are in the default 897 // Return the order of windows (top most first) as they are in the default
907 // container. If the window is visible it will be a big letter, otherwise a 898 // container. If the window is visible it will be a big letter, otherwise a
908 // small one. The backdrop will be an X and unknown windows will be shown as 899 // small one. The backdrop will be an X and unknown windows will be shown as
909 // '!'. 900 // '!'.
910 std::string GetWindowOrderAsString(aura::Window* backdrop, 901 std::string GetWindowOrderAsString(aura::Window* backdrop,
911 aura::Window* wa, 902 aura::Window* wa,
912 aura::Window* wb, 903 aura::Window* wb,
913 aura::Window* wc) { 904 aura::Window* wc) {
914 std::string result; 905 std::string result;
915 for (int i = static_cast<int>(default_container()->children().size()) - 1; 906 for (int i = static_cast<int>(default_container()->children().size()) - 1;
916 i >= 0; 907 i >= 0; --i) {
917 --i) {
918 if (!result.empty()) 908 if (!result.empty())
919 result += ","; 909 result += ",";
920 if (default_container()->children()[i] == wa) 910 if (default_container()->children()[i] == wa)
921 result += default_container()->children()[i]->IsVisible() ? "A" : "a"; 911 result += default_container()->children()[i]->IsVisible() ? "A" : "a";
922 else if (default_container()->children()[i] == wb) 912 else if (default_container()->children()[i] == wb)
923 result += default_container()->children()[i]->IsVisible() ? "B" : "b"; 913 result += default_container()->children()[i]->IsVisible() ? "B" : "b";
924 else if (default_container()->children()[i] == wc) 914 else if (default_container()->children()[i] == wc)
925 result += default_container()->children()[i]->IsVisible() ? "C" : "c"; 915 result += default_container()->children()[i]->IsVisible() ? "C" : "c";
926 else if (default_container()->children()[i] == backdrop) 916 else if (default_container()->children()[i] == backdrop)
927 result += default_container()->children()[i]->IsVisible() ? "X" : "x"; 917 result += default_container()->children()[i]->IsVisible() ? "X" : "x";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 981
992 // Create 2 more windows and check that they are also in the container. 982 // Create 2 more windows and check that they are also in the container.
993 std::unique_ptr<aura::Window> window2( 983 std::unique_ptr<aura::Window> window2(
994 CreateTestWindow(gfx::Rect(10, 2, 3, 4))); 984 CreateTestWindow(gfx::Rect(10, 2, 3, 4)));
995 std::unique_ptr<aura::Window> window3( 985 std::unique_ptr<aura::Window> window3(
996 CreateTestWindow(gfx::Rect(20, 2, 3, 4))); 986 CreateTestWindow(gfx::Rect(20, 2, 3, 4)));
997 window2->Show(); 987 window2->Show();
998 window3->Show(); 988 window3->Show();
999 989
1000 aura::Window* backdrop = nullptr; 990 aura::Window* backdrop = nullptr;
1001 EXPECT_EQ("C,B,A", 991 EXPECT_EQ("C,B,A", GetWindowOrderAsString(backdrop, window1.get(),
1002 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 992 window2.get(), window3.get()));
1003 window3.get()));
1004 993
1005 // Turn on the backdrop mode and check that the window shows up where it 994 // Turn on the backdrop mode and check that the window shows up where it
1006 // should be (second highest number). 995 // should be (second highest number).
1007 ShowTopWindowBackdrop(true); 996 ShowTopWindowBackdrop(true);
1008 backdrop = default_container()->children()[2]; 997 backdrop = default_container()->children()[2];
1009 EXPECT_EQ("C,X,B,A", 998 EXPECT_EQ("C,X,B,A", GetWindowOrderAsString(backdrop, window1.get(),
1010 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 999 window2.get(), window3.get()));
1011 window3.get()));
1012 1000
1013 // Switch the order of windows and check that it still remains in that 1001 // Switch the order of windows and check that it still remains in that
1014 // location. 1002 // location.
1015 default_container()->StackChildAtTop(window2.get()); 1003 default_container()->StackChildAtTop(window2.get());
1016 EXPECT_EQ("B,X,C,A", 1004 EXPECT_EQ("B,X,C,A", GetWindowOrderAsString(backdrop, window1.get(),
1017 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 1005 window2.get(), window3.get()));
1018 window3.get()));
1019 1006
1020 // Make the top window invisible and check. 1007 // Make the top window invisible and check.
1021 window2.get()->Hide(); 1008 window2.get()->Hide();
1022 EXPECT_EQ("b,C,X,A", 1009 EXPECT_EQ("b,C,X,A", GetWindowOrderAsString(backdrop, window1.get(),
1023 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 1010 window2.get(), window3.get()));
1024 window3.get()));
1025 // Then delete window after window and see that everything is in order. 1011 // Then delete window after window and see that everything is in order.
1026 window1.reset(); 1012 window1.reset();
1027 EXPECT_EQ("b,C,X", 1013 EXPECT_EQ("b,C,X", GetWindowOrderAsString(backdrop, window1.get(),
1028 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 1014 window2.get(), window3.get()));
1029 window3.get()));
1030 window3.reset(); 1015 window3.reset();
1031 EXPECT_EQ("b,x", 1016 EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1.get(),
1032 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 1017 window2.get(), window3.get()));
1033 window3.get()));
1034 ShowTopWindowBackdrop(false); 1018 ShowTopWindowBackdrop(false);
1035 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), 1019 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(),
1036 window3.get())); 1020 window3.get()));
1037 } 1021 }
1038 1022
1039 // Tests that when hidding the shelf, that the backdrop resizes to fill the 1023 // Tests that when hidding the shelf, that the backdrop resizes to fill the
1040 // entire workspace area. 1024 // entire workspace area.
1041 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { 1025 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) {
1042 Shelf* shelf = Shelf::ForPrimaryDisplay(); 1026 Shelf* shelf = Shelf::ForPrimaryDisplay();
1043 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); 1027 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); 1068 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_);
1085 restore_work_area_insets_ = 1069 restore_work_area_insets_ =
1086 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); 1070 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets();
1087 Shell::GetInstance()->SetDisplayWorkAreaInsets( 1071 Shell::GetInstance()->SetDisplayWorkAreaInsets(
1088 Shell::GetPrimaryRootWindow(), 1072 Shell::GetPrimaryRootWindow(),
1089 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); 1073 gfx::Insets(0, 0, keyboard_bounds_.height(), 0));
1090 } 1074 }
1091 1075
1092 void HideKeyboard() { 1076 void HideKeyboard() {
1093 Shell::GetInstance()->SetDisplayWorkAreaInsets( 1077 Shell::GetInstance()->SetDisplayWorkAreaInsets(
1094 Shell::GetPrimaryRootWindow(), 1078 Shell::GetPrimaryRootWindow(), restore_work_area_insets_);
1095 restore_work_area_insets_);
1096 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); 1079 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect());
1097 } 1080 }
1098 1081
1099 void SetKeyboardBounds(const gfx::Rect& bounds) { 1082 void SetKeyboardBounds(const gfx::Rect& bounds) { keyboard_bounds_ = bounds; }
1100 keyboard_bounds_ = bounds;
1101 }
1102 1083
1103 private: 1084 private:
1104 gfx::Insets restore_work_area_insets_; 1085 gfx::Insets restore_work_area_insets_;
1105 gfx::Rect keyboard_bounds_; 1086 gfx::Rect keyboard_bounds_;
1106 WorkspaceLayoutManager* layout_manager_; 1087 WorkspaceLayoutManager* layout_manager_;
1107 1088
1108 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); 1089 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest);
1109 }; 1090 };
1110 1091
1111 // Tests that when a child window gains focus the top level window containing it 1092 // Tests that when a child window gains focus the top level window containing it
1112 // is resized to fit the remaining workspace area. 1093 // is resized to fit the remaining workspace area.
1113 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { 1094 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
1114 gfx::Rect work_area( 1095 gfx::Rect work_area(
1115 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1096 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1116 gfx::Rect keyboard_bounds(work_area.x(), 1097 gfx::Rect keyboard_bounds(work_area.x(),
1117 work_area.y() + work_area.height() / 2, 1098 work_area.y() + work_area.height() / 2,
1118 work_area.width(), 1099 work_area.width(), work_area.height() / 2);
1119 work_area.height() / 2);
1120 1100
1121 SetKeyboardBounds(keyboard_bounds); 1101 SetKeyboardBounds(keyboard_bounds);
1122 1102
1123 aura::test::TestWindowDelegate delegate1; 1103 aura::test::TestWindowDelegate delegate1;
1124 std::unique_ptr<aura::Window> parent_window( 1104 std::unique_ptr<aura::Window> parent_window(
1125 CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area)); 1105 CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area));
1126 aura::test::TestWindowDelegate delegate2; 1106 aura::test::TestWindowDelegate delegate2;
1127 std::unique_ptr<aura::Window> window( 1107 std::unique_ptr<aura::Window> window(
1128 CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area)); 1108 CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area));
1129 parent_window->AddChild(window.get()); 1109 parent_window->AddChild(window.get());
(...skipping 14 matching lines...) Expand all
1144 HideKeyboard(); 1124 HideKeyboard();
1145 EXPECT_EQ(initial_window_bounds.ToString(), 1125 EXPECT_EQ(initial_window_bounds.ToString(),
1146 parent_window->bounds().ToString()); 1126 parent_window->bounds().ToString());
1147 } 1127 }
1148 1128
1149 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { 1129 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
1150 gfx::Rect work_area( 1130 gfx::Rect work_area(
1151 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1131 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1152 gfx::Rect keyboard_bounds(work_area.x(), 1132 gfx::Rect keyboard_bounds(work_area.x(),
1153 work_area.y() + work_area.height() / 2, 1133 work_area.y() + work_area.height() / 2,
1154 work_area.width(), 1134 work_area.width(), work_area.height() / 2);
1155 work_area.height() / 2);
1156 1135
1157 SetKeyboardBounds(keyboard_bounds); 1136 SetKeyboardBounds(keyboard_bounds);
1158 1137
1159 aura::test::TestWindowDelegate delegate; 1138 aura::test::TestWindowDelegate delegate;
1160 std::unique_ptr<aura::Window> window( 1139 std::unique_ptr<aura::Window> window(
1161 CreateTestWindowInShellWithDelegate(&delegate, -1, work_area)); 1140 CreateTestWindowInShellWithDelegate(&delegate, -1, work_area));
1162 1141
1163 int available_height = 1142 int available_height =
1164 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - 1143 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() -
1165 keyboard_bounds.height(); 1144 keyboard_bounds.height();
1166 1145
1167 wm::ActivateWindow(window.get()); 1146 wm::ActivateWindow(window.get());
1168 1147
1169 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); 1148 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString());
1170 ShowKeyboard(); 1149 ShowKeyboard();
1171 EXPECT_EQ(gfx::Rect(work_area.origin(), 1150 EXPECT_EQ(gfx::Rect(work_area.origin(),
1172 gfx::Size(work_area.width(), available_height)).ToString(), 1151 gfx::Size(work_area.width(), available_height))
1152 .ToString(),
1173 window->bounds().ToString()); 1153 window->bounds().ToString());
1174 HideKeyboard(); 1154 HideKeyboard();
1175 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); 1155 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString());
1176 1156
1177 gfx::Rect small_window_bound(50, 50, 100, 500); 1157 gfx::Rect small_window_bound(50, 50, 100, 500);
1178 window->SetBounds(small_window_bound); 1158 window->SetBounds(small_window_bound);
1179 EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString()); 1159 EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
1180 ShowKeyboard(); 1160 ShowKeyboard();
1181 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), 1161 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
1182 window->bounds().ToString()); 1162 window->bounds().ToString());
1183 HideKeyboard(); 1163 HideKeyboard();
1184 EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString()); 1164 EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
1185 1165
1186 gfx::Rect occluded_window_bounds(50, 1166 gfx::Rect occluded_window_bounds(
1187 keyboard_bounds.y() + keyboard_bounds.height()/2, 50, 1167 50, keyboard_bounds.y() + keyboard_bounds.height() / 2, 50,
1188 keyboard_bounds.height()/2); 1168 keyboard_bounds.height() / 2);
1189 window->SetBounds(occluded_window_bounds); 1169 window->SetBounds(occluded_window_bounds);
1190 EXPECT_EQ(occluded_window_bounds.ToString(), 1170 EXPECT_EQ(occluded_window_bounds.ToString(),
1191 occluded_window_bounds.ToString()); 1171 occluded_window_bounds.ToString());
1192 ShowKeyboard(); 1172 ShowKeyboard();
1193 EXPECT_EQ(gfx::Rect(50, 1173 EXPECT_EQ(
1194 keyboard_bounds.y() - keyboard_bounds.height()/2, 1174 gfx::Rect(50, keyboard_bounds.y() - keyboard_bounds.height() / 2,
1195 occluded_window_bounds.width(), 1175 occluded_window_bounds.width(), occluded_window_bounds.height())
1196 occluded_window_bounds.height()).ToString(), 1176 .ToString(),
1197 window->bounds().ToString()); 1177 window->bounds().ToString());
1198 HideKeyboard(); 1178 HideKeyboard();
1199 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); 1179 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
1200 } 1180 }
1201 1181
1202 } // namespace ash 1182 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_event_handler_unittest.cc ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698