general: working through bugs and maintainability

This commit is contained in:
Michael Freno
2026-01-14 21:28:22 -05:00
parent f7d8470a43
commit 25455e714c
10 changed files with 189 additions and 197 deletions

View File

@@ -6,15 +6,13 @@
//
import Combine
import CoreGraphics
import XCTest
@testable import Gaze
@MainActor
final class FullscreenDetectionServiceTests: XCTestCase {
func testPermissionDeniedKeepsStateFalse() {
let mockManager = MockPermissionManager(status: ScreenCaptureAuthorizationStatus.denied)
let service = FullscreenDetectionService(permissionManager: mockManager)
let service = FullscreenDetectionService(permissionManager: MockPermissionManager(status: .denied))
let expectation = expectation(description: "No change")
expectation.isInverted = true
@@ -30,77 +28,6 @@ final class FullscreenDetectionServiceTests: XCTestCase {
wait(for: [expectation], timeout: 0.5)
cancellable.cancel()
}
func testFullscreenStateBecomesTrueWhenWindowMatchesScreen() {
let mockManager = MockPermissionManager(status: ScreenCaptureAuthorizationStatus.authorized)
let environment = MockFullscreenEnvironment(
frontmostPID: 42,
windowDescriptors: [
FullscreenWindowDescriptor(
ownerPID: 42,
layer: 0,
bounds: CGRect(x: 0, y: 0, width: 1920, height: 1080)
)
],
screenFrames: [CGRect(x: 0, y: 0, width: 1920, height: 1080)]
)
let service = FullscreenDetectionService(
permissionManager: mockManager,
environmentProvider: environment
)
let expectation = expectation(description: "Fullscreen detected")
let cancellable = service.$isFullscreenActive
.dropFirst()
.sink { isActive in
if isActive {
expectation.fulfill()
}
}
service.forceUpdate()
wait(for: [expectation], timeout: 0.5)
cancellable.cancel()
}
func testFullscreenStateStaysFalseWhenWindowDoesNotMatchScreen() {
let mockManager = MockPermissionManager(status: ScreenCaptureAuthorizationStatus.authorized)
let environment = MockFullscreenEnvironment(
frontmostPID: 42,
windowDescriptors: [
FullscreenWindowDescriptor(
ownerPID: 42,
layer: 0,
bounds: CGRect(x: 100, y: 100, width: 800, height: 600)
)
],
screenFrames: [CGRect(x: 0, y: 0, width: 1920, height: 1080)]
)
let service = FullscreenDetectionService(
permissionManager: mockManager,
environmentProvider: environment
)
let expectation = expectation(description: "No fullscreen")
expectation.isInverted = true
let cancellable = service.$isFullscreenActive
.dropFirst()
.sink { isActive in
if isActive {
expectation.fulfill()
}
}
service.forceUpdate()
wait(for: [expectation], timeout: 0.5)
cancellable.cancel()
}
}
@MainActor