Index: ash/shelf/shelf_view_unittest.cc |
diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc |
index adf61ebd7fa2f81ecaff7491747c360594bcc9c6..b68c97da5bfd8d7735850938f7453f85ea0d0761 100644 |
--- a/ash/shelf/shelf_view_unittest.cc |
+++ b/ash/shelf/shelf_view_unittest.cc |
@@ -1482,7 +1482,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipTest) { |
} |
// The tooltip should not hide on the app-list button. |
- views::View* app_list_button = shelf_view_->GetAppListButtonView(); |
+ AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
app_list_button->GetMirroredBounds().CenterPoint())); |
@@ -1503,7 +1503,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipTest) { |
all_area.Union(button->GetMirroredBounds()); |
} |
- all_area.Union(shelf_view_->GetAppListButtonView()->GetMirroredBounds()); |
+ all_area.Union(shelf_view_->GetAppListButton()->GetMirroredBounds()); |
EXPECT_FALSE(shelf_view_->ShouldHideTooltip(all_area.origin())); |
EXPECT_FALSE(shelf_view_->ShouldHideTooltip( |
gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); |
@@ -1533,7 +1533,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { |
} |
// The tooltip should hide on the app-list button. |
- views::View* app_list_button = shelf_view_->GetAppListButtonView(); |
+ AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
EXPECT_TRUE(shelf_view_->ShouldHideTooltip( |
app_list_button->GetMirroredBounds().CenterPoint())); |
} |
@@ -1550,7 +1550,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { |
EXPECT_FALSE(tooltip_manager->IsVisible()); |
// Move the mouse over the button and check that it is visible. |
- views::View* app_list_button = shelf_view_->GetAppListButtonView(); |
+ AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
gfx::Rect bounds = app_list_button->GetBoundsInScreen(); |
generator.MoveMouseTo(bounds.CenterPoint()); |
// Wait for the timer to go off. |
@@ -1860,8 +1860,7 @@ TEST_F(ShelfViewTest, CheckOverflowStatusPinOpenedAppToShelf) { |
// Tests that the AppListButton renders as active in response to touches. |
TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { |
- AppListButton* app_list_button = |
- static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
+ AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
EXPECT_FALSE(app_list_button->draw_background_as_active()); |
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
@@ -1878,8 +1877,7 @@ TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { |
// Tests that a touch that slides out of the bounds of the AppListButton leads |
// to the end of rendering an active state. |
TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { |
- AppListButton* app_list_button = |
- static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
+ AppListButton* app_list_button = shelf_view_->GetAppListButton(); |
EXPECT_FALSE(app_list_button->draw_background_as_active()); |
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
@@ -1978,8 +1976,8 @@ class ShelfViewVisibleBoundsTest : public ShelfViewTest, |
void CheckAppListButtonIsInBounds() { |
gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); |
- gfx::Rect app_list_button_bounds = shelf_view_->GetAppListButtonView()-> |
- GetBoundsInScreen(); |
+ gfx::Rect app_list_button_bounds = |
+ shelf_view_->GetAppListButton()->GetBoundsInScreen(); |
EXPECT_TRUE(visible_bounds.Contains(app_list_button_bounds)); |
} |
@@ -2106,7 +2104,11 @@ class ListMenuShelfItemDelegate : public TestShelfItemDelegate { |
class ShelfViewInkDropTest : public ShelfViewTest { |
public: |
- ShelfViewInkDropTest() : ink_drop_(nullptr), browser_button_(nullptr) {} |
+ ShelfViewInkDropTest() |
+ : app_list_button_(nullptr), |
+ app_list_button_ink_drop_(nullptr), |
+ browser_button_(nullptr), |
+ browser_button_ink_drop_(nullptr) {} |
~ShelfViewInkDropTest() override {} |
void SetUp() override { |
@@ -2117,14 +2119,7 @@ class ShelfViewInkDropTest : public ShelfViewTest { |
// material mode. Currently, this is not possible as it expects material |
// mode be UNINITIALIZED. (See https://crbug.com/620093) |
ash_md_controller_.reset(new ash::test::MaterialDesignControllerTestAPI( |
- ash::MaterialDesignController::MATERIAL_NORMAL)); |
- |
- browser_button_ = test_api_->GetButton(browser_index_); |
- |
- views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); |
- ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
- views::test::InkDropHostViewTestApi(browser_button_) |
- .SetInkDrop(base::WrapUnique(ink_drop_)); |
+ ash::MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
} |
void TearDown() override { |
@@ -2134,124 +2129,341 @@ class ShelfViewInkDropTest : public ShelfViewTest { |
} |
protected: |
+ void InitAppListButtonInkDrop() { |
+ app_list_button_ = shelf_view_->GetAppListButton(); |
+ |
+ views::InkDropImpl* ink_drop_impl = |
+ new views::InkDropImpl(app_list_button_); |
+ app_list_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
+ views::test::InkDropHostViewTestApi(app_list_button_) |
+ .SetInkDrop(base::WrapUnique(app_list_button_ink_drop_)); |
+ } |
+ |
+ void InitBrowserButtonInkDrop() { |
+ browser_button_ = test_api_->GetButton(browser_index_); |
+ |
+ views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); |
+ browser_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
+ views::test::InkDropHostViewTestApi(browser_button_) |
+ .SetInkDrop(base::WrapUnique(browser_button_ink_drop_)); |
+ } |
+ |
std::unique_ptr<ash::test::MaterialDesignControllerTestAPI> |
ash_md_controller_; |
- InkDropSpy* ink_drop_; |
+ AppListButton* app_list_button_; |
+ InkDropSpy* app_list_button_ink_drop_; |
ShelfButton* browser_button_; |
+ InkDropSpy* browser_button_ink_drop_; |
private: |
DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); |
}; |
+// 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.
|
+// ink drop states correctly. |
+TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisiblityChanges) { |
+ InitAppListButtonInkDrop(); |
+ |
+ Shell::GetInstance()->ToggleAppList(nullptr); |
+ EXPECT_EQ(views::InkDropState::ACTIVATED, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::ACTIVATED)); |
+ |
+ Shell::GetInstance()->ToggleAppList(nullptr); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::DEACTIVATED)); |
+} |
+ |
+// Tests that when the app list is hidden, mouse press on the app list button, |
+// which shows the app list, transitions ink drop states correctly. Also, tests |
+// that mouse drag and mouse release does not affect the ink drop state. |
+TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenHidden) { |
+ InitAppListButtonInkDrop(); |
+ |
+ views::CustomButton* button = app_list_button_; |
+ gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
+ |
+ // Mouse press on the button, which shows the app list, should end up in the |
+ // activated state. |
+ ui::MouseEvent press_event1(ui::ET_MOUSE_PRESSED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMousePressed(press_event1); |
+ EXPECT_EQ(views::InkDropState::ACTIVATED, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::ACTION_PENDING, |
+ views::InkDropState::ACTIVATED)); |
+ |
+ // Dragging mouse out and back and releasing the button should not change the |
+ // ink drop state. |
+ mouse_location.Offset(button->width(), 0); |
+ ui::MouseEvent drag_event_outside1(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMouseDragged(drag_event_outside1); |
+ mouse_location.Offset(-button->width(), 0); |
+ ui::MouseEvent drag_event_inside1(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMouseDragged(drag_event_inside1); |
+ ui::MouseEvent release_event1(ui::ET_MOUSE_RELEASED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMouseReleased(release_event1); |
+ EXPECT_EQ(views::InkDropState::ACTIVATED, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ IsEmpty()); |
+} |
+ |
+// Tests that when the app list is visible, mouse press on the app list button, |
+// which dismisses the app list, transitions ink drop states correctly. Also, |
+// tests that mouse drag and mouse release does not affect the ink drop state. |
+TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) { |
+ InitAppListButtonInkDrop(); |
+ |
+ views::CustomButton* button = app_list_button_; |
+ gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
+ |
+ // Show the app list. |
+ Shell::GetInstance()->ToggleAppList(nullptr); |
+ EXPECT_EQ(views::InkDropState::ACTIVATED, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::ACTIVATED)); |
+ |
+ // Mouse press on the button which dismisses the app list, should end up in |
+ // the hidden state. |
+ ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMousePressed(press_event); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::DEACTIVATED)); |
+ |
+ // Dragging mouse out and back and releasing the button should not change the |
+ // ink drop state. |
+ mouse_location.Offset(button->width(), 0); |
+ ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMouseDragged(drag_event_outside); |
+ mouse_location.Offset(-button->width(), 0); |
+ ui::MouseEvent drag_event_inside(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMouseDragged(drag_event_inside); |
+ ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
+ ui::EF_LEFT_MOUSE_BUTTON, 0); |
+ button->OnMouseReleased(release_event); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ IsEmpty()); |
+} |
+ |
+// Tests that when the app list is hidden, tapping on the app list button |
+// transitions ink drop states correctly. |
+TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDownTapWhenHidden) { |
+ InitAppListButtonInkDrop(); |
+ |
+ views::CustomButton* button = app_list_button_; |
+ gfx::Point touch_location = button->GetLocalBounds().CenterPoint(); |
+ |
+ // Tap down on the button should end up in the pending state. |
+ ui::GestureEvent tap_down_event( |
+ touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); |
+ button->OnGestureEvent(&tap_down_event); |
+ EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::ACTION_PENDING)); |
+ |
+ // Tap on the button, which shows the app list, should end up in the activated |
+ // state. |
+ ui::GestureEvent tap_event(touch_location.x(), touch_location.y(), 0, |
+ ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
+ button->OnGestureEvent(&tap_event); |
+ EXPECT_EQ(views::InkDropState::ACTIVATED, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::ACTIVATED)); |
+} |
+ |
+// Tests that when the app list hidden, tapping down on the app list button and |
+// dragging the touch point transitions ink drop states correctly. |
+TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDownScrollWhenHidden) { |
+ InitAppListButtonInkDrop(); |
+ |
+ views::CustomButton* button = app_list_button_; |
+ gfx::Point touch_location = button->GetLocalBounds().CenterPoint(); |
+ |
+ // Tap down on the button should end up in the pending state. |
+ ui::GestureEvent tap_down_event( |
+ touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); |
+ button->OnGestureEvent(&tap_down_event); |
+ EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::ACTION_PENDING)); |
+ |
+ // Gesture sequence caused by dragging the touch point should hide the pending |
+ // ink drop. |
+ ui::GestureEvent tap_cancel_event( |
+ touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL)); |
+ button->OnGestureEvent(&tap_cancel_event); |
+ ui::GestureEvent scroll_begin_event( |
+ touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); |
+ button->OnGestureEvent(&scroll_begin_event); |
+ ui::GestureEvent scroll_end_event( |
+ touch_location.x(), touch_location.y(), 0, ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); |
+ button->OnGestureEvent(&scroll_end_event); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ app_list_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
+ ElementsAre(views::InkDropState::HIDDEN)); |
+} |
+ |
// Tests that clicking on a shelf item that does not show a menu transitions ink |
// drop states correctly. |
-TEST_F(ShelfViewInkDropTest, WithoutMenuPressRelease) { |
+TEST_F(ShelfViewInkDropTest, ShelfButtonWithoutMenuPressRelease) { |
+ InitBrowserButtonInkDrop(); |
+ |
views::CustomButton* button = browser_button_; |
- gfx::Point press_location = button->GetLocalBounds().CenterPoint(); |
+ gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
- ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMousePressed(press_event); |
EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
- ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::ACTION_PENDING)); |
- ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseReleased(release_event); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::ACTION_TRIGGERED)); |
} |
// Tests that dragging outside of a shelf item transitions ink drop states |
// correctly. |
-TEST_F(ShelfViewInkDropTest, WithoutMenuPressDragReleaseOutside) { |
+TEST_F(ShelfViewInkDropTest, ShelfButtonWithoutMenuPressDragReleaseOutside) { |
+ InitBrowserButtonInkDrop(); |
+ |
views::CustomButton* button = browser_button_; |
- gfx::Point press_location = button->GetLocalBounds().CenterPoint(); |
+ gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
- ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMousePressed(press_event); |
EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
- ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::ACTION_PENDING)); |
- press_location.Offset(test_api_->GetMinimumDragDistance() / 2, 0); |
- ui::MouseEvent drag_event_small(ui::ET_MOUSE_DRAGGED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ mouse_location.Offset(test_api_->GetMinimumDragDistance() / 2, 0); |
+ ui::MouseEvent drag_event_small(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseDragged(drag_event_small); |
EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
- ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
+ IsEmpty()); |
- press_location.Offset(test_api_->GetMinimumDragDistance(), 0); |
- ui::MouseEvent drag_event_large(ui::ET_MOUSE_DRAGGED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ mouse_location.Offset(test_api_->GetMinimumDragDistance(), 0); |
+ ui::MouseEvent drag_event_large(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseDragged(drag_event_large); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::HIDDEN)); |
- ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseReleased(release_event); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
+ IsEmpty()); |
} |
// Tests that dragging outside of a shelf item and back transitions ink drop |
// states correctly. |
-TEST_F(ShelfViewInkDropTest, WithoutMenuPressDragReleaseInside) { |
+TEST_F(ShelfViewInkDropTest, ShelfButtonWithoutMenuPressDragReleaseInside) { |
+ InitBrowserButtonInkDrop(); |
+ |
views::CustomButton* button = browser_button_; |
- gfx::Point press_location = button->GetLocalBounds().CenterPoint(); |
+ gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
- ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMousePressed(press_event); |
EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
- ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::ACTION_PENDING)); |
- press_location.Offset(test_api_->GetMinimumDragDistance() * 2, 0); |
- ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ mouse_location.Offset(test_api_->GetMinimumDragDistance() * 2, 0); |
+ ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseDragged(drag_event_outside); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::HIDDEN)); |
- press_location.Offset(-test_api_->GetMinimumDragDistance() * 2, 0); |
- ui::MouseEvent drag_event_inside(ui::ET_MOUSE_DRAGGED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ mouse_location.Offset(-test_api_->GetMinimumDragDistance() * 2, 0); |
+ ui::MouseEvent drag_event_inside(ui::ET_MOUSE_DRAGGED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseDragged(drag_event_inside); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
+ IsEmpty()); |
- ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseReleased(release_event); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
+ IsEmpty()); |
} |
// Tests that clicking on a shelf item that shows an app list menu transitions |
// ink drop state correctly. |
-TEST_F(ShelfViewInkDropTest, WithMenuPressRelease) { |
+TEST_F(ShelfViewInkDropTest, ShelfButtonWithMenuPressRelease) { |
+ InitBrowserButtonInkDrop(); |
+ |
// Set a delegate for the shelf item that returns an app list menu. |
ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate; |
@@ -2259,15 +2471,15 @@ TEST_F(ShelfViewInkDropTest, WithMenuPressRelease) { |
base::WrapUnique(list_menu_delegate)); |
views::CustomButton* button = browser_button_; |
- gfx::Point press_location = button->GetLocalBounds().CenterPoint(); |
+ gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
- ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMousePressed(press_event); |
EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
- ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::ACTION_PENDING)); |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
@@ -2276,12 +2488,13 @@ TEST_F(ShelfViewInkDropTest, WithMenuPressRelease) { |
// Mouse release will spawn a menu which will then get closed by the above |
// posted task. |
- ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, |
- press_location, ui::EventTimeForNow(), |
+ ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
+ mouse_location, ui::EventTimeForNow(), |
ui::EF_LEFT_MOUSE_BUTTON, 0); |
button->OnMouseReleased(release_event); |
- EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
- EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
+ EXPECT_EQ(views::InkDropState::HIDDEN, |
+ browser_button_ink_drop_->GetTargetInkDropState()); |
+ EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
ElementsAre(views::InkDropState::ACTIVATED, |
views::InkDropState::DEACTIVATED)); |
} |