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.
54 lines
2.5 KiB
Swift
54 lines
2.5 KiB
Swift
import XCTest
|
|
import CoreGraphics
|
|
@testable import EPODWindowBar
|
|
|
|
// ConstraintMathTests checks the pure constraint math (spec 7.10).
|
|
// All rects use Cocoa coordinates. The origin is bottom-left. The Y axis
|
|
// points up. limitY is the strip top edge.
|
|
final class ConstraintMathTests: XCTestCase {
|
|
|
|
// A window fully above the limit needs no change.
|
|
func testWindowAboveLimitReturnsNil() {
|
|
let window = CGRect(x: 0, y: 200, width: 800, height: 400)
|
|
XCTAssertNil(ConstraintMath.newHeight(windowCocoa: window, limitY: 30))
|
|
}
|
|
|
|
// A window with the bottom below the limit gets a new height. The top stays
|
|
// fixed. The top is maxY = 20 + 600 = 620. The new height is 620 - 30 = 590.
|
|
func testWindowBottomBelowLimitReturnsNewHeight() {
|
|
let window = CGRect(x: 0, y: 20, width: 800, height: 600)
|
|
let height = ConstraintMath.newHeight(windowCocoa: window, limitY: 30)
|
|
XCTAssertEqual(height, 590, accuracy: 0.001)
|
|
}
|
|
|
|
// The boundary case: the window bottom is exactly at the limit. No change.
|
|
func testWindowBottomExactlyAtLimitReturnsNil() {
|
|
let window = CGRect(x: 0, y: 30, width: 800, height: 400)
|
|
XCTAssertNil(ConstraintMath.newHeight(windowCocoa: window, limitY: 30))
|
|
}
|
|
|
|
// The user moved the window down on purpose. The top is also below
|
|
// (limitY - 100). The service skips the window.
|
|
func testIntentionalMoveDownIsTrue() {
|
|
// limitY = 30. limitY - 100 = -70. A top at -80 is below -70.
|
|
XCTAssertTrue(ConstraintMath.isIntentionalMoveDown(windowTopCocoa: -80, limitY: 30))
|
|
}
|
|
|
|
// A normal window with a high top is not an intentional move-down.
|
|
func testIntentionalMoveDownIsFalse() {
|
|
XCTAssertFalse(ConstraintMath.isIntentionalMoveDown(windowTopCocoa: 500, limitY: 30))
|
|
}
|
|
|
|
// A window on a second screen below the primary screen. The second screen
|
|
// has negative Cocoa Y. The strip is on that screen. limitY = -770.
|
|
// The window bottom (-900) is below the limit. The top is -300.
|
|
// The top is not below (limitY - 100 = -870), so the service corrects the
|
|
// window. The new height is top - limitY = -300 - (-770) = 470.
|
|
func testWindowOnSecondScreenGetsNewHeight() {
|
|
let window = CGRect(x: 0, y: -900, width: 800, height: 600) // top = -300
|
|
XCTAssertFalse(ConstraintMath.isIntentionalMoveDown(windowTopCocoa: window.maxY, limitY: -770))
|
|
let height = ConstraintMath.newHeight(windowCocoa: window, limitY: -770)
|
|
XCTAssertEqual(height, 470, accuracy: 0.001)
|
|
}
|
|
}
|