Files
CommandTabFree/unit-tests/UsageStatsMessageTests.swift
T
lwouis 9147a4a864 feat: introducing alt-tab pro!
BREAKING CHANGE: announcement: https://github.com/lwouis/alt-tab-macos/discussions/5533

* improved performance, especially switcher responsiveness
* reduced battery usage even more
* reduced ram usage (closes #5450, closes #5539, closes #5627)
* reduced app size even more
* polished many aspects of the ui; align more with liquid glass
* better handle "ghost" windows (closes #5509)
* fix issue with wrong window order (closes #5492)
* escape closes the switcher on tahoe (closes #5585)
* improve search matches (closes #5488)
* localizations trimmed and reviewed entirely (closes #5583)
* highlight matching app icons when searching, in addition to text
* better settings import/export
* reworked "send feedback" experience
* reworked exceptions ui (closes #5482)
* per-shortcut settings (closes #5313)
* rework about window
2026-05-21 10:21:25 +02:00

59 lines
2.2 KiB
Swift

import XCTest
final class UsageStatsTestableMessageTests: XCTestCase {
private func count(triggers: [Int] = [], appIcons: [Int] = [], titles: [Int] = [],
extraShortcuts: [Int] = [], searches: [Int] = []) -> Int {
UsageStatsTestable.proFeatureSessionCount(
triggers: triggers, appIcons: appIcons, titles: titles,
extraShortcuts: extraShortcuts, searches: searches)
}
func testEmpty_returnsZero() {
XCTAssertEqual(count(), 0)
}
func testTriggersOnlyNoFeatures_returnsZero() {
XCTAssertEqual(count(triggers: [100, 200, 300]), 0)
}
func testAppIconsAndSearchInSameSession_countsOne() {
XCTAssertEqual(count(triggers: [100], appIcons: [100], searches: [105]), 1)
}
func testCycleHeavySession_collapsesToOne() {
XCTAssertEqual(count(triggers: [100, 100, 100, 100, 100], appIcons: [100, 100, 100, 100, 100]), 1)
}
func testTwoDistinctSessionsWithDifferentFeatures() {
XCTAssertEqual(count(triggers: [100, 200], appIcons: [100], titles: [200]), 2)
}
func testSearchesMappedBackToOwningTriggers() {
XCTAssertEqual(count(triggers: [100, 200], searches: [150, 250]), 2)
}
func testSpuriousFeatureTimestamp_intersectedAway() {
XCTAssertEqual(count(triggers: [100], appIcons: [999]), 0)
}
func testSearchBeforeAnyTrigger_skipped() {
XCTAssertEqual(count(triggers: [100], searches: [50]), 0)
}
func testSessionCountNeverExceedsTriggerCount() {
let triggers = [100, 100, 200]
let result = count(triggers: triggers, appIcons: [100, 100], titles: [200], searches: [105, 205])
XCTAssertLessThanOrEqual(result, triggers.count)
XCTAssertEqual(result, 2)
}
func testFormatCount_thousandSeparator() {
XCTAssertEqual(UsageStatsTestable.formatCount(1), "1")
XCTAssertEqual(UsageStatsTestable.formatCount(999), "999")
let formatted1000 = UsageStatsTestable.formatCount(1000)
XCTAssertTrue(formatted1000.count > 4, "Expected grouping separator in '\(formatted1000)'")
XCTAssertTrue(formatted1000.contains("1"))
XCTAssertTrue(formatted1000.contains("000"))
}
}