mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
refactor: use WithRelative to set relative coordinate, absolute by default
This commit is contained in:
@@ -19,7 +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
|
||||
Relative bool `json:"relative,omitempty" yaml:"relative,omitempty"` // use relative coordinate
|
||||
|
||||
ScreenOptions
|
||||
|
||||
@@ -56,8 +56,8 @@ func (o *ActionOptions) Options() []ActionOption {
|
||||
if o.Steps != 0 {
|
||||
options = append(options, WithSteps(o.Steps))
|
||||
}
|
||||
if o.AbsCoordinate {
|
||||
options = append(options, WithAbsoluteCoordinate(true))
|
||||
if o.Relative {
|
||||
options = append(options, WithRelative(true))
|
||||
}
|
||||
|
||||
switch v := o.Direction.(type) {
|
||||
@@ -260,9 +260,10 @@ func WithDirection(direction string) ActionOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithAbsoluteCoordinate(abs bool) ActionOption {
|
||||
// WithRelative set relative coordinate, (0, 0) is the top-left corner of the screen
|
||||
func WithRelative(relative bool) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.AbsCoordinate = abs
|
||||
o.Relative = relative
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user