Skip to content

Commit

Permalink
Fix Example StyleAndOption UITests for iOS 13
Browse files Browse the repository at this point in the history
  • Loading branch information
pacient committed Jul 18, 2019
1 parent 0c8517c commit b5a8a4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions Examples/StylesAndOptions/ExampleUITests/ExampleUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,24 @@ class ExampleUITests: XCTestCase {
}
}

func showDismissablePresentation(style: String, option: String) {
func showDismissablePresentation(style: String, option: String, file: StaticString = #file, line: UInt = #line) {
let tablesQuery = app.tables

XCTAssertTrue(app.navigationBars["Presentation Styles"].exists)
XCTAssertTrue(app.navigationBars["Presentation Styles"].exists, file: file, line: line)
tablesQuery.cells.staticTexts[style].tap()
XCTAssertTrue(app.navigationBars["Presentation Options"].exists)
XCTAssertTrue(app.navigationBars["Presentation Options"].exists, file: file, line: line)
tablesQuery.cells.staticTexts[option].tap()
}

func pressBack() {
func pressBack(file: StaticString = #file, line: UInt = #line) {
let back = app.navigationBars["UIView"].buttons.firstMatch
XCTAssert(back.waitForExistence(timeout: 1.0), file: file, line: line)
back.tap()
}

func pressDismiss() {
func pressDismiss(file: StaticString = #file, line: UInt = #line) {
let dismiss = app.buttons["Tap To Dismiss"]
XCTAssert(dismiss.waitForExistence(timeout: 1.0), file: file, line: line)
dismiss.tap()
}

Expand Down
4 changes: 2 additions & 2 deletions Presentation/UIViewController+Presentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public extension UIViewController {
func present<VC: UIViewController, Value>(_ viewController: VC, style: PresentationStyle = .default, options: PresentationOptions = .defaults, function: @escaping (VC, DisposeBag) -> Future<Value>) -> Future<Value> {
let vc = viewController
let root = rootViewController

// iOS 13 temporary fix for issue #40: https://github.com/iZettle/Presentation/issues/40
let shouldPresentImmediately: Bool
if #available(iOS 13.0, *) {
shouldPresentImmediately = root is UISplitViewController || vc is UISplitViewController
} else {
shouldPresentImmediately = false
}

guard shouldPresentImmediately || (root.isViewLoaded && root.view.window != nil) || unitTestDisablePresentWaitForWindow else {
// Wait for root to be presented before presenting vc
return root.signal(for: \.view).flatMapLatest { $0.hasWindowSignal.atOnce() }.filter { $0 }.future.flatMap { _ in
Expand Down

0 comments on commit b5a8a4b

Please sign in to comment.