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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698