mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
revert(runner): drop selector-first tap; broke path/testTag selectors
This commit is contained in:
1 parent
39ccd5c7bf
commit
25ddf7d29e
2 files changed
+19
-28
No files matched your search
+16
-24
@@ -562,27 +562,23 @@ func settleForForeground(ctx context.Context, options Options) {
|
|||||||
func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.Action, tree *hierarchy.Tree) error {
|
func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.Action, tree *hierarchy.Tree) error {
|
||||||
switch action.Kind {
|
switch action.Kind {
|
||||||
case verifier.ActionKindTap:
|
case verifier.ActionKindTap:
|
||||||
// A selector resolves live on-device at tap time, so it lands correctly
|
x, y, ok := resolveCoordinates(action, tree)
|
||||||
// even when the layout shifted between observe and apply (e.g. the soft
|
if !ok {
|
||||||
// keyboard finished animating out, moving every control down). Tapping
|
if action.On == "" {
|
||||||
// the observe-time coordinates would miss the moved control. Coordinates
|
return nil
|
||||||
// are the fallback for selector-less actions (the web/V8 path only emits
|
}
|
||||||
// coordinates).
|
|
||||||
if action.On != "" {
|
|
||||||
return drv.TapSelector(ctx, action.On)
|
return drv.TapSelector(ctx, action.On)
|
||||||
}
|
}
|
||||||
if x, y, ok := resolveCoordinates(action, tree); ok {
|
return drv.Tap(ctx, x, y)
|
||||||
return drv.Tap(ctx, x, y)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case verifier.ActionKindDoubleTap:
|
case verifier.ActionKindDoubleTap:
|
||||||
if action.On != "" {
|
x, y, ok := resolveCoordinates(action, tree)
|
||||||
|
if !ok {
|
||||||
|
if action.On == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return drv.DoubleTapSelector(ctx, action.On)
|
return drv.DoubleTapSelector(ctx, action.On)
|
||||||
}
|
}
|
||||||
if x, y, ok := resolveCoordinates(action, tree); ok {
|
return drv.DoubleTap(ctx, x, y)
|
||||||
return drv.DoubleTap(ctx, x, y)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case verifier.ActionKindLongPress:
|
case verifier.ActionKindLongPress:
|
||||||
x, y, ok := resolveCoordinates(action, tree)
|
x, y, ok := resolveCoordinates(action, tree)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -600,18 +596,14 @@ func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.A
|
|||||||
}
|
}
|
||||||
return drv.Swipe(ctx, fromX, fromY, toX, toY, duration)
|
return drv.Swipe(ctx, fromX, fromY, toX, toY, duration)
|
||||||
case verifier.ActionKindInputText:
|
case verifier.ActionKindInputText:
|
||||||
// Focus the field by selector when one is present, for the same
|
|
||||||
// layout-shift reason as Tap: InputText is the action that raises the
|
|
||||||
// keyboard, so its follow-on focus tap is the most likely to land on a
|
|
||||||
// stale position. Coordinates focus the selector-less web/V8 path.
|
|
||||||
tapped := false
|
tapped := false
|
||||||
if action.On != "" {
|
if x, y, ok := resolveCoordinates(action, tree); ok {
|
||||||
if err := drv.TapSelector(ctx, action.On); err != nil {
|
if err := drv.Tap(ctx, x, y); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tapped = true
|
tapped = true
|
||||||
} else if x, y, ok := resolveCoordinates(action, tree); ok {
|
} else if action.On != "" {
|
||||||
if err := drv.Tap(ctx, x, y); err != nil {
|
if err := drv.TapSelector(ctx, action.On); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tapped = true
|
tapped = true
|
||||||
|
|||||||
@@ -673,14 +673,13 @@ func TestApplyAction_InputTextErasesExistingTextBeforeTyping(t *testing.T) {
|
|||||||
t.Fatalf("applyAction: %v", err)
|
t.Fatalf("applyAction: %v", err)
|
||||||
}
|
}
|
||||||
// The post-tap settle is now a brief internal sleep, not a WaitForIdle RPC,
|
// The post-tap settle is now a brief internal sleep, not a WaitForIdle RPC,
|
||||||
// so the recorded driver actions are focus-tap, erase, input. The focus tap
|
// so the recorded driver actions are tap, erase, input.
|
||||||
// goes by selector (live on-device resolution) since the action carries one.
|
|
||||||
actions := driverMock.Actions()
|
actions := driverMock.Actions()
|
||||||
if len(actions) != 3 {
|
if len(actions) != 3 {
|
||||||
t.Fatalf("want tap, erase, input; got %v", actions)
|
t.Fatalf("want tap, erase, input; got %v", actions)
|
||||||
}
|
}
|
||||||
if actions[0].Kind != mockdriver.ActionTapSelector || actions[0].Selector != "id:username" {
|
if actions[0].Kind != mockdriver.ActionTap {
|
||||||
t.Errorf("first action = %+v, want tap_selector id:username", actions[0])
|
t.Errorf("first action = %v, want tap", actions[0].Kind)
|
||||||
}
|
}
|
||||||
if actions[1].Kind != mockdriver.ActionEraseText || actions[1].CharacterCount != len("stale-value") {
|
if actions[1].Kind != mockdriver.ActionEraseText || actions[1].CharacterCount != len("stale-value") {
|
||||||
t.Errorf("second action = %+v, want erase_text of %d characters", actions[1], len("stale-value"))
|
t.Errorf("second action = %+v, want erase_text of %d characters", actions[1], len("stale-value"))
|
||||||
|
|||||||
Reference in new issue
Block a user