Commit 9a060864 authored by Saho Kobayashi's avatar Saho Kobayashi Committed by Commit Bot

Append kDescriptions instead of overwrite

State Description and SELECTED can be annotated as kDescription.
Append them when the node has both.

Bug: b/154433831
Test: AccessibilityNodeInfoDataWrapperTest.appendkDescription
Change-Id: I5b052cd38617f1b4766af3fdc5f61d3d40fb2a28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310055
Commit-Queue: Saho Kobayashi <sahok@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Reviewed-by: default avatarHiroki Sato <hirokisato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790821}
parent 23968702
......@@ -318,6 +318,10 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
AccessibilityInfoDataWrapper::Serialize(out_data);
bool is_node_tree_root = tree_source_->IsRootOfNodeTree(GetId());
// String properties that doesn't belong to any of existing chrome
// automation string properties are pushed into description.
// TODO: Refactor this to make clear the functionality(b/158633575).
std::vector<std::string> descriptions;
// String properties.
const std::string name = ComputeAXName(true);
......@@ -368,10 +372,7 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
out_data->AddStringAttribute(ax::mojom::StringAttribute::kValue,
state_description);
} else {
// TODO(sahok): Append strings anotated as kDescription(which is now
// overwritten).
out_data->AddStringAttribute(ax::mojom::StringAttribute::kDescription,
state_description);
descriptions.push_back(state_description);
}
}
......@@ -399,8 +400,7 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
if (ui::SupportsSelected(out_data->role)) {
out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
} else {
out_data->AddStringAttribute(
ax::mojom::StringAttribute::kDescription,
descriptions.push_back(
l10n_util::GetStringUTF8(IDS_ARC_ACCESSIBILITY_SELECTED_STATUS));
}
}
......@@ -476,6 +476,11 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
ax::mojom::StringListAttribute::kCustomActionDescriptions,
custom_action_descriptions);
}
if (!descriptions.empty()) {
out_data->AddStringAttribute(ax::mojom::StringAttribute::kDescription,
base::JoinString(descriptions, " "));
}
}
std::string AccessibilityNodeInfoDataWrapper::ComputeAXName(
......
......@@ -599,4 +599,27 @@ TEST_F(AccessibilityNodeInfoDataWrapperTest, LabeledByLoop) {
EXPECT_EQ("node2", name);
}
TEST_F(AccessibilityNodeInfoDataWrapperTest, appendkDescription) {
AXNodeInfoData node;
AccessibilityNodeInfoDataWrapper wrapper(tree_source(), &node);
node.id = 10;
// No attributes.
ui::AXNodeData data = CallSerialize(wrapper);
std::string description;
ASSERT_FALSE(data.GetStringAttribute(ax::mojom::StringAttribute::kDescription,
&description));
SetProperty(&node, AXStringProperty::STATE_DESCRIPTION, "state description");
SetProperty(&node, AXBooleanProperty::SELECTED, true);
SetProperty(&node, AXStringProperty::TEXT, "text");
data = CallSerialize(wrapper);
ASSERT_TRUE(data.GetStringAttribute(ax::mojom::StringAttribute::kDescription,
&description));
EXPECT_EQ("state description " +
l10n_util::GetStringUTF8(IDS_ARC_ACCESSIBILITY_SELECTED_STATUS),
description);
}
} // namespace arc
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