Chromium Code Reviews| 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; | |
| 610 static const int zero_delta = 0; | |
| 611 static const int small_delta = 10; | |
| 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; | |
| 566 static const int zero_delta = 0; | 701 static const int zero_delta = 0; |
| 567 static const int small_delta = 10; | 702 static const int small_delta = 10; |
| 568 static const int big_delta = 70; | 703 static const int big_delta = 70; |
| 569 static const int bigger_delta = 120; | 704 static const int bigger_delta = 120; |
| 570 static const int biggest_delta = 200; | 705 static const int biggest_delta = 200; |
| 571 static const std::vector<int> zero_deltas(max_panels, zero_delta); | 706 |
| 572 | 707 static const std::vector<int> zero_deltas(num_panels, zero_delta); |
| 573 std::vector<int> expected_delta_x_after_drag(max_panels, zero_delta); | 708 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); | 709 std::vector<int> expected_delta_x_after_finish(num_panels, zero_delta); |
| 575 std::vector<gfx::Rect> current_bounds; | 710 std::vector<gfx::Rect> current_bounds; |
| 576 std::vector<gfx::Rect> initial_bounds; | 711 std::vector<gfx::Rect> initial_bounds; |
| 577 | 712 |
| 578 // Tests with a single panel. | 713 Panel* panel1 = |
| 579 { | 714 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 580 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 715 Panel* panel2 = |
| 581 | 716 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 120, 120)); |
| 582 // Drag left. | 717 Panel* panel3 = |
| 718 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 110, 110)); | |
| 719 | |
| 720 int horizontal_spacing = | |
| 721 panel1->GetBounds().x() - panel2->GetBounds().right(); | |
| 722 | |
| 723 // Drag leftmost panel to become rightmost with two shuffles. | |
| 724 // We test both shuffles. | |
| 725 { | |
| 726 // Drag the left-most panel towards right without ending or cancelling it. | |
| 727 // Expect shuffle. | |
| 728 initial_bounds = GetAllPanelBounds(); | |
| 729 expected_delta_x_after_drag = zero_deltas; | |
| 730 | |
| 731 // Delta for panel being dragged. | |
| 732 expected_delta_x_after_drag[2] = big_delta; | |
| 733 | |
| 734 // Delta for panel being shuffled. | |
| 735 expected_delta_x_after_drag[1] = | |
| 736 -(initial_bounds[2].width() + horizontal_spacing); | |
| 737 | |
| 738 // There is no delta after finish as drag is not done yet. | |
| 739 TestDragging(big_delta, zero_delta, 2, expected_delta_x_after_drag, | |
| 740 zero_deltas, initial_bounds, DRAG_ACTION_BEGIN); | |
| 741 | |
| 742 // The drag index changes from 2 to 1 because of the first shuffle above. | |
| 743 // Drag the panel further enough to the right to trigger a another | |
| 744 // shuffle. We finish the drag here. | |
| 745 current_bounds = GetAllPanelBounds(); | |
| 746 expected_delta_x_after_drag = zero_deltas; | |
| 747 expected_delta_x_after_finish = zero_deltas; | |
| 748 | |
| 749 // big_delta is not enough to cause the second shuffle as the panel being | |
| 750 // dragged is in the middle of a drag and big_delta won't go far enough. | |
| 751 // So we use bigger_delta. | |
| 752 | |
| 753 // Deltas for panel being dragged. | |
| 754 expected_delta_x_after_drag[1] = bigger_delta; | |
| 755 int x_after_finish = current_bounds[0].x() + | |
| 756 (current_bounds[0].width() - current_bounds[1].width()); | |
| 757 expected_delta_x_after_finish[1] = x_after_finish - current_bounds[1].x(); | |
| 758 | |
| 759 // Deltas for panel being shuffled. | |
| 760 expected_delta_x_after_drag[0] = | |
| 761 -(current_bounds[1].width() + horizontal_spacing); | |
| 762 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; | |
| 763 | |
| 764 TestDragging(bigger_delta, zero_delta, 1, expected_delta_x_after_drag, | |
| 765 expected_delta_x_after_finish, initial_bounds, | |
| 766 DRAG_ACTION_FINISH); | |
| 767 } | |
| 768 | |
| 769 // Drag rightmost panel to become leftmost with two shuffles. | |
| 770 // And then cancel the drag. | |
| 771 { | |
| 772 // First drag and shuffle. | |
| 773 initial_bounds = GetAllPanelBounds(); | |
| 774 expected_delta_x_after_drag = zero_deltas; | |
| 775 | |
| 776 // Delta for panel being dragged. | |
| 583 expected_delta_x_after_drag[0] = -big_delta; | 777 expected_delta_x_after_drag[0] = -big_delta; |
| 778 | |
| 779 // Delta for panel being shuffled. | |
| 780 expected_delta_x_after_drag[1] = | |
| 781 (initial_bounds[0].width() + horizontal_spacing); | |
| 782 | |
| 783 // There is no delta after finish as drag is done yet. | |
| 784 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 785 zero_deltas, initial_bounds, DRAG_ACTION_BEGIN); | |
| 786 | |
| 787 // Second drag and shuffle. We cancel the drag here. The drag index | |
| 788 // changes from 0 to 1 because of the first shuffle above. | |
| 789 current_bounds = GetAllPanelBounds(); | |
| 790 expected_delta_x_after_drag = zero_deltas; | |
| 791 | |
| 792 // Delta for panel being dragged. | |
| 793 expected_delta_x_after_drag[1] = -bigger_delta; | |
| 794 | |
| 795 // Deltas for panel being shuffled. | |
| 796 int x_after_shuffle = current_bounds[0].x() - horizontal_spacing | |
| 797 - current_bounds[2].width(); | |
| 798 expected_delta_x_after_drag[2] = x_after_shuffle - current_bounds[2].x(); | |
| 799 | |
| 800 // There is no delta after finish as drag canceled. | |
| 801 TestDragging(-bigger_delta, zero_delta, 1, expected_delta_x_after_drag, | |
| 802 zero_deltas, initial_bounds, DRAG_ACTION_CANCEL); | |
| 803 } | |
| 804 | |
| 805 // Drag leftmost panel to become the rightmost in a single drag. This | |
| 806 // will shuffle middle panel to leftmost and rightmost to middle. | |
| 807 { | |
| 808 initial_bounds = GetAllPanelBounds(); | |
| 809 expected_delta_x_after_drag = zero_deltas; | |
| 584 expected_delta_x_after_finish = zero_deltas; | 810 expected_delta_x_after_finish = zero_deltas; |
| 585 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | 811 |
| 586 zero_deltas, GetAllPanelBounds(), | 812 // Use a delta big enough to go across two panels. |
| 587 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | 813 // Deltas for panel being dragged. |
| 588 | 814 expected_delta_x_after_drag[2] = biggest_delta; |
| 589 // Drag left and cancel. | 815 expected_delta_x_after_finish[2] = |
| 590 expected_delta_x_after_drag[0] = -big_delta; | 816 initial_bounds[1].width() + horizontal_spacing + |
| 817 initial_bounds[0].width() + horizontal_spacing; | |
| 818 | |
| 819 // Deltas for middle panels being shuffled. | |
| 820 expected_delta_x_after_drag[1] = | |
| 821 -(initial_bounds[2].width() + horizontal_spacing); | |
| 822 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; | |
| 823 | |
| 824 expected_delta_x_after_drag[0] = expected_delta_x_after_drag[1]; | |
| 825 expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; | |
| 826 | |
| 827 TestDragging(biggest_delta, zero_delta, 2, expected_delta_x_after_drag, | |
| 828 expected_delta_x_after_finish, initial_bounds, | |
| 829 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 830 } | |
| 831 | |
| 832 // Drag rightmost panel to become the leftmost in a single drag. This | |
| 833 // will shuffle middle panel to rightmost and leftmost to middle. | |
| 834 { | |
| 835 initial_bounds = GetAllPanelBounds(); | |
| 836 expected_delta_x_after_drag = zero_deltas; | |
| 591 expected_delta_x_after_finish = zero_deltas; | 837 expected_delta_x_after_finish = zero_deltas; |
| 592 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | 838 |
| 593 zero_deltas, GetAllPanelBounds(), | 839 // Deltas for panel being dragged. |
| 840 expected_delta_x_after_drag[0] = -biggest_delta; | |
| 841 expected_delta_x_after_finish[0] = | |
| 842 -(initial_bounds[1].width() + horizontal_spacing + | |
| 843 initial_bounds[2].width() + horizontal_spacing); | |
| 844 | |
| 845 // Deltas for panels being shuffled. | |
| 846 expected_delta_x_after_drag[1] = | |
| 847 initial_bounds[0].width() + horizontal_spacing; | |
| 848 expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; | |
| 849 | |
| 850 expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; | |
| 851 expected_delta_x_after_finish[2] = expected_delta_x_after_drag[2]; | |
| 852 | |
| 853 TestDragging(-biggest_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 854 expected_delta_x_after_finish, initial_bounds, | |
| 855 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | |
| 856 } | |
| 857 | |
| 858 // Drag rightmost panel to become the leftmost in a single drag. Then | |
| 859 // cancel the drag. | |
| 860 { | |
| 861 initial_bounds = GetAllPanelBounds(); | |
| 862 expected_delta_x_after_drag = zero_deltas; | |
| 863 | |
| 864 // Deltas for panel being dragged. | |
| 865 expected_delta_x_after_drag[0] = -biggest_delta; | |
| 866 | |
| 867 // Deltas for panels being shuffled. | |
| 868 expected_delta_x_after_drag[1] = | |
| 869 initial_bounds[0].width() + horizontal_spacing; | |
| 870 expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; | |
| 871 | |
| 872 // No delta after finish as drag is canceled. | |
| 873 TestDragging(-biggest_delta, zero_delta, 0, expected_delta_x_after_drag, | |
| 874 zero_deltas, initial_bounds, | |
| 594 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); | 875 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); |
| 595 | 876 } |
| 596 // Drag right. | 877 |
| 597 expected_delta_x_after_drag[0] = big_delta; | 878 panel1->Close(); |
| 598 TestDragging(big_delta, zero_delta, 0, expected_delta_x_after_drag, | 879 panel2->Close(); |
| 599 zero_deltas, GetAllPanelBounds(), | 880 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 } | 881 } |
| 851 | 882 |
|
jennb
2011/12/07 20:04:11
Oops. will delete this extra line.
| |
| 883 | |
| 852 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) { | 884 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) { |
| 853 TestCreateSettingsMenuForExtension( | 885 TestCreateSettingsMenuForExtension( |
| 854 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, | 886 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 855 "", ""); | 887 "", ""); |
| 856 TestCreateSettingsMenuForExtension( | 888 TestCreateSettingsMenuForExtension( |
| 857 FILE_PATH_LITERAL("extension2"), Extension::INVALID, | 889 FILE_PATH_LITERAL("extension2"), Extension::INVALID, |
| 858 "http://home", "options.html"); | 890 "http://home", "options.html"); |
| 859 } | 891 } |
| 860 | 892 |
| 861 // Flaky: http://crbug.com/105445 | 893 // Flaky: http://crbug.com/105445 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); | 954 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
| 923 EXPECT_EQ(bounds, panel->GetBounds()); | 955 EXPECT_EQ(bounds, panel->GetBounds()); |
| 924 | 956 |
| 925 panel->Close(); | 957 panel->Close(); |
| 926 } | 958 } |
| 927 | 959 |
| 928 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { | 960 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { |
| 929 // Disable mouse watcher. We don't care about mouse movements in this test. | 961 // Disable mouse watcher. We don't care about mouse movements in this test. |
| 930 PanelManager* panel_manager = PanelManager::GetInstance(); | 962 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 931 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 963 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 932 panel_manager->set_mouse_watcher(mouse_watcher); | 964 panel_manager->SetMouseWatcher(mouse_watcher); |
| 933 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 965 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
| 934 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 966 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
| 935 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 967 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
| 936 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | |
| 937 | 968 |
| 938 panel->SetExpansionState(Panel::MINIMIZED); | 969 panel->SetExpansionState(Panel::MINIMIZED); |
| 939 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 970 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| 940 gfx::Rect bounds = panel->GetBounds(); | 971 gfx::Rect bounds = panel->GetBounds(); |
| 941 gfx::Rect restored = panel->GetRestoredBounds(); | 972 gfx::Rect restored = panel->GetRestoredBounds(); |
| 942 EXPECT_EQ(bounds.x(), restored.x()); | 973 EXPECT_EQ(bounds.x(), restored.x()); |
| 943 EXPECT_GT(bounds.y(), restored.y()); | 974 EXPECT_GT(bounds.y(), restored.y()); |
| 944 EXPECT_EQ(bounds.width(), restored.width()); | 975 EXPECT_EQ(bounds.width(), restored.width()); |
| 945 EXPECT_LT(bounds.height(), restored.height()); | 976 EXPECT_LT(bounds.height(), restored.height()); |
| 946 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 947 | 977 |
| 948 panel->SetExpansionState(Panel::TITLE_ONLY); | 978 panel->SetExpansionState(Panel::TITLE_ONLY); |
| 949 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 979 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| 950 bounds = panel->GetBounds(); | 980 bounds = panel->GetBounds(); |
| 951 restored = panel->GetRestoredBounds(); | 981 restored = panel->GetRestoredBounds(); |
| 952 EXPECT_EQ(bounds.x(), restored.x()); | 982 EXPECT_EQ(bounds.x(), restored.x()); |
| 953 EXPECT_GT(bounds.y(), restored.y()); | 983 EXPECT_GT(bounds.y(), restored.y()); |
| 954 EXPECT_EQ(bounds.width(), restored.width()); | 984 EXPECT_EQ(bounds.width(), restored.width()); |
| 955 EXPECT_LT(bounds.height(), restored.height()); | 985 EXPECT_LT(bounds.height(), restored.height()); |
| 956 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 957 | 986 |
| 958 panel->SetExpansionState(Panel::MINIMIZED); | 987 panel->SetExpansionState(Panel::MINIMIZED); |
| 959 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 988 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| 960 bounds = panel->GetBounds(); | 989 bounds = panel->GetBounds(); |
| 961 restored = panel->GetRestoredBounds(); | 990 restored = panel->GetRestoredBounds(); |
| 962 EXPECT_EQ(bounds.x(), restored.x()); | 991 EXPECT_EQ(bounds.x(), restored.x()); |
| 963 EXPECT_GT(bounds.y(), restored.y()); | 992 EXPECT_GT(bounds.y(), restored.y()); |
| 964 EXPECT_EQ(bounds.width(), restored.width()); | 993 EXPECT_EQ(bounds.width(), restored.width()); |
| 965 EXPECT_LT(bounds.height(), restored.height()); | 994 EXPECT_LT(bounds.height(), restored.height()); |
| 966 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 967 | 995 |
| 968 panel->SetExpansionState(Panel::EXPANDED); | 996 panel->SetExpansionState(Panel::EXPANDED); |
| 969 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 997 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
| 970 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | |
| 971 | 998 |
| 972 // Verify that changing the panel bounds only affects restored height | 999 // Verify that changing the panel bounds only affects restored height |
| 973 // when panel is expanded. | 1000 // when panel is expanded. |
| 974 int saved_restored_height = restored.height(); | 1001 int saved_restored_height = restored.height(); |
| 975 panel->SetExpansionState(Panel::MINIMIZED); | 1002 panel->SetExpansionState(Panel::MINIMIZED); |
| 976 bounds = gfx::Rect(10, 20, 300, 400); | 1003 bounds = gfx::Rect(10, 20, 300, 400); |
| 977 panel->SetPanelBounds(bounds); | 1004 panel->SetPanelBounds(bounds); |
| 978 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 1005 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
| 979 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 980 | 1006 |
| 981 panel->SetExpansionState(Panel::TITLE_ONLY); | 1007 panel->SetExpansionState(Panel::TITLE_ONLY); |
| 982 bounds = gfx::Rect(20, 30, 100, 200); | 1008 bounds = gfx::Rect(20, 30, 100, 200); |
| 983 panel->SetPanelBounds(bounds); | 1009 panel->SetPanelBounds(bounds); |
| 984 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 1010 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
| 985 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | |
| 986 | 1011 |
| 987 panel->SetExpansionState(Panel::EXPANDED); | 1012 panel->SetExpansionState(Panel::EXPANDED); |
| 988 bounds = gfx::Rect(40, 60, 300, 400); | 1013 bounds = gfx::Rect(40, 60, 300, 400); |
| 989 panel->SetPanelBounds(bounds); | 1014 panel->SetPanelBounds(bounds); |
| 990 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); | 1015 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); |
| 991 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | |
| 992 | 1016 |
| 993 panel->Close(); | 1017 panel->Close(); |
| 994 } | 1018 } |
| 995 | 1019 |
| 996 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { | 1020 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { |
| 997 // We'll simulate mouse movements for test. | 1021 // We'll simulate mouse movements for test. |
| 998 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1022 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 999 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1023 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1000 | 1024 |
| 1001 // Test with one panel. | 1025 // Test with one panel. |
| 1002 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 1026 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 1003 TestMinimizeRestore(); | 1027 TestMinimizeRestore(); |
| 1004 | 1028 |
| 1005 PanelManager::GetInstance()->RemoveAll(); | 1029 PanelManager::GetInstance()->RemoveAll(); |
| 1006 } | 1030 } |
| 1007 | 1031 |
| 1008 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { | 1032 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { |
| 1009 // We'll simulate mouse movements for test. | 1033 // We'll simulate mouse movements for test. |
| 1010 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1034 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 1011 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1035 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1012 | 1036 |
| 1013 // Test with two panels. | 1037 // Test with two panels. |
| 1014 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 1038 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 1015 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 1039 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
| 1016 TestMinimizeRestore(); | 1040 TestMinimizeRestore(); |
| 1017 | 1041 |
| 1018 PanelManager::GetInstance()->RemoveAll(); | 1042 PanelManager::GetInstance()->RemoveAll(); |
| 1019 } | 1043 } |
| 1020 | 1044 |
| 1021 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { | 1045 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { |
| 1022 // We'll simulate mouse movements for test. | 1046 // We'll simulate mouse movements for test. |
| 1023 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1047 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 1024 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1048 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1025 | 1049 |
| 1026 // Test with three panels. | 1050 // Test with three panels. |
| 1027 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 1051 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 1028 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 1052 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
| 1029 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); | 1053 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); |
| 1030 TestMinimizeRestore(); | 1054 TestMinimizeRestore(); |
| 1031 | 1055 |
| 1032 PanelManager::GetInstance()->RemoveAll(); | 1056 PanelManager::GetInstance()->RemoveAll(); |
| 1033 } | 1057 } |
| 1034 | 1058 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1178 EXPECT_TRUE(panel->IsDrawingAttention()); | 1202 EXPECT_TRUE(panel->IsDrawingAttention()); |
| 1179 MessageLoop::current()->RunAllPending(); | 1203 MessageLoop::current()->RunAllPending(); |
| 1180 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1204 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
| 1181 | 1205 |
| 1182 panel->Close(); | 1206 panel->Close(); |
| 1183 } | 1207 } |
| 1184 | 1208 |
| 1185 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { | 1209 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { |
| 1186 // We'll simulate mouse movements for test. | 1210 // We'll simulate mouse movements for test. |
| 1187 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1211 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| 1188 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 1212 PanelManager::GetInstance()->SetMouseWatcher(mouse_watcher); |
| 1189 | 1213 |
| 1190 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1214 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
| 1191 Panel* panel = CreatePanelWithParams(params); | 1215 Panel* panel = CreatePanelWithParams(params); |
| 1192 NativePanel* native_panel = panel->native_panel(); | 1216 NativePanel* native_panel = panel->native_panel(); |
| 1193 scoped_ptr<NativePanelTesting> native_panel_testing( | 1217 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1194 NativePanelTesting::Create(native_panel)); | 1218 NativePanelTesting::Create(native_panel)); |
| 1195 | 1219 |
| 1196 // Test that the attention is drawn and the title-bar is brought up when the | 1220 // Test that the attention is drawn and the title-bar is brought up when the |
| 1197 // minimized panel is drawing attention. | 1221 // minimized panel is drawing attention. |
| 1198 panel->SetExpansionState(Panel::MINIMIZED); | 1222 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. | 1983 // position when tall panel brings up its titlebar. |
| 1960 CloseWindowAndWait(panel1->browser()); | 1984 CloseWindowAndWait(panel1->browser()); |
| 1961 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1985 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
| 1962 GetBalloonBottomPosition(balloon)); | 1986 GetBalloonBottomPosition(balloon)); |
| 1963 | 1987 |
| 1964 // Closing the remaining tall panel should move the notification balloon back | 1988 // Closing the remaining tall panel should move the notification balloon back |
| 1965 // to its original position. | 1989 // to its original position. |
| 1966 CloseWindowAndWait(panel2->browser()); | 1990 CloseWindowAndWait(panel2->browser()); |
| 1967 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1991 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
| 1968 } | 1992 } |
| OLD | NEW |