Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Apr 26, 2024
1 parent 4dc666f commit bcc54e1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cache/benches/wcag_cache_items.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cache/benches/zbus_docs_cache_items.json

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ pub struct CacheItem {
/// The parent object. (so)
pub parent: CacheRef,
/// The accessible index in parent.I
pub index: i32,
pub index: Option<usize>,
/// Child count of the accessible.I
pub children_num: usize,
pub children_num: Option<usize>,
/// The exposed interface(s) set
pub interfaces: InterfaceSet,
/// Accessible role. u
Expand Down Expand Up @@ -255,11 +255,11 @@ impl CacheItem {
object: atspi_cache_item.object.into(),
app: atspi_cache_item.app.into(),
parent: CacheRef::new(atspi_cache_item.parent.into()),
index: atspi_cache_item.index,
index: atspi_cache_item.index.try_into().ok(),
children_num: atspi_cache_item
.children
.try_into()
.expect("Negative values are not permitted for children_num"),
.ok(),
interfaces: atspi_cache_item.ifaces,
role: atspi_cache_item.role,
states: atspi_cache_item.states,
Expand Down Expand Up @@ -293,8 +293,8 @@ impl CacheItem {
object: atspi_cache_item.object.into(),
app: atspi_cache_item.app.into(),
parent: CacheRef::new(atspi_cache_item.parent.into()),
index,
children_num: atspi_cache_item.children.len(),
index: index.try_into().ok(),
children_num: Some(atspi_cache_item.children.len()),
interfaces: atspi_cache_item.ifaces,
role: atspi_cache_item.role,
states: atspi_cache_item.states,
Expand Down Expand Up @@ -916,9 +916,6 @@ impl Cache {
let parent_key = item.parent.key.clone();
let parent_ref_opt = cache.get(&parent_key);

// Update this item's parent reference
let ix_opt = usize::try_from(item.index).ok();

// Update this item's children references
for child_ref in &mut item.children {
if let Some(child_arc) = cache.get(&child_ref.key).as_ref() {
Expand All @@ -930,7 +927,7 @@ impl Cache {
// TODO: Should there be errors for the non let bindings?
if let Some(parent_ref) = parent_ref_opt {
item.parent.item = Arc::downgrade(&parent_ref);
if let Some(ix) = ix_opt {
if let Some(ix) = item.index {
if let Some(cache_ref) = parent_ref
.write()?
.children
Expand Down Expand Up @@ -982,10 +979,10 @@ pub async fn accessible_to_cache_item(
object: accessible.try_into()?,
app: app.into(),
parent: CacheRef::new(parent.into()),
index,
index: index.try_into().ok(),
children_num: children_num
.try_into()
.expect("Negative numbers are not permitted for children_num"),
.ok(),
interfaces,
role,
states,
Expand Down
4 changes: 2 additions & 2 deletions odilia/src/events/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ mod tests {
sender: ":1.2".into(),
}
.into(),
index: 323,
children_num: 0,
index: Some(323),
children_num: Some(0),
interfaces: InterfaceSet::new(
Interface::Accessible
| Interface::Collection | Interface::Component
Expand Down
2 changes: 1 addition & 1 deletion odilia/src/events/wcag_cache_items.json

Large diffs are not rendered by default.

0 comments on commit bcc54e1

Please sign in to comment.