mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-01 22:09:35 +08:00
feat: 加入打点支持
This commit is contained in:
@@ -19,6 +19,7 @@ type HarmonyDevice struct {
|
||||
d *ghdc.Device
|
||||
ConnectKey string `json:"connect_key,omitempty" yaml:"connect_key,omitempty"`
|
||||
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"`
|
||||
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
||||
}
|
||||
|
||||
type HarmonyDeviceOption func(*HarmonyDevice)
|
||||
@@ -29,6 +30,18 @@ func WithConnectKey(connectKey string) HarmonyDeviceOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithIgnorePopup(ignorePopup bool) HarmonyDeviceOption {
|
||||
return func(device *HarmonyDevice) {
|
||||
device.IgnorePopup = ignorePopup
|
||||
}
|
||||
}
|
||||
|
||||
func WithLogOn(logOn bool) HarmonyDeviceOption {
|
||||
return func(device *HarmonyDevice) {
|
||||
device.LogOn = logOn
|
||||
}
|
||||
}
|
||||
|
||||
func NewHarmonyDevice(options ...HarmonyDeviceOption) (device *HarmonyDevice, err error) {
|
||||
device = &HarmonyDevice{}
|
||||
for _, option := range options {
|
||||
@@ -101,7 +114,7 @@ func (dev *HarmonyDevice) UUID() string {
|
||||
}
|
||||
|
||||
func (dev *HarmonyDevice) LogEnabled() bool {
|
||||
return false
|
||||
return dev.LogOn
|
||||
}
|
||||
|
||||
func (dev *HarmonyDevice) NewDriver(options ...DriverOption) (driverExt *DriverExt, err error) {
|
||||
|
||||
@@ -145,7 +145,10 @@ func (hd *hdcDriver) TapFloat(x, y float64, options ...ActionOption) error {
|
||||
|
||||
x += actionOptions.getRandomOffset()
|
||||
y += actionOptions.getRandomOffset()
|
||||
|
||||
if actionOptions.Identifier != "" {
|
||||
startTime := int(time.Now().UnixMilli())
|
||||
hd.points = append(hd.points, ExportPoint{Start: startTime, End: startTime + 100, Ext: actionOptions.Identifier, RunTime: 100})
|
||||
}
|
||||
return hd.uiDriver.InjectGesture(ghdc.NewGesture().Start(ghdc.Point{X: int(x), Y: int(y)}).Pause(100))
|
||||
}
|
||||
|
||||
@@ -195,7 +198,10 @@ func (hd *hdcDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...Actio
|
||||
if actionOptions.PressDuration > 0 {
|
||||
duration = int(actionOptions.PressDuration * 1000)
|
||||
}
|
||||
|
||||
if actionOptions.Identifier != "" {
|
||||
startTime := int(time.Now().UnixMilli())
|
||||
hd.points = append(hd.points, ExportPoint{Start: startTime, End: startTime + 100, Ext: actionOptions.Identifier, RunTime: 100})
|
||||
}
|
||||
return hd.uiDriver.InjectGesture(ghdc.NewGesture().Start(ghdc.Point{X: int(fromX), Y: int(fromY)}).MoveTo(ghdc.Point{X: int(toX), Y: int(toY)}, duration))
|
||||
}
|
||||
|
||||
@@ -304,5 +310,6 @@ func (hd *hdcDriver) StartCaptureLog(identifier ...string) (err error) {
|
||||
}
|
||||
|
||||
func (hd *hdcDriver) StopCaptureLog() (result interface{}, err error) {
|
||||
return nil, errDriverNotImplemented
|
||||
// defer clear(hd.points)
|
||||
return hd.points, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user