#if os(macOS) import CoreGraphics import XCTest @testable import CallsKit /// One press on the mini window (2026-10-05, Paul: "Sometimes I can't /// click the mini window to either bring the call to the front or move /// it around"): click, move or resize, and on which surface. final class MiniWindowGestureTests: XCTestCase { let window = CGSize(width: 200, height: 112.5) func testAPressThatStaysPutIsAClick() { XCTAssertFalse(MiniWindowGesture.dragged(dx: 0, dy: 0)) XCTAssertFalse(MiniWindowGesture.dragged(dx: 3, dy: -2), "a shaky hand") XCTAssertEqual( MiniWindowGesture.outcome(grabbed: [], dragged: false, clickCount: 1, option: false), .click(count: 1)) XCTAssertEqual( MiniWindowGesture.outcome(grabbed: [.right], dragged: false, clickCount: 2, option: false), .click(count: 2), "a click on an edge is still a click: it brings the call forward") } func testAPressThatTravelsIsADrag() { XCTAssertTrue(MiniWindowGesture.dragged(dx: 5, dy: 0)) XCTAssertEqual( MiniWindowGesture.outcome(grabbed: [], dragged: true, clickCount: 1, option: true), .move(option: true)) XCTAssertEqual( MiniWindowGesture.outcome(grabbed: [.left, .bottom], dragged: true, clickCount: 1, option: false), .resize([.left, .bottom])) } func testTheMiddleMovesAndTheEdgesResize() { XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 100, y: 56), in: window, surface: .window), []) XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 197, y: 56), in: window, surface: .window), [.right]) XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 2, y: 2), in: window, surface: .window), [.left, .bottom]) XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 198, y: 110), in: window, surface: .window), [.right, .top]) } func testEvenTheSmallestWindowIsMostlyForMoving() { // Grips are 8 pt: at 200 × 112.5 the middle that moves is the rest. var moving = 0 var total = 0 for x in stride(from: 0.0, through: 200, by: 4) { for y in stride(from: 0.0, through: 112, by: 4) { total += 1 if MiniWindowGesture.grab(at: CGPoint(x: x, y: y), in: window, surface: .window).isEmpty { moving += 1 } } } XCTAssertGreaterThan(Double(moving) / Double(total), 0.7, "about 79% by area") } func testTheTabNeverResizes() { let tab = MiniWindowTab.size for point in [CGPoint(x: 1, y: 1), CGPoint(x: tab.width - 1, y: tab.height / 2), CGPoint(x: tab.width / 2, y: tab.height / 2)] { XCTAssertEqual(MiniWindowGesture.grab(at: point, in: tab, surface: .tab), [], "\(point)") } } func testAWindowTooSmallForGripsHasNone() { XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 1, y: 1), in: CGSize(width: 30, height: 20), surface: .window), []) } } #endif