refactor: rename options pkg to option

This commit is contained in:
lilong.129
2025-02-06 17:08:25 +08:00
parent b22f24cb6b
commit 194b61718f
61 changed files with 554 additions and 548 deletions

View File

@@ -6,10 +6,11 @@ import (
"strings"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
)
var uiClients = make(map[string]*uixt.DriverExt) // UI automation clients for iOS and Android, key is udid/serial
@@ -37,8 +38,8 @@ func handleDeviceContext() gin.HandlerFunc {
switch strings.ToLower(platform) {
case "android":
device, err := uixt.NewAndroidDevice(
options.WithSerialNumber(serial),
options.WithStub(true))
option.WithSerialNumber(serial),
option.WithStub(true))
if err != nil {
log.Error().Err(err).Str("platform", platform).Str("serial", serial).
Msg("device not found")
@@ -54,8 +55,8 @@ func handleDeviceContext() gin.HandlerFunc {
device.Init()
driver, err := device.NewDriver(
options.WithDriverImageService(true),
options.WithDriverResultFolder(true))
option.WithDriverImageService(true),
option.WithDriverResultFolder(true))
if err != nil {
log.Error().Err(err).Str("platform", platform).Str("serial", serial).
Msg("failed to init driver")

View File

@@ -1,8 +1,6 @@
package server
import (
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
import "github.com/httprunner/httprunner/v5/pkg/uixt/option"
type HttpResponse struct {
Code int `json:"code"`
@@ -15,7 +13,7 @@ type TapRequest struct {
Y float64 `json:"y"`
Text string `json:"text"`
Options *options.ActionOptions `json:"options,omitempty"`
Options *option.ActionOptions `json:"options,omitempty"`
}
type DragRequest struct {
@@ -24,7 +22,7 @@ type DragRequest struct {
ToX float64 `json:"to_x"`
ToY float64 `json:"to_y"`
Options *options.ActionOptions `json:"options,omitempty"`
Options *option.ActionOptions `json:"options,omitempty"`
}
type InputRequest struct {
@@ -33,7 +31,7 @@ type InputRequest struct {
}
type ScreenRequest struct {
Options *options.ActionOptions `json:"options,omitempty"`
Options *option.ActionOptions `json:"options,omitempty"`
}
type KeycodeRequest struct {

View File

@@ -6,10 +6,11 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
)
func screenshotHandler(c *gin.Context) {
@@ -52,7 +53,7 @@ func screenResultHandler(c *gin.Context) {
return
}
var actionOptions []options.ActionOption
var actionOptions []option.ActionOption
if screenReq.Options != nil {
actionOptions = screenReq.Options.Options()
}

View File

@@ -5,9 +5,10 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
)
func tapHandler(c *gin.Context) {
@@ -22,7 +23,7 @@ func tapHandler(c *gin.Context) {
return
}
var actionOptions []options.ActionOption
var actionOptions []option.ActionOption
if tapReq.Options != nil {
actionOptions = tapReq.Options.Options()
}
@@ -82,7 +83,7 @@ func dragHandler(c *gin.Context) {
return
}
var actionOptions []options.ActionOption
var actionOptions []option.ActionOption
if dragReq.Options != nil {
actionOptions = dragReq.Options.Options()
}
@@ -140,7 +141,7 @@ func inputHandler(c *gin.Context) {
}
err = dExt.Driver.SendKeys(inputReq.Text,
options.WithFrequency(inputReq.Frequency))
option.WithFrequency(inputReq.Frequency))
if err != nil {
log.Err(err).Msg(fmt.Sprintf("[%s]: failed to input text %s", c.HandlerName(), inputReq.Text))
c.JSON(http.StatusInternalServerError,