mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 09:49:33 +08:00
feat: add adb screen record
This commit is contained in:
@@ -120,11 +120,10 @@ func (o *ActionOptions) Options() []ActionOption {
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
options = append(options, o.GetScreenShotOptions()...)
|
||||
options = append(options, o.GetScreenRecordOptions()...)
|
||||
|
||||
func (o *ActionOptions) GetScreenOptions() []ActionOption {
|
||||
return o.ScreenOptions.Options()
|
||||
return options
|
||||
}
|
||||
|
||||
func (o *ActionOptions) ApplyOffset(absX, absY float64) (float64, float64) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import "github.com/httprunner/httprunner/v5/uixt/types"
|
||||
|
||||
type ScreenOptions struct {
|
||||
ScreenShotOptions
|
||||
ScreenRecordOptions
|
||||
ScreenFilterOptions
|
||||
}
|
||||
|
||||
@@ -18,7 +19,7 @@ type ScreenShotOptions struct {
|
||||
ScreenShotFileName string `json:"screenshot_file_name,omitempty" yaml:"screenshot_file_name,omitempty"`
|
||||
}
|
||||
|
||||
func (o *ScreenShotOptions) Options() []ActionOption {
|
||||
func (o *ScreenShotOptions) GetScreenShotOptions() []ActionOption {
|
||||
options := make([]ActionOption, 0)
|
||||
if o == nil {
|
||||
return options
|
||||
@@ -125,6 +126,49 @@ func WithScreenShotFileName(fileName string) ActionOption {
|
||||
}
|
||||
}
|
||||
|
||||
type ScreenRecordOptions struct {
|
||||
ScreenRecordDuration float64 `json:"screenrecord_duration,omitempty" yaml:"screenrecord_duration,omitempty"`
|
||||
ScreenRecordWithAudio bool `json:"screenrecord_with_audio,omitempty" yaml:"screenrecord_with_audio,omitempty"`
|
||||
ScreenRecordPath string `json:"screenrecord_path,omitempty" yaml:"screenrecord_path,omitempty"`
|
||||
}
|
||||
|
||||
func (o *ScreenRecordOptions) GetScreenRecordOptions() []ActionOption {
|
||||
options := make([]ActionOption, 0)
|
||||
if o == nil {
|
||||
return options
|
||||
}
|
||||
|
||||
// screen record options
|
||||
if o.ScreenRecordDuration > 0 {
|
||||
options = append(options, WithDuration(o.ScreenRecordDuration))
|
||||
}
|
||||
if o.ScreenRecordWithAudio {
|
||||
options = append(options, WithScreenRecordAudio(true))
|
||||
}
|
||||
if o.ScreenRecordPath != "" {
|
||||
options = append(options, WithScreenRecordPath(o.ScreenRecordPath))
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
func WithScreenRecordDuation(duration float64) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.ScreenRecordDuration = duration
|
||||
}
|
||||
}
|
||||
|
||||
func WithScreenRecordAudio(audioOn bool) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.ScreenRecordWithAudio = audioOn
|
||||
}
|
||||
}
|
||||
|
||||
func WithScreenRecordPath(path string) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.ScreenRecordPath = path
|
||||
}
|
||||
}
|
||||
|
||||
// (x1, y1) is the top left corner, (x2, y2) is the bottom right corner
|
||||
// [x1, y1, x2, y2] in percentage of the screen
|
||||
type Scope []float64
|
||||
|
||||
Reference in New Issue
Block a user