Chromium Code Reviews| Index: ash/wm/window_util_unittest.cc |
| diff --git a/ash/wm/window_util_unittest.cc b/ash/wm/window_util_unittest.cc |
| index 8073a38cc87b326790e81f96b6536790a85183eb..93b778be669aed4a983486250da6ca30d103f4f1 100644 |
| --- a/ash/wm/window_util_unittest.cc |
| +++ b/ash/wm/window_util_unittest.cc |
| @@ -4,7 +4,9 @@ |
| #include "ash/wm/window_util.h" |
| +#include "ash/root_window_controller.h" |
| #include "ash/screen_ash.h" |
| +#include "ash/shelf/shelf_layout_manager.h" |
| #include "ash/test/ash_test_base.h" |
| #include "ui/aura/window.h" |
| @@ -12,21 +14,68 @@ namespace ash { |
| typedef test::AshTestBase WindowUtilTest; |
| +// Test the behavior of SnapWindowToEdge(). |
| +TEST_F(WindowUtilTest, SnapWindowToEdge) { |
| + if (!SupportsMultipleDisplays()) |
| + return; |
| + |
| + UpdateDisplay("0+0-500x400, 0+500-600x400"); |
| + scoped_ptr<aura::Window> window( |
| + CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
| + |
| + internal::RootWindowController* root_window_controller = |
| + internal::RootWindowController::ForWindow(window.get()); |
| + internal::ShelfLayoutManager* shelf_layout_manager = |
| + root_window_controller->GetShelfLayoutManager(); |
| + EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf_layout_manager->GetAlignment()); |
| + shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| + EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| + const int kSnappedHeight = 400 - |
| + internal::ShelfLayoutManager::GetPreferredShelfSize(); |
| + |
| + wm::SnapWindowToEdge(window.get(), wm::SNAP_LEFT_EDGE); |
| + EXPECT_EQ(gfx::Rect(0,0,250,kSnappedHeight).ToString(), |
|
Mr4D (OOO till 08-26)
2013/08/29 01:03:15
0, 0, 250, kSna..
(Spaces are missing)
|
| + window->GetBoundsInScreen().ToString()); |
| + wm::SnapWindowToEdge(window.get(), wm::SNAP_RIGHT_EDGE); |
| + EXPECT_EQ(gfx::Rect(250,0,250,kSnappedHeight).ToString(), |
|
Mr4D (OOO till 08-26)
2013/08/29 01:03:15
Same here and more below.
|
| + window->GetBoundsInScreen().ToString()); |
| + window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), |
| + ScreenAsh::GetSecondaryDisplay()); |
| + wm::SnapWindowToEdge(window.get(), wm::SNAP_LEFT_EDGE); |
| + EXPECT_EQ(gfx::Rect(500,0,300,kSnappedHeight).ToString(), |
| + window->GetBoundsInScreen().ToString()); |
| + wm::SnapWindowToEdge(window.get(), wm::SNAP_RIGHT_EDGE); |
| + EXPECT_EQ(gfx::Rect(800,0,300,kSnappedHeight).ToString(), |
| + window->GetBoundsInScreen().ToString()); |
| +} |
| + |
| +// Test the behavior of CenterWindow(). |
| TEST_F(WindowUtilTest, CenterWindow) { |
| if (!SupportsMultipleDisplays()) |
| return; |
| - UpdateDisplay("500x400, 600x400"); |
| + UpdateDisplay("0+0-500x400, 0+500-600x400"); |
| scoped_ptr<aura::Window> window( |
| CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
| + |
| + internal::RootWindowController* root_window_controller = |
| + internal::RootWindowController::ForWindow(window.get()); |
| + internal::ShelfLayoutManager* shelf_layout_manager = |
| + root_window_controller->GetShelfLayoutManager(); |
| + EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf_layout_manager->GetAlignment()); |
| + shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| + EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| + const int kCenteredY = |
| + (400 - internal::ShelfLayoutManager::GetPreferredShelfSize() - 100) / 2; |
| + |
| wm::CenterWindow(window.get()); |
| - EXPECT_EQ("200,126 100x100", window->bounds().ToString()); |
| - EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); |
| + EXPECT_EQ(gfx::Rect(200,kCenteredY,100,100).ToString(), |
| + window->GetBoundsInScreen().ToString()); |
| window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), |
| ScreenAsh::GetSecondaryDisplay()); |
| wm::CenterWindow(window.get()); |
| - EXPECT_EQ("250,126 100x100", window->bounds().ToString()); |
| - EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); |
| + EXPECT_EQ(gfx::Rect(750,kCenteredY,100,100).ToString(), |
|
Mr4D (OOO till 08-26)
2013/08/29 01:03:15
And more spaces are missing.
|
| + window->GetBoundsInScreen().ToString()); |
| } |
| } // namespace ash |