add popup close_status=found

This commit is contained in:
buyuxiang
2023-08-29 17:59:12 +08:00
parent 67088469c5
commit 20b2fa51af
4 changed files with 28 additions and 3 deletions
+3 -3
View File
@@ -113,12 +113,12 @@ func (screenResults ScreenResultMap) updatePopupCloseStatus() {
continue continue
} }
// popup existed, but identical popups occurs during next retry // popup existed, but identical popups occurs during next retry
if curPopup.Text == nextPopup.Text && curPopup.Type == nextPopup.Type { if nextPopup.CloseArea.IsIdentical(curPopup.CloseArea) {
popupScreenResultList[i].Popup.CloseStatus = "fail" popupScreenResultList[i].Popup.CloseStatus = CloseStatusFail
continue continue
} }
// popup existed, but no popup or different popup occurs during next retry (IsClosed=true) // popup existed, but no popup or different popup occurs during next retry (IsClosed=true)
popupScreenResultList[i].Popup.CloseStatus = "success" popupScreenResultList[i].Popup.CloseStatus = CloseStatusSuccess
} }
} }
+8
View File
@@ -2,10 +2,13 @@ package uixt
import ( import (
"bytes" "bytes"
"math"
"strings" "strings"
"time" "time"
"github.com/httprunner/funplugin" "github.com/httprunner/funplugin"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
) )
var ( var (
@@ -434,6 +437,11 @@ type PointF struct {
Y float64 `json:"y"` Y float64 `json:"y"`
} }
func (p PointF) IsIdentical(p2 PointF) bool {
return builtin.IsZeroFloat64(math.Abs(p.X-p2.X)) &&
builtin.IsZeroFloat64(math.Abs(p.Y-p2.Y))
}
type Rect struct { type Rect struct {
Point Point
Size Size
+10
View File
@@ -27,6 +27,12 @@ var popups = [][]string{
{"管理使用时间", ".*忽略.*"}, {"管理使用时间", ".*忽略.*"},
} }
const (
CloseStatusFound = "found"
CloseStatusSuccess = "success"
CloseStatusFail = "fail"
)
func findTextPopup(screenTexts OCRTexts) (closePoint *OCRText) { func findTextPopup(screenTexts OCRTexts) (closePoint *OCRText) {
for _, popup := range popups { for _, popup := range popups {
if len(popup) != 2 { if len(popup) != 2 {
@@ -126,9 +132,13 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
break break
} }
screenResult.Popup.RetryCount = retryCount screenResult.Popup.RetryCount = retryCount
if !screenResult.Popup.PopupArea.IsEmpty() {
screenResult.Popup.CloseStatus = CloseStatusFound
}
if screenResult.Popup.CloseArea.IsEmpty() { if screenResult.Popup.CloseArea.IsEmpty() {
break break
} }
screenResult.Popup.CloseStatus = CloseStatusFound
if err = dExt.tapPopupHandler(screenResult.Popup); err != nil { if err = dExt.tapPopupHandler(screenResult.Popup); err != nil {
return err return err
+7
View File
@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"image" "image"
"io/ioutil" "io/ioutil"
"math"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"regexp" "regexp"
@@ -463,6 +464,12 @@ func (box Box) IsEmpty() bool {
return builtin.IsZeroFloat64(box.Width) && builtin.IsZeroFloat64(box.Height) return builtin.IsZeroFloat64(box.Width) && builtin.IsZeroFloat64(box.Height)
} }
func (box Box) IsIdentical(box2 Box) bool {
return box.Point.IsIdentical(box2.Point) &&
builtin.IsZeroFloat64(math.Abs(box.Width-box2.Width)) &&
builtin.IsZeroFloat64(math.Abs(box.Height-box2.Height))
}
func (box Box) Center() PointF { func (box Box) Center() PointF {
return PointF{ return PointF{
X: box.Point.X + box.Width*0.5, X: box.Point.X + box.Width*0.5,