fix(ui): 修正风扇转轴与速率图并精简进程表
This commit is contained in:
@@ -10,25 +10,40 @@ import SwiftUI
|
||||
let rotor = FanRotor.RotorView(); rotor.frame = NSRect(x: 4, y: 4, width: 20, height: 20)
|
||||
window.contentView!.addSubview(rotor); window.orderFrontRegardless()
|
||||
try? await Task.sleep(for: .milliseconds(100))
|
||||
for size: CGFloat in [11,20,32] {
|
||||
rotor.setFrameSize(NSSize(width: size, height: size)); rotor.layoutSubtreeIfNeeded()
|
||||
precondition(rotor.rotorLayer.anchorPoint == CGPoint(x: 0.5, y: 0.5))
|
||||
precondition(rotor.rotorLayer.contents != nil)
|
||||
precondition(CATransform3DIsIdentity(rotor.layer!.transform), "AppKit's host layer must never rotate")
|
||||
CATransaction.begin(); CATransaction.setDisableActions(true)
|
||||
for degrees in [0.0,45,90,180,270] {
|
||||
rotor.rotorLayer.transform = CATransform3DMakeRotation(degrees * .pi / 180, 0, 0, 1)
|
||||
let center = rotor.rotorLayer.convert(CGPoint(x: size / 2, y: size / 2), to: rotor.layer!)
|
||||
precondition(abs(center.x - rotor.bounds.midX) < 1e-9 && abs(center.y - rotor.bounds.midY) < 1e-9,
|
||||
"The icon center must not orbit at any angle or size")
|
||||
}
|
||||
rotor.rotorLayer.transform = CATransform3DIdentity
|
||||
CATransaction.commit()
|
||||
}
|
||||
for (rpm, duration) in [(1000.0,4.0),(2000,2),(4000,1.2),(6000,0.8)] {
|
||||
rotor.configure(rpm: rpm, active: true, reducedMotion: false)
|
||||
precondition(abs(rotor.layer!.animation(forKey: FanRotor.RotorView.animationKey)!.duration - duration) < 1e-9)
|
||||
precondition(abs(rotor.rotorLayer.animation(forKey: FanRotor.RotorView.animationKey)!.duration - duration) < 1e-9)
|
||||
}
|
||||
for rpm: Double? in [0,nil,.nan,-1] {
|
||||
rotor.configure(rpm: rpm, active: true, reducedMotion: false)
|
||||
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
|
||||
precondition(rotor.rotorLayer.animationKeys()?.isEmpty != false)
|
||||
}
|
||||
rotor.configure(rpm: 3000, active: true, reducedMotion: false)
|
||||
precondition(rotor.layer!.animationKeys()?.isEmpty == false)
|
||||
precondition(rotor.rotorLayer.animationKeys()?.isEmpty == false)
|
||||
rotor.configure(rpm: 3000, active: false, reducedMotion: false)
|
||||
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
|
||||
precondition(rotor.rotorLayer.animationKeys()?.isEmpty != false)
|
||||
rotor.configure(rpm: 3000, active: true, reducedMotion: true)
|
||||
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
|
||||
precondition(rotor.rotorLayer.animationKeys()?.isEmpty != false)
|
||||
rotor.configure(rpm: 3000, active: true, reducedMotion: false)
|
||||
rotor.removeFromSuperview()
|
||||
precondition(rotor.layer!.animationKeys()?.isEmpty != false, "Detached fans must stop rotating")
|
||||
precondition(rotor.rotorLayer.animationKeys()?.isEmpty != false, "Detached fans must stop rotating")
|
||||
window.orderOut(nil); window.close()
|
||||
print("PASS: native rotor speed tiers, nil/zero/invalid readings, inactive/reduced motion and detach stop")
|
||||
print("PASS: centered child-layer rotation at multiple angles/sizes, native rotor speed tiers, nil/zero/invalid readings, inactive/reduced motion and detach stop")
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
NSApp.run()
|
||||
|
||||
Reference in New Issue
Block a user