| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0); | 623 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0); |
| 624 generator.MoveMouseTo(rip_off_point); | 624 generator.MoveMouseTo(rip_off_point); |
| 625 test_api_for_overflow.RunMessageLoopUntilAnimationsDone(); | 625 test_api_for_overflow.RunMessageLoopUntilAnimationsDone(); |
| 626 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); | 626 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); |
| 627 ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf()); | 627 ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf()); |
| 628 | 628 |
| 629 // Move a dragged item into Shelf at |drop_index|. | 629 // Move a dragged item into Shelf at |drop_index|. |
| 630 int drop_index = 1; | 630 int drop_index = 1; |
| 631 gfx::Point drop_point = | 631 gfx::Point drop_point = |
| 632 test_api_->GetButton(drop_index)->GetBoundsInScreen().CenterPoint(); | 632 test_api_->GetButton(drop_index)->GetBoundsInScreen().CenterPoint(); |
| 633 int item_width = test_api_for_overflow.GetButtonSize(); | |
| 634 // To insert at |drop_index|, more smaller x-axis value of |drop_point| | 633 // To insert at |drop_index|, more smaller x-axis value of |drop_point| |
| 635 // should be used. | 634 // should be used. |
| 636 gfx::Point modified_drop_point(drop_point.x() - item_width / 4, | 635 gfx::Point modified_drop_point(drop_point.x() - kShelfButtonSize / 4, |
| 637 drop_point.y()); | 636 drop_point.y()); |
| 638 generator.MoveMouseTo(modified_drop_point); | 637 generator.MoveMouseTo(modified_drop_point); |
| 639 test_api_for_overflow.RunMessageLoopUntilAnimationsDone(); | 638 test_api_for_overflow.RunMessageLoopUntilAnimationsDone(); |
| 640 test_api_->RunMessageLoopUntilAnimationsDone(); | 639 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 641 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); | 640 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); |
| 642 ASSERT_TRUE(test_api_for_overflow.DraggedItemFromOverflowToShelf()); | 641 ASSERT_TRUE(test_api_for_overflow.DraggedItemFromOverflowToShelf()); |
| 643 | 642 |
| 644 if (cancel) | 643 if (cancel) |
| 645 drag_button->OnMouseCaptureLost(); | 644 drag_button->OnMouseCaptureLost(); |
| 646 else | 645 else |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 | 1588 |
| 1590 // Show overflow bubble. | 1589 // Show overflow bubble. |
| 1591 test_api_->ShowOverflowBubble(); | 1590 test_api_->ShowOverflowBubble(); |
| 1592 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 1591 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 1593 | 1592 |
| 1594 ShelfViewTestAPI test_for_overflow_view( | 1593 ShelfViewTestAPI test_for_overflow_view( |
| 1595 test_api_->overflow_bubble()->shelf_view()); | 1594 test_api_->overflow_bubble()->shelf_view()); |
| 1596 | 1595 |
| 1597 int ripped_index = test_for_overflow_view.GetLastVisibleIndex(); | 1596 int ripped_index = test_for_overflow_view.GetLastVisibleIndex(); |
| 1598 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize(); | 1597 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize(); |
| 1599 int item_width = test_for_overflow_view.GetButtonSize() + | 1598 int item_width = kShelfButtonSize + kShelfButtonSpacing; |
| 1600 test_for_overflow_view.GetButtonSpacing(); | |
| 1601 | 1599 |
| 1602 ui::test::EventGenerator& generator = GetEventGenerator(); | 1600 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1603 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); | 1601 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); |
| 1604 // Rip off the last visible item. | 1602 // Rip off the last visible item. |
| 1605 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); | 1603 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); |
| 1606 gfx::Point rip_off_point(start_point.x(), 0); | 1604 gfx::Point rip_off_point(start_point.x(), 0); |
| 1607 generator.MoveMouseTo(start_point.x(), start_point.y()); | 1605 generator.MoveMouseTo(start_point.x(), start_point.y()); |
| 1608 base::RunLoop().RunUntilIdle(); | 1606 base::RunLoop().RunUntilIdle(); |
| 1609 generator.PressLeftButton(); | 1607 generator.PressLeftButton(); |
| 1610 base::RunLoop().RunUntilIdle(); | 1608 base::RunLoop().RunUntilIdle(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 UpdateDisplay("400x300"); | 1640 UpdateDisplay("400x300"); |
| 1643 | 1641 |
| 1644 EXPECT_EQ(2, model_->item_count()); | 1642 EXPECT_EQ(2, model_->item_count()); |
| 1645 | 1643 |
| 1646 AddButtonsUntilOverflow(); | 1644 AddButtonsUntilOverflow(); |
| 1647 | 1645 |
| 1648 // Show overflow bubble. | 1646 // Show overflow bubble. |
| 1649 test_api_->ShowOverflowBubble(); | 1647 test_api_->ShowOverflowBubble(); |
| 1650 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 1648 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 1651 | 1649 |
| 1652 int item_width = test_api_->GetButtonSize() + test_api_->GetButtonSpacing(); | 1650 int item_width = kShelfButtonSize + kShelfButtonSpacing; |
| 1653 OverflowBubbleView* bubble_view = test_api_->overflow_bubble()->bubble_view(); | 1651 OverflowBubbleView* bubble_view = test_api_->overflow_bubble()->bubble_view(); |
| 1654 OverflowBubbleViewTestAPI bubble_view_api(bubble_view); | 1652 OverflowBubbleViewTestAPI bubble_view_api(bubble_view); |
| 1655 | 1653 |
| 1656 // Add more buttons until OverflowBubble is scrollable and it has 3 invisible | 1654 // Add more buttons until OverflowBubble is scrollable and it has 3 invisible |
| 1657 // items. | 1655 // items. |
| 1658 while (bubble_view_api.GetContentsSize().width() < | 1656 while (bubble_view_api.GetContentsSize().width() < |
| 1659 (bubble_view->GetContentsBounds().width() + 3 * item_width)) { | 1657 (bubble_view->GetContentsBounds().width() + 3 * item_width)) { |
| 1660 AddAppShortcut(); | 1658 AddAppShortcut(); |
| 1661 } | 1659 } |
| 1662 | 1660 |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3010 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3008 EXPECT_EQ(views::InkDropState::ACTIVATED, |
| 3011 overflow_button_ink_drop_->GetTargetInkDropState()); | 3009 overflow_button_ink_drop_->GetTargetInkDropState()); |
| 3012 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3010 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
| 3013 IsEmpty()); | 3011 IsEmpty()); |
| 3014 | 3012 |
| 3015 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3013 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 3016 } | 3014 } |
| 3017 | 3015 |
| 3018 } // namespace test | 3016 } // namespace test |
| 3019 } // namespace ash | 3017 } // namespace ash |
| OLD | NEW |