mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 09:49:33 +08:00
refactor: improve ActionMethod type safety and eliminate type conversions
This commit is contained in:
@@ -34,19 +34,20 @@ func (r *Router) homeHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (r *Router) backspaceHandler(c *gin.Context) {
|
||||
var deleteReq option.DeleteRequest
|
||||
if err := c.ShouldBindJSON(&deleteReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
req, err := r.processUnifiedRequest(c, option.ACTION_Backspace)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if deleteReq.Count == 0 {
|
||||
deleteReq.Count = 20
|
||||
|
||||
count := req.GetCount()
|
||||
if count == 0 {
|
||||
count = 20
|
||||
}
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = driver.Backspace(deleteReq.Count)
|
||||
err = driver.Backspace(count)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
@@ -55,18 +56,18 @@ func (r *Router) backspaceHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (r *Router) keycodeHandler(c *gin.Context) {
|
||||
var keycodeReq option.KeycodeRequest
|
||||
if err := c.ShouldBindJSON(&keycodeReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
req, err := r.processUnifiedRequest(c, option.ACTION_KeyCode)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// TODO FIXME
|
||||
err = driver.IDriver.(*uixt.ADBDriver).
|
||||
PressKeyCode(uixt.KeyCode(keycodeReq.Keycode), uixt.KMEmpty)
|
||||
PressKeyCode(uixt.KeyCode(req.GetKeycode()), uixt.KMEmpty)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user