diff --git a/bindings/c/src/common.rs b/bindings/c/src/common.rs index 21724c20a..236499106 100644 --- a/bindings/c/src/common.rs +++ b/bindings/c/src/common.rs @@ -567,6 +567,7 @@ string_property_methods! { (description, set_description, clear_description), (value, set_value, clear_value), (access_key, set_access_key, clear_access_key), + (author_id, set_author_id, clear_author_id), (class_name, set_class_name, clear_class_name), (font_family, set_font_family, clear_font_family), (html_tag, set_html_tag, clear_html_tag), diff --git a/bindings/python/src/common.rs b/bindings/python/src/common.rs index 3d6dc2538..dfe6af132 100644 --- a/bindings/python/src/common.rs +++ b/bindings/python/src/common.rs @@ -488,6 +488,7 @@ string_property_methods! { (description, set_description, clear_description), (value, set_value, clear_value), (access_key, set_access_key, clear_access_key), + (author_id, set_author_id, clear_author_id), (class_name, set_class_name, clear_class_name), (font_family, set_font_family, clear_font_family), (html_tag, set_html_tag, clear_html_tag), diff --git a/common/src/lib.rs b/common/src/lib.rs index 78913a620..737584588 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -860,6 +860,7 @@ enum PropertyId { Description, Value, AccessKey, + AuthorId, ClassName, FontFamily, HtmlTag, @@ -1497,6 +1498,9 @@ string_property_methods! { /// /// [`keyboard_shortcut`]: Node::keyboard_shortcut (AccessKey, access_key, set_access_key, clear_access_key), + /// A way for application authors to identify this node for automated + /// testing purpose. The value must be unique among this node's siblings. + (AuthorId, author_id, set_author_id, clear_author_id), (ClassName, class_name, set_class_name, clear_class_name), /// Only present when different from parent. (FontFamily, font_family, set_font_family, clear_font_family), @@ -1917,6 +1921,7 @@ impl<'de> Visitor<'de> for NodeVisitor { Description, Value, AccessKey, + AuthorId, ClassName, FontFamily, HtmlTag, @@ -2101,6 +2106,7 @@ impl JsonSchema for Node { Description, Value, AccessKey, + AuthorId, ClassName, FontFamily, HtmlTag, diff --git a/consumer/src/node.rs b/consumer/src/node.rs index 054df2e64..7825eb616 100644 --- a/consumer/src/node.rs +++ b/consumer/src/node.rs @@ -596,6 +596,10 @@ impl<'a> Node<'a> { self.data().value() } + pub fn author_id(&self) -> Option<&str> { + self.data().author_id() + } + pub fn class_name(&self) -> Option<&str> { self.data().class_name() } diff --git a/platforms/atspi-common/src/node.rs b/platforms/atspi-common/src/node.rs index 148c0a48d..28362d4f2 100644 --- a/platforms/atspi-common/src/node.rs +++ b/platforms/atspi-common/src/node.rs @@ -722,6 +722,16 @@ impl PlatformNode { self.id } + pub fn accessible_id(&self) -> Result { + self.resolve(|node| { + if let Some(author_id) = node.author_id() { + Ok(author_id.to_string()) + } else { + Ok(String::new()) + } + }) + } + pub fn child_at_index(&self, index: usize) -> Result> { self.resolve(|node| { let child = node diff --git a/platforms/atspi-common/src/simplified.rs b/platforms/atspi-common/src/simplified.rs index b451ebbec..b2ee51e61 100644 --- a/platforms/atspi-common/src/simplified.rs +++ b/platforms/atspi-common/src/simplified.rs @@ -89,6 +89,13 @@ impl Accessible { } } + pub fn accessible_id(&self) -> Result { + match self { + Self::Node(node) => node.accessible_id(), + Self::Root(_) => Ok(String::new()), + } + } + pub fn child_at_index(&self, index: usize) -> Result> { match self { Self::Node(node) => node diff --git a/platforms/macos/src/node.rs b/platforms/macos/src/node.rs index 1b523d1fd..9b8c9c1c7 100644 --- a/platforms/macos/src/node.rs +++ b/platforms/macos/src/node.rs @@ -401,6 +401,14 @@ declare_class!( .flatten() } + #[method_id(accessibilityIdentifier)] + fn identifier(&self) -> Option> { + self.resolve(|node| { + node.author_id().map(NSString::from_str) + }) + .flatten() + } + #[method_id(accessibilityTitle)] fn title(&self) -> Option> { self.resolve(|node| { @@ -777,6 +785,7 @@ declare_class!( || selector == sel!(accessibilityFrame) || selector == sel!(accessibilityRole) || selector == sel!(accessibilityRoleDescription) + || selector == sel!(accessibilityIdentifier) || selector == sel!(accessibilityTitle) || selector == sel!(accessibilityHelp) || selector == sel!(accessibilityPlaceholderValue) diff --git a/platforms/unix/src/atspi/interfaces/accessible.rs b/platforms/unix/src/atspi/interfaces/accessible.rs index a4e75eebf..b0a3e1e2f 100644 --- a/platforms/unix/src/atspi/interfaces/accessible.rs +++ b/platforms/unix/src/atspi/interfaces/accessible.rs @@ -64,8 +64,8 @@ impl NodeAccessibleInterface { } #[dbus_interface(property)] - fn accessible_id(&self) -> ObjectId { - ObjectId::from(&self.node) + fn accessible_id(&self) -> fdo::Result { + self.node.accessible_id().map_err(self.map_error()) } fn get_child_at_index(&self, index: i32) -> fdo::Result<(OwnedObjectAddress,)> { @@ -172,8 +172,8 @@ impl RootAccessibleInterface { } #[dbus_interface(property)] - fn accessible_id(&self) -> ObjectId { - ObjectId::Root + fn accessible_id(&self) -> &str { + "" } fn get_child_at_index(&self, index: i32) -> fdo::Result<(OwnedObjectAddress,)> { diff --git a/platforms/windows/src/node.rs b/platforms/windows/src/node.rs index 069d0ee08..4731424f5 100644 --- a/platforms/windows/src/node.rs +++ b/platforms/windows/src/node.rs @@ -295,6 +295,10 @@ impl<'a> NodeWrapper<'a> { } } + fn automation_id(&self) -> Option<&str> { + self.0.author_id() + } + fn class_name(&self) -> Option<&str> { self.0.class_name() } @@ -872,6 +876,7 @@ properties! { (IsKeyboardFocusable, is_focusable), (HasKeyboardFocus, is_focused), (LiveSetting, live_setting), + (AutomationId, automation_id), (ClassName, class_name), (Orientation, orientation) } diff --git a/platforms/winit/Cargo.toml b/platforms/winit/Cargo.toml index 87acf9dc6..b8302676d 100644 --- a/platforms/winit/Cargo.toml +++ b/platforms/winit/Cargo.toml @@ -40,4 +40,3 @@ accesskit_unix = { version = "0.10.1", path = "../unix", optional = true, defaul version = "0.30" default-features = false features = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"] -