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 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 ShelfButton* button = test_api_->GetButton(i); | 1475 ShelfButton* button = test_api_->GetButton(i); |
1476 if (!button) | 1476 if (!button) |
1477 continue; | 1477 continue; |
1478 | 1478 |
1479 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( | 1479 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
1480 button->GetMirroredBounds().CenterPoint())) | 1480 button->GetMirroredBounds().CenterPoint())) |
1481 << "ShelfView tries to hide on button " << i; | 1481 << "ShelfView tries to hide on button " << i; |
1482 } | 1482 } |
1483 | 1483 |
1484 // The tooltip should not hide on the app-list button. | 1484 // The tooltip should not hide on the app-list button. |
1485 views::View* app_list_button = shelf_view_->GetAppListButtonView(); | 1485 AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
1486 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( | 1486 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
1487 app_list_button->GetMirroredBounds().CenterPoint())); | 1487 app_list_button->GetMirroredBounds().CenterPoint())); |
1488 | 1488 |
1489 // The tooltip shouldn't hide if the mouse is in the gap between two buttons. | 1489 // The tooltip shouldn't hide if the mouse is in the gap between two buttons. |
1490 gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds(); | 1490 gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds(); |
1491 gfx::Rect platform_button_rect = | 1491 gfx::Rect platform_button_rect = |
1492 GetButtonByID(platform_button_id)->GetMirroredBounds(); | 1492 GetButtonByID(platform_button_id)->GetMirroredBounds(); |
1493 ASSERT_FALSE(app_button_rect.Intersects(platform_button_rect)); | 1493 ASSERT_FALSE(app_button_rect.Intersects(platform_button_rect)); |
1494 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( | 1494 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
1495 gfx::UnionRects(app_button_rect, platform_button_rect).CenterPoint())); | 1495 gfx::UnionRects(app_button_rect, platform_button_rect).CenterPoint())); |
1496 | 1496 |
1497 // The tooltip should hide if it's outside of all buttons. | 1497 // The tooltip should hide if it's outside of all buttons. |
1498 gfx::Rect all_area; | 1498 gfx::Rect all_area; |
1499 for (int i = 0; i < test_api_->GetButtonCount(); i++) { | 1499 for (int i = 0; i < test_api_->GetButtonCount(); i++) { |
1500 ShelfButton* button = test_api_->GetButton(i); | 1500 ShelfButton* button = test_api_->GetButton(i); |
1501 if (!button) | 1501 if (!button) |
1502 continue; | 1502 continue; |
1503 | 1503 |
1504 all_area.Union(button->GetMirroredBounds()); | 1504 all_area.Union(button->GetMirroredBounds()); |
1505 } | 1505 } |
1506 all_area.Union(shelf_view_->GetAppListButtonView()->GetMirroredBounds()); | 1506 all_area.Union(shelf_view_->GetAppListButton()->GetMirroredBounds()); |
1507 EXPECT_FALSE(shelf_view_->ShouldHideTooltip(all_area.origin())); | 1507 EXPECT_FALSE(shelf_view_->ShouldHideTooltip(all_area.origin())); |
1508 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( | 1508 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
1509 gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); | 1509 gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); |
1510 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1510 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1511 gfx::Point(all_area.right(), all_area.y()))); | 1511 gfx::Point(all_area.right(), all_area.y()))); |
1512 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1512 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1513 gfx::Point(all_area.x() - 1, all_area.y()))); | 1513 gfx::Point(all_area.x() - 1, all_area.y()))); |
1514 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1514 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1515 gfx::Point(all_area.x(), all_area.y() - 1))); | 1515 gfx::Point(all_area.x(), all_area.y() - 1))); |
1516 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1516 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1517 gfx::Point(all_area.x(), all_area.bottom()))); | 1517 gfx::Point(all_area.x(), all_area.bottom()))); |
1518 } | 1518 } |
1519 | 1519 |
1520 TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { | 1520 TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { |
1521 Shell::GetInstance()->ShowAppList(NULL); | 1521 Shell::GetInstance()->ShowAppList(NULL); |
1522 ASSERT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1522 ASSERT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
1523 | 1523 |
1524 // The tooltip shouldn't hide if the mouse is on normal buttons. | 1524 // The tooltip shouldn't hide if the mouse is on normal buttons. |
1525 for (int i = 1; i < test_api_->GetButtonCount(); i++) { | 1525 for (int i = 1; i < test_api_->GetButtonCount(); i++) { |
1526 ShelfButton* button = test_api_->GetButton(i); | 1526 ShelfButton* button = test_api_->GetButton(i); |
1527 if (!button) | 1527 if (!button) |
1528 continue; | 1528 continue; |
1529 | 1529 |
1530 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( | 1530 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
1531 button->GetMirroredBounds().CenterPoint())) | 1531 button->GetMirroredBounds().CenterPoint())) |
1532 << "ShelfView tries to hide on button " << i; | 1532 << "ShelfView tries to hide on button " << i; |
1533 } | 1533 } |
1534 | 1534 |
1535 // The tooltip should hide on the app-list button. | 1535 // The tooltip should hide on the app-list button. |
1536 views::View* app_list_button = shelf_view_->GetAppListButtonView(); | 1536 AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
1537 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( | 1537 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
1538 app_list_button->GetMirroredBounds().CenterPoint())); | 1538 app_list_button->GetMirroredBounds().CenterPoint())); |
1539 } | 1539 } |
1540 | 1540 |
1541 // Test that by moving the mouse cursor off the button onto the bubble it closes | 1541 // Test that by moving the mouse cursor off the button onto the bubble it closes |
1542 // the bubble. | 1542 // the bubble. |
1543 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { | 1543 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { |
1544 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); | 1544 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); |
1545 tooltip_manager->set_timer_delay_for_test(0); | 1545 tooltip_manager->set_timer_delay_for_test(0); |
1546 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1546 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1547 | 1547 |
1548 // Move the mouse off any item and check that no tooltip is shown. | 1548 // Move the mouse off any item and check that no tooltip is shown. |
1549 generator.MoveMouseTo(gfx::Point(0, 0)); | 1549 generator.MoveMouseTo(gfx::Point(0, 0)); |
1550 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1550 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1551 | 1551 |
1552 // Move the mouse over the button and check that it is visible. | 1552 // Move the mouse over the button and check that it is visible. |
1553 views::View* app_list_button = shelf_view_->GetAppListButtonView(); | 1553 AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
1554 gfx::Rect bounds = app_list_button->GetBoundsInScreen(); | 1554 gfx::Rect bounds = app_list_button->GetBoundsInScreen(); |
1555 generator.MoveMouseTo(bounds.CenterPoint()); | 1555 generator.MoveMouseTo(bounds.CenterPoint()); |
1556 // Wait for the timer to go off. | 1556 // Wait for the timer to go off. |
1557 RunAllPendingInMessageLoop(); | 1557 RunAllPendingInMessageLoop(); |
1558 EXPECT_TRUE(tooltip_manager->IsVisible()); | 1558 EXPECT_TRUE(tooltip_manager->IsVisible()); |
1559 | 1559 |
1560 // Move the mouse cursor slightly to the right of the item. The tooltip should | 1560 // Move the mouse cursor slightly to the right of the item. The tooltip should |
1561 // stay open. | 1561 // stay open. |
1562 generator.MoveMouseBy(bounds.width() / 2 + 5, 0); | 1562 generator.MoveMouseBy(bounds.width() / 2 + 5, 0); |
1563 // Make sure there is no delayed close. | 1563 // Make sure there is no delayed close. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1853 | 1853 |
1854 // Make the added running platform app to be an app shortcut. | 1854 // Make the added running platform app to be an app shortcut. |
1855 // This app shortcut should be a swapped view in overflow bubble, which is | 1855 // This app shortcut should be a swapped view in overflow bubble, which is |
1856 // invisible. | 1856 // invisible. |
1857 SetShelfItemTypeToAppShortcut(platform_app_id); | 1857 SetShelfItemTypeToAppShortcut(platform_app_id); |
1858 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); | 1858 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
1859 } | 1859 } |
1860 | 1860 |
1861 // Tests that the AppListButton renders as active in response to touches. | 1861 // Tests that the AppListButton renders as active in response to touches. |
1862 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { | 1862 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { |
1863 AppListButton* app_list_button = | 1863 AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
1864 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); | |
1865 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1864 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1866 | 1865 |
1867 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1866 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1868 generator.set_current_location(app_list_button-> | 1867 generator.set_current_location(app_list_button-> |
1869 GetBoundsInScreen().CenterPoint()); | 1868 GetBoundsInScreen().CenterPoint()); |
1870 generator.PressTouch(); | 1869 generator.PressTouch(); |
1871 EXPECT_TRUE(app_list_button->draw_background_as_active()); | 1870 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
1872 | 1871 |
1873 generator.ReleaseTouch(); | 1872 generator.ReleaseTouch(); |
1874 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1873 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1875 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1874 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
1876 } | 1875 } |
1877 | 1876 |
1878 // Tests that a touch that slides out of the bounds of the AppListButton leads | 1877 // Tests that a touch that slides out of the bounds of the AppListButton leads |
1879 // to the end of rendering an active state. | 1878 // to the end of rendering an active state. |
1880 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { | 1879 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { |
1881 AppListButton* app_list_button = | 1880 AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
1882 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); | |
1883 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1881 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1884 | 1882 |
1885 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1883 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1886 generator.set_current_location(app_list_button-> | 1884 generator.set_current_location(app_list_button-> |
1887 GetBoundsInScreen().CenterPoint()); | 1885 GetBoundsInScreen().CenterPoint()); |
1888 generator.PressTouch(); | 1886 generator.PressTouch(); |
1889 EXPECT_TRUE(app_list_button->draw_background_as_active()); | 1887 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
1890 | 1888 |
1891 gfx::Point moved_point(app_list_button->GetBoundsInScreen().right() + 1, | 1889 gfx::Point moved_point(app_list_button->GetBoundsInScreen().right() + 1, |
1892 app_list_button-> | 1890 app_list_button-> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1971 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); | 1969 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); |
1972 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); | 1970 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); |
1973 for (int i = 0; i < test_api_->GetButtonCount(); ++i) | 1971 for (int i = 0; i < test_api_->GetButtonCount(); ++i) |
1974 if (ShelfButton* button = test_api_->GetButton(i)) | 1972 if (ShelfButton* button = test_api_->GetButton(i)) |
1975 EXPECT_TRUE(visible_bounds.Contains(button->GetBoundsInScreen())); | 1973 EXPECT_TRUE(visible_bounds.Contains(button->GetBoundsInScreen())); |
1976 CheckAppListButtonIsInBounds(); | 1974 CheckAppListButtonIsInBounds(); |
1977 } | 1975 } |
1978 | 1976 |
1979 void CheckAppListButtonIsInBounds() { | 1977 void CheckAppListButtonIsInBounds() { |
1980 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); | 1978 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); |
1981 gfx::Rect app_list_button_bounds = shelf_view_->GetAppListButtonView()-> | 1979 gfx::Rect app_list_button_bounds = |
1982 GetBoundsInScreen(); | 1980 shelf_view_->GetAppListButton()->GetBoundsInScreen(); |
1983 EXPECT_TRUE(visible_bounds.Contains(app_list_button_bounds)); | 1981 EXPECT_TRUE(visible_bounds.Contains(app_list_button_bounds)); |
1984 } | 1982 } |
1985 | 1983 |
1986 private: | 1984 private: |
1987 ScopedTextDirectionChange text_direction_change_; | 1985 ScopedTextDirectionChange text_direction_change_; |
1988 | 1986 |
1989 DISALLOW_COPY_AND_ASSIGN(ShelfViewVisibleBoundsTest); | 1987 DISALLOW_COPY_AND_ASSIGN(ShelfViewVisibleBoundsTest); |
1990 }; | 1988 }; |
1991 | 1989 |
1992 TEST_P(ShelfViewVisibleBoundsTest, ItemsAreInBounds) { | 1990 TEST_P(ShelfViewVisibleBoundsTest, ItemsAreInBounds) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2099 return new TestShelfMenuModel; | 2097 return new TestShelfMenuModel; |
2100 } | 2098 } |
2101 | 2099 |
2102 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); | 2100 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); |
2103 }; | 2101 }; |
2104 | 2102 |
2105 } // namespace | 2103 } // namespace |
2106 | 2104 |
2107 class ShelfViewInkDropTest : public ShelfViewTest { | 2105 class ShelfViewInkDropTest : public ShelfViewTest { |
2108 public: | 2106 public: |
2109 ShelfViewInkDropTest() : ink_drop_(nullptr), browser_button_(nullptr) {} | 2107 ShelfViewInkDropTest() |
2108 : app_list_button_(nullptr), | |
2109 app_list_button_ink_drop_(nullptr), | |
2110 browser_button_(nullptr), | |
2111 browser_button_ink_drop_(nullptr) {} | |
2110 ~ShelfViewInkDropTest() override {} | 2112 ~ShelfViewInkDropTest() override {} |
2111 | 2113 |
2112 void SetUp() override { | 2114 void SetUp() override { |
2113 ShelfViewTest::SetUp(); | 2115 ShelfViewTest::SetUp(); |
2114 | 2116 |
2115 // TODO(mohsen): Ideally, we would want to set material mode before calling | 2117 // TODO(mohsen): Ideally, we would want to set material mode before calling |
2116 // ShelfViewTest::SetUp() so that everything is set up with the correct | 2118 // ShelfViewTest::SetUp() so that everything is set up with the correct |
2117 // material mode. Currently, this is not possible as it expects material | 2119 // material mode. Currently, this is not possible as it expects material |
2118 // mode be UNINITIALIZED. (See https://crbug.com/620093) | 2120 // mode be UNINITIALIZED. (See https://crbug.com/620093) |
2119 ash_md_controller_.reset(new ash::test::MaterialDesignControllerTestAPI( | 2121 ash_md_controller_.reset(new ash::test::MaterialDesignControllerTestAPI( |
2120 ash::MaterialDesignController::MATERIAL_NORMAL)); | 2122 ash::MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
2121 | |
2122 browser_button_ = test_api_->GetButton(browser_index_); | |
2123 | |
2124 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); | |
2125 ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | |
2126 views::test::InkDropHostViewTestApi(browser_button_) | |
2127 .SetInkDrop(base::WrapUnique(ink_drop_)); | |
2128 } | 2123 } |
2129 | 2124 |
2130 void TearDown() override { | 2125 void TearDown() override { |
2131 ash_md_controller_.reset(); | 2126 ash_md_controller_.reset(); |
2132 | 2127 |
2133 ShelfViewTest::TearDown(); | 2128 ShelfViewTest::TearDown(); |
2134 } | 2129 } |
2135 | 2130 |
2136 protected: | 2131 protected: |
2132 void InitAppListButtonInkDrop() { | |
2133 app_list_button_ = shelf_view_->GetAppListButton(); | |
2134 | |
2135 views::InkDropImpl* ink_drop_impl = | |
2136 new views::InkDropImpl(app_list_button_); | |
2137 app_list_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | |
2138 views::test::InkDropHostViewTestApi(app_list_button_) | |
2139 .SetInkDrop(base::WrapUnique(app_list_button_ink_drop_)); | |
2140 } | |
2141 | |
2142 void InitBrowserButtonInkDrop() { | |
2143 browser_button_ = test_api_->GetButton(browser_index_); | |
2144 | |
2145 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); | |
2146 browser_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | |
2147 views::test::InkDropHostViewTestApi(browser_button_) | |
2148 .SetInkDrop(base::WrapUnique(browser_button_ink_drop_)); | |
2149 } | |
2150 | |
2137 std::unique_ptr<ash::test::MaterialDesignControllerTestAPI> | 2151 std::unique_ptr<ash::test::MaterialDesignControllerTestAPI> |
2138 ash_md_controller_; | 2152 ash_md_controller_; |
2139 | 2153 |
2140 InkDropSpy* ink_drop_; | 2154 AppListButton* app_list_button_; |
2155 InkDropSpy* app_list_button_ink_drop_; | |
2141 ShelfButton* browser_button_; | 2156 ShelfButton* browser_button_; |
2157 InkDropSpy* browser_button_ink_drop_; | |
2142 | 2158 |
2143 private: | 2159 private: |
2144 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); | 2160 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); |
2145 }; | 2161 }; |
2146 | 2162 |
2163 // Tests that changing visiblity of the app list transitions app list button's | |
bruthig
2016/06/20 14:44:33
These tests should probably use the EventGenerator
mohsen
2016/06/21 06:33:23
Done.
| |
2164 // ink drop states correctly. | |
2165 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisiblityChanges) { | |
2166 InitAppListButtonInkDrop(); | |
2167 | |
2168 Shell::GetInstance()->ToggleAppList(nullptr); | |
2169 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
2170 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2171 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2172 ElementsAre(views::InkDropState::ACTIVATED)); | |
2173 | |
2174 Shell::GetInstance()->ToggleAppList(nullptr); | |
2175 EXPECT_EQ(views::InkDropState::HIDDEN, | |
2176 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2177 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2178 ElementsAre(views::InkDropState::DEACTIVATED)); | |
2179 } | |
2180 | |
2181 // Tests that when the app list is hidden, mouse press on the app list button, | |
2182 // which shows the app list, transitions ink drop states correctly. Also, tests | |
2183 // that mouse drag and mouse release does not affect the ink drop state. | |
2184 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenHidden) { | |
2185 InitAppListButtonInkDrop(); | |
2186 | |
2187 views::CustomButton* button = app_list_button_; | |
2188 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); | |
2189 | |
2190 // Mouse press on the button, which shows the app list, should end up in the | |
2191 // activated state. | |
2192 ui::MouseEvent press_event1(ui::ET_MOUSE_PRESSED, mouse_location, | |
2193 mouse_location, ui::EventTimeForNow(), | |
2194 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2195 button->OnMousePressed(press_event1); | |
2196 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
2197 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2198 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2199 ElementsAre(views::InkDropState::ACTION_PENDING, | |
2200 views::InkDropState::ACTIVATED)); | |
2201 | |
2202 // Dragging mouse out and back and releasing the button should not change the | |
2203 // ink drop state. | |
2204 mouse_location.Offset(button->width(), 0); | |
2205 ui::MouseEvent drag_event_outside1(ui::ET_MOUSE_DRAGGED, mouse_location, | |
2206 mouse_location, ui::EventTimeForNow(), | |
2207 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2208 button->OnMouseDragged(drag_event_outside1); | |
2209 mouse_location.Offset(-button->width(), 0); | |
2210 ui::MouseEvent drag_event_inside1(ui::ET_MOUSE_DRAGGED, mouse_location, | |
2211 mouse_location, ui::EventTimeForNow(), | |
2212 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2213 button->OnMouseDragged(drag_event_inside1); | |
2214 ui::MouseEvent release_event1(ui::ET_MOUSE_RELEASED, mouse_location, | |
2215 mouse_location, ui::EventTimeForNow(), | |
2216 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2217 button->OnMouseReleased(release_event1); | |
2218 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
2219 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2220 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2221 IsEmpty()); | |
2222 } | |
2223 | |
2224 // Tests that when the app list is visible, mouse press on the app list button, | |
2225 // which dismisses the app list, transitions ink drop states correctly. Also, | |
2226 // tests that mouse drag and mouse release does not affect the ink drop state. | |
2227 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) { | |
2228 InitAppListButtonInkDrop(); | |
2229 | |
2230 views::CustomButton* button = app_list_button_; | |
2231 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); | |
2232 | |
2233 // Show the app list. | |
2234 Shell::GetInstance()->ToggleAppList(nullptr); | |
2235 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
2236 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2237 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2238 ElementsAre(views::InkDropState::ACTIVATED)); | |
2239 | |
2240 // Mouse press on the button which dismisses the app list, should end up in | |
2241 // the hidden state. | |
2242 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, | |
2243 mouse_location, ui::EventTimeForNow(), | |
2244 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2245 button->OnMousePressed(press_event); | |
2246 EXPECT_EQ(views::InkDropState::HIDDEN, | |
2247 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2248 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2249 ElementsAre(views::InkDropState::DEACTIVATED)); | |
2250 | |
2251 // Dragging mouse out and back and releasing the button should not change the | |
2252 // ink drop state. | |
2253 mouse_location.Offset(button->width(), 0); | |
2254 ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, mouse_location, | |
2255 mouse_location, ui::EventTimeForNow(), | |
2256 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2257 button->OnMouseDragged(drag_event_outside); | |
2258 mouse_location.Offset(-button->width(), 0); | |
2259 ui::MouseEvent drag_event_inside(ui::ET_MOUSE_DRAGGED, mouse_location, | |
2260 mouse_location, ui::EventTimeForNow(), | |
2261 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2262 button->OnMouseDragged(drag_event_inside); | |
2263 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, | |
2264 mouse_location, ui::EventTimeForNow(), | |
2265 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
2266 button->OnMouseReleased(release_event); | |
2267 EXPECT_EQ(views::InkDropState::HIDDEN, | |
2268 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2269 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2270 IsEmpty()); | |
2271 } | |
2272 | |
2273 // Tests that when the app list is hidden, tapping on the app list button | |
2274 // transitions ink drop states correctly. | |
2275 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDownTapWhenHidden) { | |
2276 InitAppListButtonInkDrop(); | |
2277 | |
2278 views::CustomButton* button = app_list_button_; | |
2279 gfx::Point touch_location = button->GetLocalBounds().CenterPoint(); | |
2280 | |
2281 // Tap down on the button should end up in the pending state. | |
2282 ui::GestureEvent tap_down_event( | |
2283 touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), | |
2284 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); | |
2285 button->OnGestureEvent(&tap_down_event); | |
2286 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
2287 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2288 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2289 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
2290 | |
2291 // Tap on the button, which shows the app list, should end up in the activated | |
2292 // state. | |
2293 ui::GestureEvent tap_event(touch_location.x(), touch_location.y(), 0, | |
2294 ui::EventTimeForNow(), | |
2295 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | |
2296 button->OnGestureEvent(&tap_event); | |
2297 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
2298 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2299 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2300 ElementsAre(views::InkDropState::ACTIVATED)); | |
2301 } | |
2302 | |
2303 // Tests that when the app list hidden, tapping down on the app list button and | |
2304 // dragging the touch point transitions ink drop states correctly. | |
2305 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDownScrollWhenHidden) { | |
2306 InitAppListButtonInkDrop(); | |
2307 | |
2308 views::CustomButton* button = app_list_button_; | |
2309 gfx::Point touch_location = button->GetLocalBounds().CenterPoint(); | |
2310 | |
2311 // Tap down on the button should end up in the pending state. | |
2312 ui::GestureEvent tap_down_event( | |
2313 touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), | |
2314 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); | |
2315 button->OnGestureEvent(&tap_down_event); | |
2316 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
2317 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2318 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2319 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
2320 | |
2321 // Gesture sequence caused by dragging the touch point should hide the pending | |
2322 // ink drop. | |
2323 ui::GestureEvent tap_cancel_event( | |
2324 touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), | |
2325 ui::GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL)); | |
2326 button->OnGestureEvent(&tap_cancel_event); | |
2327 ui::GestureEvent scroll_begin_event( | |
2328 touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), | |
2329 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); | |
2330 button->OnGestureEvent(&scroll_begin_event); | |
2331 ui::GestureEvent scroll_end_event( | |
2332 touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), | |
2333 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); | |
2334 button->OnGestureEvent(&scroll_end_event); | |
2335 EXPECT_EQ(views::InkDropState::HIDDEN, | |
2336 app_list_button_ink_drop_->GetTargetInkDropState()); | |
2337 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | |
2338 ElementsAre(views::InkDropState::HIDDEN)); | |
2339 } | |
2340 | |
2147 // Tests that clicking on a shelf item that does not show a menu transitions ink | 2341 // Tests that clicking on a shelf item that does not show a menu transitions ink |
2148 // drop states correctly. | 2342 // drop states correctly. |
2149 TEST_F(ShelfViewInkDropTest, WithoutMenuPressRelease) { | 2343 TEST_F(ShelfViewInkDropTest, ShelfButtonWithoutMenuPressRelease) { |
2344 InitBrowserButtonInkDrop(); | |
2345 | |
2150 views::CustomButton* button = browser_button_; | 2346 views::CustomButton* button = browser_button_; |
2151 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | 2347 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
2152 | 2348 |
2153 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | 2349 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
2154 press_location, ui::EventTimeForNow(), | 2350 mouse_location, ui::EventTimeForNow(), |
2155 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2351 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2156 button->OnMousePressed(press_event); | 2352 button->OnMousePressed(press_event); |
2157 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 2353 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
2158 ink_drop_->GetTargetInkDropState()); | 2354 browser_button_ink_drop_->GetTargetInkDropState()); |
2159 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2355 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2160 ElementsAre(views::InkDropState::ACTION_PENDING)); | 2356 ElementsAre(views::InkDropState::ACTION_PENDING)); |
2161 | 2357 |
2162 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | 2358 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
2163 press_location, ui::EventTimeForNow(), | 2359 mouse_location, ui::EventTimeForNow(), |
2164 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2360 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2165 button->OnMouseReleased(release_event); | 2361 button->OnMouseReleased(release_event); |
2166 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2362 EXPECT_EQ(views::InkDropState::HIDDEN, |
2167 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2363 browser_button_ink_drop_->GetTargetInkDropState()); |
2364 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | |
2168 ElementsAre(views::InkDropState::ACTION_TRIGGERED)); | 2365 ElementsAre(views::InkDropState::ACTION_TRIGGERED)); |
2169 } | 2366 } |
2170 | 2367 |
2171 // Tests that dragging outside of a shelf item transitions ink drop states | 2368 // Tests that dragging outside of a shelf item transitions ink drop states |
2172 // correctly. | 2369 // correctly. |
2173 TEST_F(ShelfViewInkDropTest, WithoutMenuPressDragReleaseOutside) { | 2370 TEST_F(ShelfViewInkDropTest, ShelfButtonWithoutMenuPressDragReleaseOutside) { |
2371 InitBrowserButtonInkDrop(); | |
2372 | |
2174 views::CustomButton* button = browser_button_; | 2373 views::CustomButton* button = browser_button_; |
2175 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | 2374 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
2176 | 2375 |
2177 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | 2376 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
2178 press_location, ui::EventTimeForNow(), | 2377 mouse_location, ui::EventTimeForNow(), |
2179 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2378 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2180 button->OnMousePressed(press_event); | 2379 button->OnMousePressed(press_event); |
2181 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 2380 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
2182 ink_drop_->GetTargetInkDropState()); | 2381 browser_button_ink_drop_->GetTargetInkDropState()); |
2183 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2382 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2184 ElementsAre(views::InkDropState::ACTION_PENDING)); | 2383 ElementsAre(views::InkDropState::ACTION_PENDING)); |
2185 | 2384 |
2186 press_location.Offset(test_api_->GetMinimumDragDistance() / 2, 0); | 2385 mouse_location.Offset(test_api_->GetMinimumDragDistance() / 2, 0); |
2187 ui::MouseEvent drag_event_small(ui::ET_MOUSE_DRAGGED, press_location, | 2386 ui::MouseEvent drag_event_small(ui::ET_MOUSE_DRAGGED, mouse_location, |
2188 press_location, ui::EventTimeForNow(), | 2387 mouse_location, ui::EventTimeForNow(), |
2189 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2388 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2190 button->OnMouseDragged(drag_event_small); | 2389 button->OnMouseDragged(drag_event_small); |
2191 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 2390 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
2192 ink_drop_->GetTargetInkDropState()); | 2391 browser_button_ink_drop_->GetTargetInkDropState()); |
2193 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | 2392 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2194 | 2393 IsEmpty()); |
2195 press_location.Offset(test_api_->GetMinimumDragDistance(), 0); | 2394 |
2196 ui::MouseEvent drag_event_large(ui::ET_MOUSE_DRAGGED, press_location, | 2395 mouse_location.Offset(test_api_->GetMinimumDragDistance(), 0); |
2197 press_location, ui::EventTimeForNow(), | 2396 ui::MouseEvent drag_event_large(ui::ET_MOUSE_DRAGGED, mouse_location, |
2397 mouse_location, ui::EventTimeForNow(), | |
2198 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2398 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2199 button->OnMouseDragged(drag_event_large); | 2399 button->OnMouseDragged(drag_event_large); |
2200 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2400 EXPECT_EQ(views::InkDropState::HIDDEN, |
2201 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2401 browser_button_ink_drop_->GetTargetInkDropState()); |
2402 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | |
2202 ElementsAre(views::InkDropState::HIDDEN)); | 2403 ElementsAre(views::InkDropState::HIDDEN)); |
2203 | 2404 |
2204 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | 2405 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
2205 press_location, ui::EventTimeForNow(), | 2406 mouse_location, ui::EventTimeForNow(), |
2206 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2407 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2207 button->OnMouseReleased(release_event); | 2408 button->OnMouseReleased(release_event); |
2208 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2409 EXPECT_EQ(views::InkDropState::HIDDEN, |
2209 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | 2410 browser_button_ink_drop_->GetTargetInkDropState()); |
2411 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | |
2412 IsEmpty()); | |
2210 } | 2413 } |
2211 | 2414 |
2212 // Tests that dragging outside of a shelf item and back transitions ink drop | 2415 // Tests that dragging outside of a shelf item and back transitions ink drop |
2213 // states correctly. | 2416 // states correctly. |
2214 TEST_F(ShelfViewInkDropTest, WithoutMenuPressDragReleaseInside) { | 2417 TEST_F(ShelfViewInkDropTest, ShelfButtonWithoutMenuPressDragReleaseInside) { |
2418 InitBrowserButtonInkDrop(); | |
2419 | |
2215 views::CustomButton* button = browser_button_; | 2420 views::CustomButton* button = browser_button_; |
2216 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | 2421 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
2217 | 2422 |
2218 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | 2423 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
2219 press_location, ui::EventTimeForNow(), | 2424 mouse_location, ui::EventTimeForNow(), |
2220 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2425 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2221 button->OnMousePressed(press_event); | 2426 button->OnMousePressed(press_event); |
2222 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 2427 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
2223 ink_drop_->GetTargetInkDropState()); | 2428 browser_button_ink_drop_->GetTargetInkDropState()); |
2224 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2429 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2225 ElementsAre(views::InkDropState::ACTION_PENDING)); | 2430 ElementsAre(views::InkDropState::ACTION_PENDING)); |
2226 | 2431 |
2227 press_location.Offset(test_api_->GetMinimumDragDistance() * 2, 0); | 2432 mouse_location.Offset(test_api_->GetMinimumDragDistance() * 2, 0); |
2228 ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, press_location, | 2433 ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, mouse_location, |
2229 press_location, ui::EventTimeForNow(), | 2434 mouse_location, ui::EventTimeForNow(), |
2230 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2435 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2231 button->OnMouseDragged(drag_event_outside); | 2436 button->OnMouseDragged(drag_event_outside); |
2232 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2437 EXPECT_EQ(views::InkDropState::HIDDEN, |
2233 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2438 browser_button_ink_drop_->GetTargetInkDropState()); |
2439 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | |
2234 ElementsAre(views::InkDropState::HIDDEN)); | 2440 ElementsAre(views::InkDropState::HIDDEN)); |
2235 | 2441 |
2236 press_location.Offset(-test_api_->GetMinimumDragDistance() * 2, 0); | 2442 mouse_location.Offset(-test_api_->GetMinimumDragDistance() * 2, 0); |
2237 ui::MouseEvent drag_event_inside(ui::ET_MOUSE_DRAGGED, press_location, | 2443 ui::MouseEvent drag_event_inside(ui::ET_MOUSE_DRAGGED, mouse_location, |
2238 press_location, ui::EventTimeForNow(), | 2444 mouse_location, ui::EventTimeForNow(), |
2239 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2445 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2240 button->OnMouseDragged(drag_event_inside); | 2446 button->OnMouseDragged(drag_event_inside); |
2241 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2447 EXPECT_EQ(views::InkDropState::HIDDEN, |
2242 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | 2448 browser_button_ink_drop_->GetTargetInkDropState()); |
2243 | 2449 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2244 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | 2450 IsEmpty()); |
2245 press_location, ui::EventTimeForNow(), | 2451 |
2452 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, | |
2453 mouse_location, ui::EventTimeForNow(), | |
2246 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2454 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2247 button->OnMouseReleased(release_event); | 2455 button->OnMouseReleased(release_event); |
2248 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2456 EXPECT_EQ(views::InkDropState::HIDDEN, |
2249 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | 2457 browser_button_ink_drop_->GetTargetInkDropState()); |
2458 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | |
2459 IsEmpty()); | |
2250 } | 2460 } |
2251 | 2461 |
2252 // Tests that clicking on a shelf item that shows an app list menu transitions | 2462 // Tests that clicking on a shelf item that shows an app list menu transitions |
2253 // ink drop state correctly. | 2463 // ink drop state correctly. |
2254 TEST_F(ShelfViewInkDropTest, WithMenuPressRelease) { | 2464 TEST_F(ShelfViewInkDropTest, ShelfButtonWithMenuPressRelease) { |
2465 InitBrowserButtonInkDrop(); | |
2466 | |
2255 // Set a delegate for the shelf item that returns an app list menu. | 2467 // Set a delegate for the shelf item that returns an app list menu. |
2256 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 2468 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
2257 ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate; | 2469 ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate; |
2258 item_manager_->SetShelfItemDelegate(browser_shelf_id, | 2470 item_manager_->SetShelfItemDelegate(browser_shelf_id, |
2259 base::WrapUnique(list_menu_delegate)); | 2471 base::WrapUnique(list_menu_delegate)); |
2260 | 2472 |
2261 views::CustomButton* button = browser_button_; | 2473 views::CustomButton* button = browser_button_; |
2262 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | 2474 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
2263 | 2475 |
2264 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | 2476 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
2265 press_location, ui::EventTimeForNow(), | 2477 mouse_location, ui::EventTimeForNow(), |
2266 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2478 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2267 button->OnMousePressed(press_event); | 2479 button->OnMousePressed(press_event); |
2268 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 2480 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
2269 ink_drop_->GetTargetInkDropState()); | 2481 browser_button_ink_drop_->GetTargetInkDropState()); |
2270 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2482 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2271 ElementsAre(views::InkDropState::ACTION_PENDING)); | 2483 ElementsAre(views::InkDropState::ACTION_PENDING)); |
2272 | 2484 |
2273 base::ThreadTaskRunnerHandle::Get()->PostTask( | 2485 base::ThreadTaskRunnerHandle::Get()->PostTask( |
2274 FROM_HERE, base::Bind(&ShelfViewTestAPI::CloseMenu, | 2486 FROM_HERE, base::Bind(&ShelfViewTestAPI::CloseMenu, |
2275 base::Unretained(test_api_.get()))); | 2487 base::Unretained(test_api_.get()))); |
2276 | 2488 |
2277 // Mouse release will spawn a menu which will then get closed by the above | 2489 // Mouse release will spawn a menu which will then get closed by the above |
2278 // posted task. | 2490 // posted task. |
2279 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | 2491 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
2280 press_location, ui::EventTimeForNow(), | 2492 mouse_location, ui::EventTimeForNow(), |
2281 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2493 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2282 button->OnMouseReleased(release_event); | 2494 button->OnMouseReleased(release_event); |
2283 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2495 EXPECT_EQ(views::InkDropState::HIDDEN, |
2284 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2496 browser_button_ink_drop_->GetTargetInkDropState()); |
2497 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | |
2285 ElementsAre(views::InkDropState::ACTIVATED, | 2498 ElementsAre(views::InkDropState::ACTIVATED, |
2286 views::InkDropState::DEACTIVATED)); | 2499 views::InkDropState::DEACTIVATED)); |
2287 } | 2500 } |
2288 | 2501 |
2289 } // namespace test | 2502 } // namespace test |
2290 } // namespace ash | 2503 } // namespace ash |
OLD | NEW |