snapshot/lib/assets/SnapshotHelper.swift in fastlane-2.216.0 vs snapshot/lib/assets/SnapshotHelper.swift in fastlane-2.217.0
- old
+ new
@@ -13,17 +13,16 @@
// -----------------------------------------------------
import Foundation
import XCTest
-var deviceLanguage = ""
-var locale = ""
-
+@MainActor
func setupSnapshot(_ app: XCUIApplication, waitForAnimations: Bool = true) {
Snapshot.setupSnapshot(app, waitForAnimations: waitForAnimations)
}
+@MainActor
func snapshot(_ name: String, waitForLoadingIndicator: Bool) {
if waitForLoadingIndicator {
Snapshot.snapshot(name)
} else {
Snapshot.snapshot(name, timeWaitingForIdle: 0)
@@ -31,10 +30,11 @@
}
/// - Parameters:
/// - name: The name of the snapshot
/// - timeout: Amount of seconds to wait until the network loading indicator disappears. Pass `0` if you don't want to wait.
+@MainActor
func snapshot(_ name: String, timeWaitingForIdle timeout: TimeInterval = 20) {
Snapshot.snapshot(name, timeWaitingForIdle: timeout)
}
enum SnapshotError: Error, CustomDebugStringConvertible {
@@ -50,17 +50,20 @@
}
}
}
@objcMembers
+@MainActor
open class Snapshot: NSObject {
static var app: XCUIApplication?
static var waitForAnimations = true
static var cacheDirectory: URL?
static var screenshotsDirectory: URL? {
return cacheDirectory?.appendingPathComponent("screenshots", isDirectory: true)
}
+ static var deviceLanguage = ""
+ static var currentLocale = ""
open class func setupSnapshot(_ app: XCUIApplication, waitForAnimations: Bool = true) {
Snapshot.app = app
Snapshot.waitForAnimations = waitForAnimations
@@ -101,21 +104,21 @@
let path = cacheDirectory.appendingPathComponent("locale.txt")
do {
let trimCharacterSet = CharacterSet.whitespacesAndNewlines
- locale = try String(contentsOf: path, encoding: .utf8).trimmingCharacters(in: trimCharacterSet)
+ currentLocale = try String(contentsOf: path, encoding: .utf8).trimmingCharacters(in: trimCharacterSet)
} catch {
NSLog("Couldn't detect/set locale...")
}
- if locale.isEmpty && !deviceLanguage.isEmpty {
- locale = Locale(identifier: deviceLanguage).identifier
+ if currentLocale.isEmpty && !deviceLanguage.isEmpty {
+ currentLocale = Locale(identifier: deviceLanguage).identifier
}
- if !locale.isEmpty {
- app.launchArguments += ["-AppleLocale", "\"\(locale)\""]
+ if !currentLocale.isEmpty {
+ app.launchArguments += ["-AppleLocale", "\"\(currentLocale)\""]
}
}
class func setLaunchArguments(_ app: XCUIApplication) {
guard let cacheDirectory = self.cacheDirectory else {
@@ -279,10 +282,11 @@
}
return self.containing(isNetworkLoadingIndicator)
}
+ @MainActor
var deviceStatusBars: XCUIElementQuery {
guard let app = Snapshot.app else {
fatalError("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
}
@@ -304,6 +308,6 @@
}
}
// Please don't remove the lines below
// They are used to detect outdated configuration files
-// SnapshotHelperVersion [1.29]
+// SnapshotHelperVersion [1.30]