Initial MacTaskManager release
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import XCTest
|
||||
@testable import MacTaskManager
|
||||
|
||||
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 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user