Added basic handling for env vars provided by Appium

pull/1053/head^2
Morgan Pretty 5 months ago
parent 2014200a76
commit 6f2f46715f

@ -30,6 +30,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
// MARK: - Lifecycle
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Just in case we are running automated tests we should process environment variables
// before we do anything else
DeveloperSettingsViewModel.processUnitTestEnvVaraiblesIfNeeded()
Log.info("[AppDelegate] didFinishLaunchingWithOptions called.")
startTime = CACurrentMediaTime()

@ -550,6 +550,31 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
}
}
// MARK: - Automated Test Convenience
extension DeveloperSettingsViewModel {
static func processUnitTestEnvVaraiblesIfNeeded() {
#if targetEnvironment(simulator)
enum EnvironmentVariable: String {
case animationsEnabled
}
ProcessInfo.processInfo.environment.forEach { key, value in
guard let variable: EnvironmentVariable = EnvironmentVariable(rawValue: key) else { return }
switch variable {
case .animationsEnabled:
guard value == "false" else { return }
UIView.setAnimationsEnabled(false)
}
}
#endif
}
}
// MARK: - DocumentPickerResult
private class DocumentPickerResult: NSObject, UIDocumentPickerDelegate {
private let onResult: (URL?) -> Void

Loading…
Cancel
Save