diff --git a/hrp/pkg/uixt/screenshot.go b/hrp/pkg/uixt/screenshot.go index 607cfc2f..6b8f5edc 100644 --- a/hrp/pkg/uixt/screenshot.go +++ b/hrp/pkg/uixt/screenshot.go @@ -6,7 +6,7 @@ import ( "image" "image/gif" "image/jpeg" - "image/png" + _ "image/png" "os" "path/filepath" "strings" @@ -216,14 +216,14 @@ func saveScreenShot(raw *bytes.Buffer, fileName string) (string, error) { // compress image and save to file switch format { - case "jpeg": - jpegOptions := &jpeg.Options{Quality: 90} + case "jpeg", "png": + jpegOptions := &jpeg.Options{Quality: 95} err = jpeg.Encode(file, img, jpegOptions) - case "png": - encoder := png.Encoder{ - CompressionLevel: png.BestCompression, - } - err = encoder.Encode(file, img) + // case "png": + // encoder := png.Encoder{ + // CompressionLevel: png.BestCompression, + // } + // err = encoder.Encode(file, img) case "gif": gifOptions := &gif.Options{ NumColors: 256, diff --git a/hrp/pkg/uixt/screenshot_test.go b/hrp/pkg/uixt/screenshot_test.go new file mode 100644 index 00000000..cd6c6531 --- /dev/null +++ b/hrp/pkg/uixt/screenshot_test.go @@ -0,0 +1,23 @@ +//go:build localtest + +package uixt + +import ( + "testing" +) + +func TestGetScreenShot(t *testing.T) { + setupAndroidAdbDriver(t) + + fileName := "test_screenshot" + _, path, err := driverExt.GetScreenShot(fileName) + if err != nil { + t.Fatalf("GetScreenShot failed: %v", err) + } + + if path == "" { + t.Fatal("screenshot path is empty") + } + + t.Logf("screenshot saved at: %s", path) +}