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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 const gfx::Point& point_in_parent, | 175 const gfx::Point& point_in_parent, |
176 int window_component) { | 176 int window_component) { |
177 WindowResizer* resizer = CreateWindowResizer( | 177 WindowResizer* resizer = CreateWindowResizer( |
178 window, | 178 window, |
179 point_in_parent, | 179 point_in_parent, |
180 window_component, | 180 window_component, |
181 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); | 181 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); |
182 workspace_resizer_ = WorkspaceWindowResizer::instance_; | 182 workspace_resizer_ = WorkspaceWindowResizer::instance_; |
183 return resizer; | 183 return resizer; |
184 } | 184 } |
| 185 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( |
| 186 aura::Window* window, |
| 187 const gfx::Point& point_in_parent, |
| 188 int window_component, |
| 189 aura::client::WindowMoveSource source, |
| 190 const std::vector<aura::Window*>& attached_windows) { |
| 191 scoped_ptr<DragDetails> details(new DragDetails( |
| 192 window, point_in_parent, window_component, source)); |
| 193 wm::WindowState* window_state = wm::GetWindowState(window); |
| 194 window_state->set_drag_details(details.release()); |
| 195 return WorkspaceWindowResizer::Create(window_state, attached_windows); |
| 196 } |
185 | 197 |
186 PhantomWindowController* snap_phantom_window_controller() const { | 198 PhantomWindowController* snap_phantom_window_controller() const { |
187 return workspace_resizer_->snap_phantom_window_controller_.get(); | 199 return workspace_resizer_->snap_phantom_window_controller_.get(); |
188 } | 200 } |
189 | 201 |
190 gfx::Point CalculateDragPoint(const WindowResizer& resizer, | 202 gfx::Point CalculateDragPoint(const WindowResizer& resizer, |
191 int delta_x, | 203 int delta_x, |
192 int delta_y) const { | 204 int delta_y) const { |
193 gfx::Point location = resizer.GetInitialLocation(); | 205 gfx::Point location = resizer.GetInitialLocation(); |
194 location.set_x(location.x() + delta_x); | 206 location.set_x(location.x() + delta_x); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 }; | 270 }; |
259 | 271 |
260 // Assertions around attached window resize dragging from the right with 2 | 272 // Assertions around attached window resize dragging from the right with 2 |
261 // windows. | 273 // windows. |
262 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { | 274 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { |
263 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); | 275 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
264 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 276 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
265 | 277 |
266 std::vector<aura::Window*> windows; | 278 std::vector<aura::Window*> windows; |
267 windows.push_back(window2_.get()); | 279 windows.push_back(window2_.get()); |
268 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 280 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
269 window_.get(), gfx::Point(), HTRIGHT, | 281 window_.get(), gfx::Point(), HTRIGHT, |
270 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 282 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
271 ASSERT_TRUE(resizer.get()); | 283 ASSERT_TRUE(resizer.get()); |
272 // Move it 100 to the right, which should expand w1 and push w2. | 284 // Move it 100 to the right, which should expand w1 and push w2. |
273 resizer->Drag(CalculateDragPoint(*resizer, 100, 10), 0); | 285 resizer->Drag(CalculateDragPoint(*resizer, 100, 10), 0); |
274 EXPECT_EQ("0,300 500x300", window_->bounds().ToString()); | 286 EXPECT_EQ("0,300 500x300", window_->bounds().ToString()); |
275 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); | 287 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); |
276 | 288 |
277 // Push off the screen, w2 should be resized to its min. | 289 // Push off the screen, w2 should be resized to its min. |
278 delegate2_.set_min_size(gfx::Size(20, 20)); | 290 delegate2_.set_min_size(gfx::Size(20, 20)); |
(...skipping 13 matching lines...) Expand all Loading... |
292 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); | 304 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); |
293 } | 305 } |
294 | 306 |
295 // Assertions around collapsing and expanding. | 307 // Assertions around collapsing and expanding. |
296 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { | 308 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { |
297 window_->SetBounds(gfx::Rect( 0, 300, 400, 300)); | 309 window_->SetBounds(gfx::Rect( 0, 300, 400, 300)); |
298 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 310 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
299 | 311 |
300 std::vector<aura::Window*> windows; | 312 std::vector<aura::Window*> windows; |
301 windows.push_back(window2_.get()); | 313 windows.push_back(window2_.get()); |
302 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 314 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
303 window_.get(), gfx::Point(), HTRIGHT, | 315 window_.get(), gfx::Point(), HTRIGHT, |
304 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 316 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
305 ASSERT_TRUE(resizer.get()); | 317 ASSERT_TRUE(resizer.get()); |
306 // Move it 100 to the left, which should expand w2 and collapse w1. | 318 // Move it 100 to the left, which should expand w2 and collapse w1. |
307 resizer->Drag(CalculateDragPoint(*resizer, -100, 10), 0); | 319 resizer->Drag(CalculateDragPoint(*resizer, -100, 10), 0); |
308 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); | 320 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); |
309 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); | 321 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); |
310 | 322 |
311 // Collapse all the way to w1's min. | 323 // Collapse all the way to w1's min. |
312 delegate_.set_min_size(gfx::Size(20, 20)); | 324 delegate_.set_min_size(gfx::Size(20, 20)); |
(...skipping 17 matching lines...) Expand all Loading... |
330 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { | 342 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { |
331 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); | 343 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); |
332 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); | 344 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); |
333 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); | 345 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); |
334 delegate2_.set_min_size(gfx::Size(52, 50)); | 346 delegate2_.set_min_size(gfx::Size(52, 50)); |
335 delegate3_.set_min_size(gfx::Size(38, 50)); | 347 delegate3_.set_min_size(gfx::Size(38, 50)); |
336 | 348 |
337 std::vector<aura::Window*> windows; | 349 std::vector<aura::Window*> windows; |
338 windows.push_back(window2_.get()); | 350 windows.push_back(window2_.get()); |
339 windows.push_back(window3_.get()); | 351 windows.push_back(window3_.get()); |
340 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 352 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
341 window_.get(), gfx::Point(), HTRIGHT, | 353 window_.get(), gfx::Point(), HTRIGHT, |
342 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 354 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
343 ASSERT_TRUE(resizer.get()); | 355 ASSERT_TRUE(resizer.get()); |
344 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 356 // Move it 100 to the right, which should expand w1 and push w2 and w3. |
345 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 357 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
346 EXPECT_EQ("100,300 300x300", window_->bounds().ToString()); | 358 EXPECT_EQ("100,300 300x300", window_->bounds().ToString()); |
347 EXPECT_EQ("400,300 150x200", window2_->bounds().ToString()); | 359 EXPECT_EQ("400,300 150x200", window2_->bounds().ToString()); |
348 EXPECT_EQ("550,300 100x200", window3_->bounds().ToString()); | 360 EXPECT_EQ("550,300 100x200", window3_->bounds().ToString()); |
349 | 361 |
350 // Move it 300, things should compress. | 362 // Move it 300, things should compress. |
(...skipping 20 matching lines...) Expand all Loading... |
371 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { | 383 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { |
372 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); | 384 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); |
373 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); | 385 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); |
374 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); | 386 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); |
375 delegate2_.set_min_size(gfx::Size(52, 50)); | 387 delegate2_.set_min_size(gfx::Size(52, 50)); |
376 delegate3_.set_min_size(gfx::Size(38, 50)); | 388 delegate3_.set_min_size(gfx::Size(38, 50)); |
377 | 389 |
378 std::vector<aura::Window*> windows; | 390 std::vector<aura::Window*> windows; |
379 windows.push_back(window2_.get()); | 391 windows.push_back(window2_.get()); |
380 windows.push_back(window3_.get()); | 392 windows.push_back(window3_.get()); |
381 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 393 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
382 window_.get(), gfx::Point(), HTRIGHT, | 394 window_.get(), gfx::Point(), HTRIGHT, |
383 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 395 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
384 ASSERT_TRUE(resizer.get()); | 396 ASSERT_TRUE(resizer.get()); |
385 // Move it -100 to the right, which should collapse w1 and expand w2 and w3. | 397 // Move it -100 to the right, which should collapse w1 and expand w2 and w3. |
386 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); | 398 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); |
387 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); | 399 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); |
388 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); | 400 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); |
389 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); | 401 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); |
390 | 402 |
391 // Move it 100 to the right. | 403 // Move it 100 to the right. |
392 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 404 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
393 EXPECT_EQ("100,300 300x300", window_->bounds().ToString()); | 405 EXPECT_EQ("100,300 300x300", window_->bounds().ToString()); |
394 EXPECT_EQ("400,300 200x200", window2_->bounds().ToString()); | 406 EXPECT_EQ("400,300 200x200", window2_->bounds().ToString()); |
395 EXPECT_EQ("600,300 100x200", window3_->bounds().ToString()); | 407 EXPECT_EQ("600,300 100x200", window3_->bounds().ToString()); |
396 | 408 |
397 // 100 to the left again. | 409 // 100 to the left again. |
398 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); | 410 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); |
399 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); | 411 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); |
400 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); | 412 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); |
401 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); | 413 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); |
402 } | 414 } |
403 | 415 |
404 // Assertions around collapsing and expanding from the bottom. | 416 // Assertions around collapsing and expanding from the bottom. |
405 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { | 417 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { |
406 window_->SetBounds(gfx::Rect( 0, 100, 400, 300)); | 418 window_->SetBounds(gfx::Rect( 0, 100, 400, 300)); |
407 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); | 419 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); |
408 | 420 |
409 std::vector<aura::Window*> windows; | 421 std::vector<aura::Window*> windows; |
410 windows.push_back(window2_.get()); | 422 windows.push_back(window2_.get()); |
411 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 423 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
412 window_.get(), gfx::Point(), HTBOTTOM, | 424 window_.get(), gfx::Point(), HTBOTTOM, |
413 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 425 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
414 ASSERT_TRUE(resizer.get()); | 426 ASSERT_TRUE(resizer.get()); |
415 // Move it up 100, which should expand w2 and collapse w1. | 427 // Move it up 100, which should expand w2 and collapse w1. |
416 resizer->Drag(CalculateDragPoint(*resizer, 10, -100), 0); | 428 resizer->Drag(CalculateDragPoint(*resizer, 10, -100), 0); |
417 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); | 429 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); |
418 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); | 430 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); |
419 | 431 |
420 // Collapse all the way to w1's min. | 432 // Collapse all the way to w1's min. |
421 delegate_.set_min_size(gfx::Size(20, 20)); | 433 delegate_.set_min_size(gfx::Size(20, 20)); |
(...skipping 13 matching lines...) Expand all Loading... |
435 } | 447 } |
436 | 448 |
437 // Assertions around attached window resize dragging from the bottom with 2 | 449 // Assertions around attached window resize dragging from the bottom with 2 |
438 // windows. | 450 // windows. |
439 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { | 451 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { |
440 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); | 452 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); |
441 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); | 453 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); |
442 | 454 |
443 std::vector<aura::Window*> windows; | 455 std::vector<aura::Window*> windows; |
444 windows.push_back(window2_.get()); | 456 windows.push_back(window2_.get()); |
445 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 457 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
446 window_.get(), gfx::Point(), HTBOTTOM, | 458 window_.get(), gfx::Point(), HTBOTTOM, |
447 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 459 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
448 ASSERT_TRUE(resizer.get()); | 460 ASSERT_TRUE(resizer.get()); |
449 // Move it 100 to the bottom, which should expand w1 and push w2. | 461 // Move it 100 to the bottom, which should expand w1 and push w2. |
450 resizer->Drag(CalculateDragPoint(*resizer, 10, 100), 0); | 462 resizer->Drag(CalculateDragPoint(*resizer, 10, 100), 0); |
451 EXPECT_EQ("0,50 400x300", window_->bounds().ToString()); | 463 EXPECT_EQ("0,50 400x300", window_->bounds().ToString()); |
452 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString()); | 464 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString()); |
453 | 465 |
454 // Push off the screen, w2 should be resized to its min. | 466 // Push off the screen, w2 should be resized to its min. |
455 delegate2_.set_min_size(gfx::Size(20, 20)); | 467 delegate2_.set_min_size(gfx::Size(20, 20)); |
(...skipping 29 matching lines...) Expand all Loading... |
485 | 497 |
486 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 498 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); |
487 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 499 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
488 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 500 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
489 delegate2_.set_min_size(gfx::Size(50, 52)); | 501 delegate2_.set_min_size(gfx::Size(50, 52)); |
490 delegate3_.set_min_size(gfx::Size(50, 38)); | 502 delegate3_.set_min_size(gfx::Size(50, 38)); |
491 | 503 |
492 std::vector<aura::Window*> windows; | 504 std::vector<aura::Window*> windows; |
493 windows.push_back(window2_.get()); | 505 windows.push_back(window2_.get()); |
494 windows.push_back(window3_.get()); | 506 windows.push_back(window3_.get()); |
495 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 507 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
496 window_.get(), gfx::Point(), HTBOTTOM, | 508 window_.get(), gfx::Point(), HTBOTTOM, |
497 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 509 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
498 ASSERT_TRUE(resizer.get()); | 510 ASSERT_TRUE(resizer.get()); |
499 // Move it 100 down, which should expand w1 and push w2 and w3. | 511 // Move it 100 down, which should expand w1 and push w2 and w3. |
500 resizer->Drag(CalculateDragPoint(*resizer, -10, 100), 0); | 512 resizer->Drag(CalculateDragPoint(*resizer, -10, 100), 0); |
501 EXPECT_EQ("300,100 300x300", window_->bounds().ToString()); | 513 EXPECT_EQ("300,100 300x300", window_->bounds().ToString()); |
502 EXPECT_EQ("300,400 200x150", window2_->bounds().ToString()); | 514 EXPECT_EQ("300,400 200x150", window2_->bounds().ToString()); |
503 EXPECT_EQ("300,550 200x100", window3_->bounds().ToString()); | 515 EXPECT_EQ("300,550 200x100", window3_->bounds().ToString()); |
504 | 516 |
505 // Move it 296 things should compress. | 517 // Move it 296 things should compress. |
(...skipping 20 matching lines...) Expand all Loading... |
526 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { | 538 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { |
527 window_->SetBounds(gfx::Rect( 0, 0, 200, 200)); | 539 window_->SetBounds(gfx::Rect( 0, 0, 200, 200)); |
528 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); | 540 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); |
529 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); | 541 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); |
530 delegate2_.set_min_size(gfx::Size(52, 50)); | 542 delegate2_.set_min_size(gfx::Size(52, 50)); |
531 delegate3_.set_min_size(gfx::Size(38, 50)); | 543 delegate3_.set_min_size(gfx::Size(38, 50)); |
532 | 544 |
533 std::vector<aura::Window*> windows; | 545 std::vector<aura::Window*> windows; |
534 windows.push_back(window2_.get()); | 546 windows.push_back(window2_.get()); |
535 windows.push_back(window3_.get()); | 547 windows.push_back(window3_.get()); |
536 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 548 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
537 window_.get(), gfx::Point(), HTBOTTOM, | 549 window_.get(), gfx::Point(), HTBOTTOM, |
538 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 550 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
539 ASSERT_TRUE(resizer.get()); | 551 ASSERT_TRUE(resizer.get()); |
540 // Move it 100 up, which should collapse w1 and expand w2 and w3. | 552 // Move it 100 up, which should collapse w1 and expand w2 and w3. |
541 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 553 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
542 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 554 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
543 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 555 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
544 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 556 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
545 | 557 |
546 // Move it 100 down. | 558 // Move it 100 down. |
(...skipping 16 matching lines...) Expand all Loading... |
563 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 575 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
564 | 576 |
565 Shell* shell = Shell::GetInstance(); | 577 Shell* shell = Shell::GetInstance(); |
566 aura::test::EventGenerator generator(window_->GetRootWindow()); | 578 aura::test::EventGenerator generator(window_->GetRootWindow()); |
567 | 579 |
568 // The cursor should not be locked initially. | 580 // The cursor should not be locked initially. |
569 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); | 581 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); |
570 | 582 |
571 std::vector<aura::Window*> windows; | 583 std::vector<aura::Window*> windows; |
572 windows.push_back(window2_.get()); | 584 windows.push_back(window2_.get()); |
573 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 585 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
574 window_.get(), gfx::Point(), HTRIGHT, | 586 window_.get(), gfx::Point(), HTRIGHT, |
575 aura::client::WINDOW_MOVE_SOURCE_TOUCH, windows)); | 587 aura::client::WINDOW_MOVE_SOURCE_TOUCH, windows)); |
576 ASSERT_TRUE(resizer.get()); | 588 ASSERT_TRUE(resizer.get()); |
577 | 589 |
578 // Creating a WorkspaceWindowResizer should not lock the cursor. | 590 // Creating a WorkspaceWindowResizer should not lock the cursor. |
579 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); | 591 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); |
580 | 592 |
581 // The cursor should be hidden after touching the screen and | 593 // The cursor should be hidden after touching the screen and |
582 // starting a drag. | 594 // starting a drag. |
583 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); | 595 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 731 |
720 // Verifies windows are correctly restacked when reordering multiple windows. | 732 // Verifies windows are correctly restacked when reordering multiple windows. |
721 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { | 733 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { |
722 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); | 734 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); |
723 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); | 735 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); |
724 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); | 736 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); |
725 | 737 |
726 { | 738 { |
727 std::vector<aura::Window*> windows; | 739 std::vector<aura::Window*> windows; |
728 windows.push_back(window2_.get()); | 740 windows.push_back(window2_.get()); |
729 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 741 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
730 window_.get(), gfx::Point(), HTRIGHT, | 742 window_.get(), gfx::Point(), HTRIGHT, |
731 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 743 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
732 ASSERT_TRUE(resizer.get()); | 744 ASSERT_TRUE(resizer.get()); |
733 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 745 // Move it 100 to the right, which should expand w1 and push w2 and w3. |
734 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 746 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
735 | 747 |
736 // 2 should be topmost since it's initially the highest in the stack. | 748 // 2 should be topmost since it's initially the highest in the stack. |
737 EXPECT_EQ("2 1 3", WindowOrderAsString(window_->parent())); | 749 EXPECT_EQ("2 1 3", WindowOrderAsString(window_->parent())); |
738 } | 750 } |
739 | 751 |
740 { | 752 { |
741 std::vector<aura::Window*> windows; | 753 std::vector<aura::Window*> windows; |
742 windows.push_back(window3_.get()); | 754 windows.push_back(window3_.get()); |
743 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 755 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
744 window2_.get(), gfx::Point(), HTRIGHT, | 756 window2_.get(), gfx::Point(), HTRIGHT, |
745 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 757 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
746 ASSERT_TRUE(resizer.get()); | 758 ASSERT_TRUE(resizer.get()); |
747 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 759 // Move it 100 to the right, which should expand w1 and push w2 and w3. |
748 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 760 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
749 | 761 |
750 // 2 should be topmost since it's initially the highest in the stack. | 762 // 2 should be topmost since it's initially the highest in the stack. |
751 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); | 763 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); |
752 } | 764 } |
753 } | 765 } |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1551 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1540 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1552 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1541 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1553 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1542 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1554 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1543 delegate2_.set_max_size(gfx::Size(101, 0)); | 1555 delegate2_.set_max_size(gfx::Size(101, 0)); |
1544 | 1556 |
1545 std::vector<aura::Window*> windows; | 1557 std::vector<aura::Window*> windows; |
1546 windows.push_back(window2_.get()); | 1558 windows.push_back(window2_.get()); |
1547 windows.push_back(window3_.get()); | 1559 windows.push_back(window3_.get()); |
1548 windows.push_back(window4_.get()); | 1560 windows.push_back(window4_.get()); |
1549 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1561 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1550 window_.get(), gfx::Point(), HTRIGHT, | 1562 window_.get(), gfx::Point(), HTRIGHT, |
1551 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1563 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1552 ASSERT_TRUE(resizer.get()); | 1564 ASSERT_TRUE(resizer.get()); |
1553 // Move it 51 to the left, which should contract w1 and expand w2-4. | 1565 // Move it 51 to the left, which should contract w1 and expand w2-4. |
1554 // w2 will hit its max size straight away, and in doing so will leave extra | 1566 // w2 will hit its max size straight away, and in doing so will leave extra |
1555 // pixels that a naive implementation may award to the rightmost window. A | 1567 // pixels that a naive implementation may award to the rightmost window. A |
1556 // fair implementation will give 25 pixels to each of the other windows. | 1568 // fair implementation will give 25 pixels to each of the other windows. |
1557 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1569 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1558 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1570 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1559 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); | 1571 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); |
(...skipping 11 matching lines...) Expand all Loading... |
1571 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1583 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1572 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1584 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1573 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1585 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1574 delegate2_.set_max_size(gfx::Size(101, 0)); | 1586 delegate2_.set_max_size(gfx::Size(101, 0)); |
1575 delegate3_.set_max_size(gfx::Size(101, 0)); | 1587 delegate3_.set_max_size(gfx::Size(101, 0)); |
1576 | 1588 |
1577 std::vector<aura::Window*> windows; | 1589 std::vector<aura::Window*> windows; |
1578 windows.push_back(window2_.get()); | 1590 windows.push_back(window2_.get()); |
1579 windows.push_back(window3_.get()); | 1591 windows.push_back(window3_.get()); |
1580 windows.push_back(window4_.get()); | 1592 windows.push_back(window4_.get()); |
1581 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1593 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1582 window_.get(), gfx::Point(), HTRIGHT, | 1594 window_.get(), gfx::Point(), HTRIGHT, |
1583 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1595 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1584 ASSERT_TRUE(resizer.get()); | 1596 ASSERT_TRUE(resizer.get()); |
1585 // Move it 52 to the left, which should contract w1 and expand w2-4. | 1597 // Move it 52 to the left, which should contract w1 and expand w2-4. |
1586 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1598 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
1587 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1599 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
1588 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1600 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
1589 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1601 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
1590 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); | 1602 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); |
1591 } | 1603 } |
1592 | 1604 |
1593 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { | 1605 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { |
1594 UpdateDisplay("600x800"); | 1606 UpdateDisplay("600x800"); |
1595 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1607 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1596 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1608 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1597 | 1609 |
1598 // Four 100x100 windows flush against eachother, starting at 100,100. | 1610 // Four 100x100 windows flush against eachother, starting at 100,100. |
1599 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1611 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1600 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1612 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1601 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1613 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1602 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1614 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1603 delegate2_.set_max_size(gfx::Size(0, 101)); | 1615 delegate2_.set_max_size(gfx::Size(0, 101)); |
1604 delegate3_.set_max_size(gfx::Size(0, 101)); | 1616 delegate3_.set_max_size(gfx::Size(0, 101)); |
1605 | 1617 |
1606 std::vector<aura::Window*> windows; | 1618 std::vector<aura::Window*> windows; |
1607 windows.push_back(window2_.get()); | 1619 windows.push_back(window2_.get()); |
1608 windows.push_back(window3_.get()); | 1620 windows.push_back(window3_.get()); |
1609 windows.push_back(window4_.get()); | 1621 windows.push_back(window4_.get()); |
1610 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1622 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1611 window_.get(), gfx::Point(), HTBOTTOM, | 1623 window_.get(), gfx::Point(), HTBOTTOM, |
1612 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1624 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1613 ASSERT_TRUE(resizer.get()); | 1625 ASSERT_TRUE(resizer.get()); |
1614 // Move it 52 up, which should contract w1 and expand w2-4. | 1626 // Move it 52 up, which should contract w1 and expand w2-4. |
1615 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); | 1627 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); |
1616 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); | 1628 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); |
1617 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); | 1629 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); |
1618 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); | 1630 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); |
1619 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); | 1631 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); |
1620 } | 1632 } |
(...skipping 15 matching lines...) Expand all Loading... |
1636 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1648 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1637 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1649 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1638 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1650 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1639 delegate2_.set_min_size(gfx::Size(0, 99)); | 1651 delegate2_.set_min_size(gfx::Size(0, 99)); |
1640 delegate3_.set_min_size(gfx::Size(0, 99)); | 1652 delegate3_.set_min_size(gfx::Size(0, 99)); |
1641 | 1653 |
1642 std::vector<aura::Window*> windows; | 1654 std::vector<aura::Window*> windows; |
1643 windows.push_back(window2_.get()); | 1655 windows.push_back(window2_.get()); |
1644 windows.push_back(window3_.get()); | 1656 windows.push_back(window3_.get()); |
1645 windows.push_back(window4_.get()); | 1657 windows.push_back(window4_.get()); |
1646 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1658 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1647 window_.get(), gfx::Point(), HTBOTTOM, | 1659 window_.get(), gfx::Point(), HTBOTTOM, |
1648 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1660 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1649 ASSERT_TRUE(resizer.get()); | 1661 ASSERT_TRUE(resizer.get()); |
1650 // Move it 52 down, which should expand w1 and contract w2-4. | 1662 // Move it 52 down, which should expand w1 and contract w2-4. |
1651 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); | 1663 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); |
1652 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); | 1664 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); |
1653 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); | 1665 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); |
1654 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); | 1666 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); |
1655 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); | 1667 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); |
1656 } | 1668 } |
1657 | 1669 |
1658 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { | 1670 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { |
1659 UpdateDisplay("600x800"); | 1671 UpdateDisplay("600x800"); |
1660 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1672 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1661 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1673 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1662 | 1674 |
1663 // Three 100x100 windows flush against eachother, starting at 100,100. | 1675 // Three 100x100 windows flush against eachother, starting at 100,100. |
1664 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1676 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1665 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1677 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1666 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1678 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1667 delegate3_.set_max_size(gfx::Size(101, 0)); | 1679 delegate3_.set_max_size(gfx::Size(101, 0)); |
1668 | 1680 |
1669 std::vector<aura::Window*> windows; | 1681 std::vector<aura::Window*> windows; |
1670 windows.push_back(window2_.get()); | 1682 windows.push_back(window2_.get()); |
1671 windows.push_back(window3_.get()); | 1683 windows.push_back(window3_.get()); |
1672 windows.push_back(window4_.get()); | 1684 windows.push_back(window4_.get()); |
1673 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1685 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1674 window_.get(), gfx::Point(), HTRIGHT, | 1686 window_.get(), gfx::Point(), HTRIGHT, |
1675 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1687 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1676 ASSERT_TRUE(resizer.get()); | 1688 ASSERT_TRUE(resizer.get()); |
1677 // Move it 51 to the left, which should contract w1 and expand w2-3. | 1689 // Move it 51 to the left, which should contract w1 and expand w2-3. |
1678 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1690 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1679 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1691 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1680 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); | 1692 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); |
1681 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1693 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1682 } | 1694 } |
1683 | 1695 |
1684 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { | 1696 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { |
1685 UpdateDisplay("600x800"); | 1697 UpdateDisplay("600x800"); |
1686 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1698 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1687 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1699 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1688 | 1700 |
1689 // Three 100x100 windows flush against eachother, starting at 100,100. | 1701 // Three 100x100 windows flush against eachother, starting at 100,100. |
1690 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1702 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1691 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1703 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1692 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1704 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1693 delegate2_.set_max_size(gfx::Size(101, 0)); | 1705 delegate2_.set_max_size(gfx::Size(101, 0)); |
1694 delegate3_.set_max_size(gfx::Size(101, 0)); | 1706 delegate3_.set_max_size(gfx::Size(101, 0)); |
1695 | 1707 |
1696 std::vector<aura::Window*> windows; | 1708 std::vector<aura::Window*> windows; |
1697 windows.push_back(window2_.get()); | 1709 windows.push_back(window2_.get()); |
1698 windows.push_back(window3_.get()); | 1710 windows.push_back(window3_.get()); |
1699 windows.push_back(window4_.get()); | 1711 windows.push_back(window4_.get()); |
1700 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1712 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1701 window_.get(), gfx::Point(), HTRIGHT, | 1713 window_.get(), gfx::Point(), HTRIGHT, |
1702 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1714 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1703 ASSERT_TRUE(resizer.get()); | 1715 ASSERT_TRUE(resizer.get()); |
1704 // Move it 52 to the left, which should contract w1 and expand and move w2-3. | 1716 // Move it 52 to the left, which should contract w1 and expand and move w2-3. |
1705 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1717 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
1706 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1718 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
1707 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1719 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
1708 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1720 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
1709 } | 1721 } |
1710 | 1722 |
(...skipping 12 matching lines...) Expand all Loading... |
1723 // Three 100x100 windows flush against eachother, starting at 100,100. | 1735 // Three 100x100 windows flush against eachother, starting at 100,100. |
1724 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1736 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1725 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1737 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1726 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1738 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1727 delegate_.set_max_size(gfx::Size(102, 0)); | 1739 delegate_.set_max_size(gfx::Size(102, 0)); |
1728 | 1740 |
1729 std::vector<aura::Window*> windows; | 1741 std::vector<aura::Window*> windows; |
1730 windows.push_back(window2_.get()); | 1742 windows.push_back(window2_.get()); |
1731 windows.push_back(window3_.get()); | 1743 windows.push_back(window3_.get()); |
1732 windows.push_back(window4_.get()); | 1744 windows.push_back(window4_.get()); |
1733 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1745 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1734 window_.get(), gfx::Point(), HTRIGHT, | 1746 window_.get(), gfx::Point(), HTRIGHT, |
1735 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1747 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1736 ASSERT_TRUE(resizer.get()); | 1748 ASSERT_TRUE(resizer.get()); |
1737 // Move it 50 to the right, which should expand w1 and contract w2-3, as they | 1749 // Move it 50 to the right, which should expand w1 and contract w2-3, as they |
1738 // won't fit in the root window in their original sizes. | 1750 // won't fit in the root window in their original sizes. |
1739 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); | 1751 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); |
1740 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); | 1752 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); |
1741 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); | 1753 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); |
1742 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); | 1754 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); |
1743 } | 1755 } |
1744 | 1756 |
1745 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { | 1757 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
1746 UpdateDisplay("400x800"); | 1758 UpdateDisplay("400x800"); |
1747 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1759 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1748 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1760 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1749 | 1761 |
1750 // Three 100x100 windows flush against eachother, starting at 100,100. | 1762 // Three 100x100 windows flush against eachother, starting at 100,100. |
1751 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1763 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1752 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1764 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1753 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1765 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1754 delegate_.set_min_size(gfx::Size(98, 0)); | 1766 delegate_.set_min_size(gfx::Size(98, 0)); |
1755 | 1767 |
1756 std::vector<aura::Window*> windows; | 1768 std::vector<aura::Window*> windows; |
1757 windows.push_back(window2_.get()); | 1769 windows.push_back(window2_.get()); |
1758 windows.push_back(window3_.get()); | 1770 windows.push_back(window3_.get()); |
1759 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1771 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1760 window_.get(), gfx::Point(), HTRIGHT, | 1772 window_.get(), gfx::Point(), HTRIGHT, |
1761 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1773 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1762 ASSERT_TRUE(resizer.get()); | 1774 ASSERT_TRUE(resizer.get()); |
1763 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1775 // Move it 50 to the left, which should contract w1 and expand w2-3. |
1764 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1776 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
1765 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1777 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
1766 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1778 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
1767 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1779 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1768 } | 1780 } |
1769 | 1781 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 RunAnimationTillComplete(phantom_controller->animation_.get()); | 2018 RunAnimationTillComplete(phantom_controller->animation_.get()); |
2007 | 2019 |
2008 // Hide phantom controller. Both widgets should close. | 2020 // Hide phantom controller. Both widgets should close. |
2009 phantom_controller->Hide(); | 2021 phantom_controller->Hide(); |
2010 EXPECT_FALSE(phantom_controller->phantom_widget_); | 2022 EXPECT_FALSE(phantom_controller->phantom_widget_); |
2011 EXPECT_FALSE(phantom_controller->phantom_widget_start_); | 2023 EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
2012 } | 2024 } |
2013 | 2025 |
2014 } // namespace internal | 2026 } // namespace internal |
2015 } // namespace ash | 2027 } // namespace ash |
OLD | NEW |