OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ash/common/wm/panels/panel_layout_manager.h" | 9 #include "ash/common/wm/panels/panel_layout_manager.h" |
10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // updated. | 369 // updated. |
370 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { | 370 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { |
371 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 371 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
372 // it isn't over the shelf. | 372 // it isn't over the shelf. |
373 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 373 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
374 gfx::Point()); | 374 gfx::Point()); |
375 generator.MoveMouseTo(0, 0); | 375 generator.MoveMouseTo(0, 0); |
376 | 376 |
377 std::unique_ptr<Window> w1(CreateTestWindow()); | 377 std::unique_ptr<Window> w1(CreateTestWindow()); |
378 const gfx::Rect w1_bounds(0, 1, 101, 102); | 378 const gfx::Rect w1_bounds(0, 1, 101, 102); |
379 ShelfLayoutManager* shelf = shelf_layout_manager(); | 379 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
380 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 380 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
381 const gfx::Rect touches_shelf_bounds( | 381 const gfx::Rect touches_shelf_bounds( |
382 0, shelf->GetIdealBounds().y() - 10, 101, 102); | 382 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); |
383 // Move |w1| to overlap the shelf. | 383 // Move |w1| to overlap the shelf. |
384 w1->SetBounds(touches_shelf_bounds); | 384 w1->SetBounds(touches_shelf_bounds); |
385 EXPECT_FALSE(GetWindowOverlapsShelf()); | 385 EXPECT_FALSE(GetWindowOverlapsShelf()); |
386 | 386 |
387 // A visible ignored window should not trigger the overlap. | 387 // A visible ignored window should not trigger the overlap. |
388 std::unique_ptr<Window> w_ignored(CreateTestWindow()); | 388 std::unique_ptr<Window> w_ignored(CreateTestWindow()); |
389 w_ignored->SetBounds(touches_shelf_bounds); | 389 w_ignored->SetBounds(touches_shelf_bounds); |
390 wm::GetWindowState(&(*w_ignored))->set_ignored_by_shelf(true); | 390 wm::GetWindowState(&(*w_ignored))->set_ignored_by_shelf(true); |
391 w_ignored->Show(); | 391 w_ignored->Show(); |
392 EXPECT_FALSE(GetWindowOverlapsShelf()); | 392 EXPECT_FALSE(GetWindowOverlapsShelf()); |
393 | 393 |
394 // Make it visible, since visible shelf overlaps should be true. | 394 // Make it visible, since visible shelf overlaps should be true. |
395 w1->Show(); | 395 w1->Show(); |
396 EXPECT_TRUE(GetWindowOverlapsShelf()); | 396 EXPECT_TRUE(GetWindowOverlapsShelf()); |
397 | 397 |
398 wm::ActivateWindow(w1.get()); | 398 wm::ActivateWindow(w1.get()); |
399 w1->SetBounds(w1_bounds); | 399 w1->SetBounds(w1_bounds); |
400 w1->Show(); | 400 w1->Show(); |
401 wm::ActivateWindow(w1.get()); | 401 wm::ActivateWindow(w1.get()); |
402 | 402 |
403 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 403 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
404 | 404 |
405 // Maximize the window. | 405 // Maximize the window. |
406 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 406 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
407 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 407 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
408 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 408 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
409 | 409 |
410 // Restore. | 410 // Restore. |
411 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 411 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
412 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 412 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
413 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 413 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
414 | 414 |
415 // Fullscreen. | 415 // Fullscreen. |
416 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 416 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
417 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 417 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
418 | 418 |
419 // Normal. | 419 // Normal. |
420 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 420 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
421 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 421 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
422 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 422 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
423 EXPECT_FALSE(GetWindowOverlapsShelf()); | 423 EXPECT_FALSE(GetWindowOverlapsShelf()); |
424 | 424 |
425 // Move window so it obscures shelf. | 425 // Move window so it obscures shelf. |
426 w1->SetBounds(touches_shelf_bounds); | 426 w1->SetBounds(touches_shelf_bounds); |
427 EXPECT_TRUE(GetWindowOverlapsShelf()); | 427 EXPECT_TRUE(GetWindowOverlapsShelf()); |
428 | 428 |
429 // Move it back. | 429 // Move it back. |
430 w1->SetBounds(w1_bounds); | 430 w1->SetBounds(w1_bounds); |
431 EXPECT_FALSE(GetWindowOverlapsShelf()); | 431 EXPECT_FALSE(GetWindowOverlapsShelf()); |
432 | 432 |
433 // Maximize again. | 433 // Maximize again. |
434 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 434 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
435 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 435 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
437 | 437 |
438 // Minimize. | 438 // Minimize. |
439 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 439 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
440 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 440 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
441 | 441 |
442 // Since the restore from minimize will restore to the pre-minimize | 442 // Since the restore from minimize will restore to the pre-minimize |
443 // state (tested elsewhere), we abandon the current size and restore | 443 // state (tested elsewhere), we abandon the current size and restore |
444 // rect and set them to the window. | 444 // rect and set them to the window. |
445 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 445 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
446 | 446 |
447 gfx::Rect restore = window_state->GetRestoreBoundsInScreen(); | 447 gfx::Rect restore = window_state->GetRestoreBoundsInScreen(); |
448 EXPECT_EQ("0,0 800x597", w1->bounds().ToString()); | 448 EXPECT_EQ("0,0 800x597", w1->bounds().ToString()); |
449 EXPECT_EQ("0,1 101x102", restore.ToString()); | 449 EXPECT_EQ("0,1 101x102", restore.ToString()); |
450 window_state->ClearRestoreBounds(); | 450 window_state->ClearRestoreBounds(); |
451 w1->SetBounds(restore); | 451 w1->SetBounds(restore); |
452 | 452 |
453 // Restore. | 453 // Restore. |
454 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 454 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
455 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 455 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
456 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 456 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
457 | 457 |
458 // Create another window, maximized. | 458 // Create another window, maximized. |
459 std::unique_ptr<Window> w2(CreateTestWindow()); | 459 std::unique_ptr<Window> w2(CreateTestWindow()); |
460 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 460 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
461 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 461 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
462 w2->Show(); | 462 w2->Show(); |
463 wm::ActivateWindow(w2.get()); | 463 wm::ActivateWindow(w2.get()); |
464 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 464 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
465 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 465 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
466 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 466 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
467 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( | 467 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( |
468 w2->parent()).ToString(), | 468 w2->parent()).ToString(), |
469 w2->bounds().ToString()); | 469 w2->bounds().ToString()); |
470 | 470 |
471 // Switch to w1. | 471 // Switch to w1. |
472 wm::ActivateWindow(w1.get()); | 472 wm::ActivateWindow(w1.get()); |
473 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 473 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
474 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 474 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
475 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( | 475 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( |
476 w2->parent()).ToString(), | 476 w2->parent()).ToString(), |
477 w2->bounds().ToString()); | 477 w2->bounds().ToString()); |
478 | 478 |
479 // Switch to w2. | 479 // Switch to w2. |
480 wm::ActivateWindow(w2.get()); | 480 wm::ActivateWindow(w2.get()); |
481 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 481 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
482 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 482 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
483 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 483 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
484 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), | 484 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), |
485 w2->bounds().ToString()); | 485 w2->bounds().ToString()); |
486 | 486 |
487 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. | 487 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. |
488 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 488 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
489 wm::ActivateWindow(w2.get()); | 489 wm::ActivateWindow(w2.get()); |
490 EXPECT_FALSE(GetWindowOverlapsShelf()); | 490 EXPECT_FALSE(GetWindowOverlapsShelf()); |
491 | 491 |
492 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since | 492 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since |
(...skipping 15 matching lines...) Expand all Loading... |
508 // the background of the launcher. | 508 // the background of the launcher. |
509 TEST_F(WorkspaceControllerTest, MinimizeResetsVisibility) { | 509 TEST_F(WorkspaceControllerTest, MinimizeResetsVisibility) { |
510 std::unique_ptr<Window> w1(CreateTestWindow()); | 510 std::unique_ptr<Window> w1(CreateTestWindow()); |
511 w1->Show(); | 511 w1->Show(); |
512 wm::ActivateWindow(w1.get()); | 512 wm::ActivateWindow(w1.get()); |
513 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 513 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
514 EXPECT_EQ(wm::SHELF_BACKGROUND_MAXIMIZED, | 514 EXPECT_EQ(wm::SHELF_BACKGROUND_MAXIMIZED, |
515 shelf_widget()->GetBackgroundType()); | 515 shelf_widget()->GetBackgroundType()); |
516 | 516 |
517 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 517 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
518 EXPECT_EQ(SHELF_VISIBLE, | 518 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
519 shelf_layout_manager()->visibility_state()); | 519 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
520 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); | 520 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); |
521 } | 521 } |
522 | 522 |
523 // Verifies window visibility during various workspace changes. | 523 // Verifies window visibility during various workspace changes. |
524 TEST_F(WorkspaceControllerTest, VisibilityTests) { | 524 TEST_F(WorkspaceControllerTest, VisibilityTests) { |
525 std::unique_ptr<Window> w1(CreateTestWindow()); | 525 std::unique_ptr<Window> w1(CreateTestWindow()); |
526 w1->Show(); | 526 w1->Show(); |
527 EXPECT_TRUE(w1->IsVisible()); | 527 EXPECT_TRUE(w1->IsVisible()); |
528 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 528 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
529 | 529 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 EXPECT_TRUE(w1->IsVisible()); | 577 EXPECT_TRUE(w1->IsVisible()); |
578 } | 578 } |
579 | 579 |
580 // Verifies windows that are offscreen don't move when switching workspaces. | 580 // Verifies windows that are offscreen don't move when switching workspaces. |
581 TEST_F(WorkspaceControllerTest, DontMoveOnSwitch) { | 581 TEST_F(WorkspaceControllerTest, DontMoveOnSwitch) { |
582 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 582 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
583 gfx::Point()); | 583 gfx::Point()); |
584 generator.MoveMouseTo(0, 0); | 584 generator.MoveMouseTo(0, 0); |
585 | 585 |
586 std::unique_ptr<Window> w1(CreateTestWindow()); | 586 std::unique_ptr<Window> w1(CreateTestWindow()); |
587 ShelfLayoutManager* shelf = shelf_layout_manager(); | |
588 const gfx::Rect touches_shelf_bounds( | 587 const gfx::Rect touches_shelf_bounds( |
589 0, shelf->GetIdealBounds().y() - 10, 101, 102); | 588 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); |
590 // Move |w1| to overlap the shelf. | 589 // Move |w1| to overlap the shelf. |
591 w1->SetBounds(touches_shelf_bounds); | 590 w1->SetBounds(touches_shelf_bounds); |
592 w1->Show(); | 591 w1->Show(); |
593 wm::ActivateWindow(w1.get()); | 592 wm::ActivateWindow(w1.get()); |
594 | 593 |
595 // Create another window and maximize it. | 594 // Create another window and maximize it. |
596 std::unique_ptr<Window> w2(CreateTestWindow()); | 595 std::unique_ptr<Window> w2(CreateTestWindow()); |
597 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 596 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
598 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 597 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
599 w2->Show(); | 598 w2->Show(); |
600 wm::ActivateWindow(w2.get()); | 599 wm::ActivateWindow(w2.get()); |
601 | 600 |
602 // Switch to w1. | 601 // Switch to w1. |
603 wm::ActivateWindow(w1.get()); | 602 wm::ActivateWindow(w1.get()); |
604 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString()); | 603 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString()); |
605 } | 604 } |
606 | 605 |
607 // Verifies that windows that are completely offscreen move when switching | 606 // Verifies that windows that are completely offscreen move when switching |
608 // workspaces. | 607 // workspaces. |
609 TEST_F(WorkspaceControllerTest, MoveOnSwitch) { | 608 TEST_F(WorkspaceControllerTest, MoveOnSwitch) { |
610 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 609 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
611 gfx::Point()); | 610 gfx::Point()); |
612 generator.MoveMouseTo(0, 0); | 611 generator.MoveMouseTo(0, 0); |
613 | 612 |
614 std::unique_ptr<Window> w1(CreateTestWindow()); | 613 std::unique_ptr<Window> w1(CreateTestWindow()); |
615 ShelfLayoutManager* shelf = shelf_layout_manager(); | 614 const gfx::Rect w1_bounds(0, shelf_layout_manager()->GetIdealBounds().y(), |
616 const gfx::Rect w1_bounds(0, shelf->GetIdealBounds().y(), 100, 200); | 615 100, 200); |
617 // Move |w1| so that the top edge is the same as the top edge of the shelf. | 616 // Move |w1| so that the top edge is the same as the top edge of the shelf. |
618 w1->SetBounds(w1_bounds); | 617 w1->SetBounds(w1_bounds); |
619 w1->Show(); | 618 w1->Show(); |
620 wm::ActivateWindow(w1.get()); | 619 wm::ActivateWindow(w1.get()); |
621 EXPECT_EQ(w1_bounds.ToString(), w1->bounds().ToString()); | 620 EXPECT_EQ(w1_bounds.ToString(), w1->bounds().ToString()); |
622 | 621 |
623 // Create another window and maximize it. | 622 // Create another window and maximize it. |
624 std::unique_ptr<Window> w2(CreateTestWindow()); | 623 std::unique_ptr<Window> w2(CreateTestWindow()); |
625 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 624 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
626 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 625 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 | 665 |
667 } // namespace | 666 } // namespace |
668 | 667 |
669 // Exercises possible crash in W2. Here's the sequence: | 668 // Exercises possible crash in W2. Here's the sequence: |
670 // . minimize a maximized window. | 669 // . minimize a maximized window. |
671 // . remove the window (which happens when switching displays). | 670 // . remove the window (which happens when switching displays). |
672 // . add the window back. | 671 // . add the window back. |
673 // . show the window and during the bounds change activate it. | 672 // . show the window and during the bounds change activate it. |
674 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { | 673 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { |
675 // Force the shelf | 674 // Force the shelf |
676 ShelfLayoutManager* shelf = shelf_layout_manager(); | 675 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
677 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 676 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
678 | 677 |
679 DontCrashOnChangeAndActivateDelegate delegate; | 678 DontCrashOnChangeAndActivateDelegate delegate; |
680 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( | 679 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( |
681 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); | 680 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); |
682 | 681 |
683 w1->Show(); | 682 w1->Show(); |
684 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); | 683 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); |
685 w1_state->Activate(); | 684 w1_state->Activate(); |
686 w1_state->Maximize(); | 685 w1_state->Maximize(); |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 | 1387 |
1389 // Verifies that when dragging a window over the shelf overlap is detected | 1388 // Verifies that when dragging a window over the shelf overlap is detected |
1390 // during and after the drag. | 1389 // during and after the drag. |
1391 TEST_F(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { | 1390 TEST_F(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { |
1392 aura::test::TestWindowDelegate delegate; | 1391 aura::test::TestWindowDelegate delegate; |
1393 delegate.set_window_component(HTCAPTION); | 1392 delegate.set_window_component(HTCAPTION); |
1394 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1393 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1395 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1394 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1396 ParentWindowInPrimaryRootWindow(w1.get()); | 1395 ParentWindowInPrimaryRootWindow(w1.get()); |
1397 | 1396 |
1398 ShelfLayoutManager* shelf = shelf_layout_manager(); | 1397 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
1399 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1398 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1400 | 1399 |
1401 // Drag near the shelf. | 1400 // Drag near the shelf. |
1402 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1401 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1403 gfx::Point()); | 1402 gfx::Point()); |
1404 generator.MoveMouseTo(10, 10); | 1403 generator.MoveMouseTo(10, 10); |
1405 generator.PressLeftButton(); | 1404 generator.PressLeftButton(); |
1406 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); | 1405 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70); |
1407 | 1406 |
1408 // Shelf should not be in overlapped state. | 1407 // Shelf should not be in overlapped state. |
1409 EXPECT_FALSE(GetWindowOverlapsShelf()); | 1408 EXPECT_FALSE(GetWindowOverlapsShelf()); |
1410 | 1409 |
1411 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); | 1410 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20); |
1412 | 1411 |
1413 // Shelf should detect overlap. Overlap state stays after mouse is released. | 1412 // Shelf should detect overlap. Overlap state stays after mouse is released. |
1414 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1413 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1415 generator.ReleaseLeftButton(); | 1414 generator.ReleaseLeftButton(); |
1416 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1415 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1417 } | 1416 } |
1418 | 1417 |
1419 // Verifies that when dragging a window autohidden shelf stays hidden during | 1418 // Verifies that when dragging a window autohidden shelf stays hidden during |
1420 // and after the drag. | 1419 // and after the drag. |
1421 TEST_F(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { | 1420 TEST_F(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { |
1422 aura::test::TestWindowDelegate delegate; | 1421 aura::test::TestWindowDelegate delegate; |
1423 delegate.set_window_component(HTCAPTION); | 1422 delegate.set_window_component(HTCAPTION); |
1424 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1423 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1425 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1424 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1426 ParentWindowInPrimaryRootWindow(w1.get()); | 1425 ParentWindowInPrimaryRootWindow(w1.get()); |
1427 | 1426 |
1428 ShelfLayoutManager* shelf = shelf_layout_manager(); | 1427 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
1429 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1428 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1430 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1429 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
1431 | 1430 |
1432 // Drag very little. | 1431 // Drag very little. |
1433 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1432 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1434 gfx::Point()); | 1433 gfx::Point()); |
1435 generator.MoveMouseTo(10, 10); | 1434 generator.MoveMouseTo(10, 10); |
1436 generator.PressLeftButton(); | 1435 generator.PressLeftButton(); |
1437 generator.MoveMouseTo(12, 12); | 1436 generator.MoveMouseTo(12, 12); |
1438 | 1437 |
1439 // Shelf should be hidden during and after the drag. | 1438 // Shelf should be hidden during and after the drag. |
1440 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
1441 generator.ReleaseLeftButton(); | 1440 generator.ReleaseLeftButton(); |
1442 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1441 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
1443 } | 1442 } |
1444 | 1443 |
1445 // Verifies that events are targeted properly just outside the window edges. | 1444 // Verifies that events are targeted properly just outside the window edges. |
1446 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { | 1445 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { |
1447 aura::test::TestWindowDelegate d_first, d_second; | 1446 aura::test::TestWindowDelegate d_first, d_second; |
1448 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( | 1447 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( |
1449 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); | 1448 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); |
1450 ParentWindowInPrimaryRootWindow(first.get()); | 1449 ParentWindowInPrimaryRootWindow(first.get()); |
1451 first->Show(); | 1450 first->Show(); |
1452 | 1451 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 ui::EventTimeForNow()); | 1610 ui::EventTimeForNow()); |
1612 target = targeter->FindTargetForEvent(root, &touch); | 1611 target = targeter->FindTargetForEvent(root, &touch); |
1613 if (points[i].is_target_hit) | 1612 if (points[i].is_target_hit) |
1614 EXPECT_EQ(window.get(), target); | 1613 EXPECT_EQ(window.get(), target); |
1615 else | 1614 else |
1616 EXPECT_NE(window.get(), target); | 1615 EXPECT_NE(window.get(), target); |
1617 } | 1616 } |
1618 } | 1617 } |
1619 | 1618 |
1620 } // namespace ash | 1619 } // namespace ash |
OLD | NEW |