From 6f2f46715f50ea79d51d61601a8f9cc7b054c856 Mon Sep 17 00:00:00 2001 From: Morgan Pretty <morgan.t.pretty@gmail.com> Date: Mon, 9 Dec 2024 14:41:11 +1100 Subject: [PATCH 1/3] Added basic handling for env vars provided by Appium --- Session/Meta/AppDelegate.swift | 4 +++ .../Settings/DeveloperSettingsViewModel.swift | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 5f1e75595..b010b0cbb 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -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() diff --git a/Session/Settings/DeveloperSettingsViewModel.swift b/Session/Settings/DeveloperSettingsViewModel.swift index 654dbb9a8..2b418559f 100644 --- a/Session/Settings/DeveloperSettingsViewModel.swift +++ b/Session/Settings/DeveloperSettingsViewModel.swift @@ -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 From 1fd673fc243868f764838ca807e55737fee82dc1 Mon Sep 17 00:00:00 2001 From: Morgan Pretty <morgan.t.pretty@gmail.com> Date: Mon, 9 Dec 2024 14:43:27 +1100 Subject: [PATCH 2/3] Increased build number --- Session.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 63a95bdad..c4b3e04c3 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -7664,7 +7664,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 506; + CURRENT_PROJECT_VERSION = 507; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -7743,7 +7743,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Distribution"; - CURRENT_PROJECT_VERSION = 506; + CURRENT_PROJECT_VERSION = 507; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; From cc102edc26d15fc99bb7e5779aec62dd35a7b7f7 Mon Sep 17 00:00:00 2001 From: Morgan Pretty <morgan.t.pretty@gmail.com> Date: Mon, 9 Dec 2024 14:47:40 +1100 Subject: [PATCH 3/3] Fixed a typo --- Session/Meta/AppDelegate.swift | 2 +- Session/Settings/DeveloperSettingsViewModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index b010b0cbb..1f728c06e 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -32,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD 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() + DeveloperSettingsViewModel.processUnitTestEnvVariablesIfNeeded() Log.info("[AppDelegate] didFinishLaunchingWithOptions called.") startTime = CACurrentMediaTime() diff --git a/Session/Settings/DeveloperSettingsViewModel.swift b/Session/Settings/DeveloperSettingsViewModel.swift index 2b418559f..f172b7361 100644 --- a/Session/Settings/DeveloperSettingsViewModel.swift +++ b/Session/Settings/DeveloperSettingsViewModel.swift @@ -553,7 +553,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, // MARK: - Automated Test Convenience extension DeveloperSettingsViewModel { - static func processUnitTestEnvVaraiblesIfNeeded() { + static func processUnitTestEnvVariablesIfNeeded() { #if targetEnvironment(simulator) enum EnvironmentVariable: String { case animationsEnabled