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/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "ash/wm/window_positioning_utils.h" | 8 #include "ash/wm/window_positioning_utils.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "ash/wm_window.h" | 10 #include "ash/wm_window.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 typedef test::AshTestBase WindowUtilTest; | 27 typedef test::AshTestBase WindowUtilTest; |
28 | 28 |
29 TEST_F(WindowUtilTest, CenterWindow) { | 29 TEST_F(WindowUtilTest, CenterWindow) { |
30 UpdateDisplay("500x400, 600x400"); | 30 UpdateDisplay("500x400, 600x400"); |
31 std::unique_ptr<aura::Window> window( | 31 std::unique_ptr<aura::Window> window( |
32 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); | 32 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
33 | 33 |
34 WindowState* window_state = GetWindowState(window.get()); | 34 WindowState* window_state = GetWindowState(window.get()); |
35 EXPECT_FALSE(window_state->bounds_changed_by_user()); | 35 EXPECT_FALSE(window_state->bounds_changed_by_user()); |
36 | 36 |
37 CenterWindow(WmWindow::Get(window.get())); | 37 CenterWindow(window.get()); |
38 // Centring window is considered as a user's action. | 38 // Centring window is considered as a user's action. |
39 EXPECT_TRUE(window_state->bounds_changed_by_user()); | 39 EXPECT_TRUE(window_state->bounds_changed_by_user()); |
40 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); | 40 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); |
41 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); | 41 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); |
42 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); | 42 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); |
43 CenterWindow(WmWindow::Get(window.get())); | 43 CenterWindow(window.get()); |
44 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); | 44 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); |
45 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); | 45 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); |
46 } | 46 } |
47 | 47 |
48 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { | 48 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { |
49 const gfx::Rect visible_bounds(0, 0, 100, 100); | 49 const gfx::Rect visible_bounds(0, 0, 100, 100); |
50 | 50 |
51 EXPECT_EQ("0,0 90x90", | 51 EXPECT_EQ("0,0 90x90", |
52 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); | 52 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); |
53 EXPECT_EQ("0,0 100x100", | 53 EXPECT_EQ("0,0 100x100", |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 EXPECT_TRUE(MoveWindowToDisplay(window.get(), original_display_id)); | 138 EXPECT_TRUE(MoveWindowToDisplay(window.get(), original_display_id)); |
139 EXPECT_EQ(original_display_id, | 139 EXPECT_EQ(original_display_id, |
140 screen->GetDisplayNearestWindow(window.get()).id()); | 140 screen->GetDisplayNearestWindow(window.get()).id()); |
141 EXPECT_EQ(original_container_id, window->parent()->id()); | 141 EXPECT_EQ(original_container_id, window->parent()->id()); |
142 EXPECT_EQ(original_root, window->GetRootWindow()); | 142 EXPECT_EQ(original_root, window->GetRootWindow()); |
143 } | 143 } |
144 | 144 |
145 } // namespace wm | 145 } // namespace wm |
146 } // namespace ash | 146 } // namespace ash |
OLD | NEW |