| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/window_util.h" | 5 #include "ash/wm/window_util.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/window_positioning_utils.h" | 7 #include "ash/common/wm/window_positioning_utils.h" |
| 8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "ash/wm/window_state_aura.h" | 11 #include "ash/wm/window_state_aura.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 std::string GetAdjustedBounds(const gfx::Rect& visible, | 18 std::string GetAdjustedBounds(const gfx::Rect& visible, |
| 19 gfx::Rect to_be_adjusted) { | 19 gfx::Rect to_be_adjusted) { |
| 20 wm::AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted); | 20 wm::AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted); |
| 21 return to_be_adjusted.ToString(); | 21 return to_be_adjusted.ToString(); |
| 22 } | 22 } |
| 23 | |
| 24 } | 23 } |
| 25 | 24 |
| 26 typedef test::AshTestBase WindowUtilTest; | 25 typedef test::AshTestBase WindowUtilTest; |
| 27 | 26 |
| 28 TEST_F(WindowUtilTest, CenterWindow) { | 27 TEST_F(WindowUtilTest, CenterWindow) { |
| 29 if (!SupportsMultipleDisplays()) | 28 if (!SupportsMultipleDisplays()) |
| 30 return; | 29 return; |
| 31 | 30 |
| 32 UpdateDisplay("500x400, 600x400"); | 31 UpdateDisplay("500x400, 600x400"); |
| 33 std::unique_ptr<aura::Window> window( | 32 std::unique_ptr<aura::Window> window( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 150, 150))); | 56 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 150, 150))); |
| 58 EXPECT_EQ("-50,0 100x100", | 57 EXPECT_EQ("-50,0 100x100", |
| 59 GetAdjustedBounds(visible_bounds, gfx::Rect(-50, -50, 150, 150))); | 58 GetAdjustedBounds(visible_bounds, gfx::Rect(-50, -50, 150, 150))); |
| 60 EXPECT_EQ("-75,10 100x100", | 59 EXPECT_EQ("-75,10 100x100", |
| 61 GetAdjustedBounds(visible_bounds, gfx::Rect(-100, 10, 150, 150))); | 60 GetAdjustedBounds(visible_bounds, gfx::Rect(-100, 10, 150, 150))); |
| 62 EXPECT_EQ("75,75 100x100", | 61 EXPECT_EQ("75,75 100x100", |
| 63 GetAdjustedBounds(visible_bounds, gfx::Rect(100, 100, 150, 150))); | 62 GetAdjustedBounds(visible_bounds, gfx::Rect(100, 100, 150, 150))); |
| 64 | 63 |
| 65 const gfx::Rect visible_bounds_right(200, 50, 100, 100); | 64 const gfx::Rect visible_bounds_right(200, 50, 100, 100); |
| 66 | 65 |
| 67 EXPECT_EQ( | 66 EXPECT_EQ("210,60 90x90", GetAdjustedBounds(visible_bounds_right, |
| 68 "210,60 90x90", | 67 gfx::Rect(210, 60, 90, 90))); |
| 69 GetAdjustedBounds(visible_bounds_right, gfx::Rect(210, 60, 90, 90))); | 68 EXPECT_EQ("210,60 100x100", GetAdjustedBounds(visible_bounds_right, |
| 70 EXPECT_EQ( | 69 gfx::Rect(210, 60, 150, 150))); |
| 71 "210,60 100x100", | |
| 72 GetAdjustedBounds(visible_bounds_right, gfx::Rect(210, 60, 150, 150))); | |
| 73 EXPECT_EQ("125,50 100x100", | 70 EXPECT_EQ("125,50 100x100", |
| 74 GetAdjustedBounds(visible_bounds_right, gfx::Rect(0, 0, 150, 150))); | 71 GetAdjustedBounds(visible_bounds_right, gfx::Rect(0, 0, 150, 150))); |
| 75 EXPECT_EQ("275,50 100x100", GetAdjustedBounds(visible_bounds_right, | 72 EXPECT_EQ("275,50 100x100", GetAdjustedBounds(visible_bounds_right, |
| 76 gfx::Rect(300, 20, 150, 150))); | 73 gfx::Rect(300, 20, 150, 150))); |
| 77 EXPECT_EQ( | 74 EXPECT_EQ( |
| 78 "125,125 100x100", | 75 "125,125 100x100", |
| 79 GetAdjustedBounds(visible_bounds_right, gfx::Rect(-100, 150, 150, 150))); | 76 GetAdjustedBounds(visible_bounds_right, gfx::Rect(-100, 150, 150, 150))); |
| 80 | 77 |
| 81 const gfx::Rect visible_bounds_left(-200, -50, 100, 100); | 78 const gfx::Rect visible_bounds_left(-200, -50, 100, 100); |
| 82 EXPECT_EQ( | 79 EXPECT_EQ("-190,-40 90x90", GetAdjustedBounds(visible_bounds_left, |
| 83 "-190,-40 90x90", | 80 gfx::Rect(-190, -40, 90, 90))); |
| 84 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-190, -40, 90, 90))); | |
| 85 EXPECT_EQ( | 81 EXPECT_EQ( |
| 86 "-190,-40 100x100", | 82 "-190,-40 100x100", |
| 87 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-190, -40, 150, 150))); | 83 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-190, -40, 150, 150))); |
| 88 EXPECT_EQ( | 84 EXPECT_EQ( |
| 89 "-250,-40 100x100", | 85 "-250,-40 100x100", |
| 90 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150))); | 86 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150))); |
| 91 EXPECT_EQ( | 87 EXPECT_EQ( |
| 92 "-275,-50 100x100", | 88 "-275,-50 100x100", |
| 93 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150))); | 89 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150))); |
| 94 EXPECT_EQ("-125,0 100x100", | 90 EXPECT_EQ("-125,0 100x100", |
| 95 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150))); | 91 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150))); |
| 96 } | 92 } |
| 97 | 93 |
| 98 } // namespace ash | 94 } // namespace ash |
| OLD | NEW |