mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 22:44:05 +08:00
fix: revert gadb device ScreenCap
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2503032054
|
v5.0.0+2503032117
|
||||||
|
|||||||
@@ -722,5 +722,25 @@ func (d *Device) IsPackageRunning(packageName string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Device) ScreenCap() ([]byte, error) {
|
func (d *Device) ScreenCap() ([]byte, error) {
|
||||||
return d.RunShellCommandV2WithBytes("screencap", "-p")
|
if d.HasFeature(FeatShellV2) {
|
||||||
|
return d.RunShellCommandV2WithBytes("screencap", "-p")
|
||||||
|
}
|
||||||
|
|
||||||
|
// for shell v1, screenshot buffer maybe truncated
|
||||||
|
// thus we firstly save it to local file and then pull it
|
||||||
|
tempPath := fmt.Sprintf("/data/local/tmp/screenshot_%d.png",
|
||||||
|
time.Now().Unix())
|
||||||
|
_, err := d.RunShellCommandWithBytes("screencap", "-p", tempPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove temp file
|
||||||
|
defer func() {
|
||||||
|
go d.RunShellCommand("rm", tempPath)
|
||||||
|
}()
|
||||||
|
|
||||||
|
buffer := bytes.NewBuffer(nil)
|
||||||
|
err = d.Pull(tempPath, buffer)
|
||||||
|
return buffer.Bytes(), err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user