update accessibility hierarchy to treat lithoViews and LithoRecyclerViews as ViewGroups

Summary: This will correctly show all view children instead of reverting to the non-ax default behavior. Fixes bug where recycler views showed no children.

Reviewed By: jknoxville

Differential Revision: D18574220

fbshipit-source-id: f22606fb582e0bfd1a171dc4497e1d1613e800d1
This commit is contained in:
Sara Valderrama
2019-11-19 10:01:49 -08:00
committed by Facebook Github Bot
parent 19df98e525
commit 353cfeafc8
2 changed files with 24 additions and 4 deletions

View File

@@ -63,6 +63,12 @@ public class LithoRecyclerViewDescriptor extends NodeDescriptor<LithoRecylerView
return 1; return 1;
} }
@Override
public int getAXChildCount(LithoRecylerView node) throws Exception {
final NodeDescriptor descriptor = descriptorForClass(ViewGroup.class);
return descriptor.getAXChildCount(node);
}
@Override @Override
public Object getChildAt(LithoRecylerView node, int index) throws Exception { public Object getChildAt(LithoRecylerView node, int index) throws Exception {
// TODO T39526148 account for the case above // TODO T39526148 account for the case above
@@ -77,6 +83,12 @@ public class LithoRecyclerViewDescriptor extends NodeDescriptor<LithoRecylerView
return DebugSection.getRootInstance(childrenViews); return DebugSection.getRootInstance(childrenViews);
} }
@Override
public Object getAXChildAt(LithoRecylerView node, int index) throws Exception {
final NodeDescriptor descriptor = descriptorForClass(ViewGroup.class);
return descriptor.getAXChildAt(node, index);
}
@Override @Override
public List<Named<FlipperObject>> getData(LithoRecylerView node) throws Exception { public List<Named<FlipperObject>> getData(LithoRecylerView node) throws Exception {
final List<Named<FlipperObject>> props = new ArrayList<>(); final List<Named<FlipperObject>> props = new ArrayList<>();
@@ -86,6 +98,12 @@ public class LithoRecyclerViewDescriptor extends NodeDescriptor<LithoRecylerView
return props; return props;
} }
@Override
public List<Named<FlipperObject>> getAXData(LithoRecylerView node) throws Exception {
final NodeDescriptor descriptor = descriptorForClass(ViewGroup.class);
return descriptor.getAXData(node);
}
@Override @Override
public void setValue(LithoRecylerView node, String[] path, FlipperDynamic value) public void setValue(LithoRecylerView node, String[] path, FlipperDynamic value)
throws Exception { throws Exception {

View File

@@ -58,8 +58,9 @@ public class LithoViewDescriptor extends NodeDescriptor<LithoView> {
} }
@Override @Override
public int getAXChildCount(LithoView node) { public int getAXChildCount(LithoView node) throws Exception {
return node.getChildCount(); final NodeDescriptor descriptor = descriptorForClass(ViewGroup.class);
return descriptor.getAXChildCount(node);
} }
@Override @Override
@@ -68,8 +69,9 @@ public class LithoViewDescriptor extends NodeDescriptor<LithoView> {
} }
@Override @Override
public @Nullable Object getAXChildAt(LithoView node, int index) { public @Nullable Object getAXChildAt(LithoView node, int index) throws Exception {
return node.getChildAt(index); final NodeDescriptor descriptor = descriptorForClass(ViewGroup.class);
return descriptor.getChildAt(node, index);
} }
@Override @Override