mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(verifier): bind doubleTap and decode DoubleTap actions
This commit is contained in:
1 parent
237ead2d33
commit
6766f1ad58
3 files changed
+19
No files matched your search
@@ -100,6 +100,9 @@ func (v *Verifier) installRuntimeBindings() error {
|
||||
if err := sanderling.Set("tap", v.bindTap); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("doubleTap", v.bindDoubleTap); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("inputText", v.bindInputText); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -391,6 +394,17 @@ func (v *Verifier) bindTap(call goja.FunctionCall) goja.Value {
|
||||
return handle
|
||||
}
|
||||
|
||||
func (v *Verifier) bindDoubleTap(call goja.FunctionCall) goja.Value {
|
||||
parameters := call.Argument(0).ToObject(v.runtime)
|
||||
if parameters == nil {
|
||||
panic(v.runtime.NewTypeError("DoubleTap requires {on}"))
|
||||
}
|
||||
handle := v.runtime.NewObject()
|
||||
_ = handle.Set("kind", "DoubleTap")
|
||||
_ = handle.Set("on", parameters.Get("on"))
|
||||
return handle
|
||||
}
|
||||
|
||||
func (v *Verifier) bindInputText(call goja.FunctionCall) goja.Value {
|
||||
parameters := call.Argument(0).ToObject(v.runtime)
|
||||
if parameters == nil {
|
||||
|
||||
@@ -372,6 +372,10 @@ func jsValueToAction(runtime *goja.Runtime, value goja.Value) (Action, error) {
|
||||
on := object.Get("on")
|
||||
x, y := coordinatesOf(runtime, on)
|
||||
return Action{Kind: ActionKindTap, On: selectorOf(runtime, on), X: x, Y: y}, nil
|
||||
case "DoubleTap":
|
||||
on := object.Get("on")
|
||||
x, y := coordinatesOf(runtime, on)
|
||||
return Action{Kind: ActionKindDoubleTap, On: selectorOf(runtime, on), X: x, Y: y}, nil
|
||||
case "InputText":
|
||||
into := object.Get("into")
|
||||
text := object.Get("text")
|
||||
|
||||
@@ -5,6 +5,7 @@ type ActionKind string
|
||||
|
||||
const (
|
||||
ActionKindTap ActionKind = "Tap"
|
||||
ActionKindDoubleTap ActionKind = "DoubleTap"
|
||||
ActionKindInputText ActionKind = "InputText"
|
||||
ActionKindSwipe ActionKind = "Swipe"
|
||||
ActionKindPressKey ActionKind = "PressKey"
|
||||
|
||||
Reference in new issue
Block a user