Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Merge PR #83 into main: the diagnostics capture and the Saves capture share the visual-QA test

LNPANDYdfb9b306d43d
diff --cc frontend/Tests/NSPortBuilderTests/LibraryTests.swift
index 2b0ea862,dbe4039c..8ef6f0fe
--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
@@@ -762,23 -813,44 +813,61 @@@ final class LibraryTests: XCTestCase
try capture("building", activeID: library.games[1].id)
model.running = false
+ // ---- Copy diagnostics (#69): Settings with its row, and the button's Copied confirmation (nothing is copied) ----
+ do {
+ try capture("settings-diagnostics", height: 1500, page: .settings)
+ let buttons = NSHostingView(rootView: HStack(spacing: 14) {
+ DiagnosticsButton(m: model, width: BuilderView.settingsButtonWidth)
+ DiagnosticsButton(m: model, width: BuilderView.settingsButtonWidth, showCopied: true)
+ }.padding(24).background(LauncherPalette.background).environmentObject(PadFocus()))
+ buttons.frame = NSRect(x: 0, y: 0, width: 420, height: 90)
+ let window = NSWindow(contentRect: buttons.frame, styleMask: [.titled], backing: .buffered, defer: false)
+ window.contentView = buttons
+ window.orderFront(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.3))
+ let rep = try XCTUnwrap(buttons.bitmapImageRepForCachingDisplay(in: buttons.bounds))
+ buttons.cacheDisplay(in: buttons.bounds, to: rep)
+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent("diagnostics-copied.png"))
+ window.orderOut(nil)
+ }
+ // ---- Saves (#66): the sheet with a stand-in devicectl and a temporary Mac folder, then its question, reached by the controller ----
+ do {
+ let game = library.games[0]
+ let installed = temporary.appendingPathComponent("DmIOS.app")
+ try FileManager.default.createDirectory(at: installed, withIntermediateDirectories: true)
+ try PropertyListSerialization.data(fromPropertyList: ["CFBundleIdentifier": "com.example.hades"], format: .xml, options: 0)
+ .write(to: installed.appendingPathComponent("Info.plist"))
+ library.recordCompletedIOS(ipa: "", archive: "", app: installed.path, device: "00008150-AAAA", for: game.id)
+ let support = temporary.appendingPathComponent("Application Support")
+ let save = SaveTransfer.legacyMacSave(titleID: game.titleID, support: support).appendingPathComponent("data.bin")
+ try FileManager.default.createDirectory(at: save.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data("mac".utf8).write(to: save)
+ try FileManager.default.setAttributes([.modificationDate: Date(timeIntervalSinceNow: -3 * 86_400)], ofItemAtPath: save.path)
+ let device = DeviceControl { args in // a device whose save is from an hour ago
+ guard let i = args.firstIndex(of: "--json-output") else { return (false, "ERROR: not in the visual QA") }
+ let files = args.contains("--recurse") ? [["name": "data.bin", "fileType": "file", "modificationDate": ISO8601DateFormatter().string(from: Date(timeIntervalSinceNow: -3600))]] : []
+ try? JSONSerialization.data(withJSONObject: ["result": ["files": files]]).write(to: URL(fileURLWithPath: args[i + 1]))
+ return (true, "")
+ }
+ let focus = PadFocus()
+ let host = NSHostingView(rootView: SavesView(m: model, library: library, gameID: game.id, devicectl: device, support: support).environmentObject(focus))
+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 520), styleMask: [.titled], backing: .buffered, defer: false)
+ window.contentView = host
+ window.orderFront(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.6))
+ func shot(_ name: String) throws {
+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))
+ host.cacheDisplay(in: host.bounds, to: rep)
+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent(name + ".png"))
+ }
+ try shot("saves")
+ focus.scope = "saves"
+ focus.show(default: "saves.toDevice")
+ focus.activate()
+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))
+ try shot("saves-confirm")
+ window.orderOut(nil)
+ }
}
/// Issue #52: the failure note names the last real line, not just the exit code.