mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +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 {
|
if err := sanderling.Set("tap", v.bindTap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := sanderling.Set("doubleTap", v.bindDoubleTap); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := sanderling.Set("inputText", v.bindInputText); err != nil {
|
if err := sanderling.Set("inputText", v.bindInputText); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -391,6 +394,17 @@ func (v *Verifier) bindTap(call goja.FunctionCall) goja.Value {
|
|||||||
return handle
|
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 {
|
func (v *Verifier) bindInputText(call goja.FunctionCall) goja.Value {
|
||||||
parameters := call.Argument(0).ToObject(v.runtime)
|
parameters := call.Argument(0).ToObject(v.runtime)
|
||||||
if parameters == nil {
|
if parameters == nil {
|
||||||
|
|||||||
@@ -372,6 +372,10 @@ func jsValueToAction(runtime *goja.Runtime, value goja.Value) (Action, error) {
|
|||||||
on := object.Get("on")
|
on := object.Get("on")
|
||||||
x, y := coordinatesOf(runtime, on)
|
x, y := coordinatesOf(runtime, on)
|
||||||
return Action{Kind: ActionKindTap, On: selectorOf(runtime, on), X: x, Y: y}, nil
|
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":
|
case "InputText":
|
||||||
into := object.Get("into")
|
into := object.Get("into")
|
||||||
text := object.Get("text")
|
text := object.Get("text")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ type ActionKind string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ActionKindTap ActionKind = "Tap"
|
ActionKindTap ActionKind = "Tap"
|
||||||
|
ActionKindDoubleTap ActionKind = "DoubleTap"
|
||||||
ActionKindInputText ActionKind = "InputText"
|
ActionKindInputText ActionKind = "InputText"
|
||||||
ActionKindSwipe ActionKind = "Swipe"
|
ActionKindSwipe ActionKind = "Swipe"
|
||||||
ActionKindPressKey ActionKind = "PressKey"
|
ActionKindPressKey ActionKind = "PressKey"
|
||||||
|
|||||||
Reference in new issue
Block a user