Chromium Code Reviews| 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/common/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/common/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/wm/common/fullscreen_window_finder.h" | |
| 10 #include "ash/wm/common/window_state.h" | 11 #include "ash/wm/common/window_state.h" |
| 11 #include "ash/wm/common/wm_event.h" | 12 #include "ash/wm/common/wm_event.h" |
| 12 #include "ash/wm/common/workspace/workspace_window_resizer.h" | 13 #include "ash/wm/common/wm_root_window_controller_observer.h" |
| 13 #include "base/compiler_specific.h" | 14 #include "ash/wm/common/wm_screen_util.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 15 #include "components/mus/public/cpp/tests/test_window.h" |
| 15 #include "ui/base/ui_base_types.h" | 16 #include "mash/wm/bridge/wm_root_window_controller_mus.h" |
| 16 #include "ui/display/manager/display_layout.h" | 17 #include "mash/wm/bridge/wm_window_mus.h" |
| 17 #include "ui/display/screen.h" | 18 #include "mash/wm/test/wm_test_base.h" |
| 18 #include "ui/gfx/geometry/insets.h" | 19 #include "ui/display/display.h" |
| 19 #include "ui/views/widget/widget.h" | |
| 20 #include "ui/views/widget/widget_delegate.h" | |
| 21 #include "ui/wm/core/window_util.h" | |
| 22 | 20 |
| 23 namespace ash { | 21 namespace mash { |
| 22 namespace wm { | |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 25 // TODO(sky): no tests for multiple displays yet: http://crbug.com/612627. | |
| 26 /* | |
| 26 class MaximizeDelegateView : public views::WidgetDelegateView { | 27 class MaximizeDelegateView : public views::WidgetDelegateView { |
| 27 public: | 28 public: |
| 28 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) | 29 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) |
| 29 : initial_bounds_(initial_bounds) { | 30 : initial_bounds_(initial_bounds) { |
| 30 } | 31 } |
| 31 ~MaximizeDelegateView() override {} | 32 ~MaximizeDelegateView() override {} |
| 32 | 33 |
| 33 bool GetSavedWindowPlacement(const views::Widget* widget, | 34 bool GetSavedWindowPlacement(const views::Widget* widget, |
| 34 gfx::Rect* bounds, | 35 gfx::Rect* bounds, |
| 35 ui::WindowShowState* show_state) const override { | 36 ui::WindowShowState* show_state) const override { |
| 36 *bounds = initial_bounds_; | 37 *bounds = initial_bounds_; |
| 37 *show_state = ui::SHOW_STATE_MAXIMIZED; | 38 *show_state = ui::SHOW_STATE_MAXIMIZED; |
| 38 return true; | 39 return true; |
| 39 } | 40 } |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 const gfx::Rect initial_bounds_; | 43 const gfx::Rect initial_bounds_; |
| 43 | 44 |
| 44 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); | 45 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); |
| 45 }; | 46 }; |
| 47 */ | |
| 46 | 48 |
| 47 class TestShellObserver : public ShellObserver { | 49 class FullscreenObserver : public ash::wm::WmRootWindowControllerObserver { |
| 48 public: | 50 public: |
| 49 TestShellObserver() : call_count_(0), | 51 explicit FullscreenObserver( |
| 50 is_fullscreen_(false) { | 52 ash::wm::WmRootWindowController* root_window_controller) |
| 51 Shell::GetInstance()->AddShellObserver(this); | 53 : root_window_controller_(root_window_controller), |
| 54 call_count_(0), | |
| 55 is_fullscreen_(false) { | |
| 56 root_window_controller_->AddObserver(this); | |
| 52 } | 57 } |
| 53 | 58 |
| 54 ~TestShellObserver() override { | 59 ~FullscreenObserver() override { |
| 55 Shell::GetInstance()->RemoveShellObserver(this); | 60 root_window_controller_->RemoveObserver(this); |
| 56 } | 61 } |
| 57 | 62 |
| 58 void OnFullscreenStateChanged(bool is_fullscreen, | 63 void OnFullscreenStateChanged(bool is_fullscreen) override { |
| 59 aura::Window* root_window) override { | |
| 60 call_count_++; | 64 call_count_++; |
| 61 is_fullscreen_ = is_fullscreen; | 65 is_fullscreen_ = is_fullscreen; |
| 62 } | 66 } |
| 63 | 67 |
| 64 int call_count() const { | 68 int call_count() const { return call_count_; } |
| 65 return call_count_; | |
| 66 } | |
| 67 | 69 |
| 68 bool is_fullscreen() const { | 70 bool is_fullscreen() const { return is_fullscreen_; } |
| 69 return is_fullscreen_; | |
| 70 } | |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 ash::wm::WmRootWindowController* root_window_controller_; | |
| 73 int call_count_; | 74 int call_count_; |
| 74 bool is_fullscreen_; | 75 bool is_fullscreen_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); | 77 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 } // namespace | 80 } // namespace |
| 80 | 81 |
| 81 typedef test::AshTestBase WorkspaceLayoutManagerTest; | 82 using WorkspaceLayoutManagerTest = WmTestBase; |
| 82 | 83 |
| 83 // Verifies that a window containing a restore coordinate will be restored to | 84 // Verifies that a window containing a restore coordinate will be restored to |
| 84 // to the size prior to minimize, keeping the restore rectangle in tact (if | 85 // to the size prior to minimize, keeping the restore rectangle in tact (if |
| 85 // there is one). | 86 // there is one). |
| 86 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { | 87 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { |
| 87 std::unique_ptr<aura::Window> window( | 88 mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4)); |
| 88 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 89 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 89 gfx::Rect bounds(10, 15, 25, 35); | 90 gfx::Rect bounds(10, 15, 25, 35); |
| 90 window->SetBounds(bounds); | 91 window->SetBounds(bounds); |
| 91 | 92 |
| 92 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 93 ash::wm::WindowState* window_state = window->GetWindowState(); |
| 93 | 94 |
| 94 // This will not be used for un-minimizing window. | 95 // This will not be used for un-minimizing window. |
| 95 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 96 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
| 96 window_state->Minimize(); | 97 window_state->Minimize(); |
| 97 window_state->Restore(); | 98 window_state->Restore(); |
| 98 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); | 99 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); |
| 99 EXPECT_EQ("10,15 25x35", window.get()->bounds().ToString()); | 100 EXPECT_EQ("10,15 25x35", mus_window->bounds().ToString()); |
| 100 | 101 |
| 101 if (!SupportsMultipleDisplays()) | 102 if (!SupportsMultipleDisplays()) |
| 102 return; | 103 return; |
| 103 | 104 |
| 104 UpdateDisplay("400x300,500x400"); | 105 UpdateDisplay("400x300,500x400"); |
| 105 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | 106 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); |
| 106 ScreenUtil::GetSecondaryDisplay()); | 107 EXPECT_EQ(GetSecondaryRootWindow(), mus_window->GetRoot()); |
| 107 EXPECT_EQ(Shell::GetAllRootWindows()[1], window->GetRootWindow()); | |
| 108 window_state->Minimize(); | 108 window_state->Minimize(); |
| 109 // This will not be used for un-minimizing window. | 109 // This will not be used for un-minimizing window. |
| 110 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 110 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
| 111 window_state->Restore(); | 111 window_state->Restore(); |
| 112 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); | 112 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); |
| 113 | 113 |
| 114 // Make sure the unminimized window moves inside the display when | 114 // Make sure the unminimized window moves inside the display when |
| 115 // 2nd display is disconnected. | 115 // 2nd display is disconnected. |
| 116 window_state->Minimize(); | 116 window_state->Minimize(); |
| 117 UpdateDisplay("400x300"); | 117 UpdateDisplay("400x300"); |
| 118 window_state->Restore(); | 118 window_state->Restore(); |
| 119 EXPECT_EQ(Shell::GetPrimaryRootWindow(), window->GetRootWindow()); | 119 EXPECT_EQ(GetPrimaryRootWindow(), mus_window->GetRoot()); |
| 120 EXPECT_TRUE( | 120 EXPECT_TRUE( |
| 121 Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); | 121 GetPrimaryRootWindow()->bounds().Intersects(mus_window->bounds())); |
| 122 } | 122 } |
| 123 | 123 |
| 124 /* | |
| 124 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { | 125 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { |
| 125 if (!SupportsMultipleDisplays()) | 126 if (!SupportsMultipleDisplays()) |
| 126 return; | 127 return; |
| 127 | 128 |
| 128 UpdateDisplay("300x400,400x500"); | 129 UpdateDisplay("300x400,400x500"); |
| 129 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 130 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 130 | 131 |
| 131 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 132 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 132 test::CreateDisplayLayout(display::DisplayPlacement::TOP, 0)); | 133 test::CreateDisplayLayout(display::DisplayPlacement::TOP, 0)); |
| 133 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); | 134 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); |
| 134 | 135 |
| 135 std::unique_ptr<aura::Window> window1( | 136 std::unique_ptr<aura::Window> window1( |
| 136 CreateTestWindowInShellWithBounds(gfx::Rect(10, -400, 200, 200))); | 137 CreateTestWindowInShellWithBounds(gfx::Rect(10, -400, 200, 200))); |
| 137 EXPECT_EQ("10,-400 200x200", window1->GetBoundsInScreen().ToString()); | 138 EXPECT_EQ("10,-400 200x200", window1->GetBoundsInScreen().ToString()); |
| 138 | 139 |
| 139 // Make sure the caption is visible. | 140 // Make sure the caption is visible. |
| 140 std::unique_ptr<aura::Window> window2( | 141 std::unique_ptr<aura::Window> window2( |
| 141 CreateTestWindowInShellWithBounds(gfx::Rect(10, -600, 200, 200))); | 142 CreateTestWindowInShellWithBounds(gfx::Rect(10, -600, 200, 200))); |
| 142 EXPECT_EQ("10,-500 200x200", window2->GetBoundsInScreen().ToString()); | 143 EXPECT_EQ("10,-500 200x200", window2->GetBoundsInScreen().ToString()); |
| 143 } | 144 } |
| 145 */ | |
| 144 | 146 |
| 145 TEST_F(WorkspaceLayoutManagerTest, NoMinimumVisibilityForPopupWindows) { | 147 TEST_F(WorkspaceLayoutManagerTest, NoMinimumVisibilityForPopupWindows) { |
| 146 UpdateDisplay("300x400"); | 148 UpdateDisplay("300x400"); |
| 147 | 149 |
| 148 // Create a popup window out of display boundaries and make sure it is not | 150 // Create a popup window out of display boundaries and make sure it is not |
| 149 // moved to have minimum visibility. | 151 // moved to have minimum visibility. |
| 150 std::unique_ptr<aura::Window> window( | 152 mus::Window* mus_window = |
| 151 CreateTestWindowInShellWithDelegateAndType( | 153 CreateTestWindow(gfx::Rect(400, 100, 50, 50), ui::wm::WINDOW_TYPE_POPUP); |
| 152 nullptr, ui::wm::WINDOW_TYPE_POPUP, 0, gfx::Rect(400, 100, 50, 50))); | 154 WmWindowMus* window = WmWindowMus::Get(mus_window); |
| 153 EXPECT_EQ("400,100 50x50", window->GetBoundsInScreen().ToString()); | 155 EXPECT_EQ("400,100 50x50", window->GetBoundsInScreen().ToString()); |
| 154 } | 156 } |
| 155 | 157 |
| 158 /* | |
| 156 TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) { | 159 TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) { |
| 157 if (!SupportsHostWindowResize()) | 160 if (!SupportsHostWindowResize()) |
| 158 return; | 161 return; |
| 159 std::unique_ptr<aura::Window> window( | 162 std::unique_ptr<aura::Window> window( |
| 160 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | 163 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); |
| 161 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 164 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 162 | 165 |
| 163 // Maximized -> Normal transition. | 166 // Maximized -> Normal transition. |
| 164 window_state->Maximize(); | 167 window_state->Maximize(); |
| 165 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); | 168 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 186 ASSERT_EQ("0,0 30x40", window->bounds().ToString()); | 189 ASSERT_EQ("0,0 30x40", window->bounds().ToString()); |
| 187 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 190 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 188 EXPECT_EQ(window->bounds(), window->GetRootWindow()->bounds()); | 191 EXPECT_EQ(window->bounds(), window->GetRootWindow()->bounds()); |
| 189 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); | 192 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); |
| 190 window_state->Restore(); | 193 window_state->Restore(); |
| 191 EXPECT_TRUE( | 194 EXPECT_TRUE( |
| 192 Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); | 195 Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); |
| 193 // Y bounds should not be negative. | 196 // Y bounds should not be negative. |
| 194 EXPECT_EQ("-5,0 30x40", window->bounds().ToString()); | 197 EXPECT_EQ("-5,0 30x40", window->bounds().ToString()); |
| 195 } | 198 } |
| 196 | 199 |
|
James Cook
2016/05/19 05:08:22
optional: I think it would be a little clearer if
sky
2016/05/19 15:14:24
I will revisit this soon.
| |
| 197 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { | 200 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { |
| 198 if (!SupportsMultipleDisplays()) | 201 if (!SupportsMultipleDisplays()) |
| 199 return; | 202 return; |
| 200 UpdateDisplay("300x400,400x500"); | 203 UpdateDisplay("300x400,400x500"); |
| 201 | 204 |
| 202 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 205 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 203 | 206 |
| 204 std::unique_ptr<aura::Window> window( | 207 std::unique_ptr<aura::Window> window( |
| 205 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | 208 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); |
| 206 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 209 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40))); | 340 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40))); |
| 338 ::wm::AddTransientChild(window.get(), window2.get()); | 341 ::wm::AddTransientChild(window.get(), window2.get()); |
| 339 window2->Show(); | 342 window2->Show(); |
| 340 | 343 |
| 341 window_observer.set_window(window2.get()); | 344 window_observer.set_window(window2.get()); |
| 342 window_state->Maximize(); | 345 window_state->Maximize(); |
| 343 EXPECT_EQ("10,20 30x40", | 346 EXPECT_EQ("10,20 30x40", |
| 344 window_state->GetRestoreBoundsInScreen().ToString()); | 347 window_state->GetRestoreBoundsInScreen().ToString()); |
| 345 window->RemoveObserver(&window_observer); | 348 window->RemoveObserver(&window_observer); |
| 346 } | 349 } |
| 350 */ | |
| 347 | 351 |
| 348 // Verifies when a window is maximized all descendant windows have a size. | 352 // Verifies when a window is maximized all descendant windows have a size. |
| 349 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) { | 353 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) { |
| 350 std::unique_ptr<aura::Window> window( | 354 mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 30, 40)); |
| 351 CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 30, 40))); | 355 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 352 window->Show(); | 356 |
| 353 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 357 ash::wm::WindowState* window_state = window->GetWindowState(); |
| 354 window_state->Activate(); | 358 window_state->Activate(); |
| 355 std::unique_ptr<aura::Window> child_window( | 359 mus::Window* child_window = |
| 356 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 6, 7, 8), | 360 CreateChildTestWindow(mus_window, gfx::Rect(5, 6, 7, 8)); |
| 357 window.get())); | |
| 358 child_window->Show(); | |
| 359 window_state->Maximize(); | 361 window_state->Maximize(); |
| 360 EXPECT_EQ("5,6 7x8", child_window->bounds().ToString()); | 362 EXPECT_EQ("5,6 7x8", child_window->bounds().ToString()); |
| 361 } | 363 } |
| 362 | 364 |
| 363 // Verifies a window created with maximized state has the maximized | 365 // Verifies a window created with maximized state has the maximized |
| 364 // bounds. | 366 // bounds. |
| 365 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { | 367 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { |
| 366 std::unique_ptr<aura::Window> window( | 368 mus::Window* mus_window = CreateTestWindow(gfx::Rect()); |
| 367 aura::test::CreateTestWindowWithBounds(gfx::Rect(0, 0, 0, 0), nullptr)); | 369 WmWindowMus* window = WmWindowMus::Get(mus_window); |
| 368 wm::GetWindowState(window.get())->Maximize(); | 370 window->GetWindowState()->Maximize(); |
| 369 aura::Window* default_container = Shell::GetContainer( | 371 gfx::Rect work_area(GetPrimaryDisplay().work_area()); |
| 370 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); | |
| 371 default_container->AddChild(window.get()); | |
| 372 window->Show(); | |
| 373 gfx::Rect work_area( | |
| 374 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | |
| 375 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 372 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
| 376 } | 373 } |
| 377 | 374 |
| 378 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { | 375 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { |
| 379 // Normal window bounds shouldn't be changed. | 376 // Normal window bounds shouldn't be changed. |
| 380 gfx::Rect window_bounds(100, 100, 200, 200); | 377 gfx::Rect window_bounds(100, 100, 200, 200); |
| 381 std::unique_ptr<aura::Window> window( | 378 mus::Window* mus_window = CreateTestWindow(window_bounds); |
| 382 CreateTestWindowInShellWithBounds(window_bounds)); | 379 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 383 EXPECT_EQ(window_bounds, window->bounds()); | 380 EXPECT_EQ(window_bounds, mus_window->bounds()); |
| 384 | 381 |
| 385 // If the window is out of the workspace, it would be moved on screen. | 382 // If the window is out of the workspace, it would be moved on screen. |
| 386 gfx::Rect root_window_bounds = | 383 gfx::Rect root_window_bounds = GetPrimaryRootWindow()->bounds(); |
| 387 Shell::GetInstance()->GetPrimaryRootWindow()->bounds(); | |
| 388 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); | 384 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); |
| 389 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); | 385 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); |
| 390 std::unique_ptr<aura::Window> out_window( | 386 mus::Window* out_mus_window = CreateTestWindow(window_bounds); |
| 391 CreateTestWindowInShellWithBounds(window_bounds)); | 387 ash::wm::WmWindow* out_window = WmWindowMus::Get(out_mus_window); |
| 392 EXPECT_EQ(window_bounds.size(), out_window->bounds().size()); | 388 EXPECT_EQ(window_bounds.size(), out_mus_window->bounds().size()); |
| 393 gfx::Rect bounds = out_window->bounds(); | 389 gfx::Rect bounds = out_mus_window->bounds(); |
| 394 bounds.Intersect(root_window_bounds); | 390 bounds.Intersect(root_window_bounds); |
| 395 | 391 |
| 396 // 30% of the window edge must be visible. | 392 // 30% of the window edge must be visible. |
| 397 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); | 393 EXPECT_GT(bounds.width(), out_mus_window->bounds().width() * 0.29); |
| 398 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); | 394 EXPECT_GT(bounds.height(), out_mus_window->bounds().height() * 0.29); |
| 399 | 395 |
| 400 aura::Window* parent = out_window->parent(); | 396 mus::Window* mus_parent = out_mus_window->parent(); |
| 401 parent->RemoveChild(out_window.get()); | 397 mus_parent->RemoveChild(out_mus_window); |
| 402 out_window->SetBounds(gfx::Rect(-200, -200, 200, 200)); | 398 out_window->SetBounds(gfx::Rect(-200, -200, 200, 200)); |
| 403 // UserHasChangedWindowPositionOrSize flag shouldn't turn off this behavior. | 399 // UserHasChangedWindowPositionOrSize flag shouldn't turn off this behavior. |
| 404 wm::GetWindowState(window.get())->set_bounds_changed_by_user(true); | 400 window->GetWindowState()->set_bounds_changed_by_user(true); |
| 405 parent->AddChild(out_window.get()); | 401 mus_parent->AddChild(out_mus_window); |
| 406 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); | 402 EXPECT_GT(bounds.width(), out_mus_window->bounds().width() * 0.29); |
| 407 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); | 403 EXPECT_GT(bounds.height(), out_mus_window->bounds().height() * 0.29); |
| 408 | 404 |
| 409 // Make sure we always make more than 1/3 of the window edge visible even | 405 // Make sure we always make more than 1/3 of the window edge visible even |
| 410 // if the initial bounds intersects with display. | 406 // if the initial bounds intersects with display. |
| 411 window_bounds.SetRect(-150, -150, 200, 200); | 407 window_bounds.SetRect(-150, -150, 200, 200); |
| 412 bounds = window_bounds; | 408 bounds = window_bounds; |
| 413 bounds.Intersect(root_window_bounds); | 409 bounds.Intersect(root_window_bounds); |
| 414 | 410 |
| 415 // Make sure that the initial bounds' visible area is less than 26% | 411 // Make sure that the initial bounds' visible area is less than 26% |
| 416 // so that the auto adjustment logic kicks in. | 412 // so that the auto adjustment logic kicks in. |
| 417 ASSERT_LT(bounds.width(), out_window->bounds().width() * 0.26); | 413 ASSERT_LT(bounds.width(), out_mus_window->bounds().width() * 0.26); |
| 418 ASSERT_LT(bounds.height(), out_window->bounds().height() * 0.26); | 414 ASSERT_LT(bounds.height(), out_mus_window->bounds().height() * 0.26); |
| 419 ASSERT_TRUE(window_bounds.Intersects(root_window_bounds)); | 415 ASSERT_TRUE(window_bounds.Intersects(root_window_bounds)); |
| 420 | 416 |
| 421 std::unique_ptr<aura::Window> partially_out_window( | 417 mus::Window* partially_out_mus_window = CreateTestWindow(window_bounds); |
| 422 CreateTestWindowInShellWithBounds(window_bounds)); | 418 EXPECT_EQ(window_bounds.size(), partially_out_mus_window->bounds().size()); |
| 423 EXPECT_EQ(window_bounds.size(), partially_out_window->bounds().size()); | 419 bounds = partially_out_mus_window->bounds(); |
| 424 bounds = partially_out_window->bounds(); | |
| 425 bounds.Intersect(root_window_bounds); | 420 bounds.Intersect(root_window_bounds); |
| 426 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); | 421 EXPECT_GT(bounds.width(), out_mus_window->bounds().width() * 0.29); |
| 427 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); | 422 EXPECT_GT(bounds.height(), out_mus_window->bounds().height() * 0.29); |
| 428 | 423 |
| 429 // Make sure the window whose 30% width/height is bigger than display | 424 // Make sure the window whose 30% width/height is bigger than display |
| 430 // will be placed correctly. | 425 // will be placed correctly. |
| 431 window_bounds.SetRect(-1900, -1900, 3000, 3000); | 426 window_bounds.SetRect(-1900, -1900, 3000, 3000); |
| 432 std::unique_ptr<aura::Window> window_bigger_than_display( | 427 mus::Window* mus_window_bigger_than_display = CreateTestWindow(window_bounds); |
| 433 CreateTestWindowInShellWithBounds(window_bounds)); | |
| 434 EXPECT_GE(root_window_bounds.width(), | 428 EXPECT_GE(root_window_bounds.width(), |
| 435 window_bigger_than_display->bounds().width()); | 429 mus_window_bigger_than_display->bounds().width()); |
| 436 EXPECT_GE(root_window_bounds.height(), | 430 EXPECT_GE(root_window_bounds.height(), |
| 437 window_bigger_than_display->bounds().height()); | 431 mus_window_bigger_than_display->bounds().height()); |
| 438 | 432 |
| 439 bounds = window_bigger_than_display->bounds(); | 433 bounds = mus_window_bigger_than_display->bounds(); |
| 440 bounds.Intersect(root_window_bounds); | 434 bounds.Intersect(root_window_bounds); |
| 441 EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); | 435 EXPECT_GT(bounds.width(), out_mus_window->bounds().width() * 0.29); |
| 442 EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); | 436 EXPECT_GT(bounds.height(), out_mus_window->bounds().height() * 0.29); |
| 443 } | 437 } |
| 444 | 438 |
| 445 // Verifies the size of a window is enforced to be smaller than the work area. | 439 // Verifies the size of a window is enforced to be smaller than the work area. |
| 446 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) { | 440 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) { |
| 447 // Normal window bounds shouldn't be changed. | 441 // Normal window bounds shouldn't be changed. |
| 448 gfx::Size work_area( | 442 gfx::Size work_area(GetPrimaryDisplay().work_area().size()); |
| 449 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); | 443 const gfx::Rect window_bounds(100, 101, work_area.width() + 1, |
| 450 const gfx::Rect window_bounds( | 444 work_area.height() + 2); |
| 451 100, 101, work_area.width() + 1, work_area.height() + 2); | 445 mus::Window* window = CreateTestWindow(window_bounds); |
| 452 std::unique_ptr<aura::Window> window( | |
| 453 CreateTestWindowInShellWithBounds(window_bounds)); | |
| 454 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 446 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 455 window->bounds().ToString()); | 447 window->bounds().ToString()); |
| 456 | 448 |
| 457 // Directly setting the bounds triggers a slightly different code path. Verify | 449 // Directly setting the bounds triggers a slightly different code path. Verify |
| 458 // that too. | 450 // that too. |
| 459 window->SetBounds(window_bounds); | 451 WmWindowMus::Get(window)->SetBounds(window_bounds); |
| 460 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 452 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 461 window->bounds().ToString()); | 453 window->bounds().ToString()); |
| 462 } | 454 } |
| 463 | 455 |
| 464 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { | 456 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { |
| 465 TestShellObserver observer; | 457 FullscreenObserver observer( |
| 466 std::unique_ptr<aura::Window> window1( | 458 WmWindowMus::Get(GetPrimaryRootWindow())->GetRootWindowController()); |
| 467 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | 459 mus::Window* window1 = CreateTestWindow(gfx::Rect(1, 2, 30, 40)); |
| 468 std::unique_ptr<aura::Window> window2( | 460 mus::Window* window2 = CreateTestWindow(gfx::Rect(1, 2, 30, 40)); |
| 469 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | 461 ash::wm::WindowState* window_state1 = |
| 470 wm::WindowState* window_state1 = wm::GetWindowState(window1.get()); | 462 WmWindowMus::Get(window1)->GetWindowState(); |
| 471 wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); | 463 ash::wm::WindowState* window_state2 = |
| 464 WmWindowMus::Get(window2)->GetWindowState(); | |
| 472 window_state2->Activate(); | 465 window_state2->Activate(); |
| 473 | 466 |
| 474 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 467 const ash::wm::WMEvent toggle_fullscreen_event( |
| 468 ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); | |
| 475 window_state2->OnWMEvent(&toggle_fullscreen_event); | 469 window_state2->OnWMEvent(&toggle_fullscreen_event); |
| 476 EXPECT_EQ(1, observer.call_count()); | 470 EXPECT_EQ(1, observer.call_count()); |
| 477 EXPECT_TRUE(observer.is_fullscreen()); | 471 EXPECT_TRUE(observer.is_fullscreen()); |
| 478 | 472 |
| 479 // When window1 moves to the front the fullscreen state should change. | 473 // When window1 moves to the front the fullscreen state should change. |
| 480 window_state1->Activate(); | 474 window_state1->Activate(); |
| 481 EXPECT_EQ(2, observer.call_count()); | 475 EXPECT_EQ(2, observer.call_count()); |
| 482 EXPECT_FALSE(observer.is_fullscreen()); | 476 EXPECT_FALSE(observer.is_fullscreen()); |
| 483 | 477 |
| 484 // It should change back if window2 becomes active again. | 478 // It should change back if window2 becomes active again. |
| 485 window_state2->Activate(); | 479 window_state2->Activate(); |
| 486 EXPECT_EQ(3, observer.call_count()); | 480 EXPECT_EQ(3, observer.call_count()); |
| 487 EXPECT_TRUE(observer.is_fullscreen()); | 481 EXPECT_TRUE(observer.is_fullscreen()); |
| 488 | 482 |
| 489 window_state2->OnWMEvent(&toggle_fullscreen_event); | 483 window_state2->OnWMEvent(&toggle_fullscreen_event); |
| 490 EXPECT_EQ(4, observer.call_count()); | 484 EXPECT_EQ(4, observer.call_count()); |
| 491 EXPECT_FALSE(observer.is_fullscreen()); | 485 EXPECT_FALSE(observer.is_fullscreen()); |
| 492 | 486 |
| 493 window_state2->OnWMEvent(&toggle_fullscreen_event); | 487 window_state2->OnWMEvent(&toggle_fullscreen_event); |
| 494 EXPECT_EQ(5, observer.call_count()); | 488 EXPECT_EQ(5, observer.call_count()); |
| 495 EXPECT_TRUE(observer.is_fullscreen()); | 489 EXPECT_TRUE(observer.is_fullscreen()); |
| 496 | 490 |
| 497 // Closing the window should change the fullscreen state. | 491 // Closing the window should change the fullscreen state. |
| 498 window2.reset(); | 492 window2->Destroy(); |
| 499 EXPECT_EQ(6, observer.call_count()); | 493 EXPECT_EQ(6, observer.call_count()); |
| 500 EXPECT_FALSE(observer.is_fullscreen()); | 494 EXPECT_FALSE(observer.is_fullscreen()); |
| 501 } | 495 } |
| 502 | |
| 503 // Following "Solo" tests were originally written for BaseLayoutManager. | 496 // Following "Solo" tests were originally written for BaseLayoutManager. |
| 504 namespace { | 497 using WorkspaceLayoutManagerSoloTest = WmTestBase; |
| 505 | |
| 506 class WorkspaceLayoutManagerSoloTest : public test::AshTestBase { | |
| 507 public: | |
| 508 WorkspaceLayoutManagerSoloTest() {} | |
| 509 ~WorkspaceLayoutManagerSoloTest() override {} | |
| 510 | |
| 511 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | |
| 512 return CreateTestWindowInShellWithBounds(bounds); | |
| 513 } | |
| 514 | |
| 515 private: | |
| 516 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerSoloTest); | |
| 517 }; | |
| 518 | |
| 519 } // namespace | |
| 520 | 498 |
| 521 // Tests normal->maximize->normal. | 499 // Tests normal->maximize->normal. |
| 522 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { | 500 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { |
| 523 gfx::Rect bounds(100, 100, 200, 200); | 501 gfx::Rect bounds(100, 100, 200, 200); |
| 524 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 502 mus::Window* mus_window = CreateTestWindow(bounds); |
| 525 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 503 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 504 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); | |
| 526 // Maximized window fills the work area, not the whole display. | 505 // Maximized window fills the work area, not the whole display. |
| 527 EXPECT_EQ( | 506 EXPECT_EQ(ash::wm::GetMaximizedWindowBoundsInParent(window).ToString(), |
| 528 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 507 mus_window->bounds().ToString()); |
| 529 window->bounds().ToString()); | 508 window->SetShowState(ui::SHOW_STATE_NORMAL); |
| 530 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 509 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); |
| 531 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | |
| 532 } | 510 } |
| 533 | 511 |
| 534 // Tests normal->minimize->normal. | 512 // Tests normal->minimize->normal. |
| 535 TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) { | 513 TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) { |
| 536 gfx::Rect bounds(100, 100, 200, 200); | 514 gfx::Rect bounds(100, 100, 200, 200); |
| 537 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 515 mus::Window* mus_window = CreateTestWindow(bounds); |
| 538 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 516 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 517 window->SetShowState(ui::SHOW_STATE_MINIMIZED); | |
| 539 // Note: Currently minimize doesn't do anything except set the state. | 518 // Note: Currently minimize doesn't do anything except set the state. |
| 540 // See crbug.com/104571. | 519 // See crbug.com/104571. |
| 541 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 520 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); |
| 542 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 521 window->SetShowState(ui::SHOW_STATE_NORMAL); |
| 543 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 522 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); |
| 544 } | 523 } |
| 545 | 524 |
| 546 // A WindowDelegate which sets the focus when the window | 525 // A WindowObserver which sets the focus when the window becomes visible. |
| 547 // becomes visible. | 526 class FocusObserver : public mus::WindowObserver { |
| 548 class FocusDelegate : public aura::test::TestWindowDelegate { | |
| 549 public: | 527 public: |
| 550 FocusDelegate() : window_(nullptr), show_state_(ui::SHOW_STATE_END) {} | 528 explicit FocusObserver(mus::Window* window) |
| 551 ~FocusDelegate() override {} | 529 : window_(window), show_state_(ui::SHOW_STATE_END) { |
| 552 | 530 window_->AddObserver(this); |
| 553 void set_window(aura::Window* window) { window_ = window; } | 531 } |
| 532 ~FocusObserver() override { window_->RemoveObserver(this); } | |
| 554 | 533 |
| 555 // aura::test::TestWindowDelegate overrides: | 534 // aura::test::TestWindowDelegate overrides: |
| 556 void OnWindowTargetVisibilityChanged(bool visible) override { | 535 void OnWindowVisibilityChanged(mus::Window* window) override { |
| 557 if (window_) { | 536 if (window_->visible()) |
| 558 if (visible) | 537 window_->SetFocus(); |
| 559 window_->Focus(); | 538 show_state_ = WmWindowMus::Get(window_)->GetShowState(); |
| 560 show_state_ = window_->GetProperty(aura::client::kShowStateKey); | |
| 561 } | |
| 562 } | 539 } |
| 563 | 540 |
| 564 ui::WindowShowState GetShowStateAndReset() { | 541 ui::WindowShowState GetShowStateAndReset() { |
| 565 ui::WindowShowState ret = show_state_; | 542 ui::WindowShowState ret = show_state_; |
| 566 show_state_ = ui::SHOW_STATE_END; | 543 show_state_ = ui::SHOW_STATE_END; |
| 567 return ret; | 544 return ret; |
| 568 } | 545 } |
| 569 | 546 |
| 570 private: | 547 private: |
| 571 aura::Window* window_; | 548 mus::Window* window_; |
| 572 ui::WindowShowState show_state_; | 549 ui::WindowShowState show_state_; |
| 573 | 550 |
| 574 DISALLOW_COPY_AND_ASSIGN(FocusDelegate); | 551 DISALLOW_COPY_AND_ASSIGN(FocusObserver); |
| 575 }; | 552 }; |
| 576 | 553 |
| 577 // Make sure that the window's show state is correct in | 554 // Make sure that the window's show state is correct in |
| 578 // |WindowDelegate::OnWindowTargetVisibilityChanged|, and setting | 555 // |mus::WindowObserver::OnWindowVisibilityChanged|, and setting |
| 579 // focus in this callback doesn't cause DCHECK error. See | 556 // focus in this callback doesn't cause DCHECK error. See |
| 580 // crbug.com/168383. | 557 // crbug.com/168383. |
| 558 // NOTE: this was adapted from the ash test of the same name, I suspect this | |
| 559 // test isn't particularly useful for mash. | |
| 581 TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) { | 560 TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) { |
| 582 FocusDelegate delegate; | 561 mus::Window* mus_window = CreateTestWindow(gfx::Rect(100, 100, 100, 100)); |
| 583 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 562 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 584 &delegate, 0, gfx::Rect(100, 100, 100, 100))); | 563 FocusObserver observer(mus_window); |
| 585 delegate.set_window(window.get()); | 564 window->SetShowState(ui::SHOW_STATE_MINIMIZED); |
| 586 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | |
| 587 EXPECT_FALSE(window->IsVisible()); | 565 EXPECT_FALSE(window->IsVisible()); |
| 588 EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, delegate.GetShowStateAndReset()); | 566 EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, observer.GetShowStateAndReset()); |
| 589 window->Show(); | 567 window->Show(); |
| 590 EXPECT_TRUE(window->IsVisible()); | 568 EXPECT_TRUE(window->IsVisible()); |
| 591 EXPECT_EQ(ui::SHOW_STATE_NORMAL, delegate.GetShowStateAndReset()); | 569 EXPECT_EQ(ui::SHOW_STATE_NORMAL, observer.GetShowStateAndReset()); |
| 592 } | 570 } |
| 593 | 571 |
| 594 // Tests maximized window size during root window resize. | 572 // Tests maximized window size during root window resize. |
| 595 #if defined(OS_WIN) && !defined(USE_ASH) | 573 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeRootWindowResize) { |
| 596 // TODO(msw): Broken on Windows. http://crbug.com/584038 | |
| 597 #define MAYBE_MaximizeRootWindowResize DISABLED_MaximizeRootWindowResize | |
| 598 #else | |
| 599 #define MAYBE_MaximizeRootWindowResize MaximizeRootWindowResize | |
| 600 #endif | |
| 601 TEST_F(WorkspaceLayoutManagerSoloTest, MAYBE_MaximizeRootWindowResize) { | |
| 602 gfx::Rect bounds(100, 100, 200, 200); | 574 gfx::Rect bounds(100, 100, 200, 200); |
| 603 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 575 mus::Window* mus_window = CreateTestWindow(bounds); |
| 604 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 576 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 577 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); | |
| 605 gfx::Rect initial_work_area_bounds = | 578 gfx::Rect initial_work_area_bounds = |
| 606 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()); | 579 ash::wm::GetMaximizedWindowBoundsInParent(window); |
| 607 EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); | 580 EXPECT_EQ(initial_work_area_bounds.ToString(), |
| 581 mus_window->bounds().ToString()); | |
| 608 // Enlarge the root window. We should still match the work area size. | 582 // Enlarge the root window. We should still match the work area size. |
| 609 UpdateDisplay("900x700"); | 583 UpdateDisplay("900x700"); |
| 610 EXPECT_EQ( | 584 EXPECT_EQ(ash::wm::GetMaximizedWindowBoundsInParent(window).ToString(), |
| 611 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 585 mus_window->bounds().ToString()); |
| 612 window->bounds().ToString()); | 586 EXPECT_NE(initial_work_area_bounds.ToString(), |
| 613 EXPECT_NE( | 587 ash::wm::GetMaximizedWindowBoundsInParent(window).ToString()); |
| 614 initial_work_area_bounds.ToString(), | |
| 615 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString()); | |
| 616 } | 588 } |
| 617 | 589 |
| 618 // Tests normal->fullscreen->normal. | 590 // Tests normal->fullscreen->normal. |
| 619 TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) { | 591 TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) { |
| 620 gfx::Rect bounds(100, 100, 200, 200); | 592 gfx::Rect bounds(100, 100, 200, 200); |
| 621 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 593 mus::Window* mus_window = CreateTestWindow(bounds); |
| 622 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 594 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 595 window->SetShowState(ui::SHOW_STATE_FULLSCREEN); | |
| 623 // Fullscreen window fills the whole display. | 596 // Fullscreen window fills the whole display. |
| 624 EXPECT_EQ(display::Screen::GetScreen() | 597 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(), |
| 625 ->GetDisplayNearestWindow(window.get()) | 598 mus_window->bounds().ToString()); |
| 626 .bounds() | 599 window->SetShowState(ui::SHOW_STATE_NORMAL); |
| 627 .ToString(), | 600 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); |
| 628 window->bounds().ToString()); | |
| 629 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | |
| 630 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | |
| 631 } | 601 } |
| 632 | 602 |
| 633 // Tests that fullscreen window causes always_on_top windows to stack below. | 603 // Tests that fullscreen window causes always_on_top windows to stack below. |
| 634 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) { | 604 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) { |
| 635 gfx::Rect bounds(100, 100, 200, 200); | 605 gfx::Rect bounds(100, 100, 200, 200); |
| 636 std::unique_ptr<aura::Window> fullscreen_window(CreateTestWindow(bounds)); | 606 mus::Window* mus_fullscreen_window = CreateTestWindow(bounds); |
| 637 std::unique_ptr<aura::Window> always_on_top_window1(CreateTestWindow(bounds)); | 607 WmWindowMus* fullscreen_window = WmWindowMus::Get(mus_fullscreen_window); |
| 638 std::unique_ptr<aura::Window> always_on_top_window2(CreateTestWindow(bounds)); | 608 mus::Window* mus_always_on_top_window1 = CreateTestWindow(bounds); |
| 639 always_on_top_window1->SetProperty(aura::client::kAlwaysOnTopKey, true); | 609 WmWindowMus* always_on_top_window1 = |
| 640 always_on_top_window2->SetProperty(aura::client::kAlwaysOnTopKey, true); | 610 WmWindowMus::Get(mus_always_on_top_window1); |
| 611 mus::Window* mus_always_on_top_window2 = CreateTestWindow(bounds); | |
| 612 WmWindowMus* always_on_top_window2 = | |
| 613 WmWindowMus::Get(mus_always_on_top_window2); | |
| 614 always_on_top_window1->SetAlwaysOnTop(true); | |
| 615 always_on_top_window2->SetAlwaysOnTop(true); | |
| 641 // Making a window fullscreen temporarily suspends always on top state. | 616 // Making a window fullscreen temporarily suspends always on top state. |
| 642 fullscreen_window->SetProperty(aura::client::kShowStateKey, | 617 fullscreen_window->SetShowState(ui::SHOW_STATE_FULLSCREEN); |
| 643 ui::SHOW_STATE_FULLSCREEN); | 618 EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop()); |
| 644 EXPECT_FALSE( | 619 EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop()); |
| 645 always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey)); | 620 EXPECT_TRUE(GetWindowForFullscreenMode(fullscreen_window)); |
| 646 EXPECT_FALSE( | |
| 647 always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey)); | |
| 648 EXPECT_NE(nullptr, GetRootWindowController(fullscreen_window->GetRootWindow()) | |
| 649 ->GetWindowForFullscreenMode()); | |
| 650 // Making fullscreen window normal restores always on top windows. | 621 // Making fullscreen window normal restores always on top windows. |
| 651 fullscreen_window->SetProperty(aura::client::kShowStateKey, | 622 fullscreen_window->SetShowState(ui::SHOW_STATE_NORMAL); |
| 652 ui::SHOW_STATE_NORMAL); | 623 EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop()); |
| 653 EXPECT_TRUE( | 624 EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop()); |
| 654 always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey)); | 625 EXPECT_FALSE(GetWindowForFullscreenMode(fullscreen_window)); |
| 655 EXPECT_TRUE( | |
| 656 always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey)); | |
| 657 EXPECT_EQ(nullptr, GetRootWindowController(fullscreen_window->GetRootWindow()) | |
| 658 ->GetWindowForFullscreenMode()); | |
| 659 } | 626 } |
| 660 | 627 |
| 661 // Tests fullscreen window size during root window resize. | 628 // Tests fullscreen window size during root window resize. |
| 662 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) { | 629 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) { |
| 663 gfx::Rect bounds(100, 100, 200, 200); | 630 gfx::Rect bounds(100, 100, 200, 200); |
| 664 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 631 mus::Window* mus_window = CreateTestWindow(bounds); |
| 632 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); | |
| 665 // Fullscreen window fills the whole display. | 633 // Fullscreen window fills the whole display. |
| 666 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 634 window->SetShowState(ui::SHOW_STATE_FULLSCREEN); |
| 667 EXPECT_EQ(display::Screen::GetScreen() | 635 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(), |
| 668 ->GetDisplayNearestWindow(window.get()) | 636 mus_window->bounds().ToString()); |
| 669 .bounds() | |
| 670 .ToString(), | |
| 671 window->bounds().ToString()); | |
| 672 // Enlarge the root window. We should still match the display size. | 637 // Enlarge the root window. We should still match the display size. |
| 673 UpdateDisplay("800x600"); | 638 UpdateDisplay("800x600"); |
|
James Cook
2016/05/19 15:17:07
I know it was like this before but this seems a li
sky
2016/05/19 16:12:38
Done.
| |
| 674 EXPECT_EQ(display::Screen::GetScreen() | 639 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(), |
| 675 ->GetDisplayNearestWindow(window.get()) | 640 mus_window->bounds().ToString()); |
| 676 .bounds() | |
| 677 .ToString(), | |
| 678 window->bounds().ToString()); | |
| 679 } | 641 } |
| 680 | 642 |
| 681 // Tests that when the screen gets smaller the windows aren't bigger than | 643 // Tests that when the screen gets smaller the windows aren't bigger than |
| 682 // the screen. | 644 // the screen. |
| 683 TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) { | 645 TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) { |
| 684 std::unique_ptr<aura::Window> window( | 646 mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 500, 400)); |
| 685 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); | 647 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 686 gfx::Rect work_area = display::Screen::GetScreen() | 648 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); |
| 687 ->GetDisplayNearestWindow(window.get()) | |
| 688 .work_area(); | |
| 689 // Invariant: Window is smaller than work area. | 649 // Invariant: Window is smaller than work area. |
| 690 EXPECT_LE(window->bounds().width(), work_area.width()); | 650 EXPECT_LE(mus_window->bounds().width(), work_area.width()); |
| 691 EXPECT_LE(window->bounds().height(), work_area.height()); | 651 EXPECT_LE(mus_window->bounds().height(), work_area.height()); |
| 692 | 652 |
| 693 // Make the root window narrower than our window. | 653 // Make the root window narrower than our window. |
| 694 UpdateDisplay("300x400"); | 654 UpdateDisplay("300x400"); |
| 695 work_area = display::Screen::GetScreen() | 655 work_area = window->GetDisplayNearestWindow().work_area(); |
| 696 ->GetDisplayNearestWindow(window.get()) | 656 EXPECT_LE(mus_window->bounds().width(), work_area.width()); |
| 697 .work_area(); | 657 EXPECT_LE(mus_window->bounds().height(), work_area.height()); |
| 698 EXPECT_LE(window->bounds().width(), work_area.width()); | |
| 699 EXPECT_LE(window->bounds().height(), work_area.height()); | |
| 700 | 658 |
| 701 // Make the root window shorter than our window. | 659 // Make the root window shorter than our window. |
| 702 UpdateDisplay("300x200"); | 660 UpdateDisplay("300x200"); |
| 703 work_area = display::Screen::GetScreen() | 661 work_area = window->GetDisplayNearestWindow().work_area(); |
| 704 ->GetDisplayNearestWindow(window.get()) | 662 EXPECT_LE(mus_window->bounds().width(), work_area.width()); |
| 705 .work_area(); | 663 EXPECT_LE(mus_window->bounds().height(), work_area.height()); |
| 706 EXPECT_LE(window->bounds().width(), work_area.width()); | |
| 707 EXPECT_LE(window->bounds().height(), work_area.height()); | |
| 708 | 664 |
| 709 // Enlarging the root window does not change the window bounds. | 665 // Enlarging the root window does not change the window bounds. |
| 710 gfx::Rect old_bounds = window->bounds(); | 666 gfx::Rect old_bounds = mus_window->bounds(); |
| 711 UpdateDisplay("800x600"); | 667 UpdateDisplay("800x600"); |
| 712 EXPECT_EQ(old_bounds.width(), window->bounds().width()); | 668 EXPECT_EQ(old_bounds.width(), mus_window->bounds().width()); |
| 713 EXPECT_EQ(old_bounds.height(), window->bounds().height()); | 669 EXPECT_EQ(old_bounds.height(), mus_window->bounds().height()); |
| 714 } | 670 } |
| 715 | 671 |
| 716 // Verifies maximizing sets the restore bounds, and restoring | 672 // Verifies maximizing sets the restore bounds, and restoring |
| 717 // restores the bounds. | 673 // restores the bounds. |
| 718 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) { | 674 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) { |
| 719 std::unique_ptr<aura::Window> window( | 675 mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 30, 40)); |
| 720 CreateTestWindow(gfx::Rect(10, 20, 30, 40))); | 676 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); |
| 721 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 677 ash::wm::WindowState* window_state = window->GetWindowState(); |
| 722 | 678 |
| 723 // Maximize it, which will keep the previous restore bounds. | 679 // Maximize it, which will keep the previous restore bounds. |
| 724 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 680 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); |
| 725 EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString()); | 681 EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString()); |
| 726 | 682 |
| 727 // Restore it, which should restore bounds and reset restore bounds. | 683 // Restore it, which should restore bounds and reset restore bounds. |
| 728 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 684 window->SetShowState(ui::SHOW_STATE_NORMAL); |
| 729 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); | 685 EXPECT_EQ("10,20 30x40", mus_window->bounds().ToString()); |
| 730 EXPECT_FALSE(window_state->HasRestoreBounds()); | 686 EXPECT_FALSE(window_state->HasRestoreBounds()); |
| 731 } | 687 } |
| 732 | 688 |
| 733 // Verifies maximizing keeps the restore bounds if set. | 689 // Verifies maximizing keeps the restore bounds if set. |
| 734 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) { | 690 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) { |
| 735 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 691 mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4)); |
| 692 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); | |
| 736 | 693 |
| 737 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 694 ash::wm::WindowState* window_state = window->GetWindowState(); |
| 738 window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13)); | 695 window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13)); |
| 739 | 696 |
| 740 // Maximize it, which will keep the previous restore bounds. | 697 // Maximize it, which will keep the previous restore bounds. |
| 741 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 698 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); |
| 742 EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString()); | 699 EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString()); |
| 743 } | 700 } |
| 744 | 701 |
| 745 // Verifies that the restore bounds do not get reset when restoring to a | 702 // Verifies that the restore bounds do not get reset when restoring to a |
| 746 // maximzied state from a minimized state. | 703 // maximzied state from a minimized state. |
| 747 TEST_F(WorkspaceLayoutManagerSoloTest, | 704 TEST_F(WorkspaceLayoutManagerSoloTest, |
| 748 BoundsAfterRestoringToMaximizeFromMinimize) { | 705 BoundsAfterRestoringToMaximizeFromMinimize) { |
| 749 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 706 mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4)); |
| 707 ash::wm::WmWindow* window = WmWindowMus::Get(mus_window); | |
| 750 gfx::Rect bounds(10, 15, 25, 35); | 708 gfx::Rect bounds(10, 15, 25, 35); |
| 751 window->SetBounds(bounds); | 709 window->SetBounds(bounds); |
| 752 | 710 |
| 753 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 711 ash::wm::WindowState* window_state = window->GetWindowState(); |
| 754 // Maximize it, which should reset restore bounds. | 712 // Maximize it, which should reset restore bounds. |
| 755 window_state->Maximize(); | 713 window_state->Maximize(); |
| 756 EXPECT_EQ(bounds.ToString(), | 714 EXPECT_EQ(bounds.ToString(), |
| 757 window_state->GetRestoreBoundsInParent().ToString()); | 715 window_state->GetRestoreBoundsInParent().ToString()); |
| 758 // Minimize the window. The restore bounds should not change. | 716 // Minimize the window. The restore bounds should not change. |
| 759 window_state->Minimize(); | 717 window_state->Minimize(); |
| 760 EXPECT_EQ(bounds.ToString(), | 718 EXPECT_EQ(bounds.ToString(), |
| 761 window_state->GetRestoreBoundsInParent().ToString()); | 719 window_state->GetRestoreBoundsInParent().ToString()); |
| 762 | 720 |
| 763 // Show the window again. The window should be maximized, and the restore | 721 // Show the window again. The window should be maximized, and the restore |
| 764 // bounds should not change. | 722 // bounds should not change. |
| 765 window->Show(); | 723 window->Show(); |
| 766 EXPECT_EQ(bounds.ToString(), | 724 EXPECT_EQ(bounds.ToString(), |
| 767 window_state->GetRestoreBoundsInParent().ToString()); | 725 window_state->GetRestoreBoundsInParent().ToString()); |
| 768 EXPECT_TRUE(window_state->IsMaximized()); | 726 EXPECT_TRUE(window_state->IsMaximized()); |
| 769 | 727 |
| 770 window_state->Restore(); | 728 window_state->Restore(); |
| 771 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 729 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); |
| 772 } | 730 } |
| 773 | 731 |
| 732 /* | |
| 774 // Verify if the window is not resized during screen lock. See: crbug.com/173127 | 733 // Verify if the window is not resized during screen lock. See: crbug.com/173127 |
| 775 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { | 734 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { |
| 776 SetCanLockScreen(true); | 735 SetCanLockScreen(true); |
| 777 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 736 mus::Window* window = CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 778 // window with AlwaysOnTop will be managed by BaseLayoutManager. | 737 // window with AlwaysOnTop will be managed by BaseLayoutManager. |
| 779 window->SetProperty(aura::client::kAlwaysOnTopKey, true); | 738 window->SetProperty(aura::client::kAlwaysOnTopKey, true); |
| 780 window->Show(); | 739 window->Show(); |
| 781 | 740 |
| 782 ShelfLayoutManager* shelf_layout_manager = | 741 ShelfLayoutManager* shelf_layout_manager = |
| 783 Shelf::ForWindow(window.get())->shelf_layout_manager(); | 742 Shelf::ForWindow(window.get())->shelf_layout_manager(); |
| 784 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 743 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 785 | 744 |
| 786 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); | 745 window->SetBounds(ash::wm::GetMaximizedWindowBoundsInParent(window)); |
| 787 gfx::Rect window_bounds = window->bounds(); | 746 gfx::Rect window_bounds = window->bounds(); |
| 788 EXPECT_EQ( | 747 EXPECT_EQ( |
| 789 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 748 ash::wm::GetMaximizedWindowBoundsInParent(window).ToString(), |
| 790 window_bounds.ToString()); | 749 window_bounds.ToString()); |
| 791 | 750 |
| 792 // The window size should not get touched while we are in lock screen. | 751 // The window size should not get touched while we are in lock screen. |
| 793 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 752 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
| 794 shelf_layout_manager->UpdateVisibilityState(); | 753 shelf_layout_manager->UpdateVisibilityState(); |
| 795 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 754 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
| 796 | 755 |
| 797 // Coming out of the lock screen the window size should still remain. | 756 // Coming out of the lock screen the window size should still remain. |
| 798 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 757 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
| 799 shelf_layout_manager->UpdateVisibilityState(); | 758 shelf_layout_manager->UpdateVisibilityState(); |
| 800 EXPECT_EQ( | 759 EXPECT_EQ( |
| 801 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 760 ash::wm::GetMaximizedWindowBoundsInParent(window).ToString(), |
| 802 window_bounds.ToString()); | 761 window_bounds.ToString()); |
| 803 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 762 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
| 804 } | 763 } |
| 805 | 764 |
| 765 // TODO(sky): these are commented out until maximize mode ported. | |
| 766 // http://crbug.com/612629. | |
| 767 | |
| 806 // Following tests are written to test the backdrop functionality. | 768 // Following tests are written to test the backdrop functionality. |
| 807 | 769 |
| 808 namespace { | 770 namespace { |
| 809 | 771 |
| 810 WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) { | 772 WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) { |
| 811 return static_cast<WorkspaceLayoutManager*>( | 773 return static_cast<WorkspaceLayoutManager*>( |
| 812 wm::WmWindowAura::Get(container)->GetLayoutManager()); | 774 wm::WmWindowAura::Get(container)->GetLayoutManager()); |
| 813 } | 775 } |
| 814 | 776 |
| 815 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { | 777 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { | 853 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { |
| 892 // Create a backdrop and see that there is one window (the backdrop) and | 854 // Create a backdrop and see that there is one window (the backdrop) and |
| 893 // that the size is the same as the default container as well as that it is | 855 // that the size is the same as the default container as well as that it is |
| 894 // not visible. | 856 // not visible. |
| 895 ShowTopWindowBackdrop(true); | 857 ShowTopWindowBackdrop(true); |
| 896 ASSERT_EQ(1U, default_container()->children().size()); | 858 ASSERT_EQ(1U, default_container()->children().size()); |
| 897 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); | 859 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); |
| 898 | 860 |
| 899 { | 861 { |
| 900 // Add a window and make sure that the backdrop is the second child. | 862 // Add a window and make sure that the backdrop is the second child. |
| 901 std::unique_ptr<aura::Window> window( | 863 mus::Window* window( |
|
James Cook
2016/05/19 15:17:07
Do you still want to change these ones in the comm
sky
2016/05/19 16:12:38
I did a global replace of a handful of things. If
James Cook
2016/05/19 16:37:24
Yes, please revert them.
sky
2016/05/19 16:45:35
Done.
| |
| 902 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 864 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 903 window->Show(); | 865 window->Show(); |
| 904 ASSERT_EQ(2U, default_container()->children().size()); | 866 ASSERT_EQ(2U, default_container()->children().size()); |
| 905 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); | 867 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); |
| 906 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); | 868 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); |
| 907 EXPECT_EQ(window.get(), default_container()->children()[1]); | 869 EXPECT_EQ(window.get(), default_container()->children()[1]); |
| 908 EXPECT_EQ(default_container()->bounds().ToString(), | 870 EXPECT_EQ(default_container()->bounds().ToString(), |
| 909 default_container()->children()[0]->bounds().ToString()); | 871 default_container()->children()[0]->bounds().ToString()); |
| 910 } | 872 } |
| 911 | 873 |
| 912 // With the window gone the backdrop should be invisible again. | 874 // With the window gone the backdrop should be invisible again. |
| 913 ASSERT_EQ(1U, default_container()->children().size()); | 875 ASSERT_EQ(1U, default_container()->children().size()); |
| 914 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); | 876 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); |
| 915 | 877 |
| 916 // Destroying the Backdrop should empty the container. | 878 // Destroying the Backdrop should empty the container. |
| 917 ShowTopWindowBackdrop(false); | 879 ShowTopWindowBackdrop(false); |
| 918 ASSERT_EQ(0U, default_container()->children().size()); | 880 ASSERT_EQ(0U, default_container()->children().size()); |
| 919 } | 881 } |
| 920 | 882 |
| 921 // Verify that the backdrop gets properly created and placed. | 883 // Verify that the backdrop gets properly created and placed. |
| 922 TEST_F(WorkspaceLayoutManagerBackdropTest, VerifyBackdropAndItsStacking) { | 884 TEST_F(WorkspaceLayoutManagerBackdropTest, VerifyBackdropAndItsStacking) { |
| 923 std::unique_ptr<aura::Window> window1( | 885 mus::Window* window1( |
| 924 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 886 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 925 window1->Show(); | 887 window1->Show(); |
| 926 | 888 |
| 927 // Get the default container and check that only a single window is in there. | 889 // Get the default container and check that only a single window is in there. |
| 928 ASSERT_EQ(1U, default_container()->children().size()); | 890 ASSERT_EQ(1U, default_container()->children().size()); |
| 929 EXPECT_EQ(window1.get(), default_container()->children()[0]); | 891 EXPECT_EQ(window1.get(), default_container()->children()[0]); |
| 930 EXPECT_EQ("A", | 892 EXPECT_EQ("A", |
| 931 GetWindowOrderAsString(nullptr, window1.get(), nullptr, nullptr)); | 893 GetWindowOrderAsString(nullptr, window1.get(), nullptr, nullptr)); |
| 932 | 894 |
| 933 // Create 2 more windows and check that they are also in the container. | 895 // Create 2 more windows and check that they are also in the container. |
| 934 std::unique_ptr<aura::Window> window2( | 896 mus::Window* window2( |
| 935 CreateTestWindow(gfx::Rect(10, 2, 3, 4))); | 897 CreateTestWindow(gfx::Rect(10, 2, 3, 4))); |
| 936 std::unique_ptr<aura::Window> window3( | 898 mus::Window* window3( |
| 937 CreateTestWindow(gfx::Rect(20, 2, 3, 4))); | 899 CreateTestWindow(gfx::Rect(20, 2, 3, 4))); |
| 938 window2->Show(); | 900 window2->Show(); |
| 939 window3->Show(); | 901 window3->Show(); |
| 940 | 902 |
| 941 aura::Window* backdrop = nullptr; | 903 aura::Window* backdrop = nullptr; |
| 942 EXPECT_EQ("C,B,A", | 904 EXPECT_EQ("C,B,A", |
| 943 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), | 905 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), |
| 944 window3.get())); | 906 window3.get())); |
| 945 | 907 |
| 946 // Turn on the backdrop mode and check that the window shows up where it | 908 // Turn on the backdrop mode and check that the window shows up where it |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 work_area.y() + work_area.height() / 2, | 1020 work_area.y() + work_area.height() / 2, |
| 1059 work_area.width(), | 1021 work_area.width(), |
| 1060 work_area.height() / 2); | 1022 work_area.height() / 2); |
| 1061 | 1023 |
| 1062 SetKeyboardBounds(keyboard_bounds); | 1024 SetKeyboardBounds(keyboard_bounds); |
| 1063 | 1025 |
| 1064 aura::test::TestWindowDelegate delegate1; | 1026 aura::test::TestWindowDelegate delegate1; |
| 1065 std::unique_ptr<aura::Window> parent_window( | 1027 std::unique_ptr<aura::Window> parent_window( |
| 1066 CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area)); | 1028 CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area)); |
| 1067 aura::test::TestWindowDelegate delegate2; | 1029 aura::test::TestWindowDelegate delegate2; |
| 1068 std::unique_ptr<aura::Window> window( | 1030 mus::Window* window( |
| 1069 CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area)); | 1031 CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area)); |
| 1070 parent_window->AddChild(window.get()); | 1032 parent_window->AddChild(window.get()); |
| 1071 | 1033 |
| 1072 wm::ActivateWindow(window.get()); | 1034 wm::ActivateWindow(window.get()); |
| 1073 | 1035 |
| 1074 int available_height = | 1036 int available_height = |
| 1075 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - | 1037 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - |
| 1076 keyboard_bounds.height(); | 1038 keyboard_bounds.height(); |
| 1077 | 1039 |
| 1078 gfx::Rect initial_window_bounds(50, 50, 100, 500); | 1040 gfx::Rect initial_window_bounds(50, 50, 100, 500); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1091 gfx::Rect work_area( | 1053 gfx::Rect work_area( |
| 1092 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1054 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1093 gfx::Rect keyboard_bounds(work_area.x(), | 1055 gfx::Rect keyboard_bounds(work_area.x(), |
| 1094 work_area.y() + work_area.height() / 2, | 1056 work_area.y() + work_area.height() / 2, |
| 1095 work_area.width(), | 1057 work_area.width(), |
| 1096 work_area.height() / 2); | 1058 work_area.height() / 2); |
| 1097 | 1059 |
| 1098 SetKeyboardBounds(keyboard_bounds); | 1060 SetKeyboardBounds(keyboard_bounds); |
| 1099 | 1061 |
| 1100 aura::test::TestWindowDelegate delegate; | 1062 aura::test::TestWindowDelegate delegate; |
| 1101 std::unique_ptr<aura::Window> window( | 1063 mus::Window* window( |
| 1102 CreateTestWindowInShellWithDelegate(&delegate, -1, work_area)); | 1064 CreateTestWindowInShellWithDelegate(&delegate, -1, work_area)); |
| 1103 | 1065 |
| 1104 int available_height = | 1066 int available_height = |
| 1105 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - | 1067 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() - |
| 1106 keyboard_bounds.height(); | 1068 keyboard_bounds.height(); |
| 1107 | 1069 |
| 1108 wm::ActivateWindow(window.get()); | 1070 wm::ActivateWindow(window.get()); |
| 1109 | 1071 |
| 1110 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); | 1072 EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString()); |
| 1111 ShowKeyboard(); | 1073 ShowKeyboard(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1132 occluded_window_bounds.ToString()); | 1094 occluded_window_bounds.ToString()); |
| 1133 ShowKeyboard(); | 1095 ShowKeyboard(); |
| 1134 EXPECT_EQ(gfx::Rect(50, | 1096 EXPECT_EQ(gfx::Rect(50, |
| 1135 keyboard_bounds.y() - keyboard_bounds.height()/2, | 1097 keyboard_bounds.y() - keyboard_bounds.height()/2, |
| 1136 occluded_window_bounds.width(), | 1098 occluded_window_bounds.width(), |
| 1137 occluded_window_bounds.height()).ToString(), | 1099 occluded_window_bounds.height()).ToString(), |
| 1138 window->bounds().ToString()); | 1100 window->bounds().ToString()); |
| 1139 HideKeyboard(); | 1101 HideKeyboard(); |
| 1140 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1102 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
| 1141 } | 1103 } |
| 1104 */ | |
| 1142 | 1105 |
| 1143 } // namespace ash | 1106 } // namespace wm |
| 1107 } // namespace mash | |
| OLD | NEW |