mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 16:07:45 +08:00
refactor: remove unused code
This commit is contained in:
@@ -60,18 +60,6 @@ type ScreenResult struct {
|
|||||||
Icons UIResultMap `json:"icons"` // CV 识别的图标
|
Icons UIResultMap `json:"icons"` // CV 识别的图标
|
||||||
Tags []string `json:"tags"` // tags for image, e.g. ["feed", "ad", "live"]
|
Tags []string `json:"tags"` // tags for image, e.g. ["feed", "ad", "live"]
|
||||||
Popup *PopupInfo `json:"popup,omitempty"`
|
Popup *PopupInfo `json:"popup,omitempty"`
|
||||||
|
|
||||||
SwipeStartTime int64 `json:"swipe_start_time"` // 滑动开始时间戳
|
|
||||||
SwipeFinishTime int64 `json:"swipe_finish_time"` // 滑动结束时间戳
|
|
||||||
FetchVideoStartTime int64 `json:"fetch_video_start_time"` // 抓取视频开始时间戳
|
|
||||||
FetchVideoFinishTime int64 `json:"fetch_video_finish_time"` // 抓取视频结束时间戳
|
|
||||||
|
|
||||||
FetchVideoElapsed int64 `json:"fetch_video_elapsed"` // 抓取视频耗时(ms)
|
|
||||||
ScreenshotTakeElapsed int64 `json:"screenshot_take_elapsed"` // 设备截图耗时(ms)
|
|
||||||
ScreenshotCVElapsed int64 `json:"screenshot_cv_elapsed"` // CV 识别耗时(ms)
|
|
||||||
|
|
||||||
// 当前 Feed/Live 整体耗时
|
|
||||||
TotalElapsed int64 `json:"total_elapsed"` // current_swipe_finish -> next_swipe_start 整体耗时(ms)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScreenResultMap map[string]*ScreenResult // key is date time
|
type ScreenResultMap map[string]*ScreenResult // key is date time
|
||||||
|
|||||||
@@ -71,12 +71,6 @@ func (dExt *DriverExt) AutoPopupHandler() error {
|
|||||||
return dExt.handleTextPopup(screenResult.Texts)
|
return dExt.handleTextPopup(screenResult.Texts)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
CloseStatusFound = "found"
|
|
||||||
CloseStatusSuccess = "success"
|
|
||||||
CloseStatusFail = "fail"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ClosePopupsResult represents the result of recognized popup to close
|
// ClosePopupsResult represents the result of recognized popup to close
|
||||||
type ClosePopupsResult struct {
|
type ClosePopupsResult struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@@ -87,9 +81,7 @@ type ClosePopupsResult struct {
|
|||||||
|
|
||||||
type PopupInfo struct {
|
type PopupInfo struct {
|
||||||
*ClosePopupsResult
|
*ClosePopupsResult
|
||||||
CloseStatus string `json:"close_status"` // found/success/fail
|
|
||||||
ClosePoints []PointF `json:"close_points,omitempty"` // CV 识别的所有关闭按钮(仅关闭按钮,可能存在多个)
|
ClosePoints []PointF `json:"close_points,omitempty"` // CV 识别的所有关闭按钮(仅关闭按钮,可能存在多个)
|
||||||
RetryCount int `json:"retry_count"`
|
|
||||||
PicName string `json:"pic_name"`
|
PicName string `json:"pic_name"`
|
||||||
PicURL string `json:"pic_url"`
|
PicURL string `json:"pic_url"`
|
||||||
}
|
}
|
||||||
@@ -129,7 +121,6 @@ func (dExt *DriverExt) ClosePopupsHandler() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
popup.CloseStatus = CloseStatusFound
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Interface("closePoint", closePoint).
|
Interface("closePoint", closePoint).
|
||||||
Interface("popup", popup).
|
Interface("popup", popup).
|
||||||
|
|||||||
@@ -386,7 +386,6 @@ type IImageService interface {
|
|||||||
|
|
||||||
// GetScreenResult takes a screenshot, returns the image recognization result
|
// GetScreenResult takes a screenshot, returns the image recognization result
|
||||||
func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *ScreenResult, err error) {
|
func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *ScreenResult, err error) {
|
||||||
startTime := time.Now()
|
|
||||||
fileName := builtin.GenNameWithTimestamp("%d_screenshot")
|
fileName := builtin.GenNameWithTimestamp("%d_screenshot")
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
screenshotActions := actionOptions.screenshotActions()
|
screenshotActions := actionOptions.screenshotActions()
|
||||||
@@ -397,14 +396,12 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
screenshotTakeElapsed := time.Since(startTime).Milliseconds()
|
|
||||||
|
|
||||||
screenResult = &ScreenResult{
|
screenResult = &ScreenResult{
|
||||||
bufSource: bufSource,
|
bufSource: bufSource,
|
||||||
imagePath: imagePath,
|
imagePath: imagePath,
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
Resolution: dExt.WindowSize,
|
Resolution: dExt.WindowSize,
|
||||||
ScreenshotTakeElapsed: screenshotTakeElapsed,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imageResult, err := dExt.ImageService.GetImage(bufSource, options...)
|
imageResult, err := dExt.ImageService.GetImage(bufSource, options...)
|
||||||
@@ -414,7 +411,6 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
}
|
}
|
||||||
if imageResult != nil {
|
if imageResult != nil {
|
||||||
screenResult.ImageResult = imageResult
|
screenResult.ImageResult = imageResult
|
||||||
screenResult.ScreenshotCVElapsed = time.Since(startTime).Milliseconds() - screenshotTakeElapsed
|
|
||||||
screenResult.Texts = imageResult.OCRResult.ToOCRTexts()
|
screenResult.Texts = imageResult.OCRResult.ToOCRTexts()
|
||||||
screenResult.UploadedURL = imageResult.URL
|
screenResult.UploadedURL = imageResult.URL
|
||||||
screenResult.Icons = imageResult.UIResult
|
screenResult.Icons = imageResult.UIResult
|
||||||
@@ -438,8 +434,6 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
log.Debug().
|
log.Debug().
|
||||||
Str("imagePath", imagePath).
|
Str("imagePath", imagePath).
|
||||||
Str("imageUrl", screenResult.UploadedURL).
|
Str("imageUrl", screenResult.UploadedURL).
|
||||||
Int64("screenshot_take_elapsed(ms)", screenResult.ScreenshotTakeElapsed).
|
|
||||||
Int64("screenshot_cv_elapsed(ms)", screenResult.ScreenshotCVElapsed).
|
|
||||||
Msg("log screenshot")
|
Msg("log screenshot")
|
||||||
return screenResult, nil
|
return screenResult, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user