mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 06:49:38 +08:00
refactor: merge swipe methods
This commit is contained in:
@@ -19,6 +19,7 @@ type ActionOptions struct {
|
||||
Direction interface{} `json:"direction,omitempty" yaml:"direction,omitempty"` // used by swipe to tap text or app
|
||||
Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"` // TODO: wait timeout in seconds for mobile action
|
||||
Frequency int `json:"frequency,omitempty" yaml:"frequency,omitempty"`
|
||||
AbsCoordinate bool `json:"abs,omitempty" yaml:"abs,omitempty"` // use absolute coordinate
|
||||
|
||||
ScreenOptions
|
||||
|
||||
@@ -55,6 +56,9 @@ func (o *ActionOptions) Options() []ActionOption {
|
||||
if o.Steps != 0 {
|
||||
options = append(options, WithSteps(o.Steps))
|
||||
}
|
||||
if o.AbsCoordinate {
|
||||
options = append(options, WithAbsoluteCoordinate(true))
|
||||
}
|
||||
|
||||
switch v := o.Direction.(type) {
|
||||
case string:
|
||||
@@ -241,6 +245,12 @@ func WithDirection(direction string) ActionOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithAbsoluteCoordinate(abs bool) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.AbsCoordinate = abs
|
||||
}
|
||||
}
|
||||
|
||||
// WithCustomDirection inputs sx, sy, ex, ey
|
||||
func WithCustomDirection(sx, sy, ex, ey float64) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
|
||||
Reference in New Issue
Block a user