Commit 3d22ab40 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Add shelf icon tooltip test back

Add ShelfViewTest::ShouldHideTooltipWhenHoveringOnTooltip back. In
addition, this CL fixed a bug exposed by this test: shelf icon tooltip
should be hidden if the mouse cursor moves outside of icons area.

Bug: 1016874
Change-Id: I9d78993d658e659d9a738d6e0be6fa673a2b36bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146783Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758537}
parent 5bd7bf38
......@@ -1160,7 +1160,20 @@ bool ScrollableShelfView::ShouldShowTooltipForView(
bool ScrollableShelfView::ShouldHideTooltip(
const gfx::Point& cursor_location) const {
return !visible_space_.Contains(cursor_location);
if ((ShouldShowLeftArrow() &&
left_arrow_->GetMirroredBounds().Contains(cursor_location)) ||
(ShouldShowRightArrow() &&
right_arrow_->GetMirroredBounds().Contains(cursor_location))) {
return false;
}
// Should hide the tooltip if |cursor_location| is not in |visible_space_|.
if (!visible_space_.Contains(cursor_location))
return true;
gfx::Point location_in_shelf_view = cursor_location;
views::View::ConvertPointToTarget(this, shelf_view_, &location_in_shelf_view);
return shelf_view_->ShouldHideTooltip(location_in_shelf_view);
}
const std::vector<aura::Window*> ScrollableShelfView::GetOpenWindowsForView(
......
......@@ -1175,6 +1175,45 @@ TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) {
shelf_view_->GetMirroredXInView(center_point.x()), center_point.y())));
}
// Test that by moving the mouse cursor off the button onto the bubble it closes
// the bubble.
TEST_P(HotseatShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) {
ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
tooltip_manager->set_timer_delay_for_test(0);
ui::test::EventGenerator* generator = GetEventGenerator();
// Move the mouse off any item and check that no tooltip is shown.
generator->MoveMouseTo(gfx::Point(0, 0));
EXPECT_FALSE(tooltip_manager->IsVisible());
// Move the mouse over the button and check that it is visible.
views::View* button = shelf_view_->first_visible_button_for_testing();
gfx::Rect bounds = button->GetBoundsInScreen();
generator->MoveMouseTo(bounds.CenterPoint());
// Wait for the timer to go off.
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(tooltip_manager->IsVisible());
// Move the mouse cursor slightly to the right of the item. The tooltip should
// now close.
generator->MoveMouseBy(bounds.width() / 2 + 5, 0);
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tooltip_manager->IsVisible());
// Move back - it should appear again.
generator->MoveMouseBy(-(bounds.width() / 2 + 5), 0);
// Make sure there is no delayed close.
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(tooltip_manager->IsVisible());
// Now move the mouse cursor slightly above the item - so that it is over the
// tooltip bubble. Now it should disappear.
generator->MoveMouseBy(0, -(bounds.height() / 2 + 5));
// Wait until the delayed close kicked in.
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tooltip_manager->IsVisible());
}
// Checks the rip an item off from left aligned shelf in secondary monitor.
TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) {
UpdateDisplay("800x600,800x600");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment