Commit 0063faba authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Cros: Add tooltip for scrollable shelf arrows

Bug: 1009413
Change-Id: I96251acc1010789d41e43b3dd1bac5b16b8698cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863856Reviewed-by: default avatarAndrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706648}
parent 5584f7c9
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/numerics/ranges.h" #include "base/numerics/ranges.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/paint_recorder.h" #include "ui/compositor/paint_recorder.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/vector2d_conversions.h" #include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/skia_paint_util.h" #include "ui/gfx/skia_paint_util.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/focus/focus_search.h" #include "ui/views/focus/focus_search.h"
#include "ui/views/view_targeter_delegate.h" #include "ui/views/view_targeter_delegate.h"
...@@ -763,6 +765,9 @@ bool ScrollableShelfView::ShouldShowTooltipForView( ...@@ -763,6 +765,9 @@ bool ScrollableShelfView::ShouldShowTooltipForView(
if (!view || !view->parent()) if (!view || !view->parent())
return false; return false;
if (view == left_arrow_ || view == right_arrow_)
return true;
if (view->parent() != shelf_view_) if (view->parent() != shelf_view_)
return false; return false;
...@@ -799,6 +804,12 @@ base::string16 ScrollableShelfView::GetTitleForView( ...@@ -799,6 +804,12 @@ base::string16 ScrollableShelfView::GetTitleForView(
if (view->parent() == shelf_view_) if (view->parent() == shelf_view_)
return shelf_view_->GetTitleForView(view); return shelf_view_->GetTitleForView(view);
if (view == left_arrow_)
return l10n_util::GetStringUTF16(IDS_SHELF_PREVIOUS);
if (view == right_arrow_)
return l10n_util::GetStringUTF16(IDS_SHELF_NEXT);
return base::string16(); return base::string16();
} }
......
...@@ -307,4 +307,37 @@ TEST_F(ScrollableShelfViewTest, VerifyTappableAppIndices) { ...@@ -307,4 +307,37 @@ TEST_F(ScrollableShelfViewTest, VerifyTappableAppIndices) {
CheckFirstAndLastTappableIconsBounds(); CheckFirstAndLastTappableIconsBounds();
} }
TEST_F(ScrollableShelfViewTest, ShowTooltipForArrowButtons) {
AddAppShortcutsUntilOverflow();
ASSERT_EQ(ScrollableShelfView::kShowRightArrowButton,
scrollable_shelf_view_->layout_strategy_for_test());
// Check the initial state of |tooltip_manager|.
ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
EXPECT_FALSE(tooltip_manager->IsVisible());
// Verifies that tooltip should show for a visible shelf item.
views::View* right_arrow = scrollable_shelf_view_->right_arrow();
GetEventGenerator()->MoveMouseTo(
right_arrow->GetBoundsInScreen().CenterPoint());
tooltip_manager->ShowTooltip(right_arrow);
EXPECT_TRUE(tooltip_manager->IsVisible());
// Click right arrow button to scroll the shelf and show left arrow button.
GetEventGenerator()->ClickLeftButton();
ASSERT_EQ(ScrollableShelfView::kShowLeftArrowButton,
scrollable_shelf_view_->layout_strategy_for_test());
// Reset |tooltip_manager|.
GetEventGenerator()->MoveMouseTo(gfx::Point());
tooltip_manager->Close();
EXPECT_FALSE(tooltip_manager->IsVisible());
views::View* left_arrow = scrollable_shelf_view_->left_arrow();
GetEventGenerator()->MoveMouseTo(
left_arrow->GetBoundsInScreen().CenterPoint());
tooltip_manager->ShowTooltip(left_arrow);
EXPECT_TRUE(tooltip_manager->IsVisible());
}
} // namespace ash } // namespace ash
...@@ -861,6 +861,12 @@ need to be translated for each locale.--> ...@@ -861,6 +861,12 @@ need to be translated for each locale.-->
<message name="IDS_SHELF_STATE_AUTO_HIDE" desc="Accessibility announcement notifying users that the shelf will now hide itself automatically"> <message name="IDS_SHELF_STATE_AUTO_HIDE" desc="Accessibility announcement notifying users that the shelf will now hide itself automatically">
Shelf auto hidden Shelf auto hidden
</message> </message>
<message name="IDS_SHELF_NEXT" desc="Tooltip for the shelf arrow button that scrolls the shelf forward">
Next
</message>
<message name="IDS_SHELF_PREVIOUS" desc="Tooltip for the shelf arrow button that scrolls the shelf backward">
Previous
</message>
<message name="IDS_REMOVE_ZERO_STATE_SUGGESTION_TITLE" desc="Titlebar of removing zero state suggestion confirmation dialog"> <message name="IDS_REMOVE_ZERO_STATE_SUGGESTION_TITLE" desc="Titlebar of removing zero state suggestion confirmation dialog">
Delete this search from your history? Delete this search from your history?
</message> </message>
......
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