mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-03-25 09:25:47 +00:00
style: Apply SwiftFormat formatting
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a10cbb59d5
commit
cef648fa8f
1 changed files with 13 additions and 13 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import AppKit
|
||||
import CoreGraphics
|
||||
import ScreenCaptureKit
|
||||
@testable import peekaboo
|
||||
import ScreenCaptureKit
|
||||
import Testing
|
||||
|
||||
@Suite(
|
||||
|
|
@ -237,7 +237,7 @@ struct ScreenshotValidationTests {
|
|||
) throws -> ImageCaptureData {
|
||||
// Use modern ScreenCaptureKit API instead of deprecated CGWindowListCreateImage
|
||||
let image = try captureWindowWithScreenCaptureKit(windowID: windowID)
|
||||
|
||||
|
||||
// Save to file
|
||||
let nsImage = NSImage(cgImage: image, size: NSSize(width: image.width, height: image.height))
|
||||
try saveImage(nsImage, to: path, format: format)
|
||||
|
|
@ -253,55 +253,55 @@ struct ScreenshotValidationTests {
|
|||
)
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
private func captureWindowWithScreenCaptureKit(windowID: CGWindowID) throws -> CGImage {
|
||||
// This needs to be async, so we'll use a semaphore to make it synchronous for the test
|
||||
var capturedImage: CGImage?
|
||||
var captureError: Error?
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
|
||||
|
||||
Task {
|
||||
do {
|
||||
// Get available content
|
||||
let availableContent = try await SCShareableContent.current
|
||||
|
||||
|
||||
// Find the window by ID
|
||||
guard let scWindow = availableContent.windows.first(where: { $0.windowID == windowID }) else {
|
||||
throw CaptureError.windowNotFound
|
||||
}
|
||||
|
||||
|
||||
// Create content filter for the specific window
|
||||
let filter = SCContentFilter(desktopIndependentWindow: scWindow)
|
||||
|
||||
|
||||
// Configure capture settings
|
||||
let configuration = SCStreamConfiguration()
|
||||
configuration.backgroundColor = .clear
|
||||
configuration.shouldBeOpaque = true
|
||||
configuration.showsCursor = false
|
||||
|
||||
|
||||
// Capture the image
|
||||
let image = try await SCScreenshotManager.captureImage(
|
||||
contentFilter: filter,
|
||||
configuration: configuration
|
||||
)
|
||||
|
||||
|
||||
capturedImage = image
|
||||
} catch {
|
||||
captureError = error
|
||||
}
|
||||
semaphore.signal()
|
||||
}
|
||||
|
||||
|
||||
semaphore.wait()
|
||||
|
||||
|
||||
if let error = captureError {
|
||||
throw error
|
||||
}
|
||||
|
||||
|
||||
guard let image = capturedImage else {
|
||||
throw CaptureError.windowCaptureFailed
|
||||
}
|
||||
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue