fix: allow compact mode while media is loading
This commit is contained in:
@@ -36,12 +36,66 @@ struct AutomaticQualityPlaybackChecks {
|
||||
let model = PlayerModel(defaults: defaults, qualityClock: { clock.now })
|
||||
defer { model.shutdown() }
|
||||
model.setVolume(0)
|
||||
// Control only the external extractor; media decoding and all model transitions stay real.
|
||||
guard let controlPath = ProcessInfo.processInfo.environment["TEREBI_QUALITY_CONTROL"] else {
|
||||
require(false, "isolated extraction controls are available")
|
||||
return
|
||||
}
|
||||
let control = URL(fileURLWithPath: controlPath, isDirectory: true)
|
||||
func mark(_ name: String) {
|
||||
require(FileManager.default.createFile(atPath: control.appendingPathComponent(name).path,
|
||||
contents: Data()), "publish extraction control " + name)
|
||||
}
|
||||
func marked(_ name: String) -> Bool {
|
||||
FileManager.default.fileExists(atPath: control.appendingPathComponent(name).path)
|
||||
}
|
||||
require(!model.automaticYouTubeQuality, "automatic quality is opt-in")
|
||||
let window = NSWindow(contentRect: NSRect(x: -10_000, y: -10_000, width: 640, height: 360),
|
||||
styleMask: [.titled, .closable, .miniaturizable, .resizable],
|
||||
backing: .buffered, defer: false)
|
||||
window.isReleasedWhenClosed = false
|
||||
defer { window.close() }
|
||||
model.attachWindow(window)
|
||||
let normalFrame = window.frame
|
||||
let compactKey = try! KeyChord("p")
|
||||
mark("gate-open")
|
||||
model.openYouTube("https://www.youtube.com/watch?v=aqz-KE-bpKQ")
|
||||
until(model, "initial YouTube resolution reaches the controlled extraction gate") {
|
||||
model.resolvingYouTube && marked("entered-open")
|
||||
}
|
||||
model.handleKey(compactKey)
|
||||
require(model.isCompact, "compact shortcut enters while the YouTube URL is unresolved")
|
||||
until(model, "compact mode remains usable across empty playback polls while resolving") {
|
||||
model.isCompact && !model.compactWindow.isTransitioning
|
||||
}
|
||||
require(window.level == .floating && window.frame.width < normalFrame.width,
|
||||
"unresolved video has a usable compact window")
|
||||
model.handleKey(compactKey)
|
||||
until(model, "compact shortcut restores while YouTube resolution is still pending") {
|
||||
!model.isCompact && !model.compactWindow.isTransitioning
|
||||
}
|
||||
require(window.frame == normalFrame && model.resolvingYouTube,
|
||||
"resolution continues while restoring the original normal window")
|
||||
require(model.perform(.enterCompact), "compact control action is available during resolution")
|
||||
mark("release-open")
|
||||
try! FileManager.default.removeItem(at: control.appendingPathComponent("gate-open"))
|
||||
until(model, "default selects real 1080p and runs out of the gated network prefix") {
|
||||
model.youtubeHeight == 1080 && model.canTogglePlayback &&
|
||||
model.state.status == PLAYER_PLAYING && model.state.position > 0.5 && model.state.buffering
|
||||
}
|
||||
require(model.isCompact, "loading completion preserves the requested compact mode")
|
||||
until(model, "decoded metadata updates compact geometry") {
|
||||
!model.compactWindow.isTransitioning &&
|
||||
abs(window.frame.width / window.frame.height - model.state.video_aspect_ratio) < 0.01
|
||||
}
|
||||
model.handleKey(compactKey)
|
||||
until(model, "compact shortcut restores during network buffering") {
|
||||
!model.isCompact && !model.compactWindow.isTransitioning
|
||||
}
|
||||
model.handleKey(compactKey)
|
||||
until(model, "compact shortcut re-enters during network buffering") {
|
||||
model.isCompact && !model.compactWindow.isTransitioning
|
||||
}
|
||||
clock.now = 2000
|
||||
polled(model)
|
||||
require(model.youtubeHeight == 1080 && !model.resolvingYouTube,
|
||||
@@ -75,19 +129,6 @@ struct AutomaticQualityPlaybackChecks {
|
||||
qualityClock: { clock.now })
|
||||
require(manual.automaticYouTubeQuality, "manual session override does not replace startup configuration")
|
||||
manual.shutdown()
|
||||
// Control only the external extractor; media decoding and all model transitions stay real.
|
||||
guard let controlPath = ProcessInfo.processInfo.environment["TEREBI_QUALITY_CONTROL"] else {
|
||||
require(false, "isolated extraction controls are available")
|
||||
return
|
||||
}
|
||||
let control = URL(fileURLWithPath: controlPath, isDirectory: true)
|
||||
func mark(_ name: String) {
|
||||
require(FileManager.default.createFile(atPath: control.appendingPathComponent(name).path,
|
||||
contents: Data()), "publish extraction control " + name)
|
||||
}
|
||||
func marked(_ name: String) -> Bool {
|
||||
FileManager.default.fileExists(atPath: control.appendingPathComponent(name).path)
|
||||
}
|
||||
model.setYouTubeQuality(720)
|
||||
until(model, "manual selection opens real healthy 720p media") {
|
||||
model.youtubeHeight == 720 && model.canChangeYouTubeQuality && model.state.status == PLAYER_PLAYING &&
|
||||
@@ -149,6 +190,8 @@ struct AutomaticQualityPlaybackChecks {
|
||||
"failed manual quality switch retains original selected media and playback progress")
|
||||
}
|
||||
model.closeFile()
|
||||
print("PASS native adaptive playback: default-off/stalled downshift/healthy upshift/progress preservation/current+default manual override/session-only settings/cancelled extraction pause/failed manual quality playing+paused preservation")
|
||||
require(!model.isCompact && !model.compactWindow.isTransitioning,
|
||||
"closing a streamed video restores its original window mode")
|
||||
print("PASS native adaptive playback: resolving/loading/buffering compact shortcuts+controls/default-off/stalled downshift/healthy upshift/progress preservation/current+default manual override/session-only settings/cancelled extraction pause/failed manual quality playing+paused preservation")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user