Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion accesskit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,11 @@ impl Properties {
self.indices.0[id as usize] = index as u8;
&mut self.values[index]
} else {
&mut self.values[index]
let value = &mut self.values[index];
if matches!(value, PropertyValue::None) {
*value = default;
}
value
}
}

Expand Down Expand Up @@ -1374,6 +1378,14 @@ macro_rules! node_id_vec_property_methods {
assert_eq!(node.$getter(), &[NodeId(0), NodeId(1)]);
}
#[test]
fn pusher_should_start_a_new_list_after_the_clearer() {
let mut node = Node::new(Role::Unknown);
node.$setter([NodeId(0)]);
node.$clearer();
node.$pusher(NodeId(1));
assert_eq!(node.$getter(), &[NodeId(1)]);
}
#[test]
fn clearer_should_reset_the_property() {
let mut node = Node::new(Role::Unknown);
node.$setter([NodeId(0)]);
Expand Down Expand Up @@ -2629,6 +2641,21 @@ mod custom_actions {
assert_eq!(node.custom_actions(), &[first_action, second_action]);
}
#[test]
fn pusher_should_start_a_new_list_after_the_clearer() {
let mut node = Node::new(Role::Unknown);
node.set_custom_actions([CustomAction {
id: 0,
description: "first test action".into(),
}]);
node.clear_custom_actions();
let second_action = CustomAction {
id: 1,
description: "second test action".into(),
};
node.push_custom_action(second_action.clone());
assert_eq!(node.custom_actions(), slice::from_ref(&second_action));
}
#[test]
fn clearer_should_reset_the_property() {
let mut node = Node::new(Role::Unknown);
node.set_custom_actions([CustomAction {
Expand Down
Loading