mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 03:00:18 +02:00
iPhone app: verified against a Frame from the Simulator
Adds debug-only test hooks (open on a tab, run page JS, leave the tunnel URL in Caches) used to drive the app in the Simulator, and records what was verified: all four tabs with live data, capture and 31 fps live video in WKWebView, upload, install jobs and the power password check through the app's tunnel. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
fd3a25434d
commit
db75d1ca71
4 files changed
+36
-5
No files matched your search
@@ -178,7 +178,16 @@ final class AppModel: ObservableObject {
|
||||
self.server = server
|
||||
self.forwarder = f
|
||||
readySince = Date()
|
||||
phase = .ready(URL(string: "http://127.0.0.1:\(f.localPort)/?key=\(key)")!)
|
||||
var page = "http://127.0.0.1:\(f.localPort)/?key=\(key)"
|
||||
#if DEBUG
|
||||
// Test hooks for the Simulator: open on a given tab, and leave the URL where
|
||||
// a test can drive the same tunnel (`simctl get_app_container … data`).
|
||||
if let tab = ProcessInfo.processInfo.environment["FRAME_TEST_PAGE"] { page += "#\(tab)" }
|
||||
if let dir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first {
|
||||
try? page.write(to: dir.appendingPathComponent("frame-test-url.txt"), atomically: true, encoding: .utf8)
|
||||
}
|
||||
#endif
|
||||
phase = .ready(URL(string: page)!)
|
||||
// Runs at once if it stopped in the moment since the check above.
|
||||
server.whenExited { [weak self] tail in
|
||||
Task { @MainActor in self?.lost(mine, "Frame Control on the headset stopped. \(tail.suffix(200))") }
|
||||
|
||||
@@ -144,6 +144,14 @@ struct WebShell: UIViewRepresentable {
|
||||
(root.presentedViewController ?? root).present(sheet, animated: true)
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
/// Simulator test hook: FRAME_TEST_JS runs in the page once it has loaded.
|
||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
guard let js = ProcessInfo.processInfo.environment["FRAME_TEST_JS"] else { return }
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 4) { webView.evaluateJavaScript(js) }
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: navigation: the app's page stays here; other sites open in Safari
|
||||
|
||||
func webView(_ webView: WKWebView, decidePolicyFor action: WKNavigationAction,
|
||||
|
||||
Reference in new issue
Block a user