mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
fix: merge
This commit is contained in:
@@ -103,8 +103,8 @@ func createBrowserHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
func deleteBrowserHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) deleteBrowserHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
@@ -117,7 +117,6 @@ func deleteBrowserHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func pushImageHandler(c *gin.Context) {
|
||||
func (r *Router) pushImageHandler(c *gin.Context) {
|
||||
var pushMediaReq PushMediaRequest
|
||||
if err := c.ShouldBindJSON(&pushMediaReq); err != nil {
|
||||
|
||||
@@ -33,23 +33,23 @@ type IRouterBaseMethod interface {
|
||||
|
||||
func (r *Router) Init() {
|
||||
r.Engine.Use(teardown())
|
||||
r.Engine.GET("/ping", pingHandler)
|
||||
r.Engine.GET("/", pingHandler)
|
||||
r.Engine.POST("/", pingHandler)
|
||||
r.Engine.GET("/api/v1/devices", listDeviceHandler)
|
||||
r.Engine.GET("/ping", r.pingHandler)
|
||||
r.Engine.GET("/", r.pingHandler)
|
||||
r.Engine.POST("/", r.pingHandler)
|
||||
r.Engine.GET("/api/v1/devices", r.listDeviceHandler)
|
||||
r.Engine.POST("/api/v1/browser/create_browser", createBrowserHandler)
|
||||
|
||||
apiV1PlatformSerial := r.Group("/api/v1").Group("/:platform").Group("/:serial")
|
||||
|
||||
// UI operations
|
||||
apiV1PlatformSerial.POST("/ui/tap", tapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/double_tap", doubleTapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/drag", dragHandler)
|
||||
apiV1PlatformSerial.POST("/ui/input", inputHandler)
|
||||
apiV1PlatformSerial.POST("/ui/home", homeHandler)
|
||||
apiV1PlatformSerial.POST("/ui/upload", uploadHandler)
|
||||
apiV1PlatformSerial.POST("/ui/hover", hoverHandler)
|
||||
apiV1PlatformSerial.POST("/ui/scroll", scrollHandler)
|
||||
apiV1PlatformSerial.POST("/ui/tap", r.tapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/double_tap", r.doubleTapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/drag", r.dragHandler)
|
||||
apiV1PlatformSerial.POST("/ui/input", r.inputHandler)
|
||||
apiV1PlatformSerial.POST("/ui/home", r.homeHandler)
|
||||
apiV1PlatformSerial.POST("/ui/upload", r.uploadHandler)
|
||||
apiV1PlatformSerial.POST("/ui/hover", r.hoverHandler)
|
||||
apiV1PlatformSerial.POST("/ui/scroll", r.scrollHandler)
|
||||
|
||||
// Key operations
|
||||
apiV1PlatformSerial.POST("/key/unlock", r.unlockHandler)
|
||||
@@ -66,12 +66,12 @@ func (r *Router) Init() {
|
||||
apiV1PlatformSerial.POST("/app/uninstall", r.uninstallAppHandler)
|
||||
|
||||
// Device operations
|
||||
apiV1PlatformSerial.GET("/screenshot", screenshotHandler)
|
||||
apiV1PlatformSerial.DELETE("/close_browser", deleteBrowserHandler)
|
||||
apiV1PlatformSerial.GET("/video", videoHandler)
|
||||
apiV1PlatformSerial.POST("/device/push_image", pushImageHandler)
|
||||
apiV1PlatformSerial.POST("/device/clear_image", clearImageHandler)
|
||||
apiV1PlatformSerial.GET("/adb/source", adbSourceHandler)
|
||||
apiV1PlatformSerial.GET("/screenshot", r.screenshotHandler)
|
||||
apiV1PlatformSerial.DELETE("/close_browser", r.deleteBrowserHandler)
|
||||
apiV1PlatformSerial.GET("/video", r.videoHandler)
|
||||
apiV1PlatformSerial.POST("/device/push_image", r.pushImageHandler)
|
||||
apiV1PlatformSerial.POST("/device/clear_image", r.clearImageHandler)
|
||||
apiV1PlatformSerial.GET("/adb/source", r.adbSourceHandler)
|
||||
|
||||
// uixt operations
|
||||
apiV1PlatformSerial.POST("/uixt/action", r.uixtActionHandler)
|
||||
|
||||
18
server/ui.go
18
server/ui.go
@@ -30,39 +30,39 @@ func (r *Router) tapHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func uploadHandler(c *gin.Context) {
|
||||
func (r *Router) uploadHandler(c *gin.Context) {
|
||||
var uploadRequest uploadRequest
|
||||
if err := c.ShouldBindJSON(&uploadRequest); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
}
|
||||
err = driver.IDriver.(*uixt.BrowserWebDriver).UploadFile(uploadRequest.X, uploadRequest.Y, uploadRequest.FileUrl, uploadRequest.FileFormat)
|
||||
err = driver.GetIDriver().(*uixt.BrowserWebDriver).UploadFile(uploadRequest.X, uploadRequest.Y, uploadRequest.FileUrl, uploadRequest.FileFormat)
|
||||
if err != nil {
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
func hoverHandler(c *gin.Context) {
|
||||
func (r *Router) hoverHandler(c *gin.Context) {
|
||||
var hoverReq HoverRequest
|
||||
if err := c.ShouldBindJSON(&hoverReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = driver.IDriver.(*uixt.BrowserWebDriver).Hover(hoverReq.X, hoverReq.Y)
|
||||
err = driver.GetIDriver().(*uixt.BrowserWebDriver).Hover(hoverReq.X, hoverReq.Y)
|
||||
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
@@ -71,20 +71,20 @@ func hoverHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func scrollHandler(c *gin.Context) {
|
||||
func (r *Router) scrollHandler(c *gin.Context) {
|
||||
var scrollReq ScrollRequest
|
||||
if err := c.ShouldBindJSON(&scrollReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = driver.IDriver.(*uixt.BrowserWebDriver).Scroll(scrollReq.Delta)
|
||||
err = driver.GetIDriver().(*uixt.BrowserWebDriver).Scroll(scrollReq.Delta)
|
||||
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
|
||||
Reference in New Issue
Block a user