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> |
11 | 11 |
| 12 #include "ash/common/shelf/app_list_button.h" |
12 #include "ash/common/shelf/overflow_bubble.h" | 13 #include "ash/common/shelf/overflow_bubble.h" |
13 #include "ash/common/shelf/overflow_bubble_view.h" | 14 #include "ash/common/shelf/overflow_bubble_view.h" |
14 #include "ash/common/shelf/shelf_constants.h" | 15 #include "ash/common/shelf/shelf_constants.h" |
15 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 16 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
16 #include "ash/common/shelf/shelf_menu_model.h" | 17 #include "ash/common/shelf/shelf_menu_model.h" |
17 #include "ash/common/shelf/shelf_model.h" | 18 #include "ash/common/shelf/shelf_model.h" |
18 #include "ash/common/shell_window_ids.h" | 19 #include "ash/common/shell_window_ids.h" |
| 20 #include "ash/common/wm_shell.h" |
19 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
20 #include "ash/shelf/app_list_button.h" | |
21 #include "ash/shelf/shelf.h" | 22 #include "ash/shelf/shelf.h" |
22 #include "ash/shelf/shelf_button.h" | 23 #include "ash/shelf/shelf_button.h" |
23 #include "ash/shelf/shelf_icon_observer.h" | 24 #include "ash/shelf/shelf_icon_observer.h" |
24 #include "ash/shelf/shelf_tooltip_manager.h" | 25 #include "ash/shelf/shelf_tooltip_manager.h" |
25 #include "ash/shelf/shelf_widget.h" | 26 #include "ash/shelf/shelf_widget.h" |
26 #include "ash/shell.h" | 27 #include "ash/shell.h" |
27 #include "ash/test/ash_test_base.h" | 28 #include "ash/test/ash_test_base.h" |
28 #include "ash/test/ash_test_helper.h" | 29 #include "ash/test/ash_test_helper.h" |
29 #include "ash/test/material_design_controller_test_api.h" | 30 #include "ash/test/material_design_controller_test_api.h" |
30 #include "ash/test/overflow_bubble_view_test_api.h" | 31 #include "ash/test/overflow_bubble_view_test_api.h" |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 gfx::Point(all_area.right(), all_area.y()))); | 1487 gfx::Point(all_area.right(), all_area.y()))); |
1487 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1488 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1488 gfx::Point(all_area.x() - 1, all_area.y()))); | 1489 gfx::Point(all_area.x() - 1, all_area.y()))); |
1489 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1490 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1490 gfx::Point(all_area.x(), all_area.y() - 1))); | 1491 gfx::Point(all_area.x(), all_area.y() - 1))); |
1491 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1492 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1492 gfx::Point(all_area.x(), all_area.bottom()))); | 1493 gfx::Point(all_area.x(), all_area.bottom()))); |
1493 } | 1494 } |
1494 | 1495 |
1495 TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { | 1496 TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { |
1496 Shell::GetInstance()->ShowAppList(NULL); | 1497 WmShell::Get()->ShowAppList(); |
1497 ASSERT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1498 ASSERT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
1498 | 1499 |
1499 // The tooltip shouldn't hide if the mouse is on normal buttons. | 1500 // The tooltip shouldn't hide if the mouse is on normal buttons. |
1500 for (int i = 1; i < test_api_->GetButtonCount(); i++) { | 1501 for (int i = 1; i < test_api_->GetButtonCount(); i++) { |
1501 ShelfButton* button = test_api_->GetButton(i); | 1502 ShelfButton* button = test_api_->GetButton(i); |
1502 if (!button) | 1503 if (!button) |
1503 continue; | 1504 continue; |
1504 | 1505 |
1505 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( | 1506 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
1506 button->GetMirroredBounds().CenterPoint())) | 1507 button->GetMirroredBounds().CenterPoint())) |
1507 << "ShelfView tries to hide on button " << i; | 1508 << "ShelfView tries to hide on button " << i; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1839 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1839 | 1840 |
1840 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1841 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1841 generator.set_current_location( | 1842 generator.set_current_location( |
1842 app_list_button->GetBoundsInScreen().CenterPoint()); | 1843 app_list_button->GetBoundsInScreen().CenterPoint()); |
1843 generator.PressTouch(); | 1844 generator.PressTouch(); |
1844 EXPECT_TRUE(app_list_button->draw_background_as_active()); | 1845 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
1845 | 1846 |
1846 generator.ReleaseTouch(); | 1847 generator.ReleaseTouch(); |
1847 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1848 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1848 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1849 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
1849 } | 1850 } |
1850 | 1851 |
1851 // Tests that a touch that slides out of the bounds of the AppListButton leads | 1852 // Tests that a touch that slides out of the bounds of the AppListButton leads |
1852 // to the end of rendering an active state. | 1853 // to the end of rendering an active state. |
1853 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { | 1854 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { |
1854 AppListButton* app_list_button = shelf_view_->GetAppListButton(); | 1855 AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
1855 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1856 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1856 | 1857 |
1857 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1858 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1858 generator.set_current_location( | 1859 generator.set_current_location( |
1859 app_list_button->GetBoundsInScreen().CenterPoint()); | 1860 app_list_button->GetBoundsInScreen().CenterPoint()); |
1860 generator.PressTouch(); | 1861 generator.PressTouch(); |
1861 EXPECT_TRUE(app_list_button->draw_background_as_active()); | 1862 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
1862 | 1863 |
1863 gfx::Point moved_point( | 1864 gfx::Point moved_point( |
1864 app_list_button->GetBoundsInScreen().right() + 1, | 1865 app_list_button->GetBoundsInScreen().right() + 1, |
1865 app_list_button->GetBoundsInScreen().CenterPoint().y()); | 1866 app_list_button->GetBoundsInScreen().CenterPoint().y()); |
1866 generator.MoveTouch(moved_point); | 1867 generator.MoveTouch(moved_point); |
1867 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1868 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1868 | 1869 |
1869 generator.set_current_location(moved_point); | 1870 generator.set_current_location(moved_point); |
1870 generator.ReleaseTouch(); | 1871 generator.ReleaseTouch(); |
1871 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1872 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1872 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1873 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
1873 } | 1874 } |
1874 | 1875 |
1875 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an | 1876 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an |
1876 // item is selected. | 1877 // item is selected. |
1877 TEST_F(ShelfViewTest, | 1878 TEST_F(ShelfViewTest, |
1878 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { | 1879 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { |
1879 base::UserActionTester user_action_tester; | 1880 base::UserActionTester user_action_tester; |
1880 | 1881 |
1881 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1882 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1882 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1883 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 test_api_->CloseMenu(); | 2592 test_api_->CloseMenu(); |
2592 EXPECT_EQ(views::InkDropState::HIDDEN, | 2593 EXPECT_EQ(views::InkDropState::HIDDEN, |
2593 browser_button_ink_drop_->GetTargetInkDropState()); | 2594 browser_button_ink_drop_->GetTargetInkDropState()); |
2594 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | 2595 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2595 ElementsAre(views::InkDropState::ACTIVATED, | 2596 ElementsAre(views::InkDropState::ACTIVATED, |
2596 views::InkDropState::DEACTIVATED)); | 2597 views::InkDropState::DEACTIVATED)); |
2597 } | 2598 } |
2598 | 2599 |
2599 } // namespace test | 2600 } // namespace test |
2600 } // namespace ash | 2601 } // namespace ash |
OLD | NEW |