feat: add adb screen record

This commit is contained in:
lilong.129
2025-03-06 16:57:51 +08:00
parent 5b503a4394
commit cc81c00a82
14 changed files with 159 additions and 43 deletions

View File

@@ -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) {

View File

@@ -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