refactor: move uixt API

This commit is contained in:
debugtalk
2022-12-13 23:31:02 +08:00
parent 1332e71258
commit 94b17a97c9
17 changed files with 189 additions and 424 deletions

View File

@@ -15,8 +15,6 @@ import (
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v4/hrp"
"github.com/httprunner/httprunner/v4/hrp/pkg/gidevice"
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
)
@@ -39,32 +37,32 @@ func convertTimeToSeconds(timeStr string) (int, error) {
}
func initIOSDevice(uuid string) uixt.Device {
perfOptions := []gidevice.PerfOption{}
perfOptions := []uixt.IOSPerfOption{}
for _, p := range perf {
switch p {
case "sys_cpu":
perfOptions = append(perfOptions, hrp.WithPerfSystemCPU(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemCPU(true))
case "sys_mem":
perfOptions = append(perfOptions, hrp.WithPerfSystemMem(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemMem(true))
case "sys_net":
perfOptions = append(perfOptions, hrp.WithPerfSystemNetwork(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemNetwork(true))
case "sys_disk":
perfOptions = append(perfOptions, hrp.WithPerfSystemDisk(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemDisk(true))
case "network":
perfOptions = append(perfOptions, hrp.WithPerfNetwork(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfNetwork(true))
case "fps":
perfOptions = append(perfOptions, hrp.WithPerfFPS(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfFPS(true))
case "gpu":
perfOptions = append(perfOptions, hrp.WithPerfGPU(true))
perfOptions = append(perfOptions, uixt.WithIOSPerfGPU(true))
}
}
perfOptions = append(perfOptions, hrp.WithPerfOutputInterval(interval*1000))
perfOptions = append(perfOptions, uixt.WithIOSPerfOutputInterval(interval*1000))
device, err := uixt.NewIOSDevice(
uixt.WithUDID(uuid),
uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800),
uixt.WithResetHomeOnStartup(false), // not reset home on startup
uixt.WithPerfOptions(perfOptions...),
uixt.WithIOSPerfOptions(perfOptions...),
uixt.WithXCTest("com.gtf.wda.runner.xctrunner"),
)
if err != nil {

View File

@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/httprunner/httprunner/v4/hrp"
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
)
func TestConvertTimeToSeconds(t *testing.T) {
@@ -54,11 +55,11 @@ func TestIOSDouyinWorldCupLive(t *testing.T) {
"appBundleID": "com.ss.iphone.ugc.Aweme",
}).
SetIOS(
hrp.WithUDID(uuid),
hrp.WithLogOn(true),
hrp.WithWDAPort(8700),
hrp.WithWDAMjpegPort(8800),
hrp.WithXCTest("com.gtf.wda.runner.xctrunner"),
uixt.WithUDID(uuid),
uixt.WithWDALogOn(true),
uixt.WithWDAPort(8700),
uixt.WithWDAMjpegPort(8800),
uixt.WithXCTest("com.gtf.wda.runner.xctrunner"),
),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").
@@ -70,22 +71,22 @@ func TestIOSDouyinWorldCupLive(t *testing.T) {
AssertOCRExists("首页", "抖音启动失败,「首页」不存在"),
hrp.NewStep("处理青少年弹窗").
IOS().
TapByOCR("我知道了", hrp.WithIgnoreNotFoundError(true)),
TapByOCR("我知道了", uixt.WithIgnoreNotFoundError(true)),
hrp.NewStep("点击首页").
IOS().
TapByOCR("首页", hrp.WithIndex(-1)).Sleep(5),
TapByOCR("首页", uixt.WithIndex(-1)).Sleep(5),
hrp.NewStep("点击世界杯页").
IOS().
SwipeToTapText("世界杯",
hrp.WithMaxRetryTimes(5),
hrp.WithCustomDirection(0.4, 0.07, 0.6, 0.07), // 滑动 tab从左到右解决「世界杯」被遮挡的问题
hrp.WithScope(0, 0, 1, 0.15), // 限定 tab 区域
hrp.WithWaitTime(1),
uixt.WithMaxRetryTimes(5),
uixt.WithCustomDirection(0.4, 0.07, 0.6, 0.07), // 滑动 tab从左到右解决「世界杯」被遮挡的问题
uixt.WithScope(0, 0, 1, 0.15), // 限定 tab 区域
uixt.WithWaitTime(1),
),
hrp.NewStep("点击进入直播间").
IOS().
Loop(5). // 重复执行 5 次
TapByOCR("直播中", hrp.WithIdentifier("click_live"), hrp.WithIndex(-1)).
TapByOCR("直播中", uixt.WithIdentifier("click_live"), uixt.WithIndex(-1)).
Sleep(3).Back().Sleep(3),
hrp.NewStep("关闭抖音").
IOS().