faet: add ScreenCap for gadb

This commit is contained in:
lilong.129
2023-04-13 22:48:40 +08:00
parent 3d4dffbd0b
commit ef784709af
3 changed files with 6 additions and 4 deletions

View File

@@ -140,7 +140,7 @@ func TestScreenCap(t *testing.T) {
t.Error(err)
}
d := dl[0]
res, err := d.RunShellCommandV2WithBytes("screencap", "-p")
res, err := d.ScreenCap()
if err != nil {
t.Error(err)
}

View File

@@ -571,3 +571,7 @@ func (d *Device) Uninstall(packageName string, keepData ...bool) (string, error)
args = append(args, packageName)
return d.RunShellCommandV2("pm", args...)
}
func (d *Device) ScreenCap() ([]byte, error) {
return d.RunShellCommandV2WithBytes("screencap", "-p")
}

View File

@@ -280,9 +280,7 @@ func (ad *adbDriver) SetRotation(rotation Rotation) (err error) {
func (ad *adbDriver) Screenshot() (raw *bytes.Buffer, err error) {
// adb shell screencap -p
resp, err := ad.adbClient.RunShellCommandWithBytes(
"screencap", "-p",
)
resp, err := ad.adbClient.ScreenCap()
if err == nil {
return bytes.NewBuffer(resp), nil
}