OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/workspace/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" |
| 11 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
11 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
12 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
13 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
14 #include "ash/test/shell_test_api.h" | 16 #include "ash/test/shell_test_api.h" |
15 #include "ash/wm/activation_controller.h" | 17 #include "ash/wm/activation_controller.h" |
16 #include "ash/wm/property_util.h" | 18 #include "ash/wm/property_util.h" |
17 #include "ash/wm/shelf_layout_manager.h" | |
18 #include "ash/wm/window_properties.h" | 19 #include "ash/wm/window_properties.h" |
19 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
20 #include "ash/wm/workspace/workspace.h" | 21 #include "ash/wm/workspace/workspace.h" |
21 #include "ash/wm/workspace_controller_test_helper.h" | 22 #include "ash/wm/workspace_controller_test_helper.h" |
22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
23 #include "base/string_number_conversions.h" | 24 #include "base/string_number_conversions.h" |
24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
25 #include "ui/aura/root_window.h" | 26 #include "ui/aura/root_window.h" |
26 #include "ui/aura/test/event_generator.h" | 27 #include "ui/aura/test/event_generator.h" |
27 #include "ui/aura/test/test_window_delegate.h" | 28 #include "ui/aura/test/test_window_delegate.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 70 } |
70 | 71 |
71 gfx::Rect GetFullscreenBounds(aura::Window* window) { | 72 gfx::Rect GetFullscreenBounds(aura::Window* window) { |
72 return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds(); | 73 return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds(); |
73 } | 74 } |
74 | 75 |
75 Workspace* active_workspace() { | 76 Workspace* active_workspace() { |
76 return manager_->active_workspace_; | 77 return manager_->active_workspace_; |
77 } | 78 } |
78 | 79 |
| 80 ShelfWidget* shelf_widget() { |
| 81 return Shell::GetPrimaryRootWindowController()->shelf(); |
| 82 } |
| 83 |
79 ShelfLayoutManager* shelf_layout_manager() { | 84 ShelfLayoutManager* shelf_layout_manager() { |
80 return Shell::GetPrimaryRootWindowController()->shelf(); | 85 return Shell::GetPrimaryRootWindowController()->shelf_layout_manager(); |
81 } | 86 } |
82 | 87 |
83 bool GetWindowOverlapsShelf() { | 88 bool GetWindowOverlapsShelf() { |
84 return shelf_layout_manager()->window_overlaps_shelf(); | 89 return shelf_layout_manager()->window_overlaps_shelf(); |
85 } | 90 } |
86 | 91 |
87 Workspace* FindBy(aura::Window* window) const { | 92 Workspace* FindBy(aura::Window* window) const { |
88 return manager_->FindBy(window); | 93 return manager_->FindBy(window); |
89 } | 94 } |
90 | 95 |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 // Verifies going from maximized to minimized sets the right state for painting | 813 // Verifies going from maximized to minimized sets the right state for painting |
809 // the background of the launcher. | 814 // the background of the launcher. |
810 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { | 815 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { |
811 scoped_ptr<Window> w1(CreateTestWindow()); | 816 scoped_ptr<Window> w1(CreateTestWindow()); |
812 w1->Show(); | 817 w1->Show(); |
813 wm::ActivateWindow(w1.get()); | 818 wm::ActivateWindow(w1.get()); |
814 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 819 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
815 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 820 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
816 EXPECT_EQ(SHELF_VISIBLE, | 821 EXPECT_EQ(SHELF_VISIBLE, |
817 shelf_layout_manager()->visibility_state()); | 822 shelf_layout_manager()->visibility_state()); |
818 EXPECT_FALSE(Launcher::ForPrimaryDisplay()->paints_background()); | 823 EXPECT_FALSE(shelf_widget()->paints_background()); |
819 } | 824 } |
820 | 825 |
821 // Verifies transients are moved when maximizing. | 826 // Verifies transients are moved when maximizing. |
822 TEST_F(WorkspaceManagerTest, MoveTransientOnMaximize) { | 827 TEST_F(WorkspaceManagerTest, MoveTransientOnMaximize) { |
823 scoped_ptr<Window> w1(CreateTestWindow()); | 828 scoped_ptr<Window> w1(CreateTestWindow()); |
824 w1->Show(); | 829 w1->Show(); |
825 scoped_ptr<Window> w2(CreateTestWindow()); | 830 scoped_ptr<Window> w2(CreateTestWindow()); |
826 w1->AddTransientChild(w2.get()); | 831 w1->AddTransientChild(w2.get()); |
827 w2->Show(); | 832 w2->Show(); |
828 wm::ActivateWindow(w1.get()); | 833 wm::ActivateWindow(w1.get()); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 | 958 |
954 // Create another window and maximize it. | 959 // Create another window and maximize it. |
955 scoped_ptr<Window> w2(CreateTestWindow()); | 960 scoped_ptr<Window> w2(CreateTestWindow()); |
956 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 961 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
957 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 962 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
958 w2->Show(); | 963 w2->Show(); |
959 wm::ActivateWindow(w2.get()); | 964 wm::ActivateWindow(w2.get()); |
960 | 965 |
961 // Increase the size of the shelf. This would make |w1| fall completely out of | 966 // Increase the size of the shelf. This would make |w1| fall completely out of |
962 // the display work area. | 967 // the display work area. |
963 gfx::Size size(shelf->status_area_widget()->GetWindowBoundsInScreen().size()); | 968 gfx::Size size(shelf_widget()->status_area_widget()-> |
| 969 GetWindowBoundsInScreen().size()); |
964 size.Enlarge(0, 30); | 970 size.Enlarge(0, 30); |
965 shelf->status_area_widget()->SetSize(size); | 971 shelf_widget()->status_area_widget()->SetSize(size); |
966 | 972 |
967 // Switch to w1. The window should have moved. | 973 // Switch to w1. The window should have moved. |
968 wm::ActivateWindow(w1.get()); | 974 wm::ActivateWindow(w1.get()); |
969 EXPECT_NE(w1_bounds.ToString(), w1->bounds().ToString()); | 975 EXPECT_NE(w1_bounds.ToString(), w1->bounds().ToString()); |
970 } | 976 } |
971 | 977 |
972 // Verifies Focus() works in a window that isn't in the active workspace. | 978 // Verifies Focus() works in a window that isn't in the active workspace. |
973 TEST_F(WorkspaceManagerTest, FocusOnFullscreenInSeparateWorkspace) { | 979 TEST_F(WorkspaceManagerTest, FocusOnFullscreenInSeparateWorkspace) { |
974 scoped_ptr<Window> w1(CreateTestWindow()); | 980 scoped_ptr<Window> w1(CreateTestWindow()); |
975 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); | 981 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 window2->layer()->GetAnimator()->StopAnimating(); | 1440 window2->layer()->GetAnimator()->StopAnimating(); |
1435 // |window1| should be flush right and |window2| flush left. | 1441 // |window1| should be flush right and |window2| flush left. |
1436 EXPECT_EQ(base::IntToString( | 1442 EXPECT_EQ(base::IntToString( |
1437 desktop_area.width() - window1->bounds().width()) + | 1443 desktop_area.width() - window1->bounds().width()) + |
1438 ",32 640x320", window1->bounds().ToString()); | 1444 ",32 640x320", window1->bounds().ToString()); |
1439 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); | 1445 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); |
1440 } | 1446 } |
1441 | 1447 |
1442 } // namespace internal | 1448 } // namespace internal |
1443 } // namespace ash | 1449 } // namespace ash |
OLD | NEW |