Skip to content
Permalink
Browse files

refactoring

  • Loading branch information...
tarunon committed May 27, 2019
1 parent 57e5207 commit 3cb8c254e7e06b01273c697e413ccd3ef6f5dbe8
@@ -8,7 +8,7 @@
import UIKit

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

guard let origin = UIApplication.shared.keyWindow else {
assert("Should set Host Application at Test target.", file, line)
@@ -35,7 +35,7 @@ func assertNoAmbiguousLayout(_ viewController: @autoclosure () -> UIViewControll
context.finalize()
}

func assertNoAmbiguousLayout(_ f: (AssertAutolayoutContext) -> (), assert: @escaping (String, StaticString, UInt) -> (), file: StaticString, line: UInt) {
func assertAutolayout(_ f: (AssertAutolayoutContext) -> (), assert: @escaping (String, StaticString, UInt) -> (), file: StaticString, line: UInt) {
let context = AssertAutolayoutContextInternal(assert: assert, file: file, line: line)
context.process(f)
context.finalize()
@@ -16,7 +16,7 @@ import UIKit
/// - Parameters:
/// - viewController: The asssert target.
public func XCTAssertAutolayout(file: StaticString = #file, line: UInt = #line, _ viewController: @autoclosure () -> UIViewController) {
assertNoAmbiguousLayout(viewController(), assert: XCTFail, file: file, line: line)
assertAutolayout(viewController(), assert: XCTFail, file: file, line: line)
}

/// Generates a failure if the viewController has ambigous layout.
@@ -26,5 +26,5 @@ public func XCTAssertAutolayout(file: StaticString = #file, line: UInt = #line,
/// - Parameters:
/// - f: The closure givven autolayout test context.
public func XCTAssertAutolayout(file: StaticString = #file, line: UInt = #line, _ f: (AssertAutolayoutContext) -> ()) {
assertNoAmbiguousLayout(f, assert: XCTFail, file: file, line: line)
assertAutolayout(f, assert: XCTFail, file: file, line: line)
}
@@ -5,15 +5,15 @@ import UIKit
final class XCTAssertAutolayoutTests: XCTestCase {
func getAssertMessages(_ viewController: UIViewController) -> [String] {
var assertMessages = [String]()
assertNoAmbiguousLayout(viewController, assert: { message, _, _ in
assertAutolayout(viewController, assert: { message, _, _ in
assertMessages.append(message)
}, file: #file, line: #line)
return assertMessages
}

func getAssertMessages(_ f: (AssertAutolayoutContext) -> ()) -> [String] {
var assertMessages = [String]()
assertNoAmbiguousLayout(f, assert: { (message, _, _) in
assertAutolayout(f, assert: { (message, _, _) in
assertMessages.append(message)
}, file: #file, line: #line)
return assertMessages

0 comments on commit 3cb8c25

Please sign in to comment.
You can’t perform that action at this time.