| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // d2 must have been deleted. | 189 // d2 must have been deleted. |
| 190 EXPECT_FALSE(tracker.Contains(d2)); | 190 EXPECT_FALSE(tracker.Contains(d2)); |
| 191 | 191 |
| 192 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 192 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
| 193 EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 193 EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
| 194 EXPECT_EQ("50,10 100x100", | 194 EXPECT_EQ("50,10 100x100", |
| 195 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 195 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 196 | 196 |
| 197 // Maximized area on primary display has 3px (given as | 197 // Maximized area on primary display has 3px (given as |
| 198 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. | 198 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. |
| 199 |
| 200 // First clear fullscreen status, since both fullscreen and maximized windows |
| 201 // share the same desktop workspace, which cancels the shelf status. |
| 202 fullscreen->SetFullscreen(false); |
| 199 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 203 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
| 200 EXPECT_EQ("0,0 600x597", | 204 EXPECT_EQ("0,0 600x597", |
| 201 maximized->GetWindowBoundsInScreen().ToString()); | 205 maximized->GetWindowBoundsInScreen().ToString()); |
| 202 EXPECT_EQ("0,0 600x597", | 206 EXPECT_EQ("0,0 600x597", |
| 203 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 207 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 204 | 208 |
| 209 // Set fullscreen to true. In that case the 3px inset becomes invisible so |
| 210 // the maximized window can also use the area fully. |
| 211 fullscreen->SetFullscreen(true); |
| 212 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
| 213 EXPECT_EQ("0,0 600x600", |
| 214 maximized->GetWindowBoundsInScreen().ToString()); |
| 215 EXPECT_EQ("0,0 600x600", |
| 216 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 217 |
| 205 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 218 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
| 206 EXPECT_EQ("200,10 100x100", | 219 EXPECT_EQ("200,10 100x100", |
| 207 minimized->GetWindowBoundsInScreen().ToString()); | 220 minimized->GetWindowBoundsInScreen().ToString()); |
| 208 | 221 |
| 209 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 222 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
| 210 EXPECT_TRUE(fullscreen->IsFullscreen()); | 223 EXPECT_TRUE(fullscreen->IsFullscreen()); |
| 211 EXPECT_EQ("0,0 600x600", | 224 EXPECT_EQ("0,0 600x600", |
| 212 fullscreen->GetWindowBoundsInScreen().ToString()); | 225 fullscreen->GetWindowBoundsInScreen().ToString()); |
| 213 EXPECT_EQ("0,0 600x600", | 226 EXPECT_EQ("0,0 600x600", |
| 214 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 227 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 w2->SetFullscreen(true); | 383 w2->SetFullscreen(true); |
| 371 // |w3| is a transient child of |w2|. | 384 // |w3| is a transient child of |w2|. |
| 372 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, | 385 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, |
| 373 w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 386 w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
| 374 | 387 |
| 375 // Test that GetFullscreenWindow() finds the fullscreen window when one of | 388 // Test that GetFullscreenWindow() finds the fullscreen window when one of |
| 376 // its transient children is active. | 389 // its transient children is active. |
| 377 w3->Activate(); | 390 w3->Activate(); |
| 378 EXPECT_EQ(w2->GetNativeWindow(), controller->GetFullscreenWindow()); | 391 EXPECT_EQ(w2->GetNativeWindow(), controller->GetFullscreenWindow()); |
| 379 | 392 |
| 380 // Activate the maximized window's workspace. GetFullscreenWindow() should | 393 // Since there's only one desktop workspace, it always returns the same |
| 381 // fail because the fullscreen window's workspace is no longer active. | 394 // fullscreen window. |
| 382 w1->Activate(); | 395 w1->Activate(); |
| 383 EXPECT_FALSE(controller->GetFullscreenWindow()); | |
| 384 | |
| 385 // If the fullscreen window is active, GetFullscreenWindow() should find it. | |
| 386 w2->Activate(); | |
| 387 EXPECT_EQ(w2->GetNativeWindow(), controller->GetFullscreenWindow()); | 396 EXPECT_EQ(w2->GetNativeWindow(), controller->GetFullscreenWindow()); |
| 388 } | 397 } |
| 389 | 398 |
| 390 // Test that user session window can't be focused if user session blocked by | 399 // Test that user session window can't be focused if user session blocked by |
| 391 // some overlapping UI. | 400 // some overlapping UI. |
| 392 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { | 401 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { |
| 393 UpdateDisplay("600x600"); | 402 UpdateDisplay("600x600"); |
| 394 internal::RootWindowController* controller = | 403 internal::RootWindowController* controller = |
| 395 Shell::GetInstance()->GetPrimaryRootWindowController(); | 404 Shell::GetInstance()->GetPrimaryRootWindowController(); |
| 396 aura::Window* lock_container = | 405 aura::Window* lock_container = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 415 SetSessionStarted(false); | 424 SetSessionStarted(false); |
| 416 lock_window->Focus(); | 425 lock_window->Focus(); |
| 417 EXPECT_TRUE(lock_window->HasFocus()); | 426 EXPECT_TRUE(lock_window->HasFocus()); |
| 418 session_window->Focus(); | 427 session_window->Focus(); |
| 419 EXPECT_FALSE(session_window->HasFocus()); | 428 EXPECT_FALSE(session_window->HasFocus()); |
| 420 SetSessionStarted(true); | 429 SetSessionStarted(true); |
| 421 } | 430 } |
| 422 | 431 |
| 423 } // namespace test | 432 } // namespace test |
| 424 } // namespace ash | 433 } // namespace ash |
| OLD | NEW |