mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-08 17:09:33 +08:00
feat: get screen result for hrp ui server
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2411051646
|
v5.0.0+2411051738
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ func NewServer(port int) error {
|
|||||||
apiV1PlatformSerial.POST("/app/terminal", handleDeviceContext(), terminalAppHandler)
|
apiV1PlatformSerial.POST("/app/terminal", handleDeviceContext(), terminalAppHandler)
|
||||||
// get screen info
|
// get screen info
|
||||||
apiV1PlatformSerial.GET("/screenshot", handleDeviceContext(), screenshotHandler)
|
apiV1PlatformSerial.GET("/screenshot", handleDeviceContext(), screenshotHandler)
|
||||||
|
apiV1PlatformSerial.POST("/screenresult", handleDeviceContext(), screenResultHandler)
|
||||||
apiV1PlatformSerial.GET("/stub/source", handleDeviceContext(), sourceHandler)
|
apiV1PlatformSerial.GET("/stub/source", handleDeviceContext(), sourceHandler)
|
||||||
apiV1PlatformSerial.GET("/adb/source", handleDeviceContext(), adbSourceHandler)
|
apiV1PlatformSerial.GET("/adb/source", handleDeviceContext(), adbSourceHandler)
|
||||||
// Stub operations
|
// Stub operations
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ type InputRequest struct {
|
|||||||
Frequency int `json:"frequency"` // only iOS
|
Frequency int `json:"frequency"` // only iOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ScreenRequest struct {
|
||||||
|
Options *uixt.ActionOptions `json:"options,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type KeycodeRequest struct {
|
type KeycodeRequest struct {
|
||||||
Keycode int `json:"keycode"`
|
Keycode int `json:"keycode"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,51 @@ func screenshotHandler(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, HttpResponse{Result: base64.StdEncoding.EncodeToString(raw.Bytes())})
|
c.JSON(http.StatusOK,
|
||||||
|
HttpResponse{
|
||||||
|
Code: code.Success,
|
||||||
|
Message: "success",
|
||||||
|
Result: base64.StdEncoding.EncodeToString(raw.Bytes()),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func screenResultHandler(c *gin.Context) {
|
||||||
|
dExt, err := getContextDriver(c)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var screenReq ScreenRequest
|
||||||
|
if err := c.ShouldBindJSON(&screenReq); err != nil {
|
||||||
|
handlerValidateRequestFailedContext(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var actionOptions []uixt.ActionOption
|
||||||
|
if screenReq.Options != nil {
|
||||||
|
actionOptions = screenReq.Options.Options()
|
||||||
|
}
|
||||||
|
|
||||||
|
screenResult, err := dExt.GetScreenResult(actionOptions...)
|
||||||
|
if err != nil {
|
||||||
|
log.Err(err).Msg("get screen result failed")
|
||||||
|
c.JSON(http.StatusInternalServerError,
|
||||||
|
HttpResponse{
|
||||||
|
Code: code.GetErrorCode(err),
|
||||||
|
Message: err.Error(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK,
|
||||||
|
HttpResponse{
|
||||||
|
Code: code.Success,
|
||||||
|
Message: "success",
|
||||||
|
Result: screenResult,
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sourceHandler(c *gin.Context) {
|
func sourceHandler(c *gin.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user