Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #70 from wcrestfield/master
Browse files Browse the repository at this point in the history
Fixing issue where memory would bloat in UITest runner when running o…
  • Loading branch information
wojciechczerski authored Oct 20, 2019
2 parents b8831e8 + e87bed2 commit 68f49bb
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions SwiftMonkey/Monkey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,24 @@ public class Monkey {
and not in some other app that the Monkey randomly opened.
*/
func actInForeground(_ action: @escaping ActionClosure) -> ActionClosure {
return {
guard #available(iOS 9.0, *) else {
action()
return
}
let closure: ActionClosure = {
if XCUIApplication().state != .runningForeground {
XCUIApplication().activate()
}
action()
}
if Thread.isMainThread {
closure()
} else {
DispatchQueue.main.async(execute: closure)
}
}
guard #available(iOS 9.0, *) else {
return action
}

let app = XCUIApplication()
let closure: ActionClosure = {
if app.state != .runningForeground {
app.activate()
}
action()
}
return {
if Thread.isMainThread {
closure()
} else {
DispatchQueue.main.async(execute: closure)
}
}
}

/**
Expand Down

0 comments on commit 68f49bb

Please sign in to comment.