| 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/scoped_target_root_window.h" | 5 #include "ash/scoped_target_root_window.h" |
| 6 #include "ash/screen_util.h" | 6 #include "ash/screen_util.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/test/test_shell_delegate.h" | 9 #include "ash/test/test_shell_delegate.h" |
| 10 #include "ash/wm/window_positioner.h" | 10 #include "ash/wm/window_positioner.h" |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 511 |
| 512 // A common screen size for Chrome OS devices where this behavior is | 512 // A common screen size for Chrome OS devices where this behavior is |
| 513 // desirable. | 513 // desirable. |
| 514 const gfx::Rect p1366x768(0, 0, 1366, 768); | 514 const gfx::Rect p1366x768(0, 0, 1366, 768); |
| 515 | 515 |
| 516 // If there is no previous state the window should get maximized if the | 516 // If there is no previous state the window should get maximized if the |
| 517 // screen is less than or equal to our limit (1366 pixels width). | 517 // screen is less than or equal to our limit (1366 pixels width). |
| 518 gfx::Rect window_bounds; | 518 gfx::Rect window_bounds; |
| 519 ui::WindowShowState out_show_state1 = ui::SHOW_STATE_DEFAULT; | 519 ui::WindowShowState out_show_state1 = ui::SHOW_STATE_DEFAULT; |
| 520 GetWindowBoundsAndShowState( | 520 GetWindowBoundsAndShowState( |
| 521 p1366x768, // The screen resolution. | 521 p1366x768, // The screen resolution. |
| 522 p1366x768, // The monitor work area. | 522 p1366x768, // The monitor work area. |
| 523 gfx::Rect(), // The second monitor. | 523 gfx::Rect(), // The second monitor. |
| 524 gfx::Rect(), // The (persisted) bounds. | 524 gfx::Rect(), // The (persisted) bounds. |
| 525 p1366x768, // The overall work area. | 525 p1366x768, // The overall work area. |
| 526 ui::SHOW_STATE_NORMAL, // The persisted show state. | 526 ui::SHOW_STATE_NORMAL, // The persisted show state. |
| 527 ui::SHOW_STATE_DEFAULT, // The last show state. | 527 ui::SHOW_STATE_DEFAULT, // The last show state. |
| 528 DEFAULT, // No persisted values. | 528 DEFAULT, // No persisted values. |
| 529 browser.get(), // Use this browser. | 529 browser.get(), // Use this browser. |
| 530 gfx::Rect(), // Don't request valid bounds. | 530 gfx::Rect(), // Don't request valid bounds. |
| 531 &window_bounds, | 531 0u, // Display index. |
| 532 &out_show_state1); | 532 &window_bounds, &out_show_state1); |
| 533 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state1); | 533 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state1); |
| 534 | 534 |
| 535 // If there is a stored coordinate however, that should be taken instead. | 535 // If there is a stored coordinate however, that should be taken instead. |
| 536 ui::WindowShowState out_show_state2 = ui::SHOW_STATE_DEFAULT; | 536 ui::WindowShowState out_show_state2 = ui::SHOW_STATE_DEFAULT; |
| 537 GetWindowBoundsAndShowState( | 537 GetWindowBoundsAndShowState( |
| 538 p1366x768, // The screen resolution. | 538 p1366x768, // The screen resolution. |
| 539 p1366x768, // The monitor work area. | 539 p1366x768, // The monitor work area. |
| 540 gfx::Rect(), // The second monitor. | 540 gfx::Rect(), // The second monitor. |
| 541 gfx::Rect(50, 100, 300, 150), // The (persisted) bounds. | 541 gfx::Rect(50, 100, 300, 150), // The (persisted) bounds. |
| 542 p1366x768, // The overall work area. | 542 p1366x768, // The overall work area. |
| 543 ui::SHOW_STATE_NORMAL, // The persisted show state. | 543 ui::SHOW_STATE_NORMAL, // The persisted show state. |
| 544 ui::SHOW_STATE_DEFAULT, // The last show state. | 544 ui::SHOW_STATE_DEFAULT, // The last show state. |
| 545 PERSISTED, // Set the persisted values. | 545 PERSISTED, // Set the persisted values. |
| 546 browser.get(), // Use this browser. | 546 browser.get(), // Use this browser. |
| 547 gfx::Rect(), // Don't request valid bounds. | 547 gfx::Rect(), // Don't request valid bounds. |
| 548 &window_bounds, | 548 0u, // Display index. |
| 549 &out_show_state2); | 549 &window_bounds, &out_show_state2); |
| 550 EXPECT_EQ(ui::SHOW_STATE_NORMAL, out_show_state2); | 550 EXPECT_EQ(ui::SHOW_STATE_NORMAL, out_show_state2); |
| 551 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); | 551 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
| 552 | 552 |
| 553 // A larger monitor should not trigger auto-maximize. | 553 // A larger monitor should not trigger auto-maximize. |
| 554 ui::WindowShowState out_show_state3 = ui::SHOW_STATE_DEFAULT; | 554 ui::WindowShowState out_show_state3 = ui::SHOW_STATE_DEFAULT; |
| 555 GetWindowBoundsAndShowState( | 555 GetWindowBoundsAndShowState( |
| 556 p1600x1200, // The screen resolution. | 556 p1600x1200, // The screen resolution. |
| 557 p1600x1200, // The monitor work area. | 557 p1600x1200, // The monitor work area. |
| 558 gfx::Rect(), // The second monitor. | 558 gfx::Rect(), // The second monitor. |
| 559 gfx::Rect(), // The (persisted) bounds. | 559 gfx::Rect(), // The (persisted) bounds. |
| 560 p1600x1200, // The overall work area. | 560 p1600x1200, // The overall work area. |
| 561 ui::SHOW_STATE_NORMAL, // The persisted show state. | 561 ui::SHOW_STATE_NORMAL, // The persisted show state. |
| 562 ui::SHOW_STATE_DEFAULT, // The last show state. | 562 ui::SHOW_STATE_DEFAULT, // The last show state. |
| 563 DEFAULT, // No persisted values. | 563 DEFAULT, // No persisted values. |
| 564 browser.get(), // Use this browser. | 564 browser.get(), // Use this browser. |
| 565 gfx::Rect(), // Don't request valid bounds. | 565 gfx::Rect(), // Don't request valid bounds. |
| 566 &window_bounds, | 566 0u, // Display index. |
| 567 &out_show_state3); | 567 &window_bounds, &out_show_state3); |
| 568 #if defined(OS_WIN) | 568 #if defined(OS_WIN) |
| 569 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state3); | 569 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state3); |
| 570 #else | 570 #else |
| 571 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, out_show_state3); | 571 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, out_show_state3); |
| 572 #endif | 572 #endif |
| 573 } | 573 } |
| 574 | 574 |
| 575 #if defined(OS_CHROMEOS) | 575 #if defined(OS_CHROMEOS) |
| 576 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay
s | 576 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay
s |
| 577 #else | 577 #else |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 gfx::Screen::GetScreen()->GetDisplayNearestPoint( | 637 gfx::Screen::GetScreen()->GetDisplayNearestPoint( |
| 638 gfx::Point(1600 + 100, 10)); | 638 gfx::Point(1600 + 100, 10)); |
| 639 browser_window->GetNativeWindow()->SetBoundsInScreen( | 639 browser_window->GetNativeWindow()->SetBoundsInScreen( |
| 640 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), | 640 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), |
| 641 second_display); | 641 second_display); |
| 642 aura::client::GetActivationClient(native_window->GetRootWindow()) | 642 aura::client::GetActivationClient(native_window->GetRootWindow()) |
| 643 ->ActivateWindow(native_window); | 643 ->ActivateWindow(native_window); |
| 644 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), | 644 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), |
| 645 ash::Shell::GetTargetRootWindow()); | 645 ash::Shell::GetTargetRootWindow()); |
| 646 gfx::Rect window_bounds; | 646 gfx::Rect window_bounds; |
| 647 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), | 647 ui::WindowShowState out_show_state = ui::SHOW_STATE_DEFAULT; |
| 648 secondary_bounds, PERSISTED, new_browser.get(), gfx::Rect(), | 648 GetWindowBoundsAndShowState( |
| 649 &window_bounds); | 649 p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), secondary_bounds, |
| 650 ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_DEFAULT, PERSISTED, |
| 651 new_browser.get(), gfx::Rect(), 1u, &window_bounds, &out_show_state); |
| 650 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 652 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 651 // moved to ash and changed to include the result from | 653 // moved to ash and changed to include the result from |
| 652 // RearrangeVisibleWindowOnShow. | 654 // RearrangeVisibleWindowOnShow. |
| 653 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); | 655 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); |
| 654 } | 656 } |
| 655 | 657 |
| 656 // Activate another window in the primary display and create a new window. | 658 // Activate another window in the primary display and create a new window. |
| 657 // It should be created in the primary display. | 659 // It should be created in the primary display. |
| 658 { | 660 { |
| 659 aura::client::GetActivationClient(another_native_window->GetRootWindow()) | 661 aura::client::GetActivationClient(another_native_window->GetRootWindow()) |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 EXPECT_EQ( | 898 EXPECT_EQ( |
| 897 ui::SHOW_STATE_DEFAULT, | 899 ui::SHOW_STATE_DEFAULT, |
| 898 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 900 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 899 trusted_popup.get(), p1280x1024, p1600x1200)); | 901 trusted_popup.get(), p1280x1024, p1600x1200)); |
| 900 // A popup that is sized to occupy the whole work area has default state. | 902 // A popup that is sized to occupy the whole work area has default state. |
| 901 EXPECT_EQ( | 903 EXPECT_EQ( |
| 902 ui::SHOW_STATE_DEFAULT, | 904 ui::SHOW_STATE_DEFAULT, |
| 903 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 905 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 904 trusted_popup.get(), p1600x1200, p1600x1200)); | 906 trusted_popup.get(), p1600x1200, p1600x1200)); |
| 905 } | 907 } |
| OLD | NEW |