| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/maximize_mode/maximize_mode_window_manager.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 // Test that existing windows will handled properly when going into maximized | 154 // Test that existing windows will handled properly when going into maximized |
| 155 // mode. | 155 // mode. |
| 156 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) { | 156 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) { |
| 157 // Bounds for windows we know can be controlled. | 157 // Bounds for windows we know can be controlled. |
| 158 gfx::Rect rect1(10, 10, 200, 50); | 158 gfx::Rect rect1(10, 10, 200, 50); |
| 159 gfx::Rect rect2(10, 60, 200, 50); | 159 gfx::Rect rect2(10, 60, 200, 50); |
| 160 gfx::Rect rect3(20, 140, 100, 100); | 160 gfx::Rect rect3(20, 140, 100, 100); |
| 161 // Bounds for anything else. | 161 // Bounds for anything else. |
| 162 gfx::Rect rect(80, 90, 100, 110); | 162 gfx::Rect rect(80, 90, 100, 110); |
| 163 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); | 163 std::unique_ptr<aura::Window> w1( |
| 164 scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 164 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); |
| 165 scoped_ptr<aura::Window> w3( | 165 std::unique_ptr<aura::Window> w2( |
| 166 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 167 std::unique_ptr<aura::Window> w3( |
| 166 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); | 168 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); |
| 167 scoped_ptr<aura::Window> w4(CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect)); | 169 std::unique_ptr<aura::Window> w4( |
| 168 scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect)); | 170 CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect)); |
| 169 scoped_ptr<aura::Window> w6(CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect)); | 171 std::unique_ptr<aura::Window> w5( |
| 170 scoped_ptr<aura::Window> w7(CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect)); | 172 CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect)); |
| 171 scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); | 173 std::unique_ptr<aura::Window> w6( |
| 174 CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect)); |
| 175 std::unique_ptr<aura::Window> w7( |
| 176 CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect)); |
| 177 std::unique_ptr<aura::Window> w8( |
| 178 CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); |
| 172 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); | 179 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); |
| 173 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); | 180 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 174 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); | 181 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); |
| 175 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); | 182 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); |
| 176 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); | 183 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); |
| 177 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); | 184 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); |
| 178 | 185 |
| 179 // Create the manager and make sure that all qualifying windows were detected | 186 // Create the manager and make sure that all qualifying windows were detected |
| 180 // and changed. | 187 // and changed. |
| 181 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 188 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 223 } |
| 217 | 224 |
| 218 // The same test as the above but while a system modal dialog is shown. | 225 // The same test as the above but while a system modal dialog is shown. |
| 219 TEST_F(MaximizeModeWindowManagerTest, GoingToMaximizedWithModalDialogPresent) { | 226 TEST_F(MaximizeModeWindowManagerTest, GoingToMaximizedWithModalDialogPresent) { |
| 220 // Bounds for windows we know can be controlled. | 227 // Bounds for windows we know can be controlled. |
| 221 gfx::Rect rect1(10, 10, 200, 50); | 228 gfx::Rect rect1(10, 10, 200, 50); |
| 222 gfx::Rect rect2(10, 60, 200, 50); | 229 gfx::Rect rect2(10, 60, 200, 50); |
| 223 gfx::Rect rect3(20, 140, 100, 100); | 230 gfx::Rect rect3(20, 140, 100, 100); |
| 224 // Bounds for anything else. | 231 // Bounds for anything else. |
| 225 gfx::Rect rect(80, 90, 100, 110); | 232 gfx::Rect rect(80, 90, 100, 110); |
| 226 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); | 233 std::unique_ptr<aura::Window> w1( |
| 227 scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 234 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); |
| 228 scoped_ptr<aura::Window> w3( | 235 std::unique_ptr<aura::Window> w2( |
| 236 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 237 std::unique_ptr<aura::Window> w3( |
| 229 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); | 238 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); |
| 230 scoped_ptr<aura::Window> w4(CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect)); | 239 std::unique_ptr<aura::Window> w4( |
| 231 scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect)); | 240 CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect)); |
| 232 scoped_ptr<aura::Window> w6(CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect)); | 241 std::unique_ptr<aura::Window> w5( |
| 233 scoped_ptr<aura::Window> w7(CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect)); | 242 CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect)); |
| 234 scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); | 243 std::unique_ptr<aura::Window> w6( |
| 244 CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect)); |
| 245 std::unique_ptr<aura::Window> w7( |
| 246 CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect)); |
| 247 std::unique_ptr<aura::Window> w8( |
| 248 CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); |
| 235 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); | 249 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); |
| 236 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); | 250 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 237 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); | 251 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); |
| 238 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); | 252 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); |
| 239 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); | 253 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); |
| 240 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); | 254 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); |
| 241 | 255 |
| 242 // Enable system modal dialog, and make sure both shelves are still hidden. | 256 // Enable system modal dialog, and make sure both shelves are still hidden. |
| 243 ash::Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); | 257 ash::Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); |
| 244 EXPECT_TRUE(ash::Shell::GetInstance()->IsSystemModalWindowOpen()); | 258 EXPECT_TRUE(ash::Shell::GetInstance()->IsSystemModalWindowOpen()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 297 } |
| 284 | 298 |
| 285 // Test that non-maximizable windows get properly handled when going into | 299 // Test that non-maximizable windows get properly handled when going into |
| 286 // maximized mode. | 300 // maximized mode. |
| 287 TEST_F(MaximizeModeWindowManagerTest, | 301 TEST_F(MaximizeModeWindowManagerTest, |
| 288 PreCreateNonMaximizableButResizableWindows) { | 302 PreCreateNonMaximizableButResizableWindows) { |
| 289 // The window bounds. | 303 // The window bounds. |
| 290 gfx::Rect rect(10, 10, 200, 50); | 304 gfx::Rect rect(10, 10, 200, 50); |
| 291 gfx::Size max_size(300, 200); | 305 gfx::Size max_size(300, 200); |
| 292 gfx::Size empty_size; | 306 gfx::Size empty_size; |
| 293 scoped_ptr<aura::Window> unlimited_window( | 307 std::unique_ptr<aura::Window> unlimited_window( |
| 294 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size)); | 308 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size)); |
| 295 scoped_ptr<aura::Window> limited_window( | 309 std::unique_ptr<aura::Window> limited_window( |
| 296 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); | 310 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); |
| 297 scoped_ptr<aura::Window> fixed_window( | 311 std::unique_ptr<aura::Window> fixed_window( |
| 298 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 312 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 299 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); | 313 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); |
| 300 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); | 314 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); |
| 301 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); | 315 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); |
| 302 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); | 316 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); |
| 303 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); | 317 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); |
| 304 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); | 318 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); |
| 305 | 319 |
| 306 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( | 320 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( |
| 307 unlimited_window.get()).size(); | 321 unlimited_window.get()).size(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ASSERT_TRUE(manager); | 360 ASSERT_TRUE(manager); |
| 347 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); | 361 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); |
| 348 | 362 |
| 349 // Create the windows and see that the window manager picks them up. | 363 // Create the windows and see that the window manager picks them up. |
| 350 // Rects for windows we know can be controlled. | 364 // Rects for windows we know can be controlled. |
| 351 gfx::Rect rect1(10, 10, 200, 50); | 365 gfx::Rect rect1(10, 10, 200, 50); |
| 352 gfx::Rect rect2(10, 60, 200, 50); | 366 gfx::Rect rect2(10, 60, 200, 50); |
| 353 gfx::Rect rect3(20, 140, 100, 100); | 367 gfx::Rect rect3(20, 140, 100, 100); |
| 354 // One rect for anything else. | 368 // One rect for anything else. |
| 355 gfx::Rect rect(80, 90, 100, 110); | 369 gfx::Rect rect(80, 90, 100, 110); |
| 356 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); | 370 std::unique_ptr<aura::Window> w1( |
| 357 scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 371 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); |
| 358 scoped_ptr<aura::Window> w3( | 372 std::unique_ptr<aura::Window> w2( |
| 373 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 374 std::unique_ptr<aura::Window> w3( |
| 359 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); | 375 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); |
| 360 scoped_ptr<aura::Window> w4(CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect)); | 376 std::unique_ptr<aura::Window> w4( |
| 361 scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect)); | 377 CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect)); |
| 362 scoped_ptr<aura::Window> w6(CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect)); | 378 std::unique_ptr<aura::Window> w5( |
| 363 scoped_ptr<aura::Window> w7(CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect)); | 379 CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect)); |
| 364 scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); | 380 std::unique_ptr<aura::Window> w6( |
| 381 CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect)); |
| 382 std::unique_ptr<aura::Window> w7( |
| 383 CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect)); |
| 384 std::unique_ptr<aura::Window> w8( |
| 385 CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); |
| 365 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); | 386 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); |
| 366 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 387 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 367 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); | 388 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); |
| 368 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); | 389 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); |
| 369 | 390 |
| 370 // Make sure that the position of the unresizable window is in the middle of | 391 // Make sure that the position of the unresizable window is in the middle of |
| 371 // the screen. | 392 // the screen. |
| 372 gfx::Size work_area_size = | 393 gfx::Size work_area_size = |
| 373 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w3.get()).size(); | 394 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w3.get()).size(); |
| 374 gfx::Point center = | 395 gfx::Point center = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // is active gets restored to a usable (non tiny) size upon switching back. | 430 // is active gets restored to a usable (non tiny) size upon switching back. |
| 410 TEST_F(MaximizeModeWindowManagerTest, | 431 TEST_F(MaximizeModeWindowManagerTest, |
| 411 CreateWindowInMaximizedModeRestoresToUsefulSize) { | 432 CreateWindowInMaximizedModeRestoresToUsefulSize) { |
| 412 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 433 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 413 ASSERT_TRUE(manager); | 434 ASSERT_TRUE(manager); |
| 414 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); | 435 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); |
| 415 | 436 |
| 416 // We pass in an empty rectangle to simulate a window creation with no | 437 // We pass in an empty rectangle to simulate a window creation with no |
| 417 // particular size. | 438 // particular size. |
| 418 gfx::Rect empty_rect(0, 0, 0, 0); | 439 gfx::Rect empty_rect(0, 0, 0, 0); |
| 419 scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, | 440 std::unique_ptr<aura::Window> window( |
| 420 empty_rect)); | 441 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, empty_rect)); |
| 421 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); | 442 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); |
| 422 EXPECT_NE(empty_rect.ToString(), window->bounds().ToString()); | 443 EXPECT_NE(empty_rect.ToString(), window->bounds().ToString()); |
| 423 gfx::Rect maximized_size = window->bounds(); | 444 gfx::Rect maximized_size = window->bounds(); |
| 424 | 445 |
| 425 // Destroy the maximize mode and check that the resulting size of the window | 446 // Destroy the maximize mode and check that the resulting size of the window |
| 426 // is remaining as it is (but not maximized). | 447 // is remaining as it is (but not maximized). |
| 427 DestroyMaximizeModeWindowManager(); | 448 DestroyMaximizeModeWindowManager(); |
| 428 | 449 |
| 429 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); | 450 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); |
| 430 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString()); | 451 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString()); |
| 431 } | 452 } |
| 432 | 453 |
| 433 // Test that non-maximizable windows get properly handled when created in | 454 // Test that non-maximizable windows get properly handled when created in |
| 434 // maximized mode. | 455 // maximized mode. |
| 435 TEST_F(MaximizeModeWindowManagerTest, | 456 TEST_F(MaximizeModeWindowManagerTest, |
| 436 CreateNonMaximizableButResizableWindows) { | 457 CreateNonMaximizableButResizableWindows) { |
| 437 // Create the manager and make sure that all qualifying windows were detected | 458 // Create the manager and make sure that all qualifying windows were detected |
| 438 // and changed. | 459 // and changed. |
| 439 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 460 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 440 ASSERT_TRUE(manager); | 461 ASSERT_TRUE(manager); |
| 441 | 462 |
| 442 gfx::Rect rect(10, 10, 200, 50); | 463 gfx::Rect rect(10, 10, 200, 50); |
| 443 gfx::Size max_size(300, 200); | 464 gfx::Size max_size(300, 200); |
| 444 gfx::Size empty_size; | 465 gfx::Size empty_size; |
| 445 scoped_ptr<aura::Window> unlimited_window( | 466 std::unique_ptr<aura::Window> unlimited_window( |
| 446 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size)); | 467 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size)); |
| 447 scoped_ptr<aura::Window> limited_window( | 468 std::unique_ptr<aura::Window> limited_window( |
| 448 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); | 469 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); |
| 449 scoped_ptr<aura::Window> fixed_window( | 470 std::unique_ptr<aura::Window> fixed_window( |
| 450 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 471 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 451 | 472 |
| 452 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( | 473 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( |
| 453 unlimited_window.get()).size(); | 474 unlimited_window.get()).size(); |
| 454 | 475 |
| 455 // All windows should be sized now as big as possible and be centered. | 476 // All windows should be sized now as big as possible and be centered. |
| 456 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); | 477 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); |
| 457 // The unlimited window should have the size of the workspace / parent window. | 478 // The unlimited window should have the size of the workspace / parent window. |
| 458 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); | 479 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); |
| 459 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString()); | 480 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 523 } |
| 503 return std::string(); | 524 return std::string(); |
| 504 } | 525 } |
| 505 | 526 |
| 506 // Test that the restore state will be kept at its original value for | 527 // Test that the restore state will be kept at its original value for |
| 507 // session restauration purposes. | 528 // session restauration purposes. |
| 508 TEST_F(MaximizeModeWindowManagerTest, TestRestoreIntegrety) { | 529 TEST_F(MaximizeModeWindowManagerTest, TestRestoreIntegrety) { |
| 509 gfx::Rect bounds(10, 10, 200, 50); | 530 gfx::Rect bounds(10, 10, 200, 50); |
| 510 gfx::Size empty_size; | 531 gfx::Size empty_size; |
| 511 gfx::Rect empty_bounds; | 532 gfx::Rect empty_bounds; |
| 512 scoped_ptr<aura::Window> normal_window( | 533 std::unique_ptr<aura::Window> normal_window(CreateWindowWithWidget(bounds)); |
| 513 CreateWindowWithWidget(bounds)); | 534 std::unique_ptr<aura::Window> maximized_window( |
| 514 scoped_ptr<aura::Window> maximized_window( | |
| 515 CreateWindowWithWidget(bounds)); | 535 CreateWindowWithWidget(bounds)); |
| 516 wm::GetWindowState(maximized_window.get())->Maximize(); | 536 wm::GetWindowState(maximized_window.get())->Maximize(); |
| 517 | 537 |
| 518 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get())); | 538 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get())); |
| 519 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); | 539 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); |
| 520 | 540 |
| 521 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 541 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 522 ASSERT_TRUE(manager); | 542 ASSERT_TRUE(manager); |
| 523 | 543 |
| 524 // With the maximization the override states should be returned in its | 544 // With the maximization the override states should be returned in its |
| (...skipping 25 matching lines...) Expand all Loading... |
| 550 // destroyed while the maximizer is still running. | 570 // destroyed while the maximizer is still running. |
| 551 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) { | 571 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) { |
| 552 ash::MaximizeModeWindowManager* manager = NULL; | 572 ash::MaximizeModeWindowManager* manager = NULL; |
| 553 { | 573 { |
| 554 // Bounds for windows we know can be controlled. | 574 // Bounds for windows we know can be controlled. |
| 555 gfx::Rect rect1(10, 10, 200, 50); | 575 gfx::Rect rect1(10, 10, 200, 50); |
| 556 gfx::Rect rect2(10, 60, 200, 50); | 576 gfx::Rect rect2(10, 60, 200, 50); |
| 557 gfx::Rect rect3(20, 140, 100, 100); | 577 gfx::Rect rect3(20, 140, 100, 100); |
| 558 // Bounds for anything else. | 578 // Bounds for anything else. |
| 559 gfx::Rect rect(80, 90, 100, 110); | 579 gfx::Rect rect(80, 90, 100, 110); |
| 560 scoped_ptr<aura::Window> w1( | 580 std::unique_ptr<aura::Window> w1( |
| 561 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); | 581 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); |
| 562 scoped_ptr<aura::Window> w2( | 582 std::unique_ptr<aura::Window> w2( |
| 563 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 583 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 564 scoped_ptr<aura::Window> w3( | 584 std::unique_ptr<aura::Window> w3( |
| 565 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); | 585 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); |
| 566 | 586 |
| 567 // Create the manager and make sure that all qualifying windows were | 587 // Create the manager and make sure that all qualifying windows were |
| 568 // detected and changed. | 588 // detected and changed. |
| 569 manager = CreateMaximizeModeWindowManager(); | 589 manager = CreateMaximizeModeWindowManager(); |
| 570 ASSERT_TRUE(manager); | 590 ASSERT_TRUE(manager); |
| 571 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); | 591 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); |
| 572 } | 592 } |
| 573 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); | 593 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); |
| 574 DestroyMaximizeModeWindowManager(); | 594 DestroyMaximizeModeWindowManager(); |
| 575 } | 595 } |
| 576 | 596 |
| 577 // Test that windows which got created while the maximizer was running can get | 597 // Test that windows which got created while the maximizer was running can get |
| 578 // destroyed before the maximizer gets destroyed. | 598 // destroyed before the maximizer gets destroyed. |
| 579 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) { | 599 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) { |
| 580 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 600 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 581 ASSERT_TRUE(manager); | 601 ASSERT_TRUE(manager); |
| 582 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); | 602 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); |
| 583 { | 603 { |
| 584 // Bounds for windows we know can be controlled. | 604 // Bounds for windows we know can be controlled. |
| 585 gfx::Rect rect1(10, 10, 200, 50); | 605 gfx::Rect rect1(10, 10, 200, 50); |
| 586 gfx::Rect rect2(10, 60, 200, 50); | 606 gfx::Rect rect2(10, 60, 200, 50); |
| 587 gfx::Rect rect3(20, 140, 100, 100); | 607 gfx::Rect rect3(20, 140, 100, 100); |
| 588 scoped_ptr<aura::Window> w1( | 608 std::unique_ptr<aura::Window> w1( |
| 589 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); | 609 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); |
| 590 scoped_ptr<aura::Window> w2( | 610 std::unique_ptr<aura::Window> w2( |
| 591 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 60, 200, 50))); | 611 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 60, 200, 50))); |
| 592 scoped_ptr<aura::Window> w3( | 612 std::unique_ptr<aura::Window> w3(CreateFixedSizeNonMaximizableWindow( |
| 593 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, | 613 ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(20, 140, 100, 100))); |
| 594 gfx::Rect(20, 140, 100, 100))); | |
| 595 // Check that the windows got automatically maximized as well. | 614 // Check that the windows got automatically maximized as well. |
| 596 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); | 615 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); |
| 597 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); | 616 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); |
| 598 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 617 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 599 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); | 618 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); |
| 600 } | 619 } |
| 601 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); | 620 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); |
| 602 DestroyMaximizeModeWindowManager(); | 621 DestroyMaximizeModeWindowManager(); |
| 603 } | 622 } |
| 604 | 623 |
| 605 // Test that windows which were maximized stay maximized. | 624 // Test that windows which were maximized stay maximized. |
| 606 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) { | 625 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) { |
| 607 // Bounds for windows we know can be controlled. | 626 // Bounds for windows we know can be controlled. |
| 608 gfx::Rect rect(10, 10, 200, 50); | 627 gfx::Rect rect(10, 10, 200, 50); |
| 609 scoped_ptr<aura::Window> window( | 628 std::unique_ptr<aura::Window> window( |
| 610 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 629 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 611 wm::GetWindowState(window.get())->Maximize(); | 630 wm::GetWindowState(window.get())->Maximize(); |
| 612 | 631 |
| 613 // Create the manager and make sure that the window gets detected. | 632 // Create the manager and make sure that the window gets detected. |
| 614 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 633 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 615 ASSERT_TRUE(manager); | 634 ASSERT_TRUE(manager); |
| 616 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); | 635 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); |
| 617 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); | 636 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); |
| 618 | 637 |
| 619 // Destroy the manager again and check that the window will remain maximized. | 638 // Destroy the manager again and check that the window will remain maximized. |
| 620 DestroyMaximizeModeWindowManager(); | 639 DestroyMaximizeModeWindowManager(); |
| 621 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); | 640 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); |
| 622 wm::GetWindowState(window.get())->Restore(); | 641 wm::GetWindowState(window.get())->Restore(); |
| 623 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); | 642 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); |
| 624 } | 643 } |
| 625 | 644 |
| 626 // Test that minimized windows do neither get maximized nor restored upon | 645 // Test that minimized windows do neither get maximized nor restored upon |
| 627 // entering maximized mode and get restored to their previous state after | 646 // entering maximized mode and get restored to their previous state after |
| 628 // leaving. | 647 // leaving. |
| 629 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) { | 648 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) { |
| 630 // Bounds for windows we know can be controlled. | 649 // Bounds for windows we know can be controlled. |
| 631 gfx::Rect rect(10, 10, 200, 50); | 650 gfx::Rect rect(10, 10, 200, 50); |
| 632 scoped_ptr<aura::Window> initially_minimized_window( | 651 std::unique_ptr<aura::Window> initially_minimized_window( |
| 633 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 652 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 634 scoped_ptr<aura::Window> initially_normal_window( | 653 std::unique_ptr<aura::Window> initially_normal_window( |
| 635 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 654 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 636 scoped_ptr<aura::Window> initially_maximized_window( | 655 std::unique_ptr<aura::Window> initially_maximized_window( |
| 637 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 656 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 638 wm::GetWindowState(initially_minimized_window.get())->Minimize(); | 657 wm::GetWindowState(initially_minimized_window.get())->Minimize(); |
| 639 wm::GetWindowState(initially_maximized_window.get())->Maximize(); | 658 wm::GetWindowState(initially_maximized_window.get())->Maximize(); |
| 640 | 659 |
| 641 // Create the manager and make sure that the window gets detected. | 660 // Create the manager and make sure that the window gets detected. |
| 642 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 661 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 643 ASSERT_TRUE(manager); | 662 ASSERT_TRUE(manager); |
| 644 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); | 663 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); |
| 645 EXPECT_TRUE(wm::GetWindowState( | 664 EXPECT_TRUE(wm::GetWindowState( |
| 646 initially_minimized_window.get())->IsMinimized()); | 665 initially_minimized_window.get())->IsMinimized()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 667 EXPECT_TRUE(wm::GetWindowState( | 686 EXPECT_TRUE(wm::GetWindowState( |
| 668 initially_maximized_window.get())->IsMaximized()); | 687 initially_maximized_window.get())->IsMaximized()); |
| 669 } | 688 } |
| 670 | 689 |
| 671 // Check that resizing the desktop does reposition unmaximizable, unresizable & | 690 // Check that resizing the desktop does reposition unmaximizable, unresizable & |
| 672 // managed windows. | 691 // managed windows. |
| 673 TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) { | 692 TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) { |
| 674 UpdateDisplay("400x400"); | 693 UpdateDisplay("400x400"); |
| 675 // This window will move because it does not fit the new bounds. | 694 // This window will move because it does not fit the new bounds. |
| 676 gfx::Rect rect(20, 300, 100, 100); | 695 gfx::Rect rect(20, 300, 100, 100); |
| 677 scoped_ptr<aura::Window> window1( | 696 std::unique_ptr<aura::Window> window1( |
| 678 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 697 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 679 EXPECT_EQ(rect.ToString(), window1->bounds().ToString()); | 698 EXPECT_EQ(rect.ToString(), window1->bounds().ToString()); |
| 680 | 699 |
| 681 // This window will not move because it does fit the new bounds. | 700 // This window will not move because it does fit the new bounds. |
| 682 gfx::Rect rect2(20, 140, 100, 100); | 701 gfx::Rect rect2(20, 140, 100, 100); |
| 683 scoped_ptr<aura::Window> window2( | 702 std::unique_ptr<aura::Window> window2( |
| 684 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 703 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 685 | 704 |
| 686 // Turning on the manager will reposition (but not resize) the window. | 705 // Turning on the manager will reposition (but not resize) the window. |
| 687 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 706 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 688 ASSERT_TRUE(manager); | 707 ASSERT_TRUE(manager); |
| 689 EXPECT_EQ(2, manager->GetNumberOfManagedWindows()); | 708 EXPECT_EQ(2, manager->GetNumberOfManagedWindows()); |
| 690 gfx::Rect moved_bounds(window1->bounds()); | 709 gfx::Rect moved_bounds(window1->bounds()); |
| 691 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); | 710 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); |
| 692 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); | 711 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); |
| 693 | 712 |
| 694 // Simulating a desktop resize should move the window again. | 713 // Simulating a desktop resize should move the window again. |
| 695 UpdateDisplay("300x300"); | 714 UpdateDisplay("300x300"); |
| 696 gfx::Rect new_moved_bounds(window1->bounds()); | 715 gfx::Rect new_moved_bounds(window1->bounds()); |
| 697 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); | 716 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); |
| 698 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); | 717 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); |
| 699 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); | 718 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); |
| 700 | 719 |
| 701 // Turning off the mode should not restore to the initial coordinates since | 720 // Turning off the mode should not restore to the initial coordinates since |
| 702 // the new resolution is smaller and the window was on the edge. | 721 // the new resolution is smaller and the window was on the edge. |
| 703 DestroyMaximizeModeWindowManager(); | 722 DestroyMaximizeModeWindowManager(); |
| 704 EXPECT_NE(rect.ToString(), window1->bounds().ToString()); | 723 EXPECT_NE(rect.ToString(), window1->bounds().ToString()); |
| 705 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString()); | 724 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString()); |
| 706 } | 725 } |
| 707 | 726 |
| 708 // Check that windows return to original location if desktop size changes to | 727 // Check that windows return to original location if desktop size changes to |
| 709 // something else and back while in maximize mode. | 728 // something else and back while in maximize mode. |
| 710 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) { | 729 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) { |
| 711 gfx::Rect rect(20, 140, 100, 100); | 730 gfx::Rect rect(20, 140, 100, 100); |
| 712 scoped_ptr<aura::Window> window( | 731 std::unique_ptr<aura::Window> window( |
| 713 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 732 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 714 | 733 |
| 715 // Turning on the manager will reposition (but not resize) the window. | 734 // Turning on the manager will reposition (but not resize) the window. |
| 716 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 735 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 717 ASSERT_TRUE(manager); | 736 ASSERT_TRUE(manager); |
| 718 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); | 737 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); |
| 719 gfx::Rect moved_bounds(window->bounds()); | 738 gfx::Rect moved_bounds(window->bounds()); |
| 720 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); | 739 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); |
| 721 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); | 740 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); |
| 722 | 741 |
| 723 // Simulating a desktop resize should move the window again. | 742 // Simulating a desktop resize should move the window again. |
| 724 ResizeDesktop(-10); | 743 ResizeDesktop(-10); |
| 725 gfx::Rect new_moved_bounds(window->bounds()); | 744 gfx::Rect new_moved_bounds(window->bounds()); |
| 726 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); | 745 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); |
| 727 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); | 746 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); |
| 728 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); | 747 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); |
| 729 | 748 |
| 730 // Then resize back to the original desktop size which should move windows | 749 // Then resize back to the original desktop size which should move windows |
| 731 // to their original location after leaving the maximize mode. | 750 // to their original location after leaving the maximize mode. |
| 732 ResizeDesktop(10); | 751 ResizeDesktop(10); |
| 733 DestroyMaximizeModeWindowManager(); | 752 DestroyMaximizeModeWindowManager(); |
| 734 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); | 753 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); |
| 735 } | 754 } |
| 736 | 755 |
| 737 // Check that enabling of the maximize mode does not have an impact on the MRU | 756 // Check that enabling of the maximize mode does not have an impact on the MRU |
| 738 // order of windows. | 757 // order of windows. |
| 739 TEST_F(MaximizeModeWindowManagerTest, ModeChangeKeepsMRUOrder) { | 758 TEST_F(MaximizeModeWindowManagerTest, ModeChangeKeepsMRUOrder) { |
| 740 gfx::Rect rect(20, 140, 100, 100); | 759 gfx::Rect rect(20, 140, 100, 100); |
| 741 scoped_ptr<aura::Window> w1( | 760 std::unique_ptr<aura::Window> w1( |
| 742 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 761 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 743 scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 762 std::unique_ptr<aura::Window> w2( |
| 744 scoped_ptr<aura::Window> w3(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 763 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 745 scoped_ptr<aura::Window> w4( | 764 std::unique_ptr<aura::Window> w3( |
| 765 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 766 std::unique_ptr<aura::Window> w4( |
| 746 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 767 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 747 scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 768 std::unique_ptr<aura::Window> w5( |
| 769 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 748 | 770 |
| 749 // The windows should be in the reverse order of creation in the MRU list. | 771 // The windows should be in the reverse order of creation in the MRU list. |
| 750 { | 772 { |
| 751 MruWindowTracker::WindowList windows = ash::Shell::GetInstance()-> | 773 MruWindowTracker::WindowList windows = ash::Shell::GetInstance()-> |
| 752 mru_window_tracker()->BuildMruWindowList(); | 774 mru_window_tracker()->BuildMruWindowList(); |
| 753 EXPECT_EQ(w1.get(), windows[4]); | 775 EXPECT_EQ(w1.get(), windows[4]); |
| 754 EXPECT_EQ(w2.get(), windows[3]); | 776 EXPECT_EQ(w2.get(), windows[3]); |
| 755 EXPECT_EQ(w3.get(), windows[2]); | 777 EXPECT_EQ(w3.get(), windows[2]); |
| 756 EXPECT_EQ(w4.get(), windows[1]); | 778 EXPECT_EQ(w4.get(), windows[1]); |
| 757 EXPECT_EQ(w5.get(), windows[0]); | 779 EXPECT_EQ(w5.get(), windows[0]); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 782 EXPECT_EQ(w2.get(), windows[3]); | 804 EXPECT_EQ(w2.get(), windows[3]); |
| 783 EXPECT_EQ(w3.get(), windows[2]); | 805 EXPECT_EQ(w3.get(), windows[2]); |
| 784 EXPECT_EQ(w4.get(), windows[1]); | 806 EXPECT_EQ(w4.get(), windows[1]); |
| 785 EXPECT_EQ(w5.get(), windows[0]); | 807 EXPECT_EQ(w5.get(), windows[0]); |
| 786 } | 808 } |
| 787 } | 809 } |
| 788 | 810 |
| 789 // Check that a restore state change does always restore to maximized. | 811 // Check that a restore state change does always restore to maximized. |
| 790 TEST_F(MaximizeModeWindowManagerTest, IgnoreRestoreStateChages) { | 812 TEST_F(MaximizeModeWindowManagerTest, IgnoreRestoreStateChages) { |
| 791 gfx::Rect rect(20, 140, 100, 100); | 813 gfx::Rect rect(20, 140, 100, 100); |
| 792 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 814 std::unique_ptr<aura::Window> w1( |
| 815 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 793 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 816 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 794 CreateMaximizeModeWindowManager(); | 817 CreateMaximizeModeWindowManager(); |
| 795 EXPECT_TRUE(window_state->IsMaximized()); | 818 EXPECT_TRUE(window_state->IsMaximized()); |
| 796 window_state->Minimize(); | 819 window_state->Minimize(); |
| 797 EXPECT_TRUE(window_state->IsMinimized()); | 820 EXPECT_TRUE(window_state->IsMinimized()); |
| 798 window_state->Restore(); | 821 window_state->Restore(); |
| 799 EXPECT_TRUE(window_state->IsMaximized()); | 822 EXPECT_TRUE(window_state->IsMaximized()); |
| 800 window_state->Restore(); | 823 window_state->Restore(); |
| 801 EXPECT_TRUE(window_state->IsMaximized()); | 824 EXPECT_TRUE(window_state->IsMaximized()); |
| 802 DestroyMaximizeModeWindowManager(); | 825 DestroyMaximizeModeWindowManager(); |
| 803 } | 826 } |
| 804 | 827 |
| 805 // Check that minimize and restore do the right thing. | 828 // Check that minimize and restore do the right thing. |
| 806 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) { | 829 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) { |
| 807 gfx::Rect rect(10, 10, 100, 100); | 830 gfx::Rect rect(10, 10, 100, 100); |
| 808 scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, | 831 std::unique_ptr<aura::Window> window( |
| 809 rect)); | 832 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 810 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 833 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 811 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); | 834 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); |
| 812 ash::Shell::GetInstance()->maximize_mode_controller()-> | 835 ash::Shell::GetInstance()->maximize_mode_controller()-> |
| 813 EnableMaximizeModeWindowManager(true); | 836 EnableMaximizeModeWindowManager(true); |
| 814 EXPECT_TRUE(window_state->IsMaximized()); | 837 EXPECT_TRUE(window_state->IsMaximized()); |
| 815 EXPECT_FALSE(window_state->IsMinimized()); | 838 EXPECT_FALSE(window_state->IsMinimized()); |
| 816 EXPECT_TRUE(window->IsVisible()); | 839 EXPECT_TRUE(window->IsVisible()); |
| 817 | 840 |
| 818 window_state->Minimize(); | 841 window_state->Minimize(); |
| 819 EXPECT_FALSE(window_state->IsMaximized()); | 842 EXPECT_FALSE(window_state->IsMaximized()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 830 EXPECT_FALSE(window_state->IsMaximized()); | 853 EXPECT_FALSE(window_state->IsMaximized()); |
| 831 EXPECT_FALSE(window_state->IsMinimized()); | 854 EXPECT_FALSE(window_state->IsMinimized()); |
| 832 EXPECT_TRUE(window->IsVisible()); | 855 EXPECT_TRUE(window->IsVisible()); |
| 833 } | 856 } |
| 834 | 857 |
| 835 // Check that a full screen window remains full screen upon entering maximize | 858 // Check that a full screen window remains full screen upon entering maximize |
| 836 // mode. Furthermore, checks that this window is not full screen upon exiting | 859 // mode. Furthermore, checks that this window is not full screen upon exiting |
| 837 // maximize mode if it was un-full-screened while in maximize mode. | 860 // maximize mode if it was un-full-screened while in maximize mode. |
| 838 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { | 861 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { |
| 839 gfx::Rect rect(20, 140, 100, 100); | 862 gfx::Rect rect(20, 140, 100, 100); |
| 840 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 863 std::unique_ptr<aura::Window> w1( |
| 864 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 841 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 865 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 842 | 866 |
| 843 ShelfLayoutManager* shelf = | 867 ShelfLayoutManager* shelf = |
| 844 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 868 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 845 | 869 |
| 846 // Allow the shelf to hide. | 870 // Allow the shelf to hide. |
| 847 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 871 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 848 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 872 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 849 | 873 |
| 850 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 874 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 875 EXPECT_FALSE(window_state->IsFullscreen()); | 899 EXPECT_FALSE(window_state->IsFullscreen()); |
| 876 EXPECT_TRUE(window_state->IsMaximized()); | 900 EXPECT_TRUE(window_state->IsMaximized()); |
| 877 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 901 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 878 } | 902 } |
| 879 | 903 |
| 880 // Verifies that if a window is un-full-screened while in maximize mode, | 904 // Verifies that if a window is un-full-screened while in maximize mode, |
| 881 // other changes to that window's state (such as minimizing it) are | 905 // other changes to that window's state (such as minimizing it) are |
| 882 // preserved upon exiting maximize mode. | 906 // preserved upon exiting maximize mode. |
| 883 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) { | 907 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) { |
| 884 gfx::Rect rect(20, 140, 100, 100); | 908 gfx::Rect rect(20, 140, 100, 100); |
| 885 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 909 std::unique_ptr<aura::Window> w1( |
| 910 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 886 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 911 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 887 | 912 |
| 888 ShelfLayoutManager* shelf = | 913 ShelfLayoutManager* shelf = |
| 889 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 914 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 890 | 915 |
| 891 // Allow the shelf to hide and enter full screen. | 916 // Allow the shelf to hide and enter full screen. |
| 892 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 917 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 893 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 918 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 894 window_state->OnWMEvent(&event); | 919 window_state->OnWMEvent(&event); |
| 895 ASSERT_FALSE(window_state->IsMinimized()); | 920 ASSERT_FALSE(window_state->IsMinimized()); |
| 896 | 921 |
| 897 // Enter maximize mode, exit full screen, and then minimize the window. | 922 // Enter maximize mode, exit full screen, and then minimize the window. |
| 898 CreateMaximizeModeWindowManager(); | 923 CreateMaximizeModeWindowManager(); |
| 899 window_state->OnWMEvent(&event); | 924 window_state->OnWMEvent(&event); |
| 900 window_state->Minimize(); | 925 window_state->Minimize(); |
| 901 ASSERT_TRUE(window_state->IsMinimized()); | 926 ASSERT_TRUE(window_state->IsMinimized()); |
| 902 | 927 |
| 903 // The window should remain minimized when exiting maximize mode. | 928 // The window should remain minimized when exiting maximize mode. |
| 904 DestroyMaximizeModeWindowManager(); | 929 DestroyMaximizeModeWindowManager(); |
| 905 EXPECT_TRUE(window_state->IsMinimized()); | 930 EXPECT_TRUE(window_state->IsMinimized()); |
| 906 } | 931 } |
| 907 | 932 |
| 908 // Check that full screen mode can be turned on in maximized mode and remains | 933 // Check that full screen mode can be turned on in maximized mode and remains |
| 909 // upon coming back. | 934 // upon coming back. |
| 910 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { | 935 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { |
| 911 gfx::Rect rect(20, 140, 100, 100); | 936 gfx::Rect rect(20, 140, 100, 100); |
| 912 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 937 std::unique_ptr<aura::Window> w1( |
| 938 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 913 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 939 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 914 | 940 |
| 915 ShelfLayoutManager* shelf = | 941 ShelfLayoutManager* shelf = |
| 916 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 942 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 917 | 943 |
| 918 // Allow the shelf to hide. | 944 // Allow the shelf to hide. |
| 919 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 945 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 920 | 946 |
| 921 EXPECT_FALSE(window_state->IsFullscreen()); | 947 EXPECT_FALSE(window_state->IsFullscreen()); |
| 922 EXPECT_FALSE(window_state->IsMaximized()); | 948 EXPECT_FALSE(window_state->IsMaximized()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 944 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 970 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 945 } | 971 } |
| 946 | 972 |
| 947 // Check that the full screen mode will stay active when the maximize mode is | 973 // Check that the full screen mode will stay active when the maximize mode is |
| 948 // ended. | 974 // ended. |
| 949 TEST_F(MaximizeModeWindowManagerTest, | 975 TEST_F(MaximizeModeWindowManagerTest, |
| 950 FullScreenModeRemainsWhenCreatedInMaximizedMode) { | 976 FullScreenModeRemainsWhenCreatedInMaximizedMode) { |
| 951 CreateMaximizeModeWindowManager(); | 977 CreateMaximizeModeWindowManager(); |
| 952 | 978 |
| 953 gfx::Rect rect(20, 140, 100, 100); | 979 gfx::Rect rect(20, 140, 100, 100); |
| 954 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 980 std::unique_ptr<aura::Window> w1( |
| 981 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 955 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 982 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 956 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 983 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 957 window_state->OnWMEvent(&event_full_screen); | 984 window_state->OnWMEvent(&event_full_screen); |
| 958 EXPECT_TRUE(window_state->IsFullscreen()); | 985 EXPECT_TRUE(window_state->IsFullscreen()); |
| 959 | 986 |
| 960 // After the maximize mode manager is ended, full screen will remain. | 987 // After the maximize mode manager is ended, full screen will remain. |
| 961 DestroyMaximizeModeWindowManager(); | 988 DestroyMaximizeModeWindowManager(); |
| 962 EXPECT_TRUE(window_state->IsFullscreen()); | 989 EXPECT_TRUE(window_state->IsFullscreen()); |
| 963 } | 990 } |
| 964 | 991 |
| 965 // Check that the full screen mode will stay active throughout a maximzied mode | 992 // Check that the full screen mode will stay active throughout a maximzied mode |
| 966 // session. | 993 // session. |
| 967 TEST_F(MaximizeModeWindowManagerTest, | 994 TEST_F(MaximizeModeWindowManagerTest, |
| 968 FullScreenModeRemainsThroughMaximizeModeSwitch) { | 995 FullScreenModeRemainsThroughMaximizeModeSwitch) { |
| 969 gfx::Rect rect(20, 140, 100, 100); | 996 gfx::Rect rect(20, 140, 100, 100); |
| 970 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 997 std::unique_ptr<aura::Window> w1( |
| 998 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 971 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 999 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 972 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1000 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 973 window_state->OnWMEvent(&event_full_screen); | 1001 window_state->OnWMEvent(&event_full_screen); |
| 974 EXPECT_TRUE(window_state->IsFullscreen()); | 1002 EXPECT_TRUE(window_state->IsFullscreen()); |
| 975 | 1003 |
| 976 CreateMaximizeModeWindowManager(); | 1004 CreateMaximizeModeWindowManager(); |
| 977 EXPECT_TRUE(window_state->IsFullscreen()); | 1005 EXPECT_TRUE(window_state->IsFullscreen()); |
| 978 DestroyMaximizeModeWindowManager(); | 1006 DestroyMaximizeModeWindowManager(); |
| 979 EXPECT_TRUE(window_state->IsFullscreen()); | 1007 EXPECT_TRUE(window_state->IsFullscreen()); |
| 980 } | 1008 } |
| 981 | 1009 |
| 982 // Check that an empty window does not get restored to a tiny size. | 1010 // Check that an empty window does not get restored to a tiny size. |
| 983 TEST_F(MaximizeModeWindowManagerTest, | 1011 TEST_F(MaximizeModeWindowManagerTest, |
| 984 CreateAndMaximizeInMaximizeModeShouldRetoreToGoodSizeGoingToDefault) { | 1012 CreateAndMaximizeInMaximizeModeShouldRetoreToGoodSizeGoingToDefault) { |
| 985 CreateMaximizeModeWindowManager(); | 1013 CreateMaximizeModeWindowManager(); |
| 986 gfx::Rect rect; | 1014 gfx::Rect rect; |
| 987 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1015 std::unique_ptr<aura::Window> w1( |
| 1016 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 988 w1->Show(); | 1017 w1->Show(); |
| 989 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1018 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 990 EXPECT_TRUE(window_state->IsMaximized()); | 1019 EXPECT_TRUE(window_state->IsMaximized()); |
| 991 | 1020 |
| 992 // There is a calling order in which the restore bounds can get set to an | 1021 // There is a calling order in which the restore bounds can get set to an |
| 993 // empty rectangle. We simulate this here. | 1022 // empty rectangle. We simulate this here. |
| 994 window_state->SetRestoreBoundsInScreen(rect); | 1023 window_state->SetRestoreBoundsInScreen(rect); |
| 995 EXPECT_TRUE(window_state->GetRestoreBoundsInScreen().IsEmpty()); | 1024 EXPECT_TRUE(window_state->GetRestoreBoundsInScreen().IsEmpty()); |
| 996 | 1025 |
| 997 // Setting the window to a new size will physically not change the window, | 1026 // Setting the window to a new size will physically not change the window, |
| 998 // but the restore size should get updated so that a restore later on will | 1027 // but the restore size should get updated so that a restore later on will |
| 999 // return to this size. | 1028 // return to this size. |
| 1000 gfx::Rect requested_bounds(10, 20, 50, 70); | 1029 gfx::Rect requested_bounds(10, 20, 50, 70); |
| 1001 w1->SetBounds(requested_bounds); | 1030 w1->SetBounds(requested_bounds); |
| 1002 EXPECT_TRUE(window_state->IsMaximized()); | 1031 EXPECT_TRUE(window_state->IsMaximized()); |
| 1003 EXPECT_EQ(requested_bounds.ToString(), | 1032 EXPECT_EQ(requested_bounds.ToString(), |
| 1004 window_state->GetRestoreBoundsInScreen().ToString()); | 1033 window_state->GetRestoreBoundsInScreen().ToString()); |
| 1005 | 1034 |
| 1006 DestroyMaximizeModeWindowManager(); | 1035 DestroyMaximizeModeWindowManager(); |
| 1007 | 1036 |
| 1008 EXPECT_FALSE(window_state->IsMaximized()); | 1037 EXPECT_FALSE(window_state->IsMaximized()); |
| 1009 EXPECT_EQ(w1->bounds().ToString(), requested_bounds.ToString()); | 1038 EXPECT_EQ(w1->bounds().ToString(), requested_bounds.ToString()); |
| 1010 } | 1039 } |
| 1011 | 1040 |
| 1012 // Check that snapping operations get ignored. | 1041 // Check that snapping operations get ignored. |
| 1013 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { | 1042 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { |
| 1014 gfx::Rect rect(20, 140, 100, 100); | 1043 gfx::Rect rect(20, 140, 100, 100); |
| 1015 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1044 std::unique_ptr<aura::Window> w1( |
| 1045 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1016 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1046 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 1017 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); | 1047 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); |
| 1018 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); | 1048 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); |
| 1019 window_state->OnWMEvent(&event_left); | 1049 window_state->OnWMEvent(&event_left); |
| 1020 EXPECT_TRUE(window_state->IsSnapped()); | 1050 EXPECT_TRUE(window_state->IsSnapped()); |
| 1021 | 1051 |
| 1022 CreateMaximizeModeWindowManager(); | 1052 CreateMaximizeModeWindowManager(); |
| 1023 | 1053 |
| 1024 // Fullscreen mode should now be off and it should not come back while in | 1054 // Fullscreen mode should now be off and it should not come back while in |
| 1025 // maximize mode. | 1055 // maximize mode. |
| 1026 EXPECT_FALSE(window_state->IsSnapped()); | 1056 EXPECT_FALSE(window_state->IsSnapped()); |
| 1027 EXPECT_TRUE(window_state->IsMaximized()); | 1057 EXPECT_TRUE(window_state->IsMaximized()); |
| 1028 window_state->OnWMEvent(&event_left); | 1058 window_state->OnWMEvent(&event_left); |
| 1029 EXPECT_FALSE(window_state->IsSnapped()); | 1059 EXPECT_FALSE(window_state->IsSnapped()); |
| 1030 EXPECT_TRUE(window_state->IsMaximized()); | 1060 EXPECT_TRUE(window_state->IsMaximized()); |
| 1031 window_state->OnWMEvent(&event_right); | 1061 window_state->OnWMEvent(&event_right); |
| 1032 EXPECT_FALSE(window_state->IsSnapped()); | 1062 EXPECT_FALSE(window_state->IsSnapped()); |
| 1033 EXPECT_TRUE(window_state->IsMaximized()); | 1063 EXPECT_TRUE(window_state->IsMaximized()); |
| 1034 | 1064 |
| 1035 DestroyMaximizeModeWindowManager(); | 1065 DestroyMaximizeModeWindowManager(); |
| 1036 EXPECT_TRUE(window_state->IsSnapped()); | 1066 EXPECT_TRUE(window_state->IsSnapped()); |
| 1037 } | 1067 } |
| 1038 | 1068 |
| 1039 // Check that non maximizable windows cannot be dragged by the user. | 1069 // Check that non maximizable windows cannot be dragged by the user. |
| 1040 TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) { | 1070 TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) { |
| 1041 gfx::Rect rect(10, 10, 100, 100); | 1071 gfx::Rect rect(10, 10, 100, 100); |
| 1042 scoped_ptr<aura::Window> window( | 1072 std::unique_ptr<aura::Window> window( |
| 1043 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1073 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1044 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); | 1074 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); |
| 1045 | 1075 |
| 1046 // 1. Move the mouse over the caption and check that dragging the window does | 1076 // 1. Move the mouse over the caption and check that dragging the window does |
| 1047 // change the location. | 1077 // change the location. |
| 1048 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1078 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1049 generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2)); | 1079 generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2)); |
| 1050 generator.PressLeftButton(); | 1080 generator.PressLeftButton(); |
| 1051 generator.MoveMouseBy(10, 5); | 1081 generator.MoveMouseBy(10, 5); |
| 1052 RunAllPendingInMessageLoop(); | 1082 RunAllPendingInMessageLoop(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); | 1114 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); |
| 1085 } | 1115 } |
| 1086 | 1116 |
| 1087 // Test that overview is exited before entering / exiting maximize mode so that | 1117 // Test that overview is exited before entering / exiting maximize mode so that |
| 1088 // the window changes made by MaximizeModeWindowManager do not conflict with | 1118 // the window changes made by MaximizeModeWindowManager do not conflict with |
| 1089 // those made in WindowOverview. | 1119 // those made in WindowOverview. |
| 1090 TEST_F(MaximizeModeWindowManagerTest, ExitsOverview) { | 1120 TEST_F(MaximizeModeWindowManagerTest, ExitsOverview) { |
| 1091 // Bounds for windows we know can be controlled. | 1121 // Bounds for windows we know can be controlled. |
| 1092 gfx::Rect rect1(10, 10, 200, 50); | 1122 gfx::Rect rect1(10, 10, 200, 50); |
| 1093 gfx::Rect rect2(10, 60, 200, 50); | 1123 gfx::Rect rect2(10, 60, 200, 50); |
| 1094 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); | 1124 std::unique_ptr<aura::Window> w1( |
| 1095 scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 1125 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); |
| 1126 std::unique_ptr<aura::Window> w2( |
| 1127 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 1096 | 1128 |
| 1097 WindowSelectorController* window_selector_controller = | 1129 WindowSelectorController* window_selector_controller = |
| 1098 Shell::GetInstance()->window_selector_controller(); | 1130 Shell::GetInstance()->window_selector_controller(); |
| 1099 window_selector_controller->ToggleOverview(); | 1131 window_selector_controller->ToggleOverview(); |
| 1100 ASSERT_TRUE(window_selector_controller->IsSelecting()); | 1132 ASSERT_TRUE(window_selector_controller->IsSelecting()); |
| 1101 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 1133 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 1102 ASSERT_TRUE(manager); | 1134 ASSERT_TRUE(manager); |
| 1103 EXPECT_FALSE(window_selector_controller->IsSelecting()); | 1135 EXPECT_FALSE(window_selector_controller->IsSelecting()); |
| 1104 | 1136 |
| 1105 window_selector_controller->ToggleOverview(); | 1137 window_selector_controller->ToggleOverview(); |
| 1106 ASSERT_TRUE(window_selector_controller->IsSelecting()); | 1138 ASSERT_TRUE(window_selector_controller->IsSelecting()); |
| 1107 // Destroy the manager again and check that the windows return to their | 1139 // Destroy the manager again and check that the windows return to their |
| 1108 // previous state. | 1140 // previous state. |
| 1109 DestroyMaximizeModeWindowManager(); | 1141 DestroyMaximizeModeWindowManager(); |
| 1110 EXPECT_FALSE(window_selector_controller->IsSelecting()); | 1142 EXPECT_FALSE(window_selector_controller->IsSelecting()); |
| 1111 } | 1143 } |
| 1112 | 1144 |
| 1113 // Test that an edge swipe from the top will end full screen mode. | 1145 // Test that an edge swipe from the top will end full screen mode. |
| 1114 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromTop) { | 1146 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromTop) { |
| 1115 gfx::Rect rect(10, 10, 200, 50); | 1147 gfx::Rect rect(10, 10, 200, 50); |
| 1116 scoped_ptr<aura::Window> | 1148 std::unique_ptr<aura::Window> background_window( |
| 1117 background_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1149 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1118 scoped_ptr<aura::Window> | 1150 std::unique_ptr<aura::Window> foreground_window( |
| 1119 foreground_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1151 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1120 wm::WindowState* background_window_state = | 1152 wm::WindowState* background_window_state = |
| 1121 wm::GetWindowState(background_window.get()); | 1153 wm::GetWindowState(background_window.get()); |
| 1122 wm::WindowState* foreground_window_state = | 1154 wm::WindowState* foreground_window_state = |
| 1123 wm::GetWindowState(foreground_window.get()); | 1155 wm::GetWindowState(foreground_window.get()); |
| 1124 wm::ActivateWindow(foreground_window.get()); | 1156 wm::ActivateWindow(foreground_window.get()); |
| 1125 CreateMaximizeModeWindowManager(); | 1157 CreateMaximizeModeWindowManager(); |
| 1126 | 1158 |
| 1127 // Fullscreen both windows. | 1159 // Fullscreen both windows. |
| 1128 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1160 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1129 background_window_state->OnWMEvent(&event); | 1161 background_window_state->OnWMEvent(&event); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1150 | 1182 |
| 1151 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1183 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
| 1152 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1184 EXPECT_TRUE(background_window_state->IsFullscreen()); |
| 1153 | 1185 |
| 1154 DestroyMaximizeModeWindowManager(); | 1186 DestroyMaximizeModeWindowManager(); |
| 1155 } | 1187 } |
| 1156 | 1188 |
| 1157 // Test that an edge swipe from the bottom will end full screen mode. | 1189 // Test that an edge swipe from the bottom will end full screen mode. |
| 1158 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromBottom) { | 1190 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromBottom) { |
| 1159 gfx::Rect rect(10, 10, 200, 50); | 1191 gfx::Rect rect(10, 10, 200, 50); |
| 1160 scoped_ptr<aura::Window> | 1192 std::unique_ptr<aura::Window> background_window( |
| 1161 background_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1193 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1162 scoped_ptr<aura::Window> | 1194 std::unique_ptr<aura::Window> foreground_window( |
| 1163 foreground_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1195 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1164 wm::WindowState* background_window_state = | 1196 wm::WindowState* background_window_state = |
| 1165 wm::GetWindowState(background_window.get()); | 1197 wm::GetWindowState(background_window.get()); |
| 1166 wm::WindowState* foreground_window_state = | 1198 wm::WindowState* foreground_window_state = |
| 1167 wm::GetWindowState(foreground_window.get()); | 1199 wm::GetWindowState(foreground_window.get()); |
| 1168 wm::ActivateWindow(foreground_window.get()); | 1200 wm::ActivateWindow(foreground_window.get()); |
| 1169 CreateMaximizeModeWindowManager(); | 1201 CreateMaximizeModeWindowManager(); |
| 1170 | 1202 |
| 1171 // Fullscreen both windows. | 1203 // Fullscreen both windows. |
| 1172 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1204 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1173 background_window_state->OnWMEvent(&event); | 1205 background_window_state->OnWMEvent(&event); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1186 | 1218 |
| 1187 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1219 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
| 1188 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1220 EXPECT_TRUE(background_window_state->IsFullscreen()); |
| 1189 | 1221 |
| 1190 DestroyMaximizeModeWindowManager(); | 1222 DestroyMaximizeModeWindowManager(); |
| 1191 } | 1223 } |
| 1192 | 1224 |
| 1193 // Test that an edge touch press at the top will end full screen mode. | 1225 // Test that an edge touch press at the top will end full screen mode. |
| 1194 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtTop) { | 1226 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtTop) { |
| 1195 gfx::Rect rect(10, 10, 200, 50); | 1227 gfx::Rect rect(10, 10, 200, 50); |
| 1196 scoped_ptr<aura::Window> | 1228 std::unique_ptr<aura::Window> background_window( |
| 1197 background_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1229 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1198 scoped_ptr<aura::Window> | 1230 std::unique_ptr<aura::Window> foreground_window( |
| 1199 foreground_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1231 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1200 wm::WindowState* background_window_state = | 1232 wm::WindowState* background_window_state = |
| 1201 wm::GetWindowState(background_window.get()); | 1233 wm::GetWindowState(background_window.get()); |
| 1202 wm::WindowState* foreground_window_state = | 1234 wm::WindowState* foreground_window_state = |
| 1203 wm::GetWindowState(foreground_window.get()); | 1235 wm::GetWindowState(foreground_window.get()); |
| 1204 wm::ActivateWindow(foreground_window.get()); | 1236 wm::ActivateWindow(foreground_window.get()); |
| 1205 CreateMaximizeModeWindowManager(); | 1237 CreateMaximizeModeWindowManager(); |
| 1206 | 1238 |
| 1207 // Fullscreen both windows. | 1239 // Fullscreen both windows. |
| 1208 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1240 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1209 background_window_state->OnWMEvent(&event); | 1241 background_window_state->OnWMEvent(&event); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1222 generator.GestureTapAt(gfx::Point(100, 0)); | 1254 generator.GestureTapAt(gfx::Point(100, 0)); |
| 1223 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1255 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
| 1224 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1256 EXPECT_TRUE(background_window_state->IsFullscreen()); |
| 1225 | 1257 |
| 1226 DestroyMaximizeModeWindowManager(); | 1258 DestroyMaximizeModeWindowManager(); |
| 1227 } | 1259 } |
| 1228 | 1260 |
| 1229 // Test that an edge touch press at the bottom will end full screen mode. | 1261 // Test that an edge touch press at the bottom will end full screen mode. |
| 1230 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtBottom) { | 1262 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtBottom) { |
| 1231 gfx::Rect rect(10, 10, 200, 50); | 1263 gfx::Rect rect(10, 10, 200, 50); |
| 1232 scoped_ptr<aura::Window> | 1264 std::unique_ptr<aura::Window> background_window( |
| 1233 background_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1265 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1234 scoped_ptr<aura::Window> | 1266 std::unique_ptr<aura::Window> foreground_window( |
| 1235 foreground_window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1267 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1236 wm::WindowState* background_window_state = | 1268 wm::WindowState* background_window_state = |
| 1237 wm::GetWindowState(background_window.get()); | 1269 wm::GetWindowState(background_window.get()); |
| 1238 wm::WindowState* foreground_window_state = | 1270 wm::WindowState* foreground_window_state = |
| 1239 wm::GetWindowState(foreground_window.get()); | 1271 wm::GetWindowState(foreground_window.get()); |
| 1240 wm::ActivateWindow(foreground_window.get()); | 1272 wm::ActivateWindow(foreground_window.get()); |
| 1241 CreateMaximizeModeWindowManager(); | 1273 CreateMaximizeModeWindowManager(); |
| 1242 | 1274 |
| 1243 // Fullscreen both windows. | 1275 // Fullscreen both windows. |
| 1244 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1276 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1245 background_window_state->OnWMEvent(&event); | 1277 background_window_state->OnWMEvent(&event); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1260 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); | 1292 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); |
| 1261 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1293 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
| 1262 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1294 EXPECT_TRUE(background_window_state->IsFullscreen()); |
| 1263 | 1295 |
| 1264 DestroyMaximizeModeWindowManager(); | 1296 DestroyMaximizeModeWindowManager(); |
| 1265 } | 1297 } |
| 1266 | 1298 |
| 1267 // Test that an edge swipe from the top on an immersive mode window will not end | 1299 // Test that an edge swipe from the top on an immersive mode window will not end |
| 1268 // full screen mode. | 1300 // full screen mode. |
| 1269 TEST_F(MaximizeModeWindowManagerTest, NoExitImmersiveModeWithEdgeSwipeFromTop) { | 1301 TEST_F(MaximizeModeWindowManagerTest, NoExitImmersiveModeWithEdgeSwipeFromTop) { |
| 1270 scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, | 1302 std::unique_ptr<aura::Window> window( |
| 1271 gfx::Rect(10, 10, 200, 50))); | 1303 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); |
| 1272 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 1304 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 1273 wm::ActivateWindow(window.get()); | 1305 wm::ActivateWindow(window.get()); |
| 1274 CreateMaximizeModeWindowManager(); | 1306 CreateMaximizeModeWindowManager(); |
| 1275 | 1307 |
| 1276 // Fullscreen the window. | 1308 // Fullscreen the window. |
| 1277 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1309 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1278 window_state->OnWMEvent(&event); | 1310 window_state->OnWMEvent(&event); |
| 1279 EXPECT_TRUE(window_state->IsFullscreen()); | 1311 EXPECT_TRUE(window_state->IsFullscreen()); |
| 1280 EXPECT_FALSE(window_state->in_immersive_fullscreen()); | 1312 EXPECT_FALSE(window_state->in_immersive_fullscreen()); |
| 1281 EXPECT_EQ(window.get(), wm::GetActiveWindow()); | 1313 EXPECT_EQ(window.get(), wm::GetActiveWindow()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1292 // It should have not exited full screen or immersive mode. | 1324 // It should have not exited full screen or immersive mode. |
| 1293 EXPECT_TRUE(window_state->IsFullscreen()); | 1325 EXPECT_TRUE(window_state->IsFullscreen()); |
| 1294 EXPECT_TRUE(window_state->in_immersive_fullscreen()); | 1326 EXPECT_TRUE(window_state->in_immersive_fullscreen()); |
| 1295 | 1327 |
| 1296 DestroyMaximizeModeWindowManager(); | 1328 DestroyMaximizeModeWindowManager(); |
| 1297 } | 1329 } |
| 1298 | 1330 |
| 1299 // Test that an edge swipe from the bottom will not end immersive mode. | 1331 // Test that an edge swipe from the bottom will not end immersive mode. |
| 1300 TEST_F(MaximizeModeWindowManagerTest, | 1332 TEST_F(MaximizeModeWindowManagerTest, |
| 1301 NoExitImmersiveModeWithEdgeSwipeFromBottom) { | 1333 NoExitImmersiveModeWithEdgeSwipeFromBottom) { |
| 1302 scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, | 1334 std::unique_ptr<aura::Window> window( |
| 1303 gfx::Rect(10, 10, 200, 50))); | 1335 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); |
| 1304 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 1336 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 1305 wm::ActivateWindow(window.get()); | 1337 wm::ActivateWindow(window.get()); |
| 1306 CreateMaximizeModeWindowManager(); | 1338 CreateMaximizeModeWindowManager(); |
| 1307 | 1339 |
| 1308 // Fullscreen the window. | 1340 // Fullscreen the window. |
| 1309 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1341 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1310 window_state->OnWMEvent(&event); | 1342 window_state->OnWMEvent(&event); |
| 1311 EXPECT_TRUE(window_state->IsFullscreen()); | 1343 EXPECT_TRUE(window_state->IsFullscreen()); |
| 1312 EXPECT_FALSE(window_state->in_immersive_fullscreen()); | 1344 EXPECT_FALSE(window_state->in_immersive_fullscreen()); |
| 1313 EXPECT_EQ(window.get(), wm::GetActiveWindow()); | 1345 EXPECT_EQ(window.get(), wm::GetActiveWindow()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1330 } | 1362 } |
| 1331 | 1363 |
| 1332 // Tests that windows with the always-on-top property are not managed by | 1364 // Tests that windows with the always-on-top property are not managed by |
| 1333 // the MaximizeModeWindowManager while maximize mode is engaged (i.e., | 1365 // the MaximizeModeWindowManager while maximize mode is engaged (i.e., |
| 1334 // they remain free-floating). | 1366 // they remain free-floating). |
| 1335 TEST_F(MaximizeModeWindowManagerTest, AlwaysOnTopWindows) { | 1367 TEST_F(MaximizeModeWindowManagerTest, AlwaysOnTopWindows) { |
| 1336 gfx::Rect rect1(10, 10, 200, 50); | 1368 gfx::Rect rect1(10, 10, 200, 50); |
| 1337 gfx::Rect rect2(20, 140, 100, 100); | 1369 gfx::Rect rect2(20, 140, 100, 100); |
| 1338 | 1370 |
| 1339 // Create two windows with the always-on-top property. | 1371 // Create two windows with the always-on-top property. |
| 1340 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); | 1372 std::unique_ptr<aura::Window> w1( |
| 1341 scoped_ptr<aura::Window> w2( | 1373 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); |
| 1374 std::unique_ptr<aura::Window> w2( |
| 1342 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); | 1375 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); |
| 1343 w1->SetProperty(aura::client::kAlwaysOnTopKey, true); | 1376 w1->SetProperty(aura::client::kAlwaysOnTopKey, true); |
| 1344 w2->SetProperty(aura::client::kAlwaysOnTopKey, true); | 1377 w2->SetProperty(aura::client::kAlwaysOnTopKey, true); |
| 1345 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); | 1378 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); |
| 1346 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); | 1379 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 1347 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); | 1380 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); |
| 1348 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); | 1381 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); |
| 1349 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); | 1382 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); |
| 1350 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); | 1383 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); |
| 1351 | 1384 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); | 1429 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 1397 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); | 1430 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); |
| 1398 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); | 1431 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); |
| 1399 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); | 1432 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); |
| 1400 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); | 1433 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); |
| 1401 } | 1434 } |
| 1402 | 1435 |
| 1403 // Tests that docked windows are not maximized, and not tracked. | 1436 // Tests that docked windows are not maximized, and not tracked. |
| 1404 TEST_F(MaximizeModeWindowManagerTest, DontMaximizeDockedWindows) { | 1437 TEST_F(MaximizeModeWindowManagerTest, DontMaximizeDockedWindows) { |
| 1405 gfx::Rect rect(10, 10, 200, 50); | 1438 gfx::Rect rect(10, 10, 200, 50); |
| 1406 scoped_ptr<aura::Window> window( | 1439 std::unique_ptr<aura::Window> window( |
| 1407 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1440 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1408 | 1441 |
| 1409 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); | 1442 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); |
| 1410 wm::GetWindowState(window.get())->OnWMEvent(&dock_event); | 1443 wm::GetWindowState(window.get())->OnWMEvent(&dock_event); |
| 1411 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); | 1444 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); |
| 1412 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); | 1445 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); |
| 1413 | 1446 |
| 1414 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 1447 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); |
| 1415 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); | 1448 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); |
| 1416 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); | 1449 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); |
| 1417 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); | 1450 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); |
| 1418 } | 1451 } |
| 1419 | 1452 |
| 1420 #endif // OS_WIN | 1453 #endif // OS_WIN |
| 1421 | 1454 |
| 1422 } // namespace ash | 1455 } // namespace ash |
| OLD | NEW |