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 <map> | 7 #include <map> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 137 } |
138 | 138 |
139 ShelfLayoutManager* shelf_layout_manager() { | 139 ShelfLayoutManager* shelf_layout_manager() { |
140 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 140 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
141 } | 141 } |
142 | 142 |
143 bool GetWindowOverlapsShelf() { | 143 bool GetWindowOverlapsShelf() { |
144 return shelf_layout_manager()->window_overlaps_shelf(); | 144 return shelf_layout_manager()->window_overlaps_shelf(); |
145 } | 145 } |
146 | 146 |
147 bool IsBackgroundVisible(aura::Window* window) { | |
148 RootWindowController* controller = RootWindowController::ForWindow(window); | |
149 aura::Window* background = | |
150 controller->GetContainer(kShellWindowId_DesktopBackgroundContainer); | |
151 return background->IsVisible(); | |
152 } | |
153 | |
154 Workspace* FindBy(aura::Window* window) const { | 147 Workspace* FindBy(aura::Window* window) const { |
155 return manager_->FindBy(window); | 148 return manager_->FindBy(window); |
156 } | 149 } |
157 | 150 |
158 std::string WorkspaceStateString(Workspace* workspace) { | 151 std::string WorkspaceStateString(Workspace* workspace) { |
159 return (workspace->is_fullscreen() ? "F" : "") + | 152 return (workspace->is_fullscreen() ? "F" : "") + |
160 base::IntToString(static_cast<int>( | 153 base::IntToString(static_cast<int>( |
161 workspace->window()->children().size())); | 154 workspace->window()->children().size())); |
162 } | 155 } |
163 | 156 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 292 |
300 // Close w2. | 293 // Close w2. |
301 w2.reset(); | 294 w2.reset(); |
302 | 295 |
303 // Should have one workspace. | 296 // Should have one workspace. |
304 ASSERT_EQ("1 active=0", StateString()); | 297 ASSERT_EQ("1 active=0", StateString()); |
305 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 298 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
306 EXPECT_TRUE(w1->IsVisible()); | 299 EXPECT_TRUE(w1->IsVisible()); |
307 } | 300 } |
308 | 301 |
309 TEST_F(WorkspaceManagerTest, BackgroundWithMaximizedWindow) { | |
310 scoped_ptr<Window> w1(CreateTestWindow()); | |
311 scoped_ptr<Window> w2(CreateTestWindow()); | |
312 scoped_ptr<Window> w3(CreateTestWindow()); | |
313 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | |
314 w1->Show(); | |
315 w2->SetBounds(gfx::Rect(0, 0, 250, 251)); | |
316 w2->Show(); | |
317 w3->SetBounds(gfx::Rect(0, 0, 250, 251)); | |
318 w3->Show(); | |
319 wm::ActivateWindow(w1.get()); | |
320 wm::ActivateWindow(w2.get()); | |
321 wm::ActivateWindow(w3.get()); | |
322 EXPECT_TRUE(IsBackgroundVisible(w1.get())); | |
323 | |
324 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
325 EXPECT_FALSE(IsBackgroundVisible(w1.get())); | |
326 | |
327 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
328 EXPECT_FALSE(IsBackgroundVisible(w1.get())); | |
329 | |
330 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | |
331 EXPECT_FALSE(IsBackgroundVisible(w1.get())); | |
332 | |
333 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | |
334 EXPECT_TRUE(IsBackgroundVisible(w1.get())); | |
335 | |
336 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
337 EXPECT_FALSE(IsBackgroundVisible(w1.get())); | |
338 | |
339 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
340 EXPECT_FALSE(IsBackgroundVisible(w1.get())); | |
341 | |
342 w2.reset(); | |
343 EXPECT_FALSE(IsBackgroundVisible(w1.get())); | |
344 | |
345 w3.reset(); | |
346 EXPECT_TRUE(IsBackgroundVisible(w1.get())); | |
347 } | |
348 | |
349 // Assertions around adding a fullscreen window when empty. | 302 // Assertions around adding a fullscreen window when empty. |
350 TEST_F(WorkspaceManagerTest, AddFullscreenWindowWhenEmpty) { | 303 TEST_F(WorkspaceManagerTest, AddFullscreenWindowWhenEmpty) { |
351 scoped_ptr<Window> w1(CreateTestWindow()); | 304 scoped_ptr<Window> w1(CreateTestWindow()); |
352 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 305 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
353 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 306 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
354 w1->Show(); | 307 w1->Show(); |
355 wm::ActivateWindow(w1.get()); | 308 wm::ActivateWindow(w1.get()); |
356 | 309 |
357 ASSERT_TRUE(w1->layer() != NULL); | 310 ASSERT_TRUE(w1->layer() != NULL); |
358 EXPECT_TRUE(w1->layer()->visible()); | 311 EXPECT_TRUE(w1->layer()->visible()); |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 ASSERT_EQ("1 active=0", StateString()); | 989 ASSERT_EQ("1 active=0", StateString()); |
1037 } | 990 } |
1038 | 991 |
1039 // Verifies going from maximized to minimized sets the right state for painting | 992 // Verifies going from maximized to minimized sets the right state for painting |
1040 // the background of the launcher. | 993 // the background of the launcher. |
1041 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { | 994 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { |
1042 scoped_ptr<Window> w1(CreateTestWindow()); | 995 scoped_ptr<Window> w1(CreateTestWindow()); |
1043 w1->Show(); | 996 w1->Show(); |
1044 wm::ActivateWindow(w1.get()); | 997 wm::ActivateWindow(w1.get()); |
1045 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 998 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 999 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); |
| 1000 |
1046 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 1001 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
1047 EXPECT_EQ(SHELF_VISIBLE, | 1002 EXPECT_EQ(SHELF_VISIBLE, |
1048 shelf_layout_manager()->visibility_state()); | 1003 shelf_layout_manager()->visibility_state()); |
1049 EXPECT_FALSE(shelf_widget()->paints_background()); | 1004 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); |
1050 } | 1005 } |
1051 | 1006 |
1052 // Verifies transients are moved when fullscreen. | 1007 // Verifies transients are moved when fullscreen. |
1053 TEST_F(WorkspaceManagerTest, MoveTransientOnFullscreen) { | 1008 TEST_F(WorkspaceManagerTest, MoveTransientOnFullscreen) { |
1054 scoped_ptr<Window> w1(CreateTestWindow()); | 1009 scoped_ptr<Window> w1(CreateTestWindow()); |
1055 w1->Show(); | 1010 w1->Show(); |
1056 scoped_ptr<Window> w2(CreateTestWindow()); | 1011 scoped_ptr<Window> w2(CreateTestWindow()); |
1057 w1->AddTransientChild(w2.get()); | 1012 w1->AddTransientChild(w2.get()); |
1058 w2->Show(); | 1013 w2->Show(); |
1059 wm::ActivateWindow(w1.get()); | 1014 wm::ActivateWindow(w1.get()); |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 scoped_ptr<Window> maximized_window(CreateTestWindow()); | 1856 scoped_ptr<Window> maximized_window(CreateTestWindow()); |
1902 maximized_window->SetProperty( | 1857 maximized_window->SetProperty( |
1903 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1858 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1904 maximized_window->Show(); | 1859 maximized_window->Show(); |
1905 wm::ActivateWindow(maximized_window.get()); | 1860 wm::ActivateWindow(maximized_window.get()); |
1906 EXPECT_TRUE(maximized_window->IsVisible()); | 1861 EXPECT_TRUE(maximized_window->IsVisible()); |
1907 } | 1862 } |
1908 | 1863 |
1909 } // namespace internal | 1864 } // namespace internal |
1910 } // namespace ash | 1865 } // namespace ash |
OLD | NEW |