mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(verifier): add LongPress and Scroll action kinds
This commit is contained in:
1 parent
ae271b86e0
commit
8ffb174c1b
2 files changed
+29
No files matched your search
@@ -350,6 +350,16 @@ func lastActionObject(runtime *goja.Runtime, action *Action) goja.Value {
|
|||||||
if action.DurationMillis > 0 {
|
if action.DurationMillis > 0 {
|
||||||
_ = object.Set("durationMillis", action.DurationMillis)
|
_ = object.Set("durationMillis", action.DurationMillis)
|
||||||
}
|
}
|
||||||
|
case ActionKindScroll:
|
||||||
|
_ = object.Set("direction", action.Direction)
|
||||||
|
from := runtime.NewObject()
|
||||||
|
_ = from.Set("x", action.FromX)
|
||||||
|
_ = from.Set("y", action.FromY)
|
||||||
|
to := runtime.NewObject()
|
||||||
|
_ = to.Set("x", action.ToX)
|
||||||
|
_ = to.Set("y", action.ToY)
|
||||||
|
_ = object.Set("from", from)
|
||||||
|
_ = object.Set("to", to)
|
||||||
case ActionKindPressKey:
|
case ActionKindPressKey:
|
||||||
_ = object.Set("key", action.Key)
|
_ = object.Set("key", action.Key)
|
||||||
case ActionKindWait:
|
case ActionKindWait:
|
||||||
@@ -448,6 +458,20 @@ func jsValueToAction(runtime *goja.Runtime, value goja.Value) (Action, error) {
|
|||||||
ToY: toY,
|
ToY: toY,
|
||||||
DurationMillis: intField(object, "durationMillis"),
|
DurationMillis: intField(object, "durationMillis"),
|
||||||
}, nil
|
}, nil
|
||||||
|
case "LongPress":
|
||||||
|
on := object.Get("on")
|
||||||
|
x, y := coordinatesOf(runtime, on)
|
||||||
|
return Action{Kind: ActionKindLongPress, On: selectorOf(runtime, on), X: x, Y: y}, nil
|
||||||
|
case "Scroll":
|
||||||
|
in := object.Get("in")
|
||||||
|
x, y := coordinatesOf(runtime, in)
|
||||||
|
return Action{
|
||||||
|
Kind: ActionKindScroll,
|
||||||
|
Direction: stringOf(object.Get("direction")),
|
||||||
|
On: selectorOf(runtime, in),
|
||||||
|
X: x,
|
||||||
|
Y: y,
|
||||||
|
}, nil
|
||||||
case "PressKey":
|
case "PressKey":
|
||||||
return Action{Kind: ActionKindPressKey, Key: stringOf(object.Get("key"))}, nil
|
return Action{Kind: ActionKindPressKey, Key: stringOf(object.Get("key"))}, nil
|
||||||
case "Wait":
|
case "Wait":
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const (
|
|||||||
ActionKindSwipe ActionKind = "Swipe"
|
ActionKindSwipe ActionKind = "Swipe"
|
||||||
ActionKindPressKey ActionKind = "PressKey"
|
ActionKindPressKey ActionKind = "PressKey"
|
||||||
ActionKindWait ActionKind = "Wait"
|
ActionKindWait ActionKind = "Wait"
|
||||||
|
ActionKindLongPress ActionKind = "LongPress"
|
||||||
|
ActionKindScroll ActionKind = "Scroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Action is a single UI interaction produced by the spec's action generator.
|
// Action is a single UI interaction produced by the spec's action generator.
|
||||||
@@ -28,6 +30,9 @@ type Action struct {
|
|||||||
DurationMillis int
|
DurationMillis int
|
||||||
// Key is the logical key name for ActionKindPressKey.
|
// Key is the logical key name for ActionKindPressKey.
|
||||||
Key string
|
Key string
|
||||||
|
// Direction is the scroll direction for ActionKindScroll: one of "up",
|
||||||
|
// "down", "left", "right". Empty for every other kind.
|
||||||
|
Direction string
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogEntry mirrors a logcat line captured between steps.
|
// LogEntry mirrors a logcat line captured between steps.
|
||||||
|
|||||||
Reference in new issue
Block a user