From a69db8500cfb4870aebfc372efe2390e2701507a Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sun, 30 Apr 2023 00:13:18 +0800 Subject: [PATCH] feat: save video stat to summary --- hrp/pkg/uixt/ext.go | 2 ++ hrp/pkg/uixt/video_crawler.go | 6 +++++- hrp/step_mobile_ui.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index 3c57ffb6..901d2553 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -50,6 +50,8 @@ type cacheStepData struct { ScreenShots []string // cache step screenshot ocr results, key is image path, value is dumped OCRTexts OcrResults map[string]string + // cache feed/live video stat + VideoStat *VideoStat } type DriverExt struct { diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 9394f2fb..2b129c2a 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -130,13 +130,17 @@ func (l *LiveCrawler) exitLiveRoom() error { } func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) { + currVideoStat := &VideoStat{} + defer func() { + dExt.cacheStepData.VideoStat = currVideoStat + }() + // launch app if err = dExt.Driver.AppLaunch(configs.AppPackageName); err != nil { return err } time.Sleep(5 * time.Second) - currVideoStat := &VideoStat{} liveCrawler := LiveCrawler{ driver: dExt, configs: configs, diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index 2ba33467..2a4f1f6a 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -619,6 +619,7 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err cacheData := uiDriver.GetStepCacheData() attachments["screenshots"] = cacheData.ScreenShots attachments["ocr_results"] = cacheData.OcrResults + attachments["video_stat"] = cacheData.VideoStat stepResult.Attachments = attachments }()