oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2 import CoreGraphics
3 import XCTest
4
5 @testable import CallsKit
6
7 /// One press on the mini window (2026-10-05, Paul: "Sometimes I can't
8 /// click the mini window to either bring the call to the front or move
9 /// it around"): click, move or resize, and on which surface.
10 final class MiniWindowGestureTests: XCTestCase {
11 let window = CGSize(width: 200, height: 112.5)
12
13 func testAPressThatStaysPutIsAClick() {
14 XCTAssertFalse(MiniWindowGesture.dragged(dx: 0, dy: 0))
15 XCTAssertFalse(MiniWindowGesture.dragged(dx: 3, dy: -2), "a shaky hand")
16 XCTAssertEqual(
17 MiniWindowGesture.outcome(grabbed: [], dragged: false, clickCount: 1, option: false), .click(count: 1))
18 XCTAssertEqual(
19 MiniWindowGesture.outcome(grabbed: [.right], dragged: false, clickCount: 2, option: false), .click(count: 2),
20 "a click on an edge is still a click: it brings the call forward")
21 }
22
23 func testAPressThatTravelsIsADrag() {
24 XCTAssertTrue(MiniWindowGesture.dragged(dx: 5, dy: 0))
25 XCTAssertEqual(
26 MiniWindowGesture.outcome(grabbed: [], dragged: true, clickCount: 1, option: true), .move(option: true))
27 XCTAssertEqual(
28 MiniWindowGesture.outcome(grabbed: [.left, .bottom], dragged: true, clickCount: 1, option: false),
29 .resize([.left, .bottom]))
30 }
31
32 func testTheMiddleMovesAndTheEdgesResize() {
33 XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 100, y: 56), in: window, surface: .window), [])
34 XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 197, y: 56), in: window, surface: .window), [.right])
35 XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 2, y: 2), in: window, surface: .window), [.left, .bottom])
36 XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 198, y: 110), in: window, surface: .window), [.right, .top])
37 }
38
39 func testEvenTheSmallestWindowIsMostlyForMoving() {
40 // Grips are 8 pt: at 200 × 112.5 the middle that moves is the rest.
41 var moving = 0
42 var total = 0
43 for x in stride(from: 0.0, through: 200, by: 4) {
44 for y in stride(from: 0.0, through: 112, by: 4) {
45 total += 1
46 if MiniWindowGesture.grab(at: CGPoint(x: x, y: y), in: window, surface: .window).isEmpty { moving += 1 }
47 }
48 }
49 XCTAssertGreaterThan(Double(moving) / Double(total), 0.7, "about 79% by area")
50 }
51
52 func testTheTabNeverResizes() {
53 let tab = MiniWindowTab.size
54 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)] {
55 XCTAssertEqual(MiniWindowGesture.grab(at: point, in: tab, surface: .tab), [], "\(point)")
56 }
57 }
58
59 func testAWindowTooSmallForGripsHasNone() {
60 XCTAssertEqual(MiniWindowGesture.grab(at: CGPoint(x: 1, y: 1), in: CGSize(width: 30, height: 20), surface: .window), [])
61 }
62 }
63#endif
64