mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-28 11:01:30 +08:00
refactor ios: replace gidevice with go-ios
This commit is contained in:
35
examples/uitest/demo_harmony_test.go
Normal file
35
examples/uitest/demo_harmony_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
//go:build localtest
|
||||
|
||||
package uitest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
func TestHamonyDouyinFeedTest(t *testing.T) {
|
||||
testCase := &hrp.TestCase{
|
||||
Config: hrp.NewConfig("点播_抖音_滑动场景_随机间隔_android").
|
||||
WithVariables(map[string]interface{}{
|
||||
"device": "a38c2c5c",
|
||||
"query": "${ENV(query)}",
|
||||
}).
|
||||
SetAndroid(uixt.WithSerialNumber("$device")),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("启动抖音").
|
||||
Android().
|
||||
AppTerminate("com.ss.hm.ugc.aweme"),
|
||||
},
|
||||
}
|
||||
|
||||
if err := testCase.Dump2JSON("demo_android_swipe.json"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err := hrp.Run(t, testCase)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,6 @@ func TestIOSDouyinLive(t *testing.T) {
|
||||
uixt.WithWDALogOn(true),
|
||||
uixt.WithWDAPort(8700),
|
||||
uixt.WithWDAMjpegPort(8800),
|
||||
uixt.WithIOSPerfOptions(
|
||||
uixt.WithIOSPerfSystemCPU(true),
|
||||
uixt.WithIOSPerfSystemMem(true),
|
||||
),
|
||||
),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("启动抖音").
|
||||
|
||||
@@ -18,13 +18,6 @@ func TestWDALog(t *testing.T) {
|
||||
SetIOS(
|
||||
uixt.WithWDALogOn(true),
|
||||
uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800),
|
||||
uixt.WithIOSPerfOptions(
|
||||
uixt.WithIOSPerfSystemCPU(true),
|
||||
uixt.WithIOSPerfSystemMem(true),
|
||||
uixt.WithIOSPerfNetwork(true),
|
||||
uixt.WithIOSPerfFPS(true),
|
||||
),
|
||||
uixt.WithXCTest("com.gtf.wda.runner.xctrunner"),
|
||||
),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("启动抖音").
|
||||
|
||||
@@ -37,33 +37,11 @@ func convertTimeToSeconds(timeStr string) (int, error) {
|
||||
}
|
||||
|
||||
func initIOSDevice(uuid string) uixt.IDevice {
|
||||
perfOptions := []uixt.IOSPerfOption{}
|
||||
for _, p := range perf {
|
||||
switch p {
|
||||
case "sys_cpu":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemCPU(true))
|
||||
case "sys_mem":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemMem(true))
|
||||
case "sys_net":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemNetwork(true))
|
||||
case "sys_disk":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfSystemDisk(true))
|
||||
case "network":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfNetwork(true))
|
||||
case "fps":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfFPS(true))
|
||||
case "gpu":
|
||||
perfOptions = append(perfOptions, uixt.WithIOSPerfGPU(true))
|
||||
}
|
||||
}
|
||||
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.WithIOSPerfOptions(perfOptions...),
|
||||
uixt.WithXCTest("com.gtf.wda.runner.xctrunner"),
|
||||
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("failed to init ios device")
|
||||
@@ -267,7 +245,6 @@ func (wc *WorldCupLive) dumpResult() error {
|
||||
encoder.SetEscapeHTML(false)
|
||||
encoder.SetIndent("", " ")
|
||||
|
||||
wc.PerfFile = wc.driver.Device.StopPerf()
|
||||
err := encoder.Encode(wc)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("encode json failed")
|
||||
|
||||
@@ -59,17 +59,6 @@ func TestIOSDouyinWorldCupLive(t *testing.T) {
|
||||
uixt.WithWDALogOn(true),
|
||||
uixt.WithWDAPort(8700),
|
||||
uixt.WithWDAMjpegPort(8800),
|
||||
uixt.WithXCTest("com.gtf.wda.runner.xctrunner"),
|
||||
uixt.WithIOSPerfOptions(
|
||||
uixt.WithIOSPerfNetwork(true),
|
||||
// uixt.WithIOSPerfBundleID("com.ss.iphone.ugc.Aweme"),
|
||||
),
|
||||
uixt.WithIOSPcapOptions(
|
||||
// uixt.WithIOSPcapAll(true),
|
||||
// uixt.WithIOSPcapPID(1234),
|
||||
// uixt.WithIOSPcapProcName("Awe"),
|
||||
uixt.WithIOSPcapBundleID("com.ss.iphone.ugc.Aweme"),
|
||||
),
|
||||
),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("启动抖音").
|
||||
|
||||
Reference in New Issue
Block a user