Commit fa335394 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Ensure GetTextForTooltipAndAccessibleName() doesn't return empty.

This is the cause of the attached bug. Animations in the toolbar mean
that some buttons which are being hidden are visible briefly as they
fade out, which previously created the situation that some tests which
closed the browser window while the fade-out animation was happening
would fail.

This solves the problem by having a default tooltip during fade-out.

Bug: 1038567
Change-Id: Ia24f3493e8b5d062b5ab67e2a8950e2fcf58b49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985171
Commit-Queue: Dana Fried <dfried@chromium.org>
Auto-Submit: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728093}
parent 5b2defd3
...@@ -91,13 +91,18 @@ const char* SaveCardIconView::GetClassName() const { ...@@ -91,13 +91,18 @@ const char* SaveCardIconView::GetClassName() const {
} }
base::string16 SaveCardIconView::GetTextForTooltipAndAccessibleName() const { base::string16 SaveCardIconView::GetTextForTooltipAndAccessibleName() const {
SaveCardBubbleController* controller = GetController(); base::string16 text;
if (!controller) {
// The controller can be null in unit tests only.
return base::string16();
}
return controller->GetSaveCardIconTooltipText(); SaveCardBubbleController* const controller = GetController();
if (controller)
text = controller->GetSaveCardIconTooltipText();
// Because the card icon is in an animated container, it is still briefly
// visible as it's disappearing. Since our test infrastructure does not allow
// views to have empty tooltip text when they are visible, we instead return
// the default text.
return text.empty() ? l10n_util::GetStringUTF16(IDS_TOOLTIP_SAVE_CREDIT_CARD)
: text;
} }
SaveCardBubbleController* SaveCardIconView::GetController() const { SaveCardBubbleController* SaveCardIconView::GetController() const {
......
...@@ -94,11 +94,6 @@ void PageActionIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -94,11 +94,6 @@ void PageActionIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kButton; node_data->role = ax::mojom::Role::kButton;
const base::string16 name_text = GetTextForTooltipAndAccessibleName(); const base::string16 name_text = GetTextForTooltipAndAccessibleName();
node_data->SetName(name_text); node_data->SetName(name_text);
// TODO(crbug/1038567): This shouldn't be necessary and suggests a bug in how
// we deconstruct icons as we're fading them out. In the interim let's make
// sure interactive uitests don't crash as they're trying to hide a button.
if (name_text.empty())
node_data->SetNameExplicitlyEmpty();
} }
base::string16 PageActionIconView::GetTooltipText(const gfx::Point& p) const { base::string16 PageActionIconView::GetTooltipText(const gfx::Point& p) const {
......
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