refactor: IDriver

This commit is contained in:
lilong.129
2025-02-11 17:08:25 +08:00
parent 804a2cd90f
commit 0839ef5bd6
22 changed files with 105 additions and 347 deletions

View File

@@ -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"})
}