| 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> |
| 11 | 11 |
| 12 #include "ash/common/shelf/app_list_button.h" | 12 #include "ash/common/shelf/app_list_button.h" |
| 13 #include "ash/common/shelf/overflow_bubble.h" | 13 #include "ash/common/shelf/overflow_bubble.h" |
| 14 #include "ash/common/shelf/overflow_bubble_view.h" | 14 #include "ash/common/shelf/overflow_bubble_view.h" |
| 15 #include "ash/common/shelf/overflow_button.h" | 15 #include "ash/common/shelf/overflow_button.h" |
| 16 #include "ash/common/shelf/shelf_button.h" | 16 #include "ash/common/shelf/shelf_button.h" |
| 17 #include "ash/common/shelf/shelf_constants.h" | 17 #include "ash/common/shelf/shelf_constants.h" |
| 18 #include "ash/common/shelf/shelf_model.h" | 18 #include "ash/common/shelf/shelf_model.h" |
| 19 #include "ash/common/shelf/shelf_tooltip_manager.h" | 19 #include "ash/common/shelf/shelf_tooltip_manager.h" |
| 20 #include "ash/common/shelf/shelf_widget.h" | 20 #include "ash/common/shelf/shelf_widget.h" |
| 21 #include "ash/common/shelf/wm_shelf.h" | 21 #include "ash/common/shelf/wm_shelf.h" |
| 22 #include "ash/common/shelf/wm_shelf_observer.h" | 22 #include "ash/common/shelf/wm_shelf_observer.h" |
| 23 #include "ash/common/system/web_notification/web_notification_tray.h" | 23 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 24 #include "ash/common/test/material_design_controller_test_api.h" | |
| 25 #include "ash/common/test/test_shelf_delegate.h" | 24 #include "ash/common/test/test_shelf_delegate.h" |
| 26 #include "ash/common/test/test_shelf_item_delegate.h" | 25 #include "ash/common/test/test_shelf_item_delegate.h" |
| 27 #include "ash/common/test/test_system_tray_delegate.h" | 26 #include "ash/common/test/test_system_tray_delegate.h" |
| 28 #include "ash/common/wm_lookup.h" | 27 #include "ash/common/wm_lookup.h" |
| 29 #include "ash/common/wm_shell.h" | 28 #include "ash/common/wm_shell.h" |
| 30 #include "ash/common/wm_window.h" | 29 #include "ash/common/wm_window.h" |
| 31 #include "ash/public/cpp/shell_window_ids.h" | 30 #include "ash/public/cpp/shell_window_ids.h" |
| 32 #include "ash/root_window_controller.h" | 31 #include "ash/root_window_controller.h" |
| 33 #include "ash/shell.h" | 32 #include "ash/shell.h" |
| 34 #include "ash/test/ash_test_base.h" | 33 #include "ash/test/ash_test_base.h" |
| (...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 ShelfID platform_app_id = AddApp(); | 1798 ShelfID platform_app_id = AddApp(); |
| 1800 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); | 1799 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
| 1801 | 1800 |
| 1802 // Make the added running platform app to be an app shortcut. | 1801 // Make the added running platform app to be an app shortcut. |
| 1803 // This app shortcut should be a swapped view in overflow bubble, which is | 1802 // This app shortcut should be a swapped view in overflow bubble, which is |
| 1804 // invisible. | 1803 // invisible. |
| 1805 SetShelfItemTypeToAppShortcut(platform_app_id); | 1804 SetShelfItemTypeToAppShortcut(platform_app_id); |
| 1806 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); | 1805 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
| 1807 } | 1806 } |
| 1808 | 1807 |
| 1809 // Tests that the AppListButton renders as active in response to touches. | |
| 1810 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { | |
| 1811 // Touch feedback is not available in material mode. | |
| 1812 if (ash::MaterialDesignController::IsShelfMaterial()) | |
| 1813 return; | |
| 1814 | |
| 1815 AppListButton* app_list_button = shelf_view_->GetAppListButton(); | |
| 1816 EXPECT_FALSE(app_list_button->draw_background_as_active()); | |
| 1817 | |
| 1818 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1819 generator.set_current_location( | |
| 1820 app_list_button->GetBoundsInScreen().CenterPoint()); | |
| 1821 generator.PressTouch(); | |
| 1822 EXPECT_TRUE(app_list_button->draw_background_as_active()); | |
| 1823 | |
| 1824 generator.ReleaseTouch(); | |
| 1825 EXPECT_FALSE(app_list_button->draw_background_as_active()); | |
| 1826 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); | |
| 1827 } | |
| 1828 | |
| 1829 // Tests that a touch that slides out of the bounds of the AppListButton leads | |
| 1830 // to the end of rendering an active state. | |
| 1831 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { | |
| 1832 // Touch feedback is not available in material mode. | |
| 1833 if (ash::MaterialDesignController::IsShelfMaterial()) | |
| 1834 return; | |
| 1835 | |
| 1836 AppListButton* app_list_button = shelf_view_->GetAppListButton(); | |
| 1837 EXPECT_FALSE(app_list_button->draw_background_as_active()); | |
| 1838 | |
| 1839 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1840 generator.set_current_location( | |
| 1841 app_list_button->GetBoundsInScreen().CenterPoint()); | |
| 1842 generator.PressTouch(); | |
| 1843 EXPECT_TRUE(app_list_button->draw_background_as_active()); | |
| 1844 | |
| 1845 gfx::Point moved_point( | |
| 1846 app_list_button->GetBoundsInScreen().right() + 1, | |
| 1847 app_list_button->GetBoundsInScreen().CenterPoint().y()); | |
| 1848 generator.MoveTouch(moved_point); | |
| 1849 EXPECT_FALSE(app_list_button->draw_background_as_active()); | |
| 1850 | |
| 1851 generator.set_current_location(moved_point); | |
| 1852 generator.ReleaseTouch(); | |
| 1853 EXPECT_FALSE(app_list_button->draw_background_as_active()); | |
| 1854 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); | |
| 1855 } | |
| 1856 | |
| 1857 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an | 1808 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an |
| 1858 // item is selected. | 1809 // item is selected. |
| 1859 TEST_F(ShelfViewTest, | 1810 TEST_F(ShelfViewTest, |
| 1860 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { | 1811 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { |
| 1861 base::UserActionTester user_action_tester; | 1812 base::UserActionTester user_action_tester; |
| 1862 | 1813 |
| 1863 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1814 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
| 1864 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1815 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
| 1865 model_->SetShelfItemDelegate( | 1816 model_->SetShelfItemDelegate( |
| 1866 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1817 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(title)); | 1969 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(title)); |
| 2019 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(title)); | 1970 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(title)); |
| 2020 return items; | 1971 return items; |
| 2021 } | 1972 } |
| 2022 | 1973 |
| 2023 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); | 1974 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); |
| 2024 }; | 1975 }; |
| 2025 | 1976 |
| 2026 } // namespace | 1977 } // namespace |
| 2027 | 1978 |
| 2028 // Test fixture that forces material design mode in order to test ink drop | 1979 // Test fixture for testing material design ink drop ripples on shelf. |
| 2029 // ripples on shelf. | |
| 2030 class ShelfViewInkDropTest : public ShelfViewTest { | 1980 class ShelfViewInkDropTest : public ShelfViewTest { |
| 2031 public: | 1981 public: |
| 2032 ShelfViewInkDropTest() {} | 1982 ShelfViewInkDropTest() {} |
| 2033 ~ShelfViewInkDropTest() override {} | 1983 ~ShelfViewInkDropTest() override {} |
| 2034 | 1984 |
| 2035 void SetUp() override { | 1985 void SetUp() override { |
| 2036 ash_test_helper()->set_test_shell_delegate(CreateTestShellDelegate()); | 1986 ash_test_helper()->set_test_shell_delegate(CreateTestShellDelegate()); |
| 2037 | 1987 |
| 2038 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL); | |
| 2039 | |
| 2040 ShelfViewTest::SetUp(); | 1988 ShelfViewTest::SetUp(); |
| 2041 } | 1989 } |
| 2042 | 1990 |
| 2043 protected: | 1991 protected: |
| 2044 // Gives subclasses a chance to return a custom test shell delegate to install | 1992 // Gives subclasses a chance to return a custom test shell delegate to install |
| 2045 // before calling base class's SetUp(). Shell will take ownership of the | 1993 // before calling base class's SetUp(). Shell will take ownership of the |
| 2046 // returned object. | 1994 // returned object. |
| 2047 virtual TestShellDelegate* CreateTestShellDelegate() { | 1995 virtual TestShellDelegate* CreateTestShellDelegate() { |
| 2048 return new TestShellDelegate; | 1996 return new TestShellDelegate; |
| 2049 } | 1997 } |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3022 EXPECT_EQ(views::InkDropState::ACTIVATED, | 2970 EXPECT_EQ(views::InkDropState::ACTIVATED, |
| 3023 overflow_button_ink_drop_->GetTargetInkDropState()); | 2971 overflow_button_ink_drop_->GetTargetInkDropState()); |
| 3024 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 2972 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
| 3025 IsEmpty()); | 2973 IsEmpty()); |
| 3026 | 2974 |
| 3027 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 2975 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 3028 } | 2976 } |
| 3029 | 2977 |
| 3030 } // namespace test | 2978 } // namespace test |
| 3031 } // namespace ash | 2979 } // namespace ash |
| OLD | NEW |