Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: ash/wm/drag_window_resizer_unittest.cc

Issue 64933002: Eliminate Shell::RootWindowList in favor of aura::Window::Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 aura::Window* window, 120 aura::Window* window,
121 const gfx::Point& point_in_parent, 121 const gfx::Point& point_in_parent,
122 int window_component) { 122 int window_component) {
123 return CreateWindowResizer( 123 return CreateWindowResizer(
124 window, 124 window,
125 point_in_parent, 125 point_in_parent,
126 window_component, 126 window_component,
127 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); 127 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
128 } 128 }
129 129
130 bool WarpMouseCursorIfNecessary(aura::RootWindow* target_root, 130 bool WarpMouseCursorIfNecessary(aura::Window* target_root,
131 const gfx::Point& point_in_screen) { 131 const gfx::Point& point_in_screen) {
132 MouseCursorEventFilter* event_filter = 132 MouseCursorEventFilter* event_filter =
133 Shell::GetInstance()->mouse_cursor_filter(); 133 Shell::GetInstance()->mouse_cursor_filter();
134 bool is_warped = event_filter->WarpMouseCursorIfNecessary(target_root, 134 bool is_warped = event_filter->WarpMouseCursorIfNecessary(target_root,
135 point_in_screen); 135 point_in_screen);
136 event_filter->reset_was_mouse_warped_for_test(); 136 event_filter->reset_was_mouse_warped_for_test();
137 return is_warped; 137 return is_warped;
138 } 138 }
139 139
140 aura::test::TestWindowDelegate delegate_; 140 aura::test::TestWindowDelegate delegate_;
(...skipping 15 matching lines...) Expand all
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) {
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,800x600");
166 Shell::RootWindowList 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));
176 ASSERT_TRUE(resizer.get()); 176 ASSERT_TRUE(resizer.get());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Verifies that dragging the active window to another display makes the new 228 // Verifies that dragging the active window to another display makes the new
229 // root window the active root window. 229 // root window the active root window.
230 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { 230 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) {
231 if (!SupportsMultipleDisplays()) 231 if (!SupportsMultipleDisplays())
232 return; 232 return;
233 233
234 // The secondary display is logically on the right, but on the system (e.g. X) 234 // 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. 235 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
236 UpdateDisplay("800x600,800x600"); 236 UpdateDisplay("800x600,800x600");
237 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 237 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
238 ASSERT_EQ(2U, root_windows.size()); 238 ASSERT_EQ(2U, root_windows.size());
239 239
240 aura::test::TestWindowDelegate delegate; 240 aura::test::TestWindowDelegate delegate;
241 scoped_ptr<aura::Window> window(new aura::Window(&delegate)); 241 scoped_ptr<aura::Window> window(new aura::Window(&delegate));
242 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 242 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
243 window->Init(ui::LAYER_TEXTURED); 243 window->Init(ui::LAYER_TEXTURED);
244 ParentWindowInPrimaryRootWindow(window.get()); 244 ParentWindowInPrimaryRootWindow(window.get());
245 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 245 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
246 Shell::GetScreen()->GetPrimaryDisplay()); 246 Shell::GetScreen()->GetPrimaryDisplay());
247 window->Show(); 247 window->Show();
(...skipping 16 matching lines...) Expand all
264 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); 264 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow());
265 } 265 }
266 } 266 }
267 267
268 // Verifies a window can be moved from the secondary display to primary. 268 // Verifies a window can be moved from the secondary display to primary.
269 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 269 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
270 if (!SupportsMultipleDisplays()) 270 if (!SupportsMultipleDisplays())
271 return; 271 return;
272 272
273 UpdateDisplay("800x600,800x600"); 273 UpdateDisplay("800x600,800x600");
274 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 274 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
275 ASSERT_EQ(2U, root_windows.size()); 275 ASSERT_EQ(2U, root_windows.size());
276 276
277 window_->SetBoundsInScreen( 277 window_->SetBoundsInScreen(
278 gfx::Rect(800, 00, 50, 60), 278 gfx::Rect(800, 00, 50, 60),
279 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 279 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
280 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 280 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
281 { 281 {
282 // Grab (0, 0) of the window. 282 // Grab (0, 0) of the window.
283 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 283 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
284 window_.get(), gfx::Point(), HTCAPTION)); 284 window_.get(), gfx::Point(), HTCAPTION));
285 ASSERT_TRUE(resizer.get()); 285 ASSERT_TRUE(resizer.get());
286 // Move the mouse near the right edge, (798, 0), of the primary display. 286 // Move the mouse near the right edge, (798, 0), of the primary display.
287 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 287 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
288 resizer->CompleteDrag(0); 288 resizer->CompleteDrag(0);
289 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 289 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
290 // Window origin should be adjusted for minimum visibility (10px). 290 // Window origin should be adjusted for minimum visibility (10px).
291 int expected_x = 800 - 10; 291 int expected_x = 800 - 10;
292 EXPECT_EQ(base::IntToString(expected_x) + ",0 50x60", 292 EXPECT_EQ(base::IntToString(expected_x) + ",0 50x60",
293 window_->bounds().ToString()); 293 window_->bounds().ToString());
294 } 294 }
295 } 295 }
296 296
297 // Verifies the drag window is shown correctly. 297 // Verifies the drag window is shown correctly.
298 TEST_F(DragWindowResizerTest, DragWindowController) { 298 TEST_F(DragWindowResizerTest, DragWindowController) {
299 if (!SupportsMultipleDisplays()) 299 if (!SupportsMultipleDisplays())
300 return; 300 return;
301 301
302 UpdateDisplay("800x600,800x600"); 302 UpdateDisplay("800x600,800x600");
303 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 303 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
304 ASSERT_EQ(2U, root_windows.size()); 304 ASSERT_EQ(2U, root_windows.size());
305 305
306 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 306 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
307 Shell::GetScreen()->GetPrimaryDisplay()); 307 Shell::GetScreen()->GetPrimaryDisplay());
308 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 308 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
309 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 309 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
310 { 310 {
311 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 311 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
312 window_.get(), gfx::Point(), HTCAPTION)); 312 window_.get(), gfx::Point(), HTCAPTION));
313 ASSERT_TRUE(resizer.get()); 313 ASSERT_TRUE(resizer.get());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 // Verifies cursor's device scale factor is updated whe a window is moved across 430 // Verifies cursor's device scale factor is updated whe a window is moved across
431 // root windows with different device scale factors (http://crbug.com/154183). 431 // root windows with different device scale factors (http://crbug.com/154183).
432 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) { 432 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) {
433 if (!SupportsMultipleDisplays()) 433 if (!SupportsMultipleDisplays())
434 return; 434 return;
435 435
436 // The secondary display is logically on the right, but on the system (e.g. X) 436 // The secondary display is logically on the right, but on the system (e.g. X)
437 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 437 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
438 UpdateDisplay("400x400,800x800*2"); 438 UpdateDisplay("400x400,800x800*2");
439 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 439 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
440 ASSERT_EQ(2U, root_windows.size()); 440 ASSERT_EQ(2U, root_windows.size());
441 441
442 test::CursorManagerTestApi cursor_test_api( 442 test::CursorManagerTestApi cursor_test_api(
443 Shell::GetInstance()->cursor_manager()); 443 Shell::GetInstance()->cursor_manager());
444 // Move window from the root window with 1.0 device scale factor to the root 444 // Move window from the root window with 1.0 device scale factor to the root
445 // window with 2.0 device scale factor. 445 // window with 2.0 device scale factor.
446 { 446 {
447 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 447 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
448 Shell::GetScreen()->GetPrimaryDisplay()); 448 Shell::GetScreen()->GetPrimaryDisplay());
449 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 449 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 // Verifies several kinds of windows can be moved across displays. 482 // Verifies several kinds of windows can be moved across displays.
483 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { 483 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) {
484 if (!SupportsMultipleDisplays()) 484 if (!SupportsMultipleDisplays())
485 return; 485 return;
486 486
487 // The secondary display is logically on the right, but on the system (e.g. X) 487 // The secondary display is logically on the right, but on the system (e.g. X)
488 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 488 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
489 UpdateDisplay("400x400,400x400"); 489 UpdateDisplay("400x400,400x400");
490 490
491 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 491 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
492 ASSERT_EQ(2U, root_windows.size()); 492 ASSERT_EQ(2U, root_windows.size());
493 493
494 // Normal window can be moved across display. 494 // Normal window can be moved across display.
495 { 495 {
496 aura::Window* window = window_.get(); 496 aura::Window* window = window_.get();
497 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 497 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
498 Shell::GetScreen()->GetPrimaryDisplay()); 498 Shell::GetScreen()->GetPrimaryDisplay());
499 // Grab (0, 0) of the window. 499 // Grab (0, 0) of the window.
500 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 500 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
501 window, gfx::Point(), HTCAPTION)); 501 window, gfx::Point(), HTCAPTION));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 resizer->CompleteDrag(0); 665 resizer->CompleteDrag(0);
666 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); 666 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls());
667 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); 667 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString());
668 } 668 }
669 } 669 }
670 #endif 670 #endif
671 671
672 672
673 } // namespace internal 673 } // namespace internal
674 } // namespace ash 674 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698