File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 1+ //go:build darwin && cgo
2+
13package permissions
24
35import (
@@ -11,15 +13,10 @@ import (
1113*/
1214import "C"
1315
14- // HasScreenRecordingPermission checks if the application has screen recording permission.
15- // It uses CGPreflightScreenCaptureAccess() from the macOS CoreGraphics framework.
16- // This function works on macOS 10.15+ (all supported macOS versions for this project).
1716func HasScreenRecordingPermission () bool {
1817 return bool (C .CGPreflightScreenCaptureAccess ())
1918}
2019
21- // OpenScreenRecordingSettings opens the macOS System Preferences screen recording settings.
22- // It uses the x-apple.systempreferences URL scheme to navigate to the Privacy > Screen Recording settings.
2320func OpenScreenRecordingSettings () error {
2421 cmd := exec .Command ("open" , "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture" )
2522 if err := cmd .Run (); err != nil {
Original file line number Diff line number Diff line change 1+ //go:build !darwin || !cgo
2+
3+ package permissions
4+
5+ func HasScreenRecordingPermission () bool {
6+ return false
7+ }
8+
9+ func OpenScreenRecordingSettings () error {
10+ return nil
11+ }
Original file line number Diff line number Diff line change @@ -6,18 +6,12 @@ import (
66 "github.com/stretchr/testify/assert"
77)
88
9- // TestHasScreenRecordingPermission_Returns verifies that HasScreenRecordingPermission
10- // returns a boolean value without panicking. This is an actual system call to the
11- // macOS CoreGraphics framework, so the result depends on the system state.
129func TestHasScreenRecordingPermission_Returns (t * testing.T ) {
1310 result := HasScreenRecordingPermission ()
1411 assert .IsType (t , true , result )
1512}
1613
17- // TestOpenScreenRecordingSettings_NoError verifies that OpenScreenRecordingSettings
18- // executes without panicking and returns an error type (even if nil).
1914func TestOpenScreenRecordingSettings_NoError (t * testing.T ) {
2015 err := OpenScreenRecordingSettings ()
21- // The function should return an error type (may be nil or non-nil depending on system state)
2216 assert .IsType (t , (* error )(nil ), & err )
2317}
You can’t perform that action at this time.
0 commit comments