Skip to content

Commit

Permalink
assert if test target don't have host application
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunon committed May 25, 2019
1 parent 7f59c5a commit 9d497b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/XCTAssertAutolayout/Core/Core.swift
Expand Up @@ -10,7 +10,10 @@ import UIKit

func assertNoAmbiguousLayout(_ viewController: @autoclosure () -> UIViewController, assert: @escaping (String, StaticString, UInt) -> (), file: StaticString, line: UInt) {

let origin = UIApplication.shared.keyWindow
guard let origin = UIApplication.shared.keyWindow else {
assert("Should set Host Application at Test target.", file, line)
return
}
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
window.makeKeyAndVisible()
Expand All @@ -30,7 +33,7 @@ func assertNoAmbiguousLayout(_ viewController: @autoclosure () -> UIViewControll
}

window.resignKey()
origin?.makeKeyAndVisible()
origin.makeKeyAndVisible()

context.finalize()
}

0 comments on commit 9d497b8

Please sign in to comment.