| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/download/download_service.h" | 9 #include "chrome/browser/download/download_service.h" |
| 10 #include "chrome/browser/download/download_service_factory.h" | 10 #include "chrome/browser/download/download_service_factory.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 CloseWindowAndWait(panel4->browser()); | 157 CloseWindowAndWait(panel4->browser()); |
| 158 ASSERT_EQ(2, panel_manager->num_panels()); | 158 ASSERT_EQ(2, panel_manager->num_panels()); |
| 159 EXPECT_EQ(2, panel_strip->num_panels()); | 159 EXPECT_EQ(2, panel_strip->num_panels()); |
| 160 EXPECT_EQ(0, panel_overflow_strip->num_panels()); | 160 EXPECT_EQ(0, panel_overflow_strip->num_panels()); |
| 161 EXPECT_NE(Panel::IN_OVERFLOW, panel5->expansion_state()); | 161 EXPECT_NE(Panel::IN_OVERFLOW, panel5->expansion_state()); |
| 162 | 162 |
| 163 panel1->Close(); | 163 panel1->Close(); |
| 164 panel5->Close(); | 164 panel5->Close(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 int horizontal_spacing() { | |
| 168 return PanelManager::horizontal_spacing(); | |
| 169 } | |
| 170 | |
| 171 // Helper function for debugging. | 167 // Helper function for debugging. |
| 172 void PrintAllPanelBounds() { | 168 void PrintAllPanelBounds() { |
| 173 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); | 169 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); |
| 174 DLOG(WARNING) << "PanelBounds:"; | 170 DLOG(WARNING) << "PanelBounds:"; |
| 175 for (size_t i = 0; i < panels.size(); ++i) { | 171 for (size_t i = 0; i < panels.size(); ++i) { |
| 176 DLOG(WARNING) << "#=" << i | 172 DLOG(WARNING) << "#=" << i |
| 177 << ", ptr=" << panels[i] | 173 << ", ptr=" << panels[i] |
| 178 << ", x=" << panels[i]->GetBounds().x() | 174 << ", x=" << panels[i]->GetBounds().x() |
| 179 << ", y=" << panels[i]->GetBounds().y() | 175 << ", y=" << panels[i]->GetBounds().y() |
| 180 << ", width=" << panels[i]->GetBounds().width() | 176 << ", width=" << panels[i]->GetBounds().width() |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 // platforms. http://crbug.com/105073 | 550 // platforms. http://crbug.com/105073 |
| 555 #if defined(OS_WIN) | 551 #if defined(OS_WIN) |
| 556 #define MAYBE_CreatePanelOnOverflow CreatePanelOnOverflow | 552 #define MAYBE_CreatePanelOnOverflow CreatePanelOnOverflow |
| 557 #else | 553 #else |
| 558 #define MAYBE_CreatePanelOnOverflow DISABLED_CreatePanelOnOverflow | 554 #define MAYBE_CreatePanelOnOverflow DISABLED_CreatePanelOnOverflow |
| 559 #endif | 555 #endif |
| 560 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_CreatePanelOnOverflow) { | 556 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_CreatePanelOnOverflow) { |
| 561 TestCreatePanelOnOverflow(); | 557 TestCreatePanelOnOverflow(); |
| 562 } | 558 } |
| 563 | 559 |
| 564 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DragPanels) { | 560 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DragOnePanel) { |
| 565 static const int max_panels = 3; | 561 static const int num_panels = 1; |
| 562 static const int zero_delta = 0; |
| 563 static const int big_delta = 70; |
| 564 |
| 565 static const std::vector<int> zero_deltas(num_panels, zero_delta); |
| 566 std::vector<int> expected_delta_x_after_drag(num_panels, zero_delta); |
| 567 std::vector<int> expected_delta_x_after_finish(num_panels, zero_delta); |
| 568 |
| 569 Panel* panel1 = |
| 570 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 571 |
| 572 // Drag left. |
| 573 expected_delta_x_after_drag[0] = -big_delta; |
| 574 expected_delta_x_after_finish = zero_deltas; |
| 575 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 576 zero_deltas, GetAllPanelBounds(), |
| 577 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 578 |
| 579 // Drag left and cancel. |
| 580 expected_delta_x_after_drag[0] = -big_delta; |
| 581 expected_delta_x_after_finish = zero_deltas; |
| 582 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 583 zero_deltas, GetAllPanelBounds(), |
| 584 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); |
| 585 |
| 586 // Drag right. |
| 587 expected_delta_x_after_drag[0] = big_delta; |
| 588 TestDragging(big_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 589 zero_deltas, GetAllPanelBounds(), |
| 590 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 591 |
| 592 // Drag right and up. Expect no vertical movement. |
| 593 TestDragging(big_delta, big_delta, 0, expected_delta_x_after_drag, |
| 594 zero_deltas, GetAllPanelBounds(), |
| 595 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 596 |
| 597 // Drag up. Expect no movement on drag. |
| 598 TestDragging(0, -big_delta, 0, zero_deltas, zero_deltas, |
| 599 GetAllPanelBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 600 |
| 601 // Drag down. Expect no movement on drag. |
| 602 TestDragging(0, big_delta, 0, zero_deltas, zero_deltas, |
| 603 GetAllPanelBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 604 |
| 605 panel1->Close(); |
| 606 } |
| 607 |
| 608 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DragTwoPanels) { |
| 609 static const int num_panels = 2; |
| 566 static const int zero_delta = 0; | 610 static const int zero_delta = 0; |
| 567 static const int small_delta = 10; | 611 static const int small_delta = 10; |
| 568 static const int big_delta = 70; | 612 static const int big_delta = 70; |
| 613 |
| 614 static const std::vector<int> zero_deltas(num_panels, zero_delta); |
| 615 std::vector<int> expected_delta_x_after_drag(num_panels, zero_delta); |
| 616 std::vector<int> expected_delta_x_after_finish(num_panels, zero_delta); |
| 617 std::vector<gfx::Rect> initial_bounds; |
| 618 |
| 619 Panel* panel1 = |
| 620 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 621 Panel* panel2 = |
| 622 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 120, 120)); |
| 623 |
| 624 int horizontal_spacing = |
| 625 panel1->GetBounds().x() - panel2->GetBounds().right(); |
| 626 |
| 627 // Drag left, small delta, expect no shuffle. |
| 628 { |
| 629 expected_delta_x_after_drag = zero_deltas; |
| 630 expected_delta_x_after_drag[0] = -small_delta; |
| 631 TestDragging(-small_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 632 zero_deltas, GetAllPanelBounds(), |
| 633 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 634 |
| 635 // Drag right panel i.e index 0, towards left, big delta, expect shuffle. |
| 636 initial_bounds = GetAllPanelBounds(); |
| 637 expected_delta_x_after_drag = zero_deltas; |
| 638 |
| 639 // Deltas for panel being dragged. |
| 640 expected_delta_x_after_drag[0] = -big_delta; |
| 641 expected_delta_x_after_finish[0] = |
| 642 -(initial_bounds[1].width() + horizontal_spacing); |
| 643 |
| 644 // Deltas for panel being shuffled. |
| 645 expected_delta_x_after_drag[1] = |
| 646 initial_bounds[0].width() + horizontal_spacing; |
| 647 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; |
| 648 |
| 649 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 650 expected_delta_x_after_finish, initial_bounds, |
| 651 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 652 } |
| 653 |
| 654 // Drag left panel i.e index 1, towards right, big delta, expect shuffle. |
| 655 { |
| 656 initial_bounds = GetAllPanelBounds(); |
| 657 expected_delta_x_after_drag = zero_deltas; |
| 658 expected_delta_x_after_finish = zero_deltas; |
| 659 |
| 660 // Deltas for panel being dragged. |
| 661 expected_delta_x_after_drag[1] = big_delta; |
| 662 expected_delta_x_after_finish[1] = |
| 663 initial_bounds[0].width() + horizontal_spacing; |
| 664 |
| 665 // Deltas for panel being shuffled. |
| 666 expected_delta_x_after_drag[0] = |
| 667 -(initial_bounds[1].width() + horizontal_spacing); |
| 668 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; |
| 669 |
| 670 TestDragging(big_delta, zero_delta, 1, expected_delta_x_after_drag, |
| 671 expected_delta_x_after_finish, initial_bounds, |
| 672 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 673 } |
| 674 |
| 675 // Drag left panel i.e index 1, towards right, big delta, expect shuffle. |
| 676 // Cancel drag. |
| 677 { |
| 678 initial_bounds = GetAllPanelBounds(); |
| 679 expected_delta_x_after_drag = zero_deltas; |
| 680 |
| 681 // Delta for panel being dragged. |
| 682 expected_delta_x_after_drag[1] = big_delta; |
| 683 |
| 684 // Delta for panel being shuffled. |
| 685 expected_delta_x_after_drag[0] = |
| 686 -(initial_bounds[1].width() + horizontal_spacing); |
| 687 |
| 688 // As the drag is being canceled, we don't need expected_delta_x_after |
| 689 // finish. Instead initial_bounds will be used. |
| 690 TestDragging(big_delta, zero_delta, 1, expected_delta_x_after_drag, |
| 691 zero_deltas, initial_bounds, |
| 692 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); |
| 693 } |
| 694 |
| 695 panel1->Close(); |
| 696 panel2->Close(); |
| 697 } |
| 698 |
| 699 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DragThreePanels) { |
| 700 static const int num_panels = 3; |
| 701 static const int zero_delta = 0; |
| 702 static const int big_delta = 70; |
| 569 static const int bigger_delta = 120; | 703 static const int bigger_delta = 120; |
| 570 static const int biggest_delta = 200; | 704 static const int biggest_delta = 200; |
| 571 static const std::vector<int> zero_deltas(max_panels, zero_delta); | 705 |
| 572 | 706 static const std::vector<int> zero_deltas(num_panels, zero_delta); |
| 573 std::vector<int> expected_delta_x_after_drag(max_panels, zero_delta); | 707 std::vector<int> expected_delta_x_after_drag(num_panels, zero_delta); |
| 574 std::vector<int> expected_delta_x_after_finish(max_panels, zero_delta); | 708 std::vector<int> expected_delta_x_after_finish(num_panels, zero_delta); |
| 575 std::vector<gfx::Rect> current_bounds; | 709 std::vector<gfx::Rect> current_bounds; |
| 576 std::vector<gfx::Rect> initial_bounds; | 710 std::vector<gfx::Rect> initial_bounds; |
| 577 | 711 |
| 578 // Tests with a single panel. | 712 Panel* panel1 = |
| 579 { | 713 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 580 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 714 Panel* panel2 = |
| 581 | 715 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 120, 120)); |
| 582 // Drag left. | 716 Panel* panel3 = |
| 717 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 110, 110)); |
| 718 |
| 719 int horizontal_spacing = |
| 720 panel1->GetBounds().x() - panel2->GetBounds().right(); |
| 721 |
| 722 // Drag leftmost panel to become rightmost with two shuffles. |
| 723 // We test both shuffles. |
| 724 { |
| 725 // Drag the left-most panel towards right without ending or cancelling it. |
| 726 // Expect shuffle. |
| 727 initial_bounds = GetAllPanelBounds(); |
| 728 expected_delta_x_after_drag = zero_deltas; |
| 729 |
| 730 // Delta for panel being dragged. |
| 731 expected_delta_x_after_drag[2] = big_delta; |
| 732 |
| 733 // Delta for panel being shuffled. |
| 734 expected_delta_x_after_drag[1] = |
| 735 -(initial_bounds[2].width() + horizontal_spacing); |
| 736 |
| 737 // There is no delta after finish as drag is not done yet. |
| 738 TestDragging(big_delta, zero_delta, 2, expected_delta_x_after_drag, |
| 739 zero_deltas, initial_bounds, DRAG_ACTION_BEGIN); |
| 740 |
| 741 // The drag index changes from 2 to 1 because of the first shuffle above. |
| 742 // Drag the panel further enough to the right to trigger a another |
| 743 // shuffle. We finish the drag here. |
| 744 current_bounds = GetAllPanelBounds(); |
| 745 expected_delta_x_after_drag = zero_deltas; |
| 746 expected_delta_x_after_finish = zero_deltas; |
| 747 |
| 748 // big_delta is not enough to cause the second shuffle as the panel being |
| 749 // dragged is in the middle of a drag and big_delta won't go far enough. |
| 750 // So we use bigger_delta. |
| 751 |
| 752 // Deltas for panel being dragged. |
| 753 expected_delta_x_after_drag[1] = bigger_delta; |
| 754 int x_after_finish = current_bounds[0].x() + |
| 755 (current_bounds[0].width() - current_bounds[1].width()); |
| 756 expected_delta_x_after_finish[1] = x_after_finish - current_bounds[1].x(); |
| 757 |
| 758 // Deltas for panel being shuffled. |
| 759 expected_delta_x_after_drag[0] = |
| 760 -(current_bounds[1].width() + horizontal_spacing); |
| 761 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; |
| 762 |
| 763 TestDragging(bigger_delta, zero_delta, 1, expected_delta_x_after_drag, |
| 764 expected_delta_x_after_finish, initial_bounds, |
| 765 DRAG_ACTION_FINISH); |
| 766 } |
| 767 |
| 768 // Drag rightmost panel to become leftmost with two shuffles. |
| 769 // And then cancel the drag. |
| 770 { |
| 771 // First drag and shuffle. |
| 772 initial_bounds = GetAllPanelBounds(); |
| 773 expected_delta_x_after_drag = zero_deltas; |
| 774 |
| 775 // Delta for panel being dragged. |
| 583 expected_delta_x_after_drag[0] = -big_delta; | 776 expected_delta_x_after_drag[0] = -big_delta; |
| 777 |
| 778 // Delta for panel being shuffled. |
| 779 expected_delta_x_after_drag[1] = |
| 780 (initial_bounds[0].width() + horizontal_spacing); |
| 781 |
| 782 // There is no delta after finish as drag is done yet. |
| 783 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 784 zero_deltas, initial_bounds, DRAG_ACTION_BEGIN); |
| 785 |
| 786 // Second drag and shuffle. We cancel the drag here. The drag index |
| 787 // changes from 0 to 1 because of the first shuffle above. |
| 788 current_bounds = GetAllPanelBounds(); |
| 789 expected_delta_x_after_drag = zero_deltas; |
| 790 |
| 791 // Delta for panel being dragged. |
| 792 expected_delta_x_after_drag[1] = -bigger_delta; |
| 793 |
| 794 // Deltas for panel being shuffled. |
| 795 int x_after_shuffle = current_bounds[0].x() - horizontal_spacing |
| 796 - current_bounds[2].width(); |
| 797 expected_delta_x_after_drag[2] = x_after_shuffle - current_bounds[2].x(); |
| 798 |
| 799 // There is no delta after finish as drag canceled. |
| 800 TestDragging(-bigger_delta, zero_delta, 1, expected_delta_x_after_drag, |
| 801 zero_deltas, initial_bounds, DRAG_ACTION_CANCEL); |
| 802 } |
| 803 |
| 804 // Drag leftmost panel to become the rightmost in a single drag. This |
| 805 // will shuffle middle panel to leftmost and rightmost to middle. |
| 806 { |
| 807 initial_bounds = GetAllPanelBounds(); |
| 808 expected_delta_x_after_drag = zero_deltas; |
| 584 expected_delta_x_after_finish = zero_deltas; | 809 expected_delta_x_after_finish = zero_deltas; |
| 585 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | 810 |
| 586 zero_deltas, GetAllPanelBounds(), | 811 // Use a delta big enough to go across two panels. |
| 587 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | 812 // Deltas for panel being dragged. |
| 588 | 813 expected_delta_x_after_drag[2] = biggest_delta; |
| 589 // Drag left and cancel. | 814 expected_delta_x_after_finish[2] = |
| 590 expected_delta_x_after_drag[0] = -big_delta; | 815 initial_bounds[1].width() + horizontal_spacing + |
| 816 initial_bounds[0].width() + horizontal_spacing; |
| 817 |
| 818 // Deltas for middle panels being shuffled. |
| 819 expected_delta_x_after_drag[1] = |
| 820 -(initial_bounds[2].width() + horizontal_spacing); |
| 821 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; |
| 822 |
| 823 expected_delta_x_after_drag[0] = expected_delta_x_after_drag[1]; |
| 824 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; |
| 825 |
| 826 TestDragging(biggest_delta, zero_delta, 2, expected_delta_x_after_drag, |
| 827 expected_delta_x_after_finish, initial_bounds, |
| 828 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 829 } |
| 830 |
| 831 // Drag rightmost panel to become the leftmost in a single drag. This |
| 832 // will shuffle middle panel to rightmost and leftmost to middle. |
| 833 { |
| 834 initial_bounds = GetAllPanelBounds(); |
| 835 expected_delta_x_after_drag = zero_deltas; |
| 591 expected_delta_x_after_finish = zero_deltas; | 836 expected_delta_x_after_finish = zero_deltas; |
| 592 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | 837 |
| 593 zero_deltas, GetAllPanelBounds(), | 838 // Deltas for panel being dragged. |
| 839 expected_delta_x_after_drag[0] = -biggest_delta; |
| 840 expected_delta_x_after_finish[0] = |
| 841 -(initial_bounds[1].width() + horizontal_spacing + |
| 842 initial_bounds[2].width() + horizontal_spacing); |
| 843 |
| 844 // Deltas for panels being shuffled. |
| 845 expected_delta_x_after_drag[1] = |
| 846 initial_bounds[0].width() + horizontal_spacing; |
| 847 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; |
| 848 |
| 849 expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; |
| 850 expected_delta_x_after_finish[2] = expected_delta_x_after_drag[2]; |
| 851 |
| 852 TestDragging(-biggest_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 853 expected_delta_x_after_finish, initial_bounds, |
| 854 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 855 } |
| 856 |
| 857 // Drag rightmost panel to become the leftmost in a single drag. Then |
| 858 // cancel the drag. |
| 859 { |
| 860 initial_bounds = GetAllPanelBounds(); |
| 861 expected_delta_x_after_drag = zero_deltas; |
| 862 |
| 863 // Deltas for panel being dragged. |
| 864 expected_delta_x_after_drag[0] = -biggest_delta; |
| 865 |
| 866 // Deltas for panels being shuffled. |
| 867 expected_delta_x_after_drag[1] = |
| 868 initial_bounds[0].width() + horizontal_spacing; |
| 869 expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; |
| 870 |
| 871 // No delta after finish as drag is canceled. |
| 872 TestDragging(-biggest_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 873 zero_deltas, initial_bounds, |
| 594 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); | 874 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); |
| 595 | 875 } |
| 596 // Drag right. | 876 |
| 597 expected_delta_x_after_drag[0] = big_delta; | 877 panel1->Close(); |
| 598 TestDragging(big_delta, zero_delta, 0, expected_delta_x_after_drag, | 878 panel2->Close(); |
| 599 zero_deltas, GetAllPanelBounds(), | 879 panel3->Close(); |
| 600 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 601 | |
| 602 // Drag right and up. Expect no vertical movement. | |
| 603 TestDragging(big_delta, big_delta, 0, expected_delta_x_after_drag, | |
| 604 zero_deltas, GetAllPanelBounds(), | |
| 605 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 606 | |
| 607 // Drag up. Expect no movement on drag. | |
| 608 TestDragging(0, -big_delta, 0, zero_deltas, zero_deltas, | |
| 609 GetAllPanelBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 610 | |
| 611 // Drag down. Expect no movement on drag. | |
| 612 TestDragging(0, big_delta, 0, zero_deltas, zero_deltas, | |
| 613 GetAllPanelBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 614 } | |
| 615 | |
| 616 // Tests with two panels. | |
| 617 { | |
| 618 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 120, 120)); | |
| 619 | |
| 620 // Drag left, small delta, expect no shuffle. | |
| 621 { | |
| 622 expected_delta_x_after_drag = zero_deltas; | |
| 623 expected_delta_x_after_drag[0] = -small_delta; | |
| 624 TestDragging(-small_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 625 zero_deltas, GetAllPanelBounds(), | |
| 626 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 627 | |
| 628 // Drag right panel i.e index 0, towards left, big delta, expect shuffle. | |
| 629 initial_bounds = GetAllPanelBounds(); | |
| 630 expected_delta_x_after_drag = zero_deltas; | |
| 631 | |
| 632 // Deltas for panel being dragged. | |
| 633 expected_delta_x_after_drag[0] = -big_delta; | |
| 634 expected_delta_x_after_finish[0] = | |
| 635 -(initial_bounds[1].width() + horizontal_spacing()); | |
| 636 | |
| 637 // Deltas for panel being shuffled. | |
| 638 expected_delta_x_after_drag[1] = | |
| 639 initial_bounds[0].width() + horizontal_spacing(); | |
| 640 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; | |
| 641 | |
| 642 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 643 expected_delta_x_after_finish, initial_bounds, | |
| 644 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 645 } | |
| 646 | |
| 647 // Drag left panel i.e index 1, towards right, big delta, expect shuffle. | |
| 648 { | |
| 649 initial_bounds = GetAllPanelBounds(); | |
| 650 expected_delta_x_after_drag = zero_deltas; | |
| 651 expected_delta_x_after_finish = zero_deltas; | |
| 652 | |
| 653 // Deltas for panel being dragged. | |
| 654 expected_delta_x_after_drag[1] = big_delta; | |
| 655 expected_delta_x_after_finish[1] = | |
| 656 initial_bounds[0].width() + horizontal_spacing(); | |
| 657 | |
| 658 // Deltas for panel being shuffled. | |
| 659 expected_delta_x_after_drag[0] = | |
| 660 -(initial_bounds[1].width() + horizontal_spacing()); | |
| 661 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; | |
| 662 | |
| 663 TestDragging(big_delta, zero_delta, 1, expected_delta_x_after_drag, | |
| 664 expected_delta_x_after_finish, initial_bounds, | |
| 665 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 666 } | |
| 667 | |
| 668 // Drag left panel i.e index 1, towards right, big delta, expect shuffle. | |
| 669 // Cancel drag. | |
| 670 { | |
| 671 initial_bounds = GetAllPanelBounds(); | |
| 672 expected_delta_x_after_drag = zero_deltas; | |
| 673 | |
| 674 // Delta for panel being dragged. | |
| 675 expected_delta_x_after_drag[1] = big_delta; | |
| 676 | |
| 677 // Delta for panel being shuffled. | |
| 678 expected_delta_x_after_drag[0] = | |
| 679 -(initial_bounds[1].width() + horizontal_spacing()); | |
| 680 | |
| 681 // As the drag is being canceled, we don't need expected_delta_x_after | |
| 682 // finish. Instead initial_bounds will be used. | |
| 683 TestDragging(big_delta, zero_delta, 1, expected_delta_x_after_drag, | |
| 684 zero_deltas, initial_bounds, | |
| 685 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); | |
| 686 } | |
| 687 } | |
| 688 | |
| 689 // Tests with three panels. | |
| 690 { | |
| 691 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 110, 110)); | |
| 692 | |
| 693 // Drag leftmost panel to become rightmost with two shuffles. | |
| 694 // We test both shuffles. | |
| 695 { | |
| 696 // Drag the left-most panel towards right without ending or cancelling it. | |
| 697 // Expect shuffle. | |
| 698 initial_bounds = GetAllPanelBounds(); | |
| 699 expected_delta_x_after_drag = zero_deltas; | |
| 700 | |
| 701 // Delta for panel being dragged. | |
| 702 expected_delta_x_after_drag[2] = big_delta; | |
| 703 | |
| 704 // Delta for panel being shuffled. | |
| 705 expected_delta_x_after_drag[1] = | |
| 706 -(initial_bounds[2].width() + horizontal_spacing()); | |
| 707 | |
| 708 // There is no delta after finish as drag is not done yet. | |
| 709 TestDragging(big_delta, zero_delta, 2, expected_delta_x_after_drag, | |
| 710 zero_deltas, initial_bounds, DRAG_ACTION_BEGIN); | |
| 711 | |
| 712 // The drag index changes from 2 to 1 because of the first shuffle above. | |
| 713 // Drag the panel further enough to the right to trigger a another | |
| 714 // shuffle. We finish the drag here. | |
| 715 current_bounds = GetAllPanelBounds(); | |
| 716 expected_delta_x_after_drag = zero_deltas; | |
| 717 expected_delta_x_after_finish = zero_deltas; | |
| 718 | |
| 719 // big_delta is not enough to cause the second shuffle as the panel being | |
| 720 // dragged is in the middle of a drag and big_delta won't go far enough. | |
| 721 // So we use bigger_delta. | |
| 722 | |
| 723 // Deltas for panel being dragged. | |
| 724 expected_delta_x_after_drag[1] = bigger_delta; | |
| 725 int x_after_finish = current_bounds[0].x() + | |
| 726 (current_bounds[0].width() - current_bounds[1].width()); | |
| 727 expected_delta_x_after_finish[1] = x_after_finish - current_bounds[1].x(); | |
| 728 | |
| 729 // Deltas for panel being shuffled. | |
| 730 expected_delta_x_after_drag[0] = | |
| 731 -(current_bounds[1].width() + horizontal_spacing()); | |
| 732 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; | |
| 733 | |
| 734 TestDragging(bigger_delta, zero_delta, 1, expected_delta_x_after_drag, | |
| 735 expected_delta_x_after_finish, initial_bounds, | |
| 736 DRAG_ACTION_FINISH); | |
| 737 } | |
| 738 | |
| 739 // Drag rightmost panel to become leftmost with two shuffles. | |
| 740 // And then cancel the drag. | |
| 741 { | |
| 742 // First drag and shuffle. | |
| 743 initial_bounds = GetAllPanelBounds(); | |
| 744 expected_delta_x_after_drag = zero_deltas; | |
| 745 | |
| 746 // Delta for panel being dragged. | |
| 747 expected_delta_x_after_drag[0] = -big_delta; | |
| 748 | |
| 749 // Delta for panel being shuffled. | |
| 750 expected_delta_x_after_drag[1] = | |
| 751 (initial_bounds[0].width() + horizontal_spacing()); | |
| 752 | |
| 753 // There is no delta after finish as drag is done yet. | |
| 754 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 755 zero_deltas, initial_bounds, DRAG_ACTION_BEGIN); | |
| 756 | |
| 757 // Second drag and shuffle. We cancel the drag here. The drag index | |
| 758 // changes from 0 to 1 because of the first shuffle above. | |
| 759 current_bounds = GetAllPanelBounds(); | |
| 760 expected_delta_x_after_drag = zero_deltas; | |
| 761 | |
| 762 // Delta for panel being dragged. | |
| 763 expected_delta_x_after_drag[1] = -bigger_delta; | |
| 764 | |
| 765 // Deltas for panel being shuffled. | |
| 766 int x_after_shuffle = current_bounds[0].x() - horizontal_spacing() | |
| 767 - current_bounds[2].width(); | |
| 768 expected_delta_x_after_drag[2] = x_after_shuffle - current_bounds[2].x(); | |
| 769 | |
| 770 // There is no delta after finish as drag canceled. | |
| 771 TestDragging(-bigger_delta, zero_delta, 1, expected_delta_x_after_drag, | |
| 772 zero_deltas, initial_bounds, DRAG_ACTION_CANCEL); | |
| 773 } | |
| 774 | |
| 775 // Drag leftmost panel to become the rightmost in a single drag. This | |
| 776 // will shuffle middle panel to leftmost and rightmost to middle. | |
| 777 { | |
| 778 initial_bounds = GetAllPanelBounds(); | |
| 779 expected_delta_x_after_drag = zero_deltas; | |
| 780 expected_delta_x_after_finish = zero_deltas; | |
| 781 | |
| 782 // Use a delta big enough to go across two panels. | |
| 783 // Deltas for panel being dragged. | |
| 784 expected_delta_x_after_drag[2] = biggest_delta; | |
| 785 expected_delta_x_after_finish[2] = | |
| 786 initial_bounds[1].width() + horizontal_spacing() + | |
| 787 initial_bounds[0].width() + horizontal_spacing(); | |
| 788 | |
| 789 // Deltas for middle panels being shuffled. | |
| 790 expected_delta_x_after_drag[1] = | |
| 791 -(initial_bounds[2].width() + horizontal_spacing()); | |
| 792 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; | |
| 793 | |
| 794 expected_delta_x_after_drag[0] = expected_delta_x_after_drag[1]; | |
| 795 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; | |
| 796 | |
| 797 TestDragging(biggest_delta, zero_delta, 2, expected_delta_x_after_drag, | |
| 798 expected_delta_x_after_finish, initial_bounds, | |
| 799 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 800 } | |
| 801 | |
| 802 // Drag rightmost panel to become the leftmost in a single drag. This | |
| 803 // will shuffle middle panel to rightmost and leftmost to middle. | |
| 804 { | |
| 805 initial_bounds = GetAllPanelBounds(); | |
| 806 expected_delta_x_after_drag = zero_deltas; | |
| 807 expected_delta_x_after_finish = zero_deltas; | |
| 808 | |
| 809 // Deltas for panel being dragged. | |
| 810 expected_delta_x_after_drag[0] = -biggest_delta; | |
| 811 expected_delta_x_after_finish[0] = | |
| 812 -(initial_bounds[1].width() + horizontal_spacing() + | |
| 813 initial_bounds[2].width() + horizontal_spacing()); | |
| 814 | |
| 815 // Deltas for panels being shuffled. | |
| 816 expected_delta_x_after_drag[1] = | |
| 817 initial_bounds[0].width() + horizontal_spacing(); | |
| 818 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; | |
| 819 | |
| 820 expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; | |
| 821 expected_delta_x_after_finish[2] = expected_delta_x_after_drag[2]; | |
| 822 | |
| 823 TestDragging(-biggest_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 824 expected_delta_x_after_finish, initial_bounds, | |
| 825 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 826 } | |
| 827 | |
| 828 // Drag rightmost panel to become the leftmost in a single drag. Then | |
| 829 // cancel the drag. | |
| 830 { | |
| 831 initial_bounds = GetAllPanelBounds(); | |
| 832 expected_delta_x_after_drag = zero_deltas; | |
| 833 | |
| 834 // Deltas for panel being dragged. | |
| 835 expected_delta_x_after_drag[0] = -biggest_delta; | |
| 836 | |
| 837 // Deltas for panels being shuffled. | |
| 838 expected_delta_x_after_drag[1] = | |
| 839 initial_bounds[0].width() + horizontal_spacing(); | |
| 840 expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; | |
| 841 | |
| 842 // No delta after finish as drag is canceled. | |
| 843 TestDragging(-biggest_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 844 zero_deltas, initial_bounds, | |
| 845 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); | |
| 846 } | |
| 847 } | |
| 848 | |
| 849 PanelManager::GetInstance()->RemoveAll(); | |
| 850 } | 880 } |
| 851 | 881 |
| 852 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) { | 882 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) { |
| 853 TestCreateSettingsMenuForExtension( | 883 TestCreateSettingsMenuForExtension( |
| 854 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, | 884 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 855 "", ""); | 885 "", ""); |
| 856 TestCreateSettingsMenuForExtension( | 886 TestCreateSettingsMenuForExtension( |
| 857 FILE_PATH_LITERAL("extension2"), Extension::INVALID, | 887 FILE_PATH_LITERAL("extension2"), Extension::INVALID, |
| 858 "http://home", "options.html"); | 888 "http://home", "options.html"); |
| 859 } | 889 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); | 952 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
| 923 EXPECT_EQ(bounds, panel->GetBounds()); | 953 EXPECT_EQ(bounds, panel->GetBounds()); |
| 924 | 954 |
| 925 panel->Close(); | 955 panel->Close(); |
| 926 } | 956 } |
| 927 | 957 |
| 928 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { | 958 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { |
| 929 // Disable mouse watcher. We don't care about mouse movements in this test. | 959 // Disable mouse watcher. We don't care about mouse movements in this test. |
| 930 PanelManager* panel_manager = PanelManager::GetInstance(); | 960 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 931 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 961 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 932 panel_manager->set_mouse_watcher(mouse_watcher); | 962 panel_manager->SetMouseWatcher(mouse_watcher); |
| 933 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 963 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
| 934 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 964 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
| 935 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 965 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
| 936 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | |
| 937 | 966 |
| 938 panel->SetExpansionState(Panel::MINIMIZED); | 967 panel->SetExpansionState(Panel::MINIMIZED); |
| 939 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 968 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| 940 gfx::Rect bounds = panel->GetBounds(); | 969 gfx::Rect bounds = panel->GetBounds(); |
| 941 gfx::Rect restored = panel->GetRestoredBounds(); | 970 gfx::Rect restored = panel->GetRestoredBounds(); |
| 942 EXPECT_EQ(bounds.x(), restored.x()); | 971 EXPECT_EQ(bounds.x(), restored.x()); |
| 943 EXPECT_GT(bounds.y(), restored.y()); | 972 EXPECT_GT(bounds.y(), restored.y()); |
| 944 EXPECT_EQ(bounds.width(), restored.width()); | 973 EXPECT_EQ(bounds.width(), restored.width()); |
| 945 EXPECT_LT(bounds.height(), restored.height()); | 974 EXPECT_LT(bounds.height(), restored.height()); |
| 946 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 947 | 975 |
| 948 panel->SetExpansionState(Panel::TITLE_ONLY); | 976 panel->SetExpansionState(Panel::TITLE_ONLY); |
| 949 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 977 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| 950 bounds = panel->GetBounds(); | 978 bounds = panel->GetBounds(); |
| 951 restored = panel->GetRestoredBounds(); | 979 restored = panel->GetRestoredBounds(); |
| 952 EXPECT_EQ(bounds.x(), restored.x()); | 980 EXPECT_EQ(bounds.x(), restored.x()); |
| 953 EXPECT_GT(bounds.y(), restored.y()); | 981 EXPECT_GT(bounds.y(), restored.y()); |
| 954 EXPECT_EQ(bounds.width(), restored.width()); | 982 EXPECT_EQ(bounds.width(), restored.width()); |
| 955 EXPECT_LT(bounds.height(), restored.height()); | 983 EXPECT_LT(bounds.height(), restored.height()); |
| 956 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 957 | 984 |
| 958 panel->SetExpansionState(Panel::MINIMIZED); | 985 panel->SetExpansionState(Panel::MINIMIZED); |
| 959 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 986 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| 960 bounds = panel->GetBounds(); | 987 bounds = panel->GetBounds(); |
| 961 restored = panel->GetRestoredBounds(); | 988 restored = panel->GetRestoredBounds(); |
| 962 EXPECT_EQ(bounds.x(), restored.x()); | 989 EXPECT_EQ(bounds.x(), restored.x()); |
| 963 EXPECT_GT(bounds.y(), restored.y()); | 990 EXPECT_GT(bounds.y(), restored.y()); |
| 964 EXPECT_EQ(bounds.width(), restored.width()); | 991 EXPECT_EQ(bounds.width(), restored.width()); |
| 965 EXPECT_LT(bounds.height(), restored.height()); | 992 EXPECT_LT(bounds.height(), restored.height()); |
| 966 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 967 | 993 |
| 968 panel->SetExpansionState(Panel::EXPANDED); | 994 panel->SetExpansionState(Panel::EXPANDED); |
| 969 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 995 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
| 970 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | |
| 971 | 996 |
| 972 // Verify that changing the panel bounds only affects restored height | 997 // Verify that changing the panel bounds only affects restored height |
| 973 // when panel is expanded. | 998 // when panel is expanded. |
| 974 int saved_restored_height = restored.height(); | 999 int saved_restored_height = restored.height(); |
| 975 panel->SetExpansionState(Panel::MINIMIZED); | 1000 panel->SetExpansionState(Panel::MINIMIZED); |
| 976 bounds = gfx::Rect(10, 20, 300, 400); | 1001 bounds = gfx::Rect(10, 20, 300, 400); |
| 977 panel->SetPanelBounds(bounds); | 1002 panel->SetPanelBounds(bounds); |
| 978 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 1003 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
| 979 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 980 | 1004 |
| 981 panel->SetExpansionState(Panel::TITLE_ONLY); | 1005 panel->SetExpansionState(Panel::TITLE_ONLY); |
| 982 bounds = gfx::Rect(20, 30, 100, 200); | 1006 bounds = gfx::Rect(20, 30, 100, 200); |
| 983 panel->SetPanelBounds(bounds); | 1007 panel->SetPanelBounds(bounds); |
| 984 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 1008 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
| 985 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 986 | 1009 |
| 987 panel->SetExpansionState(Panel::EXPANDED); | 1010 panel->SetExpansionState(Panel::EXPANDED); |
| 988 bounds = gfx::Rect(40, 60, 300, 400); | 1011 bounds = gfx::Rect(40, 60, 300, 400); |
| 989 panel->SetPanelBounds(bounds); | 1012 panel->SetPanelBounds(bounds); |
| 990 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); | 1013 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); |
| 991 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | |
| 992 | 1014 |
| 993 panel->Close(); | 1015 panel->Close(); |
| 994 } | 1016 } |
| 995 | 1017 |
| 996 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { | 1018 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { |
| 997 // We'll simulate mouse movements for test. | 1019 // We'll simulate mouse movements for test. |
| 998 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1020 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 999 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1021 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1000 | 1022 |
| 1001 // Test with one panel. | 1023 // Test with one panel. |
| 1002 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 1024 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 1003 TestMinimizeRestore(); | 1025 TestMinimizeRestore(); |
| 1004 | 1026 |
| 1005 PanelManager::GetInstance()->RemoveAll(); | 1027 PanelManager::GetInstance()->RemoveAll(); |
| 1006 } | 1028 } |
| 1007 | 1029 |
| 1008 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { | 1030 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { |
| 1009 // We'll simulate mouse movements for test. | 1031 // We'll simulate mouse movements for test. |
| 1010 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1032 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 1011 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1033 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1012 | 1034 |
| 1013 // Test with two panels. | 1035 // Test with two panels. |
| 1014 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 1036 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 1015 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 1037 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
| 1016 TestMinimizeRestore(); | 1038 TestMinimizeRestore(); |
| 1017 | 1039 |
| 1018 PanelManager::GetInstance()->RemoveAll(); | 1040 PanelManager::GetInstance()->RemoveAll(); |
| 1019 } | 1041 } |
| 1020 | 1042 |
| 1021 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { | 1043 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { |
| 1022 // We'll simulate mouse movements for test. | 1044 // We'll simulate mouse movements for test. |
| 1023 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1045 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 1024 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1046 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1025 | 1047 |
| 1026 // Test with three panels. | 1048 // Test with three panels. |
| 1027 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 1049 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 1028 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 1050 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
| 1029 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); | 1051 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); |
| 1030 TestMinimizeRestore(); | 1052 TestMinimizeRestore(); |
| 1031 | 1053 |
| 1032 PanelManager::GetInstance()->RemoveAll(); | 1054 PanelManager::GetInstance()->RemoveAll(); |
| 1033 } | 1055 } |
| 1034 | 1056 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 EXPECT_TRUE(panel->IsDrawingAttention()); | 1200 EXPECT_TRUE(panel->IsDrawingAttention()); |
| 1179 MessageLoop::current()->RunAllPending(); | 1201 MessageLoop::current()->RunAllPending(); |
| 1180 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1202 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
| 1181 | 1203 |
| 1182 panel->Close(); | 1204 panel->Close(); |
| 1183 } | 1205 } |
| 1184 | 1206 |
| 1185 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { | 1207 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { |
| 1186 // We'll simulate mouse movements for test. | 1208 // We'll simulate mouse movements for test. |
| 1187 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1209 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 1188 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1210 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1189 | 1211 |
| 1190 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1212 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
| 1191 Panel* panel = CreatePanelWithParams(params); | 1213 Panel* panel = CreatePanelWithParams(params); |
| 1192 NativePanel* native_panel = panel->native_panel(); | 1214 NativePanel* native_panel = panel->native_panel(); |
| 1193 scoped_ptr<NativePanelTesting> native_panel_testing( | 1215 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1194 NativePanelTesting::Create(native_panel)); | 1216 NativePanelTesting::Create(native_panel)); |
| 1195 | 1217 |
| 1196 // Test that the attention is drawn and the title-bar is brought up when the | 1218 // Test that the attention is drawn and the title-bar is brought up when the |
| 1197 // minimized panel is drawing attention. | 1219 // minimized panel is drawing attention. |
| 1198 panel->SetExpansionState(Panel::MINIMIZED); | 1220 panel->SetExpansionState(Panel::MINIMIZED); |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 // position when tall panel brings up its titlebar. | 1981 // position when tall panel brings up its titlebar. |
| 1960 CloseWindowAndWait(panel1->browser()); | 1982 CloseWindowAndWait(panel1->browser()); |
| 1961 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1983 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
| 1962 GetBalloonBottomPosition(balloon)); | 1984 GetBalloonBottomPosition(balloon)); |
| 1963 | 1985 |
| 1964 // Closing the remaining tall panel should move the notification balloon back | 1986 // Closing the remaining tall panel should move the notification balloon back |
| 1965 // to its original position. | 1987 // to its original position. |
| 1966 CloseWindowAndWait(panel2->browser()); | 1988 CloseWindowAndWait(panel2->browser()); |
| 1967 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1989 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
| 1968 } | 1990 } |
| OLD | NEW |