refactor: XTDriver

This commit is contained in:
lilong.129
2025-02-11 15:34:51 +08:00
parent b35116fdf7
commit 72f7b77bc8
28 changed files with 100 additions and 121 deletions

View File

@@ -15,7 +15,7 @@ func foregroundAppHandler(c *gin.Context) {
return
}
appInfo, err := dExt.GetDriver().GetForegroundApp()
appInfo, err := dExt.GetForegroundApp()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to unlick screen", c.HandlerName()))
c.JSON(http.StatusInternalServerError,
@@ -42,7 +42,7 @@ func clearAppHandler(c *gin.Context) {
return
}
err = dExt.Driver.AppClear(appClearReq.PackageName)
err = dExt.AppClear(appClearReq.PackageName)
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to unlick screen", c.HandlerName()))
c.JSON(http.StatusInternalServerError,
@@ -69,7 +69,7 @@ func launchAppHandler(c *gin.Context) {
return
}
err = dExt.GetDriver().AppLaunch(appLaunchReq.PackageName)
err = dExt.AppLaunch(appLaunchReq.PackageName)
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to launch app %s", c.HandlerName(), appLaunchReq.PackageName))
c.JSON(http.StatusInternalServerError,
@@ -96,7 +96,7 @@ func terminalAppHandler(c *gin.Context) {
return
}
success, err := dExt.GetDriver().AppTerminate(appTerminalReq.PackageName)
success, err := dExt.AppTerminate(appTerminalReq.PackageName)
if !success {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to launch app %s", c.HandlerName(), appTerminalReq.PackageName))
c.JSON(http.StatusInternalServerError,

View File

@@ -16,7 +16,7 @@ func unlockHandler(c *gin.Context) {
return
}
err = dExt.GetDriver().Unlock()
err = dExt.Unlock()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to unlick screen", c.HandlerName()))
c.JSON(http.StatusInternalServerError,
@@ -37,7 +37,7 @@ func homeHandler(c *gin.Context) {
return
}
err = dExt.GetDriver().Homescreen()
err = dExt.Homescreen()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to enter homescreen", c.HandlerName()))
c.JSON(http.StatusInternalServerError,
@@ -64,7 +64,7 @@ func keycodeHandler(c *gin.Context) {
return
}
err = dExt.GetDriver().PressKeyCode(uixt.KeyCode(keycodeReq.Keycode))
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,

View File

@@ -18,7 +18,7 @@ func screenshotHandler(c *gin.Context) {
return
}
raw, err := dExt.GetDriver().Screenshot()
raw, err := dExt.Screenshot()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to get screenshot", c.HandlerName()))
c.JSON(http.StatusInternalServerError,
@@ -84,7 +84,7 @@ func adbSourceHandler(c *gin.Context) {
return
}
source, err := dExt.GetDriver().Source()
source, err := dExt.Source()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to get adb source", c.HandlerName()))
c.JSON(http.StatusInternalServerError,

View File

@@ -107,7 +107,7 @@ func dragHandler(c *gin.Context) {
return
}
} else {
err := dExt.GetDriver().Swipe(
err := dExt.Swipe(
dragReq.FromX, dragReq.FromY, dragReq.ToX, dragReq.ToY,
actionOptions...)
if err != nil {
@@ -140,7 +140,7 @@ func inputHandler(c *gin.Context) {
return
}
err = dExt.GetDriver().SendKeys(inputReq.Text,
err = dExt.SendKeys(inputReq.Text,
option.WithFrequency(inputReq.Frequency))
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to input text %s", c.HandlerName(), inputReq.Text))