Commit 6cb9cf0a authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Fix ARC++ root URL computation

Previously, a role of the root ARC++ accessibility nodes was changed
from rootWebArea to genericContainer. (http://crrev/c/1469064)

There was a remaining logic that checks role==rootWebArea. This CL fixes
it.
This CL also adds an unit test to check string properties, and moved
a tooltip related test into here as it was previously in name
computation test.

Bug: None
Test: unit_tests --gtest_filter="AXTreeSourceArcTest.*"
Change-Id: Id945f7fdd3e48455593986b975a339a73c83c1b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886554Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710606}
parent e8ff9b79
...@@ -269,6 +269,8 @@ void AccessibilityNodeInfoDataWrapper::Serialize( ...@@ -269,6 +269,8 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
ui::AXNodeData* out_data) const { ui::AXNodeData* out_data) const {
AccessibilityInfoDataWrapper::Serialize(out_data); AccessibilityInfoDataWrapper::Serialize(out_data);
bool is_node_tree_root = tree_source_->IsRootOfNodeTree(GetId());
// String properties. // String properties.
int labelled_by = -1; int labelled_by = -1;
...@@ -333,7 +335,7 @@ void AccessibilityNodeInfoDataWrapper::Serialize( ...@@ -333,7 +335,7 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
role_description); role_description);
} }
if (out_data->role == ax::mojom::Role::kRootWebArea) { if (is_node_tree_root) {
std::string package_name; std::string package_name;
if (GetProperty(AXStringProperty::PACKAGE_NAME, &package_name)) { if (GetProperty(AXStringProperty::PACKAGE_NAME, &package_name)) {
const std::string& url = const std::string& url =
...@@ -381,7 +383,7 @@ void AccessibilityNodeInfoDataWrapper::Serialize( ...@@ -381,7 +383,7 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kSupportsTextLocation, out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kSupportsTextLocation,
true); true);
} }
if (tree_source_->IsRootOfNodeTree(GetId())) { if (is_node_tree_root) {
out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true); out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true);
} }
......
...@@ -491,13 +491,6 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputation) { ...@@ -491,13 +491,6 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputation) {
data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name)); data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name));
ASSERT_EQ("root label text", name); ASSERT_EQ("root label text", name);
// Set tooltip on child2.
SetProperty(child2, AXStringProperty::TOOLTIP, "tooltip text");
CallSerializeNode(child2, &data);
ASSERT_TRUE(
data->GetStringAttribute(ax::mojom::StringAttribute::kTooltip, &name));
ASSERT_EQ("tooltip text", name);
// Clearing both clickable and name from root, the name should not be // Clearing both clickable and name from root, the name should not be
// populated. // populated.
root->boolean_properties->clear(); root->boolean_properties->clear();
...@@ -687,6 +680,51 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputationWindowWithChildren) { ...@@ -687,6 +680,51 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputationWindowWithChildren) {
EXPECT_EQ(1, GetDispatchedEventCount(ax::mojom::Event::kFocus)); EXPECT_EQ(1, GetDispatchedEventCount(ax::mojom::Event::kFocus));
} }
TEST_F(AXTreeSourceArcTest, StringPropertiesComputations) {
auto event = AXEventData::New();
event->source_id = 1;
event->task_id = 1;
event->event_type = AXEventType::VIEW_FOCUSED;
event->node_data.push_back(AXNodeInfoData::New());
AXNodeInfoData* root = event->node_data.back().get();
root->id = 1;
event->window_data = std::vector<mojom::AccessibilityWindowInfoDataPtr>();
event->window_data->push_back(AXWindowInfoData::New());
AXWindowInfoData* root_window = event->window_data->back().get();
root_window->window_id = 100;
root_window->root_node_id = 1;
// Add a child node.
event->node_data.push_back(AXNodeInfoData::New());
AXNodeInfoData* child = event->node_data.back().get();
child->id = 2;
// Set properties to the root.
SetProperty(root, AXIntListProperty::CHILD_NODE_IDS, std::vector<int>({2}));
SetProperty(root, AXStringProperty::PACKAGE_NAME, "com.android.vending");
// Set properties to the child.
SetProperty(child, AXStringProperty::TOOLTIP, "tooltip text");
// Populate the tree source with the data.
CallNotifyAccessibilityEvent(event.get());
std::unique_ptr<ui::AXNodeData> data;
CallSerializeNode(root, &data);
std::string prop;
// Url includes AXTreeId, which is unguessable. Just verifies the prefix.
ASSERT_TRUE(
data->GetStringAttribute(ax::mojom::StringAttribute::kUrl, &prop));
EXPECT_EQ(0U, prop.find("com.android.vending/"));
CallSerializeNode(child, &data);
ASSERT_TRUE(
data->GetStringAttribute(ax::mojom::StringAttribute::kTooltip, &prop));
ASSERT_EQ("tooltip text", prop);
}
TEST_F(AXTreeSourceArcTest, ComplexTreeStructure) { TEST_F(AXTreeSourceArcTest, ComplexTreeStructure) {
int tree_size = 4; int tree_size = 4;
int num_trees = 3; int num_trees = 3;
......
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