Skip to content

Commit

Permalink
Add settings to disable some new features
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellanata committed Jan 8, 2025
1 parent 6796f9b commit 7c0b662
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Hammer/EventGenerator/EventGenerator+Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ extension EventGenerator {

/// The delay to wait after activating the accessibility engine for the first time in a simulator.
public var accessibilityActivateFirstTimeDelay: TimeInterval = 5.0

/// The accessibility engine is required for finding accessibility labels. We proactively enable it
/// to avoid issues with the first test case that uses it.
public var forceActivateAccessibilityEngine: Bool = true

/// If we should wait for animations to complete when an event generator is created.
public var waitForAnimations: Bool = false
}
}
9 changes: 9 additions & 0 deletions Sources/Hammer/EventGenerator/EventGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public final class EventGenerator {
do {
try self.waitUntil(self.isWindowReady, timeout: timeout)
try self.waitUntilAccessibilityActivate()

if EventGenerator.settings.waitForAnimations {
try self.waitUntilAnimationsAreFinished(timeout: timeout)
}

try self.waitUntilRunloopIsFlushed(timeout: timeout)
} catch {
throw HammerError.windowIsNotReadyForInteraction
Expand Down Expand Up @@ -225,6 +230,10 @@ public final class EventGenerator {
private var isAccessibilityActivated = false

private func waitUntilAccessibilityActivate() throws {
guard EventGenerator.settings.forceActivateAccessibilityEngine else {
return
}

UIApplication.shared.accessibilityActivate()
if self.isAccessibilityActivated {
return
Expand Down

0 comments on commit 7c0b662

Please sign in to comment.