Live Activities unter der Notch, nicht daneben
Neben ihr wären die Arme zwangsläufig gleich breit — die Silhouette zeichnet den Steg mittig um die Hardware. Ein Symbol links und ein Balken rechts hieße dann 132 Punkte Schwarz für ein Symbol. Darunter hängt die Fläche frei und wird so breit, wie ihr Inhalt es braucht. Lautstärke, Strom, Titelwechsel und Helligkeit. Gemeldet wird nur, was sich **geändert** hat: `PowerWatcher` schweigt beim ersten gelesenen Zustand, sonst begrüßte Onyx jeden Start mit „am Netz". Die Helligkeit kostete einen Spike. Von drei Wegen trägt nur `DisplayServices`, und nur für den eingebauten Bildschirm. `CoreDisplay` — der Weg, den jede Anleitung empfiehlt — gibt für alle Bildschirme 1.0 zurück, auch für den, der auf 62 % stand. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c05ccb8ae1
commit
9b600de9a9
@@ -0,0 +1,71 @@
|
||||
import Testing
|
||||
@testable import MetricsProvider
|
||||
|
||||
@Suite("Strom: was gemeldet wird")
|
||||
struct PowerWatcherTests {
|
||||
|
||||
@Test("Der erste gelesene Zustand meldet nichts")
|
||||
func firstReadingIsSilent() {
|
||||
var watcher = PowerWatcher()
|
||||
// Beim Start ist „am Netz" kein Ereignis, sondern die Lage.
|
||||
#expect(watcher.observe(isCharging: false, isPluggedIn: true,
|
||||
charge: 0.8, limit: nil) == nil)
|
||||
#expect(watcher.current == .plugged)
|
||||
}
|
||||
|
||||
@Test("Derselbe Zustand meldet sich nicht noch einmal")
|
||||
func repeatedStateIsSilent() {
|
||||
var watcher = PowerWatcher()
|
||||
_ = watcher.observe(isCharging: true, isPluggedIn: true, charge: 0.5, limit: nil)
|
||||
#expect(watcher.observe(isCharging: true, isPluggedIn: true,
|
||||
charge: 0.51, limit: nil) == nil)
|
||||
#expect(watcher.observe(isCharging: true, isPluggedIn: true,
|
||||
charge: 0.99, limit: nil) == nil)
|
||||
}
|
||||
|
||||
@Test("Netzteil abgezogen: das ist ein Ereignis")
|
||||
func unplugging() {
|
||||
var watcher = PowerWatcher()
|
||||
_ = watcher.observe(isCharging: true, isPluggedIn: true, charge: 0.5, limit: nil)
|
||||
#expect(watcher.observe(isCharging: false, isPluggedIn: false,
|
||||
charge: 0.5, limit: nil) == .unplugged)
|
||||
}
|
||||
|
||||
@Test("Fast leer schlägt „am Akku\"")
|
||||
func lowBeatsUnplugged() {
|
||||
var watcher = PowerWatcher()
|
||||
_ = watcher.observe(isCharging: true, isPluggedIn: true, charge: 0.9, limit: nil)
|
||||
// Beides trifft zu — gemeldet wird das, was man nicht verpassen darf.
|
||||
#expect(watcher.observe(isCharging: false, isPluggedIn: false,
|
||||
charge: 0.15, limit: nil) == .low)
|
||||
}
|
||||
|
||||
@Test("Von fast leer zurück auf normal ist wieder ein Wechsel")
|
||||
func recoveringFromLow() {
|
||||
var watcher = PowerWatcher()
|
||||
_ = watcher.observe(isCharging: false, isPluggedIn: false, charge: 0.1, limit: nil)
|
||||
#expect(watcher.observe(isCharging: false, isPluggedIn: false,
|
||||
charge: 0.5, limit: nil) == .unplugged)
|
||||
}
|
||||
|
||||
@Test("Die Schwelle liegt bei zwanzig Prozent, einschließlich")
|
||||
func thresholdIsInclusive() {
|
||||
var atThreshold = PowerWatcher()
|
||||
_ = atThreshold.observe(isCharging: true, isPluggedIn: true, charge: 0.9, limit: nil)
|
||||
#expect(atThreshold.observe(isCharging: false, isPluggedIn: false,
|
||||
charge: 0.2, limit: nil) == .low)
|
||||
|
||||
var above = PowerWatcher()
|
||||
_ = above.observe(isCharging: true, isPluggedIn: true, charge: 0.9, limit: nil)
|
||||
#expect(above.observe(isCharging: false, isPluggedIn: false,
|
||||
charge: 0.21, limit: nil) == .unplugged)
|
||||
}
|
||||
|
||||
@Test("Am Ladelimit ist ein eigener Zustand, nicht „am Netz\"")
|
||||
func limitIsItsOwnState() {
|
||||
var watcher = PowerWatcher()
|
||||
_ = watcher.observe(isCharging: true, isPluggedIn: true, charge: 0.5, limit: 80)
|
||||
#expect(watcher.observe(isCharging: false, isPluggedIn: true,
|
||||
charge: 0.80, limit: 80) == .atLimit(80))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user