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/wm/drag_window_resizer.h" | 5 #include "ash/wm/drag_window_resizer.h" |
6 | 6 |
7 #include "ash/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 scoped_ptr<aura::Window> system_modal_window_; | 149 scoped_ptr<aura::Window> system_modal_window_; |
150 scoped_ptr<aura::Window> panel_window_; | 150 scoped_ptr<aura::Window> panel_window_; |
151 aura::Window* transient_child_; | 151 aura::Window* transient_child_; |
152 scoped_ptr<aura::Window> transient_parent_; | 152 scoped_ptr<aura::Window> transient_parent_; |
153 | 153 |
154 private: | 154 private: |
155 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); | 155 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); |
156 }; | 156 }; |
157 | 157 |
158 // Verifies a window can be moved from the primary display to another. | 158 // Verifies a window can be moved from the primary display to another. |
159 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { | 159 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { |
varkha
2013/12/12 16:20:46
nit: This test too could be quoted in the CL TEST
oshima
2013/12/12 19:07:14
Done.
| |
160 if (!SupportsMultipleDisplays()) | 160 if (!SupportsMultipleDisplays()) |
161 return; | 161 return; |
162 | 162 |
163 // The secondary display is logically on the right, but on the system (e.g. X) | 163 // The secondary display is logically on the right, but on the system (e.g. X) |
164 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 164 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
165 UpdateDisplay("800x600,800x600"); | 165 UpdateDisplay("800x600,400x300"); |
166 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 166 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
167 ASSERT_EQ(2U, root_windows.size()); | 167 ASSERT_EQ(2U, root_windows.size()); |
168 | 168 |
169 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 169 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
170 Shell::GetScreen()->GetPrimaryDisplay()); | 170 Shell::GetScreen()->GetPrimaryDisplay()); |
171 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 171 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
172 { | 172 { |
173 // Grab (0, 0) of the window. | 173 // Grab (0, 0) of the window. |
174 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | 174 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( |
175 window_.get(), gfx::Point(), HTCAPTION)); | 175 window_.get(), gfx::Point(), HTCAPTION)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 resizer->CompleteDrag(0); | 216 resizer->CompleteDrag(0); |
217 // Since the pointer is on the secondary, the parent should be changed | 217 // Since the pointer is on the secondary, the parent should be changed |
218 // even though only small fraction of the window is within the secondary | 218 // even though only small fraction of the window is within the secondary |
219 // root window's bounds. | 219 // root window's bounds. |
220 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 220 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
221 // Window origin should be adjusted for minimum visibility (10px). | 221 // Window origin should be adjusted for minimum visibility (10px). |
222 int expected_x = -50 + 10; | 222 int expected_x = -50 + 10; |
223 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", | 223 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", |
224 window_->bounds().ToString()); | 224 window_->bounds().ToString()); |
225 } | 225 } |
226 // Dropping a window that is larger than the destination work area | |
227 // will shrink to fit to the work area. | |
228 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), | |
229 Shell::GetScreen()->GetPrimaryDisplay()); | |
230 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
231 { | |
232 // Grab the top-right edge of the window and move the pointer to (0, 10) | |
233 // in the secondary root window's coordinates. | |
234 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | |
235 window_.get(), gfx::Point(699, 0), HTCAPTION)); | |
236 ASSERT_TRUE(resizer.get()); | |
237 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); | |
238 resizer->CompleteDrag(0); | |
239 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
240 // Window size should be adjusted to fit to the work area | |
241 EXPECT_EQ("400x253", window_->bounds().size().ToString()); | |
242 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | |
243 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | |
244 intersect.Intersect(window_bounds_in_screen); | |
245 EXPECT_LE(10, intersect.width()); | |
246 EXPECT_LE(10, intersect.height()); | |
247 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); | |
248 } | |
249 | |
250 // Dropping a window that is larger than the destination work area | |
251 // will shrink to fit to the work area. | |
252 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), | |
253 Shell::GetScreen()->GetPrimaryDisplay()); | |
254 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
255 { | |
256 // Grab the top-left edge of the window and move the pointer to (150, 10) | |
257 // in the secondary root window's coordinates. Make sure the window is | |
258 // shrink in such a way that it keeps the cursor within. | |
259 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | |
260 window_.get(), gfx::Point(0, 0), HTCAPTION)); | |
261 ASSERT_TRUE(resizer.get()); | |
262 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); | |
263 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); | |
264 resizer->CompleteDrag(0); | |
265 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
266 // Window size should be adjusted to fit to the work area | |
267 EXPECT_EQ("400x253", window_->bounds().size().ToString()); | |
268 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | |
269 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | |
270 intersect.Intersect(window_bounds_in_screen); | |
271 EXPECT_LE(10, intersect.width()); | |
272 EXPECT_LE(10, intersect.height()); | |
273 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); | |
274 } | |
226 } | 275 } |
227 | 276 |
228 // Verifies that dragging the active window to another display makes the new | 277 // Verifies that dragging the active window to another display makes the new |
229 // root window the active root window. | 278 // root window the active root window. |
230 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { | 279 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { |
231 if (!SupportsMultipleDisplays()) | 280 if (!SupportsMultipleDisplays()) |
232 return; | 281 return; |
233 | 282 |
234 // The secondary display is logically on the right, but on the system (e.g. X) | 283 // The secondary display is logically on the right, but on the system (e.g. X) |
235 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 284 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 resizer->CompleteDrag(0); | 714 resizer->CompleteDrag(0); |
666 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); | 715 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); |
667 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); | 716 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); |
668 } | 717 } |
669 } | 718 } |
670 #endif | 719 #endif |
671 | 720 |
672 | 721 |
673 } // namespace internal | 722 } // namespace internal |
674 } // namespace ash | 723 } // namespace ash |
OLD | NEW |