Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release History

## v4.3.2 (2022-12-26)

**go version**

- feat: run Android UI automation with adb by default, add `uixt.WithUIA2(true)` option to use uiautomator2
- refactor: remove unused APIs in UI automation
- refactor: convert cases by specifying from/to format
- change: remove traceroute/curl sub commands

## v4.3.1 (2022-12-22)

**go version**
Expand Down
2 changes: 1 addition & 1 deletion examples/uitest/demo_android_douyin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestAndroidDouYinLive(t *testing.T) {
testCase := &hrp.TestCase{
Config: hrp.NewConfig("通过 feed 头像进入抖音直播间").
SetAndroid(uixt.WithAdbLogOn(true)),
SetAndroid(uixt.WithUIA2(false), uixt.WithAdbLogOn(true)),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").
Android().
Expand Down
2 changes: 1 addition & 1 deletion hrp/internal/version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.3.1
v4.3.2
10 changes: 7 additions & 3 deletions hrp/pkg/gadb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"fmt"
"strconv"
"strings"

"github.com/rs/zerolog/log"
)

const AdbServerPort = 5037
const AdbDaemonPort = 5555
const (
AdbServerPort = 5037
AdbDaemonPort = 5555
)

type Client struct {
host string
Expand Down Expand Up @@ -86,7 +90,7 @@ func (c Client) DeviceList() (devices []Device, err error) {

fields := strings.Fields(line)
if len(fields) < 5 || len(fields[0]) == 0 {
debugLog(fmt.Sprintf("can't parse: %s", line))
log.Error().Str("line", line).Msg("get unexpected line")
continue
}

Expand Down
18 changes: 0 additions & 18 deletions hrp/pkg/gadb/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
)

func TestClient_ServerVersion(t *testing.T) {
SetDebug(true)

adbClient, err := NewClient()
if err != nil {
t.Fatal(err)
Expand All @@ -23,8 +21,6 @@ func TestClient_ServerVersion(t *testing.T) {
}

func TestClient_DeviceSerialList(t *testing.T) {
SetDebug(true)

adbClient, err := NewClient()
if err != nil {
t.Fatal(err)
Expand All @@ -41,8 +37,6 @@ func TestClient_DeviceSerialList(t *testing.T) {
}

func TestClient_DeviceList(t *testing.T) {
SetDebug(true)

adbClient, err := NewClient()
if err != nil {
t.Fatal(err)
Expand All @@ -59,8 +53,6 @@ func TestClient_DeviceList(t *testing.T) {
}

func TestClient_ForwardList(t *testing.T) {
SetDebug(true)

adbClient, err := NewClient()
if err != nil {
t.Fatal(err)
Expand All @@ -77,8 +69,6 @@ func TestClient_ForwardList(t *testing.T) {
}

func TestClient_ForwardKillAll(t *testing.T) {
SetDebug(true)

adbClient, err := NewClient()
if err != nil {
t.Fatal(err)
Expand All @@ -96,8 +86,6 @@ func TestClient_Connect(t *testing.T) {
t.Fatal(err)
}

SetDebug(true)

err = adbClient.Connect("192.168.1.28")
if err != nil {
t.Fatal(err)
Expand All @@ -110,8 +98,6 @@ func TestClient_Disconnect(t *testing.T) {
t.Fatal(err)
}

SetDebug(true)

err = adbClient.Disconnect("192.168.1.28")
if err != nil {
t.Fatal(err)
Expand All @@ -124,17 +110,13 @@ func TestClient_DisconnectAll(t *testing.T) {
t.Fatal(err)
}

SetDebug(true)

err = adbClient.DisconnectAll()
if err != nil {
t.Fatal(err)
}
}

func TestClient_KillServer(t *testing.T) {
SetDebug(true)

adbClient, err := NewClient()
if err != nil {
t.Fatal(err)
Expand Down
10 changes: 9 additions & 1 deletion hrp/pkg/gadb/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"strings"
"time"

"github.com/rs/zerolog/log"
)

type DeviceFileInfo struct {
Expand All @@ -20,7 +22,7 @@ func (info DeviceFileInfo) IsDir() bool {
return (info.Mode & (1 << 14)) == (1 << 14)
}

const DefaultFileMode = os.FileMode(0664)
const DefaultFileMode = os.FileMode(0o664)

type DeviceState string

Expand Down Expand Up @@ -147,6 +149,9 @@ func (d Device) RunShellCommandWithBytes(cmd string, args ...string) ([]byte, er
if strings.TrimSpace(cmd) == "" {
return nil, errors.New("adb shell: command cannot be empty")
}
log.Debug().Str("cmd",
fmt.Sprintf("adb -s %s shell %s", d.serial, cmd)).
Msg("run adb command")
raw, err := d.executeCommand(fmt.Sprintf("shell:%s", cmd))
return raw, err
}
Expand All @@ -156,6 +161,9 @@ func (d Device) EnableAdbOverTCP(port ...int) (err error) {
port = []int{AdbDaemonPort}
}

log.Info().Str("cmd",
fmt.Sprintf("adb -s %s tcpip %d", d.serial, port[0])).
Msg("enable adb over tcp")
_, err = d.executeCommand(fmt.Sprintf("tcpip:%d", port[0]), true)
return
}
Expand Down
18 changes: 0 additions & 18 deletions hrp/pkg/gadb/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func TestDevice_Usb(t *testing.T) {
dev := devices[i]
t.Log(dev.Serial(), dev.Usb(), dev.IsUsb())
}

}

func TestDevice_DeviceInfo(t *testing.T) {
Expand Down Expand Up @@ -134,8 +133,6 @@ func TestDevice_Forward(t *testing.T) {
t.Fatal(err)
}

SetDebug(true)

localPort := 61000
err = devices[0].Forward(localPort, 6790)
if err != nil {
Expand All @@ -159,8 +156,6 @@ func TestDevice_ForwardList(t *testing.T) {
t.Fatal(err)
}

SetDebug(true)

for i := range devices {
dev := devices[i]
forwardList, err := dev.ForwardList()
Expand All @@ -182,8 +177,6 @@ func TestDevice_ForwardKill(t *testing.T) {
t.Fatal(err)
}

SetDebug(true)

err = devices[0].ForwardKill(6790)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -213,8 +206,6 @@ func TestDevice_RunShellCommand(t *testing.T) {
// t.Log("\n"+dev.serial, cmdOutput)
// }

// SetDebug(true)

dev := devices[len(devices)-1]
dev = devices[0]

Expand All @@ -225,7 +216,6 @@ func TestDevice_RunShellCommand(t *testing.T) {
t.Fatal(dev.serial, err)
}
t.Log("\n⬇️"+dev.serial+"⬇️\n", cmdOutput)

}

func TestDevice_EnableAdbOverTCP(t *testing.T) {
Expand All @@ -242,8 +232,6 @@ func TestDevice_EnableAdbOverTCP(t *testing.T) {
dev := devices[len(devices)-1]
dev = devices[0]

SetDebug(true)

err = dev.EnableAdbOverTCP()
if err != nil {
t.Fatal(err)
Expand All @@ -264,8 +252,6 @@ func TestDevice_List(t *testing.T) {
dev := devices[len(devices)-1]
dev = devices[0]

SetDebug(true)

// fileEntries, err := dev.List("/sdcard")
fileEntries, err := dev.List("/sdcard/Download")
if err != nil {
Expand All @@ -291,8 +277,6 @@ func TestDevice_Push(t *testing.T) {
dev := devices[len(devices)-1]
dev = devices[0]

SetDebug(true)

file, _ := os.Open("/Users/hero/Documents/temp/MuMu共享文件夹/test.txt")
err = dev.PushFile(file, "/sdcard/Download/push.txt", time.Now())
if err != nil {
Expand All @@ -319,8 +303,6 @@ func TestDevice_Pull(t *testing.T) {
dev := devices[len(devices)-1]
dev = devices[0]

SetDebug(true)

buffer := bytes.NewBufferString("")
err = dev.Pull("/sdcard/Download/hello.txt", buffer)
if err != nil {
Expand Down
17 changes: 0 additions & 17 deletions hrp/pkg/gadb/gadb.go

This file was deleted.

Loading