refactor(process): 简化进程表并统一表头排序与应用图标
This commit is contained in:
@@ -34,15 +34,27 @@ import CoreGraphics
|
||||
return ProcessMetrics(id: id, name: "worker-\(index)",
|
||||
path: path, cpu: Double(index), residentBytes: UInt64(2000 - index), threads: 1, restricted: false)
|
||||
}
|
||||
let cpu = ProcessTableProjection.rows(input, query: "", byMemory: false, order: [])
|
||||
let cpu = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .cpu)], order: [])
|
||||
precondition(cpu.first?.id.pid == 2000 && cpu.count == 2000)
|
||||
let memory = ProcessTableProjection.rows(input, query: "", byMemory: true, order: [])
|
||||
let memory = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .memory)], order: [])
|
||||
precondition(memory.first?.id.pid == 1)
|
||||
let held = ProcessTableProjection.rows(input, query: "", byMemory: true, order: cpu.map(\.id))
|
||||
let held = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .memory)], order: cpu.map(\.id))
|
||||
precondition(held.map(\.id) == cpu.map(\.id))
|
||||
let matched = ProcessTableProjection.rows(input, query: "needle", byMemory: false, order: [])
|
||||
let matched = ProcessTableProjection.rows(input, query: "needle", sorting: [ProcessSort(key: .cpu)], order: [])
|
||||
precondition(matched.count == 1 && matched[0].id.pid == 43)
|
||||
precondition(ProcessTableProjection.rows(input, query: "does-not-exist", byMemory: false, order: []).isEmpty)
|
||||
precondition(ProcessTableProjection.rows(input, query: "does-not-exist", sorting: [ProcessSort(key: .cpu)], order: []).isEmpty)
|
||||
let ascending = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .cpu, order: .forward)], order: [])
|
||||
precondition(ascending.first?.id.pid == 1)
|
||||
let missing = ProcessMetrics(id: ProcessIdentity(pid: 3000, seconds: 1, microseconds: 0), name: "missing", path: nil,
|
||||
cpu: nil, residentBytes: nil, threads: nil, restricted: true)
|
||||
for direction in [SortOrder.forward, .reverse] {
|
||||
for key in [ProcessSort.Key.cpu, .memory, .threads] {
|
||||
let result = ProcessTableProjection.rows(input + [missing], query: "", sorting: [ProcessSort(key: key, order: direction)], order: [])
|
||||
precondition(result.last?.id == missing.id)
|
||||
}
|
||||
}
|
||||
let pidSorted = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .pid)], order: [])
|
||||
precondition(pidSorted.first?.id.pid == 2000)
|
||||
print("PASS: physical-row heights, column breakpoints, width conservation, resource scrolling, visible-frame bounds/chrome/negative origins, 2000-row CPU/RSS projection, frozen order, path search and empty results")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user