Merge branch 'feat/caoshuai.1900/live-popularity' into 'video-release'

feat: add live popularity

See merge request iesqa/httprunner!37
This commit is contained in:
曹帅
2024-05-28 03:20:43 +00:00
3 changed files with 25 additions and 11 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
v4.5.0 v4.5.1
+19 -6
View File
@@ -117,12 +117,13 @@ type ActionOptions struct {
Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"` Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
// screenshot related // screenshot related
ScreenShotWithOCR bool `json:"screenshot_with_ocr,omitempty" yaml:"screenshot_with_ocr,omitempty"` ScreenShotWithOCR bool `json:"screenshot_with_ocr,omitempty" yaml:"screenshot_with_ocr,omitempty"`
ScreenShotWithUpload bool `json:"screenshot_with_upload,omitempty" yaml:"screenshot_with_upload,omitempty"` ScreenShotWithUpload bool `json:"screenshot_with_upload,omitempty" yaml:"screenshot_with_upload,omitempty"`
ScreenShotWithLiveType bool `json:"screenshot_with_live_type,omitempty" yaml:"screenshot_with_live_type,omitempty"` ScreenShotWithLiveType bool `json:"screenshot_with_live_type,omitempty" yaml:"screenshot_with_live_type,omitempty"`
ScreenShotWithUITypes []string `json:"screenshot_with_ui_types,omitempty" yaml:"screenshot_with_ui_types,omitempty"` ScreenShotWithLivePopularity bool `json:"screenshot_with_live_popularity,omitempty" yaml:"screenshot_with_live_popularity,omitempty"`
ScreenShotWithClosePopups bool `json:"screenshot_with_close_popups,omitempty" yaml:"screenshot_with_close_popups,omitempty"` ScreenShotWithUITypes []string `json:"screenshot_with_ui_types,omitempty" yaml:"screenshot_with_ui_types,omitempty"`
ScreenShotWithOCRCluster string `json:"screenshot_with_ocr_cluster,omitempty" yaml:"screenshot_with_ocr_cluster,omitempty"` ScreenShotWithClosePopups bool `json:"screenshot_with_close_popups,omitempty" yaml:"screenshot_with_close_popups,omitempty"`
ScreenShotWithOCRCluster string `json:"screenshot_with_ocr_cluster,omitempty" yaml:"screenshot_with_ocr_cluster,omitempty"`
} }
func (o *ActionOptions) Options() []ActionOption { func (o *ActionOptions) Options() []ActionOption {
@@ -226,6 +227,9 @@ func (o *ActionOptions) Options() []ActionOption {
if o.ScreenShotWithLiveType { if o.ScreenShotWithLiveType {
options = append(options, WithScreenShotLiveType(true)) options = append(options, WithScreenShotLiveType(true))
} }
if o.ScreenShotWithLivePopularity {
options = append(options, WithScreenShotLivePopularity(true))
}
if len(o.ScreenShotWithUITypes) > 0 { if len(o.ScreenShotWithUITypes) > 0 {
options = append(options, WithScreenShotUITypes(o.ScreenShotWithUITypes...)) options = append(options, WithScreenShotUITypes(o.ScreenShotWithUITypes...))
} }
@@ -250,6 +254,9 @@ func (o *ActionOptions) screenshotActions() []string {
if o.ScreenShotWithLiveType { if o.ScreenShotWithLiveType {
actions = append(actions, "liveType") actions = append(actions, "liveType")
} }
if o.ScreenShotWithLivePopularity {
actions = append(actions, "livePopularity")
}
// UI detection // UI detection
if len(o.ScreenShotWithUITypes) > 0 { if len(o.ScreenShotWithUITypes) > 0 {
actions = append(actions, "ui") actions = append(actions, "ui")
@@ -476,6 +483,12 @@ func WithScreenShotLiveType(liveTypeOn bool) ActionOption {
} }
} }
func WithScreenShotLivePopularity(livePopularityOn bool) ActionOption {
return func(o *ActionOptions) {
o.ScreenShotWithLivePopularity = livePopularityOn
}
}
func WithScreenShotUITypes(uiTypes ...string) ActionOption { func WithScreenShotUITypes(uiTypes ...string) ActionOption {
return func(o *ActionOptions) { return func(o *ActionOptions) {
o.ScreenShotWithUITypes = uiTypes o.ScreenShotWithUITypes = uiTypes
+5 -4
View File
@@ -67,9 +67,10 @@ type ImageResult struct {
// Media(媒体) // Media(媒体)
// Chat(语音) // Chat(语音)
// Event(赛事) // Event(赛事)
LiveType string `json:"liveType,omitempty"` // 直播间类型 LiveType string `json:"liveType,omitempty"` // 直播间类型
UIResult UIResultMap `json:"uiResult,omitempty"` // 图标检测 LivePopularity int64 `json:"livePopularity,omitempty"` // 直播间热度
CPResult *ClosePopupsResult `json:"closeResult,omitempty"` // 弹窗按钮检测 UIResult UIResultMap `json:"uiResult,omitempty"` // 图标检测
CPResult *ClosePopupsResult `json:"closeResult,omitempty"` // 弹窗按钮检测
} }
type APIResponseImage struct { type APIResponseImage struct {
@@ -417,7 +418,7 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
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
screenResult.Video = &Video{LiveType: imageResult.LiveType} screenResult.Video = &Video{LiveType: imageResult.LiveType, ViewCount: imageResult.LivePopularity}
if actionOptions.ScreenShotWithClosePopups && imageResult.CPResult != nil { if actionOptions.ScreenShotWithClosePopups && imageResult.CPResult != nil {
screenResult.Popup = &PopupInfo{ screenResult.Popup = &PopupInfo{