mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 21:39:41 +08:00
refactor: IDriver
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/httprunner/httprunner/v5/code"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v5/code"
|
||||
)
|
||||
|
||||
func unlockHandler(c *gin.Context) {
|
||||
@@ -37,7 +37,7 @@ func homeHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err = dExt.Homescreen()
|
||||
err = dExt.Home()
|
||||
if err != nil {
|
||||
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to enter homescreen", c.HandlerName()))
|
||||
c.JSON(http.StatusInternalServerError,
|
||||
@@ -51,30 +51,3 @@ func homeHandler(c *gin.Context) {
|
||||
}
|
||||
c.JSON(http.StatusOK, HttpResponse{Code: 0, Message: "success"})
|
||||
}
|
||||
|
||||
func keycodeHandler(c *gin.Context) {
|
||||
dExt, err := GetContextDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var keycodeReq KeycodeRequest
|
||||
if err := c.ShouldBindJSON(&keycodeReq); err != nil {
|
||||
handlerValidateRequestFailedContext(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = dExt.PressKeyCode(uixt.KeyCode(keycodeReq.Keycode))
|
||||
if err != nil {
|
||||
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to input keycode %d", c.HandlerName(), keycodeReq.Keycode))
|
||||
c.JSON(http.StatusInternalServerError,
|
||||
HttpResponse{
|
||||
Code: code.GetErrorCode(err),
|
||||
Message: err.Error(),
|
||||
},
|
||||
)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, HttpResponse{Code: 0, Message: "success"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user