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/shelf/shelf_view.h" | 5 #include "ash/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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Make sure creating/deleting an window on one displays notifies a | 188 // Make sure creating/deleting an window on one displays notifies a |
189 // shelf on external display as well as one on primary. | 189 // shelf on external display as well as one on primary. |
190 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) { | 190 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) { |
191 // TODO: investigate failure in mash, http://crbug.com/695751. | 191 // TODO: investigate failure in mash, http://crbug.com/695751. |
192 if (Shell::GetAshConfig() == Config::MASH) | 192 if (Shell::GetAshConfig() == Config::MASH) |
193 return; | 193 return; |
194 | 194 |
195 UpdateDisplay("400x400,400x400"); | 195 UpdateDisplay("400x400,400x400"); |
196 observer()->Reset(); | 196 observer()->Reset(); |
197 | 197 |
198 WmWindow* second_root = ShellPort::Get()->GetAllRootWindows()[1]; | 198 WmShelf* second_shelf = WmShelf::ForWindow(Shell::GetAllRootWindows()[1]); |
199 WmShelf* second_shelf = second_root->GetRootWindowController()->GetShelf(); | |
200 TestWmShelfObserver second_observer(second_shelf); | 199 TestWmShelfObserver second_observer(second_shelf); |
201 | 200 |
202 ShelfItem item; | 201 ShelfItem item; |
203 item.id = ShelfID("foo"); | 202 item.id = ShelfID("foo"); |
204 item.type = TYPE_APP; | 203 item.type = TYPE_APP; |
205 EXPECT_FALSE(observer()->icon_positions_changed()); | 204 EXPECT_FALSE(observer()->icon_positions_changed()); |
206 EXPECT_FALSE(second_observer.icon_positions_changed()); | 205 EXPECT_FALSE(second_observer.icon_positions_changed()); |
207 const int shelf_item_index = Shell::Get()->shelf_model()->Add(item); | 206 const int shelf_item_index = Shell::Get()->shelf_model()->Add(item); |
208 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 207 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
209 EXPECT_TRUE(observer()->icon_positions_changed()); | 208 EXPECT_TRUE(observer()->icon_positions_changed()); |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 test_for_overflow_view.GetBoundsForDragInsertInScreen(); | 1634 test_for_overflow_view.GetBoundsForDragInsertInScreen(); |
1636 first_point = first_button->GetBoundsInScreen().CenterPoint(); | 1635 first_point = first_button->GetBoundsInScreen().CenterPoint(); |
1637 last_point = last_button->GetBoundsInScreen().CenterPoint(); | 1636 last_point = last_button->GetBoundsInScreen().CenterPoint(); |
1638 EXPECT_FALSE(drag_reinsert_bounds.Contains(first_point)); | 1637 EXPECT_FALSE(drag_reinsert_bounds.Contains(first_point)); |
1639 EXPECT_TRUE(drag_reinsert_bounds.Contains(last_point)); | 1638 EXPECT_TRUE(drag_reinsert_bounds.Contains(last_point)); |
1640 } | 1639 } |
1641 | 1640 |
1642 // Check the drag insertion bounds of shelf view in multi monitor environment. | 1641 // Check the drag insertion bounds of shelf view in multi monitor environment. |
1643 TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { | 1642 TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { |
1644 UpdateDisplay("800x600,800x600"); | 1643 UpdateDisplay("800x600,800x600"); |
1645 WmShelf* secondary_shelf = | 1644 WmShelf* secondary_shelf = WmShelf::ForWindow(Shell::GetAllRootWindows()[1]); |
1646 WmShelf::ForWindow(ShellPort::Get()->GetAllRootWindows()[1]); | |
1647 ShelfView* shelf_view_for_secondary = | 1645 ShelfView* shelf_view_for_secondary = |
1648 secondary_shelf->GetShelfViewForTesting(); | 1646 secondary_shelf->GetShelfViewForTesting(); |
1649 | 1647 |
1650 // The bounds should be big enough for 4 buttons + overflow chevron. | 1648 // The bounds should be big enough for 4 buttons + overflow chevron. |
1651 shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); | 1649 shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); |
1652 | 1650 |
1653 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); | 1651 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); |
1654 // Speeds up animation for test. | 1652 // Speeds up animation for test. |
1655 test_api_for_secondary.SetAnimationDuration(1); | 1653 test_api_for_secondary.SetAnimationDuration(1); |
1656 | 1654 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 // Checks that a point of overflow bubble in primary shelf should not be | 1699 // Checks that a point of overflow bubble in primary shelf should not be |
1702 // contained by insert bounds of secondary shelf. | 1700 // contained by insert bounds of secondary shelf. |
1703 EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view)); | 1701 EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view)); |
1704 } | 1702 } |
1705 | 1703 |
1706 // Checks the rip an item off from left aligned shelf in secondary monitor. | 1704 // Checks the rip an item off from left aligned shelf in secondary monitor. |
1707 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { | 1705 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { |
1708 UpdateDisplay("800x600,800x600"); | 1706 UpdateDisplay("800x600,800x600"); |
1709 ASSERT_EQ(2U, ShellPort::Get()->GetAllRootWindows().size()); | 1707 ASSERT_EQ(2U, ShellPort::Get()->GetAllRootWindows().size()); |
1710 | 1708 |
1711 WmWindow* second_root = ShellPort::Get()->GetAllRootWindows()[1]; | 1709 WmShelf* secondary_shelf = WmShelf::ForWindow(Shell::GetAllRootWindows()[1]); |
1712 WmShelf* secondary_shelf = second_root->GetRootWindowController()->GetShelf(); | |
1713 | 1710 |
1714 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1711 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
1715 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); | 1712 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); |
1716 | 1713 |
1717 // Initially, app list and browser shortcut are added. | 1714 // Initially, app list and browser shortcut are added. |
1718 EXPECT_EQ(2, model_->item_count()); | 1715 EXPECT_EQ(2, model_->item_count()); |
1719 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); | 1716 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); |
1720 EXPECT_GT(browser_index, 0); | 1717 EXPECT_GT(browser_index, 0); |
1721 | 1718 |
1722 ShelfView* shelf_view_for_secondary = | 1719 ShelfView* shelf_view_for_secondary = |
1723 secondary_shelf->GetShelfViewForTesting(); | 1720 secondary_shelf->GetShelfViewForTesting(); |
1724 | 1721 |
1725 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); | 1722 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); |
1726 ShelfButton* button = | 1723 ShelfButton* button = |
1727 test_api_for_secondary_shelf_view.GetButton(browser_index); | 1724 test_api_for_secondary_shelf_view.GetButton(browser_index); |
1728 | 1725 |
1729 // Fetch the start point of dragging. | 1726 // Fetch the start point of dragging. |
1730 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); | 1727 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); |
1731 start_point = second_root->ConvertPointFromScreen(start_point); | 1728 start_point = |
| 1729 secondary_shelf->GetWindow()->ConvertPointFromScreen(start_point); |
1732 | 1730 |
1733 ui::test::EventGenerator generator(Shell::GetAllRootWindows()[1], | 1731 ui::test::EventGenerator generator(Shell::GetAllRootWindows()[1], |
1734 start_point); | 1732 start_point); |
1735 | 1733 |
1736 // Rip off the browser item. | 1734 // Rip off the browser item. |
1737 generator.PressLeftButton(); | 1735 generator.PressLeftButton(); |
1738 generator.MoveMouseTo(start_point.x() + 400, start_point.y()); | 1736 generator.MoveMouseTo(start_point.x() + 400, start_point.y()); |
1739 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone(); | 1737 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone(); |
1740 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf()); | 1738 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf()); |
1741 } | 1739 } |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3124 EXPECT_EQ(views::InkDropState::ACTIVATED, |
3127 overflow_button_ink_drop_->GetTargetInkDropState()); | 3125 overflow_button_ink_drop_->GetTargetInkDropState()); |
3128 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3126 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
3129 IsEmpty()); | 3127 IsEmpty()); |
3130 | 3128 |
3131 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3129 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
3132 } | 3130 } |
3133 | 3131 |
3134 } // namespace test | 3132 } // namespace test |
3135 } // namespace ash | 3133 } // namespace ash |
OLD | NEW |