EPOD Window Bar: a window strip above the macOS Dock
EPOD Window Bar is a macOS agent app. It shows a thin strip above the Dock with one tab per window of the frontmost application. One click raises the window. Build from source with XcodeGen and Xcode. Signing uses Config.xcconfig (ad-hoc by default; a local Local.xcconfig can set a team ID). The app needs Accessibility and Screen Recording permissions, and runs in a reduced mode without Screen Recording. See README.md and docs/ for details.
This commit is contained in:
55
Tests/GeometryTests.swift
Normal file
55
Tests/GeometryTests.swift
Normal file
@@ -0,0 +1,55 @@
|
||||
import XCTest
|
||||
@testable import EPODWindowBar
|
||||
|
||||
// GeometryTests checks the coordinate conversion between the Cocoa system and
|
||||
// the AX system. The tests use a primary screen height of 1000. The tests
|
||||
// cover the primary screen and a second screen above, below, and left of the
|
||||
// primary screen (spec section 7.10).
|
||||
final class GeometryTests: XCTestCase {
|
||||
|
||||
private let primaryHeight: CGFloat = 1000
|
||||
|
||||
func testPrimaryScreenRect() {
|
||||
// A window sits at the bottom-left of the primary screen.
|
||||
let cocoa = CGRect(x: 0, y: 0, width: 100, height: 100)
|
||||
let ax = Geometry.cocoaToAX(cocoa, primaryHeight: primaryHeight)
|
||||
XCTAssertEqual(ax.origin.x, 0)
|
||||
XCTAssertEqual(ax.origin.y, 900) // 1000 - 100
|
||||
XCTAssertEqual(ax.width, 100)
|
||||
XCTAssertEqual(ax.height, 100)
|
||||
}
|
||||
|
||||
func testRoundTripPrimary() {
|
||||
let cocoa = CGRect(x: 10, y: 20, width: 300, height: 200)
|
||||
let ax = Geometry.cocoaToAX(cocoa, primaryHeight: primaryHeight)
|
||||
let back = Geometry.axToCocoa(ax, primaryHeight: primaryHeight)
|
||||
XCTAssertEqual(back, cocoa)
|
||||
}
|
||||
|
||||
func testScreenAbovePrimary() {
|
||||
// A window above the primary top has a negative AX Y value.
|
||||
let cocoa = CGRect(x: 0, y: 1000, width: 100, height: 100)
|
||||
let ax = Geometry.cocoaToAX(cocoa, primaryHeight: primaryHeight)
|
||||
XCTAssertEqual(ax.origin.y, -100) // 1000 - 1100
|
||||
}
|
||||
|
||||
func testScreenBelowPrimary() {
|
||||
// A window below the primary bottom has an AX Y value past the height.
|
||||
let cocoa = CGRect(x: 0, y: -200, width: 100, height: 100)
|
||||
let ax = Geometry.cocoaToAX(cocoa, primaryHeight: primaryHeight)
|
||||
XCTAssertEqual(ax.origin.y, 1100) // 1000 - (-100)
|
||||
}
|
||||
|
||||
func testScreenLeftKeepsX() {
|
||||
// A screen left of the primary has a negative X. The X value does not
|
||||
// change in the conversion.
|
||||
let cocoa = CGRect(x: -1440, y: 0, width: 100, height: 100)
|
||||
let ax = Geometry.cocoaToAX(cocoa, primaryHeight: primaryHeight)
|
||||
XCTAssertEqual(ax.origin.x, -1440)
|
||||
}
|
||||
|
||||
func testCocoaYToAXTop() {
|
||||
let top = Geometry.cocoaYToAXTop(100, primaryHeight: primaryHeight)
|
||||
XCTAssertEqual(top, 900)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user