Skip to content

Commit 4e29a63

Browse files
authored
Merge pull request #679 from sakhisheikh/sm-decouple-ax-response
[Accessibility Inspector] Decouple AX element response callback
2 parents 64f9a0e + 81c89fd commit 4e29a63

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ios/accessibility/accessibility_control.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,23 @@ func (a *ControlInterface) TurnOff() {
251251
a.deviceInspectorShowVisuals(false)
252252
}
253253

254-
// Move navigates focus using the given direction and returns selected element data.
255-
func (a *ControlInterface) Move(ctx context.Context, direction MoveDirection) (AXElementData, error) {
256-
log.Info("changing")
254+
// Move sends the move command without waiting for response.
255+
// Use AwaitElementChanged to get the response asynchronously.
256+
func (a *ControlInterface) Move(direction MoveDirection) {
257257
a.deviceInspectorMoveWithOptions(direction)
258-
log.Info("before changed")
258+
}
259259

260+
// AwaitElementChanged waits for timeout if available
261+
// returns the next element change response.
262+
func (a *ControlInterface) AwaitElementChanged(ctx context.Context) (AXElementData, error) {
260263
resp, err := a.awaitHostInspectorCurrentElementChanged(ctx)
261264
if err != nil {
262265
return AXElementData{}, err
263266
}
267+
return a.parseElementResponse(resp)
268+
}
264269

270+
func (a *ControlInterface) parseElementResponse(resp map[string]interface{}) (AXElementData, error) {
265271
innerValue, err := getInnerValue(resp)
266272
if err != nil {
267273
return AXElementData{}, err
@@ -469,7 +475,8 @@ func (a *ControlInterface) PerformAction(actionName Action, currentPlatformEleme
469475

470476
// GetElement moves the green selection rectangle one element further
471477
func (a *ControlInterface) GetElement(ctx context.Context) (AXElementData, error) {
472-
return a.Move(ctx, DirectionNext)
478+
a.Move(DirectionNext)
479+
return a.AwaitElementChanged(ctx)
473480
}
474481

475482
func (a *ControlInterface) UpdateAccessibilitySetting(name string, val interface{}) {

0 commit comments

Comments
 (0)