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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shelf/app_list_button.h" |
12 #include "ash/shelf/overflow_bubble.h" | 13 #include "ash/shelf/overflow_bubble.h" |
13 #include "ash/shelf/overflow_bubble_view.h" | 14 #include "ash/shelf/overflow_bubble_view.h" |
14 #include "ash/shelf/shelf.h" | 15 #include "ash/shelf/shelf.h" |
15 #include "ash/shelf/shelf_button.h" | 16 #include "ash/shelf/shelf_button.h" |
16 #include "ash/shelf/shelf_constants.h" | 17 #include "ash/shelf/shelf_constants.h" |
17 #include "ash/shelf/shelf_icon_observer.h" | 18 #include "ash/shelf/shelf_icon_observer.h" |
18 #include "ash/shelf/shelf_item_delegate_manager.h" | 19 #include "ash/shelf/shelf_item_delegate_manager.h" |
19 #include "ash/shelf/shelf_layout_manager.h" | 20 #include "ash/shelf/shelf_layout_manager.h" |
20 #include "ash/shelf/shelf_model.h" | 21 #include "ash/shelf/shelf_model.h" |
21 #include "ash/shelf/shelf_tooltip_manager.h" | 22 #include "ash/shelf/shelf_tooltip_manager.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 class ShelfViewTest : public AshTestBase { | 289 class ShelfViewTest : public AshTestBase { |
289 public: | 290 public: |
290 ShelfViewTest() | 291 ShelfViewTest() |
291 : model_(NULL), | 292 : model_(NULL), |
292 shelf_view_(NULL), | 293 shelf_view_(NULL), |
293 browser_index_(1), | 294 browser_index_(1), |
294 item_manager_(NULL) {} | 295 item_manager_(NULL) {} |
295 virtual ~ShelfViewTest() {} | 296 virtual ~ShelfViewTest() {} |
296 | 297 |
297 virtual void SetUp() OVERRIDE { | 298 virtual void SetUp() OVERRIDE { |
| 299 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 300 switches::kAshEnableTouchViewTouchFeedback); |
298 AshTestBase::SetUp(); | 301 AshTestBase::SetUp(); |
299 test::ShellTestApi test_api(Shell::GetInstance()); | 302 test::ShellTestApi test_api(Shell::GetInstance()); |
300 model_ = test_api.shelf_model(); | 303 model_ = test_api.shelf_model(); |
301 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 304 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
302 shelf_view_ = ShelfTestAPI(shelf).shelf_view(); | 305 shelf_view_ = ShelfTestAPI(shelf).shelf_view(); |
303 | 306 |
304 // The bounds should be big enough for 4 buttons + overflow chevron. | 307 // The bounds should be big enough for 4 buttons + overflow chevron. |
305 shelf_view_->SetBounds(0, 0, 500, kShelfSize); | 308 shelf_view_->SetBounds(0, 0, 500, kShelfSize); |
306 | 309 |
307 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); | 310 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { | 1666 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { |
1664 // Replace current ShelfDelegate with TestShelfDelegateForShelfView. | 1667 // Replace current ShelfDelegate with TestShelfDelegateForShelfView. |
1665 ReplaceShelfDelegateForRipOffTest(); | 1668 ReplaceShelfDelegateForRipOffTest(); |
1666 | 1669 |
1667 AddButtonsUntilOverflow(); | 1670 AddButtonsUntilOverflow(); |
1668 | 1671 |
1669 TestDraggingAnItemFromOverflowToShelf(false); | 1672 TestDraggingAnItemFromOverflowToShelf(false); |
1670 TestDraggingAnItemFromOverflowToShelf(true); | 1673 TestDraggingAnItemFromOverflowToShelf(true); |
1671 } | 1674 } |
1672 | 1675 |
| 1676 // Tests that the AppListButton renders as active in response to touches. |
| 1677 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { |
| 1678 AppListButton* app_list_button = |
| 1679 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
| 1680 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
| 1681 |
| 1682 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1683 generator.set_current_location(app_list_button-> |
| 1684 GetBoundsInScreen().CenterPoint()); |
| 1685 generator.PressTouch(); |
| 1686 RunAllPendingInMessageLoop(); |
| 1687 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
| 1688 |
| 1689 generator.ReleaseTouch(); |
| 1690 RunAllPendingInMessageLoop(); |
| 1691 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
| 1692 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 1693 } |
| 1694 |
| 1695 // Tests that a touch that slides out of the bounds of the AppListButton leads |
| 1696 // to the end of rendering an active state. |
| 1697 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { |
| 1698 AppListButton* app_list_button = |
| 1699 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
| 1700 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
| 1701 |
| 1702 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1703 generator.set_current_location(app_list_button-> |
| 1704 GetBoundsInScreen().CenterPoint()); |
| 1705 generator.PressTouch(); |
| 1706 RunAllPendingInMessageLoop(); |
| 1707 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
| 1708 |
| 1709 gfx::Point moved_point(app_list_button->GetBoundsInScreen().right() + 1, |
| 1710 app_list_button-> |
| 1711 GetBoundsInScreen().CenterPoint().y()); |
| 1712 generator.MoveTouch(moved_point); |
| 1713 RunAllPendingInMessageLoop(); |
| 1714 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
| 1715 |
| 1716 generator.set_current_location(moved_point); |
| 1717 generator.ReleaseTouch(); |
| 1718 RunAllPendingInMessageLoop(); |
| 1719 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
| 1720 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 1721 } |
| 1722 |
1673 class ShelfViewVisibleBoundsTest : public ShelfViewTest, | 1723 class ShelfViewVisibleBoundsTest : public ShelfViewTest, |
1674 public testing::WithParamInterface<bool> { | 1724 public testing::WithParamInterface<bool> { |
1675 public: | 1725 public: |
1676 ShelfViewVisibleBoundsTest() : text_direction_change_(GetParam()) {} | 1726 ShelfViewVisibleBoundsTest() : text_direction_change_(GetParam()) {} |
1677 | 1727 |
1678 void CheckAllItemsAreInBounds() { | 1728 void CheckAllItemsAreInBounds() { |
1679 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); | 1729 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); |
1680 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); | 1730 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); |
1681 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); | 1731 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); |
1682 for (int i = 0; i < test_api_->GetButtonCount(); ++i) | 1732 for (int i = 0; i < test_api_->GetButtonCount(); ++i) |
(...skipping 30 matching lines...) Expand all Loading... |
1713 test_api_->RunMessageLoopUntilAnimationsDone(); | 1763 test_api_->RunMessageLoopUntilAnimationsDone(); |
1714 CheckAllItemsAreInBounds(); | 1764 CheckAllItemsAreInBounds(); |
1715 } | 1765 } |
1716 | 1766 |
1717 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1767 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
1718 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1768 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
1719 testing::Bool()); | 1769 testing::Bool()); |
1720 | 1770 |
1721 } // namespace test | 1771 } // namespace test |
1722 } // namespace ash | 1772 } // namespace ash |
OLD | NEW |