Skip to content

Commit 7c0b662

Browse files
committed
Add settings to disable some new features
1 parent 6796f9b commit 7c0b662

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/Hammer/EventGenerator/EventGenerator+Settings.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@ extension EventGenerator {
1111

1212
/// The delay to wait after activating the accessibility engine for the first time in a simulator.
1313
public var accessibilityActivateFirstTimeDelay: TimeInterval = 5.0
14+
15+
/// The accessibility engine is required for finding accessibility labels. We proactively enable it
16+
/// to avoid issues with the first test case that uses it.
17+
public var forceActivateAccessibilityEngine: Bool = true
18+
19+
/// If we should wait for animations to complete when an event generator is created.
20+
public var waitForAnimations: Bool = false
1421
}
1522
}

Sources/Hammer/EventGenerator/EventGenerator.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public final class EventGenerator {
115115
do {
116116
try self.waitUntil(self.isWindowReady, timeout: timeout)
117117
try self.waitUntilAccessibilityActivate()
118+
119+
if EventGenerator.settings.waitForAnimations {
120+
try self.waitUntilAnimationsAreFinished(timeout: timeout)
121+
}
122+
118123
try self.waitUntilRunloopIsFlushed(timeout: timeout)
119124
} catch {
120125
throw HammerError.windowIsNotReadyForInteraction
@@ -225,6 +230,10 @@ public final class EventGenerator {
225230
private var isAccessibilityActivated = false
226231

227232
private func waitUntilAccessibilityActivate() throws {
233+
guard EventGenerator.settings.forceActivateAccessibilityEngine else {
234+
return
235+
}
236+
228237
UIApplication.shared.accessibilityActivate()
229238
if self.isAccessibilityActivated {
230239
return

0 commit comments

Comments
 (0)