Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit ef7df0c

Browse files
Get mainViewController in automation server
1 parent 6d71981 commit ef7df0c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

DuckDuckGo/AppLifecycle/AppStates/Launching.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,13 @@ struct Launching: AppState {
183183

184184
private func startAutomationServerIfNeeded() {
185185
let launchOptionsHandler = LaunchOptionsHandler()
186-
if launchOptionsHandler.isUITesting && launchOptionsHandler.automationPort != nil {
187-
AutomationServer(main: mainViewController!, port: launchOptionsHandler.automationPort)
186+
guard launchOptionsHandler.isUITesting && launchOptionsHandler.automationPort != nil else {
187+
return
188188
}
189+
guard let rootViewController = window.rootViewController as? MainViewController else {
190+
return
191+
}
192+
AutomationServer(main: rootViewController, port: launchOptionsHandler.automationPort)
189193
}
190194
}
191195

DuckDuckGo/TabViewController+Automation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension TabViewController {
2828
arguments: args,
2929
in: nil,
3030
contentWorld: .page
31-
)
31+
) ?? ""
3232
return .success(result)
3333
} catch {
3434
return .failure(error)

0 commit comments

Comments
 (0)