Rename app and repository to Puter
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
import XCTest
|
||||
@testable import Puter
|
||||
|
||||
final class ModelTests: XCTestCase {
|
||||
func testAppleSystemServicePublisherAndDomainIdentity() {
|
||||
let system = ServiceRecord(label: "com.apple.accessoryd", pid: 7750, lastExitStatus: 0, domain: .system)
|
||||
let user = ServiceRecord(label: "com.apple.accessoryd", pid: 731, lastExitStatus: 0, domain: .user)
|
||||
|
||||
XCTAssertEqual(system.publisher, "Apple")
|
||||
XCTAssertEqual(system.domain.launchctlPrefix, "system")
|
||||
XCTAssertFalse(system.isControllable)
|
||||
XCTAssertTrue(user.isControllable)
|
||||
XCTAssertNotEqual(system.id, user.id)
|
||||
}
|
||||
|
||||
func testThirdPartyApplicationServicePublisher() {
|
||||
let service = ServiceRecord(
|
||||
label: "application.com.adobe.AdobeResourceSynchronizer.210006977.210006983",
|
||||
pid: 938,
|
||||
lastExitStatus: 0,
|
||||
domain: .user
|
||||
)
|
||||
XCTAssertEqual(service.publisher, "Adobe")
|
||||
XCTAssertEqual(service.displayName, "AdobeResourceSynchronizer")
|
||||
}
|
||||
|
||||
func testProcessDisplayNameFallback() {
|
||||
let process = ProcessRecord(
|
||||
pid: 42,
|
||||
parentPID: 1,
|
||||
name: " ",
|
||||
executablePath: "/usr/bin/example",
|
||||
user: "tester",
|
||||
cpu: 0,
|
||||
memoryPercent: 0,
|
||||
residentBytes: 0,
|
||||
state: "S",
|
||||
elapsed: "00:01",
|
||||
cpuTime: 0,
|
||||
threadCount: 1,
|
||||
openFileCount: 0,
|
||||
architecture: "ARM64",
|
||||
priority: 31,
|
||||
nice: 0
|
||||
)
|
||||
XCTAssertEqual(process.displayName, "Process 42")
|
||||
}
|
||||
|
||||
func testAllNavigationSectionsHaveIcons() {
|
||||
XCTAssertEqual(Set(TaskSection.allCases.map(\.rawValue)).count, TaskSection.allCases.count)
|
||||
XCTAssertTrue(TaskSection.allCases.allSatisfy { !$0.icon.isEmpty })
|
||||
}
|
||||
|
||||
func testBatteryHealthUsesFullChargeAndDesignCapacity() {
|
||||
let battery = BatterySnapshot(fullChargeCapacityMAh: 5_761, designCapacityMAh: 6_249)
|
||||
XCTAssertEqual(battery.healthPercent, 92.19, accuracy: 0.01)
|
||||
}
|
||||
|
||||
func testBatteryPowerRejectsCorruptTelemetry() {
|
||||
let normal = BatterySnapshot(voltageVolts: 12.1, currentAmps: -2.5)
|
||||
let corrupt = BatterySnapshot(voltageVolts: 12.1, currentAmps: Double(UInt64.max))
|
||||
|
||||
XCTAssertEqual(normal.batteryPowerWatts, 30.25, accuracy: 0.001)
|
||||
XCTAssertEqual(corrupt.batteryPowerWatts, 0)
|
||||
}
|
||||
|
||||
func testUSBPDProfileAndNegotiatedPower() {
|
||||
let profile = PowerProfile(voltageVolts: 20, currentAmps: 4.29)
|
||||
let adapter = PowerAdapterSnapshot(
|
||||
ratedWatts: 86,
|
||||
negotiatedVoltage: profile.voltageVolts,
|
||||
negotiatedCurrent: profile.currentAmps,
|
||||
profiles: [profile]
|
||||
)
|
||||
XCTAssertEqual(profile.watts, 85.8, accuracy: 0.001)
|
||||
XCTAssertEqual(adapter.negotiatedWatts, 85.8, accuracy: 0.001)
|
||||
}
|
||||
|
||||
func testMemoryBandwidthCatalogUsesSpecificChipBeforeFamilyFallback() {
|
||||
XCTAssertEqual(
|
||||
MemoryBandwidthCatalog.description(for: "Apple M4 Pro", cpuCoreCount: 14),
|
||||
"273 GB/s bandwidth (Apple specification)"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
MemoryBandwidthCatalog.description(for: "Apple M4 Max", cpuCoreCount: 14),
|
||||
"410 GB/s bandwidth (Apple specification)"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
MemoryBandwidthCatalog.description(for: "Apple M4 Max", cpuCoreCount: 16),
|
||||
"546 GB/s bandwidth (Apple specification)"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
MemoryBandwidthCatalog.description(for: "Apple M5 Pro", cpuCoreCount: 18),
|
||||
"Up to 307 GB/s bandwidth (Apple specification)"
|
||||
)
|
||||
XCTAssertEqual(MemoryBandwidthCatalog.description(for: "Intel Core i9", cpuCoreCount: 8), "Clock not published by macOS")
|
||||
XCTAssertEqual(MemoryBandwidthCatalog.specifications.count, 20)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user