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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 11 months 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
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ash/wm/immersive_fullscreen_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (!SupportsMultipleDisplays()) 149 if (!SupportsMultipleDisplays())
150 return; 150 return;
151 151
152 // The secondary display is logically on the right, but on the system (e.g. X) 152 // The secondary display is logically on the right, but on the system (e.g. X)
153 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 153 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
154 UpdateDisplay("800x600,400x300"); 154 UpdateDisplay("800x600,400x300");
155 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 155 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
156 ASSERT_EQ(2U, root_windows.size()); 156 ASSERT_EQ(2U, root_windows.size());
157 157
158 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 158 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
159 Shell::GetScreen()->GetPrimaryDisplay()); 159 gfx::Screen::GetScreen()->GetPrimaryDisplay());
160 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 160 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
161 { 161 {
162 // Grab (0, 0) of the window. 162 // Grab (0, 0) of the window.
163 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 163 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
164 window_.get(), gfx::Point(), HTCAPTION)); 164 window_.get(), gfx::Point(), HTCAPTION));
165 ASSERT_TRUE(resizer.get()); 165 ASSERT_TRUE(resizer.get());
166 // Drag the pointer to the right. Once it reaches the right edge of the 166 // Drag the pointer to the right. Once it reaches the right edge of the
167 // primary display, it warps to the secondary. 167 // primary display, it warps to the secondary.
168 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 168 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
169 resizer->CompleteDrag(); 169 resizer->CompleteDrag();
170 // The whole window is on the secondary display now. The parent should be 170 // The whole window is on the secondary display now. The parent should be
171 // changed. 171 // changed.
172 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 172 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
173 EXPECT_EQ("0,10 50x60", window_->bounds().ToString()); 173 EXPECT_EQ("0,10 50x60", window_->bounds().ToString());
174 } 174 }
175 175
176 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 176 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
177 Shell::GetScreen()->GetPrimaryDisplay()); 177 gfx::Screen::GetScreen()->GetPrimaryDisplay());
178 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 178 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
179 { 179 {
180 // Grab (0, 0) of the window and move the pointer to (775, 10). 180 // Grab (0, 0) of the window and move the pointer to (775, 10).
181 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 181 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
182 window_.get(), gfx::Point(), HTCAPTION)); 182 window_.get(), gfx::Point(), HTCAPTION));
183 ASSERT_TRUE(resizer.get()); 183 ASSERT_TRUE(resizer.get());
184 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0); 184 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0);
185 // Window should be adjusted for minimum visibility (25px) during the drag. 185 // Window should be adjusted for minimum visibility (25px) during the drag.
186 EXPECT_EQ("775,10 50x60", window_->bounds().ToString()); 186 EXPECT_EQ("775,10 50x60", window_->bounds().ToString());
187 resizer->CompleteDrag(); 187 resizer->CompleteDrag();
188 // Since the pointer is still on the primary root window, the parent should 188 // Since the pointer is still on the primary root window, the parent should
189 // not be changed. 189 // not be changed.
190 // Window origin should be adjusted for minimum visibility (25px). 190 // Window origin should be adjusted for minimum visibility (25px).
191 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 191 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
192 EXPECT_EQ("775,10 50x60", window_->bounds().ToString()); 192 EXPECT_EQ("775,10 50x60", window_->bounds().ToString());
193 } 193 }
194 194
195 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 195 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
196 Shell::GetScreen()->GetPrimaryDisplay()); 196 gfx::Screen::GetScreen()->GetPrimaryDisplay());
197 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 197 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
198 { 198 {
199 // Grab the top-right edge of the window and move the pointer to (0, 10) 199 // Grab the top-right edge of the window and move the pointer to (0, 10)
200 // in the secondary root window's coordinates. 200 // in the secondary root window's coordinates.
201 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 201 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
202 window_.get(), gfx::Point(49, 0), HTCAPTION)); 202 window_.get(), gfx::Point(49, 0), HTCAPTION));
203 ASSERT_TRUE(resizer.get()); 203 ASSERT_TRUE(resizer.get());
204 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); 204 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN);
205 resizer->CompleteDrag(); 205 resizer->CompleteDrag();
206 // Since the pointer is on the secondary, the parent should be changed 206 // Since the pointer is on the secondary, the parent should be changed
207 // even though only small fraction of the window is within the secondary 207 // even though only small fraction of the window is within the secondary
208 // root window's bounds. 208 // root window's bounds.
209 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 209 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
210 // Window origin should be adjusted for minimum visibility (25px). 210 // Window origin should be adjusted for minimum visibility (25px).
211 int expected_x = -50 + kMinimumOnScreenArea; 211 int expected_x = -50 + kMinimumOnScreenArea;
212 212
213 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", 213 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60",
214 window_->bounds().ToString()); 214 window_->bounds().ToString());
215 } 215 }
216 // Dropping a window that is larger than the destination work area 216 // Dropping a window that is larger than the destination work area
217 // will shrink to fit to the work area. 217 // will shrink to fit to the work area.
218 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 218 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
219 Shell::GetScreen()->GetPrimaryDisplay()); 219 gfx::Screen::GetScreen()->GetPrimaryDisplay());
220 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 220 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
221 { 221 {
222 // Grab the top-right edge of the window and move the pointer to (0, 10) 222 // Grab the top-right edge of the window and move the pointer to (0, 10)
223 // in the secondary root window's coordinates. 223 // in the secondary root window's coordinates.
224 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 224 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
225 window_.get(), gfx::Point(699, 0), HTCAPTION)); 225 window_.get(), gfx::Point(699, 0), HTCAPTION));
226 ASSERT_TRUE(resizer.get()); 226 ASSERT_TRUE(resizer.get());
227 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); 227 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN);
228 resizer->CompleteDrag(); 228 resizer->CompleteDrag();
229 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 229 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
230 // Window size should be adjusted to fit to the work area 230 // Window size should be adjusted to fit to the work area
231 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 231 EXPECT_EQ("400x253", window_->bounds().size().ToString());
232 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 232 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
233 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 233 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
234 intersect.Intersect(window_bounds_in_screen); 234 intersect.Intersect(window_bounds_in_screen);
235 235
236 EXPECT_LE(10, intersect.width()); 236 EXPECT_LE(10, intersect.width());
237 EXPECT_LE(10, intersect.height()); 237 EXPECT_LE(10, intersect.height());
238 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); 238 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10)));
239 } 239 }
240 240
241 // Dropping a window that is larger than the destination work area 241 // Dropping a window that is larger than the destination work area
242 // will shrink to fit to the work area. 242 // will shrink to fit to the work area.
243 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 243 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
244 Shell::GetScreen()->GetPrimaryDisplay()); 244 gfx::Screen::GetScreen()->GetPrimaryDisplay());
245 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 245 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
246 { 246 {
247 // Grab the top-left edge of the window and move the pointer to (150, 10) 247 // Grab the top-left edge of the window and move the pointer to (150, 10)
248 // in the secondary root window's coordinates. Make sure the window is 248 // in the secondary root window's coordinates. Make sure the window is
249 // shrink in such a way that it keeps the cursor within. 249 // shrink in such a way that it keeps the cursor within.
250 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 250 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
251 window_.get(), gfx::Point(0, 0), HTCAPTION)); 251 window_.get(), gfx::Point(0, 0), HTCAPTION));
252 ASSERT_TRUE(resizer.get()); 252 ASSERT_TRUE(resizer.get());
253 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); 253 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN);
254 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); 254 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN);
(...skipping 21 matching lines...) Expand all
276 UpdateDisplay("800x600,800x600"); 276 UpdateDisplay("800x600,800x600");
277 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 277 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
278 ASSERT_EQ(2U, root_windows.size()); 278 ASSERT_EQ(2U, root_windows.size());
279 279
280 aura::test::TestWindowDelegate delegate; 280 aura::test::TestWindowDelegate delegate;
281 scoped_ptr<aura::Window> window(new aura::Window(&delegate)); 281 scoped_ptr<aura::Window> window(new aura::Window(&delegate));
282 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 282 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
283 window->Init(ui::LAYER_TEXTURED); 283 window->Init(ui::LAYER_TEXTURED);
284 ParentWindowInPrimaryRootWindow(window.get()); 284 ParentWindowInPrimaryRootWindow(window.get());
285 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 285 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
286 Shell::GetScreen()->GetPrimaryDisplay()); 286 gfx::Screen::GetScreen()->GetPrimaryDisplay());
287 window->Show(); 287 window->Show();
288 EXPECT_TRUE(ash::wm::CanActivateWindow(window.get())); 288 EXPECT_TRUE(ash::wm::CanActivateWindow(window.get()));
289 ash::wm::ActivateWindow(window.get()); 289 ash::wm::ActivateWindow(window.get());
290 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 290 EXPECT_EQ(root_windows[0], window->GetRootWindow());
291 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); 291 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow());
292 { 292 {
293 // Grab (0, 0) of the window. 293 // Grab (0, 0) of the window.
294 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 294 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
295 window.get(), gfx::Point(), HTCAPTION)); 295 window.get(), gfx::Point(), HTCAPTION));
296 ASSERT_TRUE(resizer.get()); 296 ASSERT_TRUE(resizer.get());
(...skipping 12 matching lines...) Expand all
309 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 309 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
310 if (!SupportsMultipleDisplays()) 310 if (!SupportsMultipleDisplays())
311 return; 311 return;
312 312
313 UpdateDisplay("800x600,800x600"); 313 UpdateDisplay("800x600,800x600");
314 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 314 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
315 ASSERT_EQ(2U, root_windows.size()); 315 ASSERT_EQ(2U, root_windows.size());
316 316
317 window_->SetBoundsInScreen( 317 window_->SetBoundsInScreen(
318 gfx::Rect(800, 00, 50, 60), 318 gfx::Rect(800, 00, 50, 60),
319 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 319 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
320 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 320 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
321 { 321 {
322 // Grab (0, 0) of the window. 322 // Grab (0, 0) of the window.
323 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 323 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
324 window_.get(), gfx::Point(), HTCAPTION)); 324 window_.get(), gfx::Point(), HTCAPTION));
325 ASSERT_TRUE(resizer.get()); 325 ASSERT_TRUE(resizer.get());
326 // Move the mouse near the right edge, (798, 0), of the primary display. 326 // Move the mouse near the right edge, (798, 0), of the primary display.
327 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 327 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
328 resizer->CompleteDrag(); 328 resizer->CompleteDrag();
329 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 329 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
330 // Window origin should be adjusted for minimum visibility (25px). 330 // Window origin should be adjusted for minimum visibility (25px).
331 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); 331 EXPECT_EQ("775,0 50x60", window_->bounds().ToString());
332 } 332 }
333 } 333 }
334 334
335 // Verifies the drag window is shown correctly. 335 // Verifies the drag window is shown correctly.
336 TEST_F(DragWindowResizerTest, DragWindowController) { 336 TEST_F(DragWindowResizerTest, DragWindowController) {
337 if (!SupportsMultipleDisplays()) 337 if (!SupportsMultipleDisplays())
338 return; 338 return;
339 339
340 UpdateDisplay("800x600,800x600"); 340 UpdateDisplay("800x600,800x600");
341 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 341 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
342 ASSERT_EQ(2U, root_windows.size()); 342 ASSERT_EQ(2U, root_windows.size());
343 343
344 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 344 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
345 Shell::GetScreen()->GetPrimaryDisplay()); 345 gfx::Screen::GetScreen()->GetPrimaryDisplay());
346 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 346 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
347 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 347 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
348 { 348 {
349 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 349 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
350 window_.get(), gfx::Point(), HTCAPTION)); 350 window_.get(), gfx::Point(), HTCAPTION));
351 ASSERT_TRUE(resizer.get()); 351 ASSERT_TRUE(resizer.get());
352 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 352 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
353 ASSERT_TRUE(drag_resizer); 353 ASSERT_TRUE(drag_resizer);
354 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size()); 354 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size());
355 355
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 EXPECT_GT(1.0f, window_->layer()->opacity()); 389 EXPECT_GT(1.0f, window_->layer()->opacity());
390 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity()); 390 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity());
391 391
392 resizer->CompleteDrag(); 392 resizer->CompleteDrag();
393 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 393 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
394 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 394 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
395 } 395 }
396 396
397 // Do the same test with RevertDrag(). 397 // Do the same test with RevertDrag().
398 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 398 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
399 Shell::GetScreen()->GetPrimaryDisplay()); 399 gfx::Screen::GetScreen()->GetPrimaryDisplay());
400 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 400 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
401 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 401 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
402 { 402 {
403 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 403 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
404 window_.get(), gfx::Point(), HTCAPTION)); 404 window_.get(), gfx::Point(), HTCAPTION));
405 ASSERT_TRUE(resizer.get()); 405 ASSERT_TRUE(resizer.get());
406 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 406 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
407 ASSERT_TRUE(drag_resizer); 407 ASSERT_TRUE(drag_resizer);
408 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size()); 408 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size());
409 409
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 UpdateDisplay("400x400,800x800*2"); 469 UpdateDisplay("400x400,800x800*2");
470 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 470 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
471 ASSERT_EQ(2U, root_windows.size()); 471 ASSERT_EQ(2U, root_windows.size());
472 472
473 test::CursorManagerTestApi cursor_test_api( 473 test::CursorManagerTestApi cursor_test_api(
474 Shell::GetInstance()->cursor_manager()); 474 Shell::GetInstance()->cursor_manager());
475 // Move window from the root window with 1.0 device scale factor to the root 475 // Move window from the root window with 1.0 device scale factor to the root
476 // window with 2.0 device scale factor. 476 // window with 2.0 device scale factor.
477 { 477 {
478 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 478 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
479 Shell::GetScreen()->GetPrimaryDisplay()); 479 gfx::Screen::GetScreen()->GetPrimaryDisplay());
480 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 480 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
481 // Grab (0, 0) of the window. 481 // Grab (0, 0) of the window.
482 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 482 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
483 window_.get(), gfx::Point(), HTCAPTION)); 483 window_.get(), gfx::Point(), HTCAPTION));
484 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 484 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
485 ASSERT_TRUE(resizer.get()); 485 ASSERT_TRUE(resizer.get());
486 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 486 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
487 TestIfMouseWarpsAt(gfx::Point(399, 200)); 487 TestIfMouseWarpsAt(gfx::Point(399, 200));
488 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 488 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
489 resizer->CompleteDrag(); 489 resizer->CompleteDrag();
490 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 490 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
491 } 491 }
492 492
493 // Move window from the root window with 2.0 device scale factor to the root 493 // Move window from the root window with 2.0 device scale factor to the root
494 // window with 1.0 device scale factor. 494 // window with 1.0 device scale factor.
495 { 495 {
496 // Make sure the window is on the default container first. 496 // Make sure the window is on the default container first.
497 aura::Window* default_container = 497 aura::Window* default_container =
498 GetRootWindowController(root_windows[1]) 498 GetRootWindowController(root_windows[1])
499 ->GetContainer(kShellWindowId_DefaultContainer); 499 ->GetContainer(kShellWindowId_DefaultContainer);
500 default_container->AddChild(window_.get()); 500 default_container->AddChild(window_.get());
501 window_->SetBoundsInScreen( 501 window_->SetBoundsInScreen(
502 gfx::Rect(600, 0, 50, 60), 502 gfx::Rect(600, 0, 50, 60),
503 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 503 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
504 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 504 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
505 // Grab (0, 0) of the window. 505 // Grab (0, 0) of the window.
506 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 506 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
507 window_.get(), gfx::Point(), HTCAPTION)); 507 window_.get(), gfx::Point(), HTCAPTION));
508 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 508 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
509 ASSERT_TRUE(resizer.get()); 509 ASSERT_TRUE(resizer.get());
510 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 510 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
511 TestIfMouseWarpsAt(gfx::Point(400, 200)); 511 TestIfMouseWarpsAt(gfx::Point(400, 200));
512 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 512 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
513 resizer->CompleteDrag(); 513 resizer->CompleteDrag();
(...skipping 10 matching lines...) Expand all
524 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 524 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
525 UpdateDisplay("400x400,400x400"); 525 UpdateDisplay("400x400,400x400");
526 526
527 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 527 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
528 ASSERT_EQ(2U, root_windows.size()); 528 ASSERT_EQ(2U, root_windows.size());
529 529
530 // Normal window can be moved across display. 530 // Normal window can be moved across display.
531 { 531 {
532 aura::Window* window = window_.get(); 532 aura::Window* window = window_.get();
533 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 533 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
534 Shell::GetScreen()->GetPrimaryDisplay()); 534 gfx::Screen::GetScreen()->GetPrimaryDisplay());
535 // Grab (0, 0) of the window. 535 // Grab (0, 0) of the window.
536 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 536 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
537 window, gfx::Point(), HTCAPTION)); 537 window, gfx::Point(), HTCAPTION));
538 ASSERT_TRUE(resizer.get()); 538 ASSERT_TRUE(resizer.get());
539 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 539 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
540 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 540 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
541 EXPECT_EQ("401,200", 541 EXPECT_EQ("401,200",
542 aura::Env::GetInstance()->last_mouse_location().ToString()); 542 aura::Env::GetInstance()->last_mouse_location().ToString());
543 resizer->CompleteDrag(); 543 resizer->CompleteDrag();
544 } 544 }
545 545
546 // Always on top window can be moved across display. 546 // Always on top window can be moved across display.
547 { 547 {
548 aura::Window* window = always_on_top_window_.get(); 548 aura::Window* window = always_on_top_window_.get();
549 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 549 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
550 Shell::GetScreen()->GetPrimaryDisplay()); 550 gfx::Screen::GetScreen()->GetPrimaryDisplay());
551 // Grab (0, 0) of the window. 551 // Grab (0, 0) of the window.
552 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 552 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
553 window, gfx::Point(), HTCAPTION)); 553 window, gfx::Point(), HTCAPTION));
554 ASSERT_TRUE(resizer.get()); 554 ASSERT_TRUE(resizer.get());
555 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 555 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
556 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 556 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
557 EXPECT_EQ("401,200", 557 EXPECT_EQ("401,200",
558 aura::Env::GetInstance()->last_mouse_location().ToString()); 558 aura::Env::GetInstance()->last_mouse_location().ToString());
559 resizer->CompleteDrag(); 559 resizer->CompleteDrag();
560 } 560 }
561 561
562 // System modal window can be moved across display. 562 // System modal window can be moved across display.
563 { 563 {
564 aura::Window* window = system_modal_window_.get(); 564 aura::Window* window = system_modal_window_.get();
565 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 565 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
566 Shell::GetScreen()->GetPrimaryDisplay()); 566 gfx::Screen::GetScreen()->GetPrimaryDisplay());
567 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(0, 0)); 567 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(0, 0));
568 // Grab (0, 0) of the window. 568 // Grab (0, 0) of the window.
569 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 569 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
570 window, gfx::Point(), HTCAPTION)); 570 window, gfx::Point(), HTCAPTION));
571 ASSERT_TRUE(resizer.get()); 571 ASSERT_TRUE(resizer.get());
572 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 572 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
573 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 573 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
574 EXPECT_EQ("401,200", 574 EXPECT_EQ("401,200",
575 aura::Env::GetInstance()->last_mouse_location().ToString()); 575 aura::Env::GetInstance()->last_mouse_location().ToString());
576 resizer->CompleteDrag(); 576 resizer->CompleteDrag();
577 } 577 }
578 578
579 // Transient window cannot be moved across display. 579 // Transient window cannot be moved across display.
580 { 580 {
581 aura::Window* window = transient_child_; 581 aura::Window* window = transient_child_;
582 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 582 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
583 Shell::GetScreen()->GetPrimaryDisplay()); 583 gfx::Screen::GetScreen()->GetPrimaryDisplay());
584 // Grab (0, 0) of the window. 584 // Grab (0, 0) of the window.
585 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 585 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
586 window, gfx::Point(), HTCAPTION)); 586 window, gfx::Point(), HTCAPTION));
587 ASSERT_TRUE(resizer.get()); 587 ASSERT_TRUE(resizer.get());
588 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 588 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
589 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 589 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
590 EXPECT_EQ("399,200", 590 EXPECT_EQ("399,200",
591 aura::Env::GetInstance()->last_mouse_location().ToString()); 591 aura::Env::GetInstance()->last_mouse_location().ToString());
592 resizer->CompleteDrag(); 592 resizer->CompleteDrag();
593 } 593 }
594 594
595 // The parent of transient window can be moved across display. 595 // The parent of transient window can be moved across display.
596 { 596 {
597 aura::Window* window = transient_parent_.get(); 597 aura::Window* window = transient_parent_.get();
598 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 598 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
599 Shell::GetScreen()->GetPrimaryDisplay()); 599 gfx::Screen::GetScreen()->GetPrimaryDisplay());
600 // Grab (0, 0) of the window. 600 // Grab (0, 0) of the window.
601 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 601 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
602 window, gfx::Point(), HTCAPTION)); 602 window, gfx::Point(), HTCAPTION));
603 ASSERT_TRUE(resizer.get()); 603 ASSERT_TRUE(resizer.get());
604 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 604 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
605 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 605 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
606 EXPECT_EQ("401,200", 606 EXPECT_EQ("401,200",
607 aura::Env::GetInstance()->last_mouse_location().ToString()); 607 aura::Env::GetInstance()->last_mouse_location().ToString());
608 resizer->CompleteDrag(); 608 resizer->CompleteDrag();
609 } 609 }
610 610
611 // Panel window can be moved across display. 611 // Panel window can be moved across display.
612 { 612 {
613 aura::Window* window = panel_window_.get(); 613 aura::Window* window = panel_window_.get();
614 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 614 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
615 Shell::GetScreen()->GetPrimaryDisplay()); 615 gfx::Screen::GetScreen()->GetPrimaryDisplay());
616 // Grab (0, 0) of the window. 616 // Grab (0, 0) of the window.
617 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 617 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
618 window, gfx::Point(), HTCAPTION)); 618 window, gfx::Point(), HTCAPTION));
619 ASSERT_TRUE(resizer.get()); 619 ASSERT_TRUE(resizer.get());
620 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 620 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
621 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 621 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
622 EXPECT_EQ("401,200", 622 EXPECT_EQ("401,200",
623 aura::Env::GetInstance()->last_mouse_location().ToString()); 623 aura::Env::GetInstance()->last_mouse_location().ToString());
624 resizer->CompleteDrag(); 624 resizer->CompleteDrag();
625 } 625 }
626 } 626 }
627 627
628 } // namespace ash 628 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ash/wm/immersive_fullscreen_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698