|
| 1 | +// |
| 2 | +// UIAccessiblityPerformEscapeTests.swift |
| 3 | +// PanModalTests |
| 4 | +// |
| 5 | +// Created by Sungdoo on 2022/03/17. |
| 6 | +// Copyright © 2022 Detail. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +import XCTest |
| 10 | +import PanModal |
| 11 | + |
| 12 | +class UIAccessiblityPerformEscapeTests: XCTestCase { |
| 13 | + |
| 14 | + class MockViewController: UIViewController, PanModalPresentable { |
| 15 | + var panScrollable: UIScrollView? { return nil } |
| 16 | + } |
| 17 | + |
| 18 | + override func setUpWithError() throws { |
| 19 | + // Put setup code here. This method is called before the invocation of each test method in the class. |
| 20 | + } |
| 21 | + |
| 22 | + override func tearDownWithError() throws { |
| 23 | + // Put teardown code here. This method is called after the invocation of each test method in the class. |
| 24 | + } |
| 25 | + |
| 26 | + func testAccessibilityPerformEscape() throws { |
| 27 | + |
| 28 | + let presenterViewController = UIApplication.shared.keyWindow?.rootViewController |
| 29 | + let panModal: UIViewController & PanModalPresentable = MockViewController() |
| 30 | + |
| 31 | + presenterViewController?.presentPanModal(panModal) |
| 32 | + XCTAssertNotNil(presenterViewController?.presentedViewController, "panModal should have been presented") |
| 33 | + |
| 34 | + let presentDidFisnish = XCTestExpectation() |
| 35 | + let dismissDidFinish = XCTestExpectation() |
| 36 | + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { |
| 37 | + |
| 38 | + let panContainerView = panModal.view.superview |
| 39 | + presentDidFisnish.fulfill() |
| 40 | + panContainerView?.accessibilityPerformEscape() |
| 41 | + |
| 42 | + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { |
| 43 | + XCTAssertNil(presenterViewController?.presentedViewController, "panModal should have been dismissed") |
| 44 | + dismissDidFinish.fulfill() |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + wait(for: [presentDidFisnish, dismissDidFinish], timeout: 10) |
| 49 | + } |
| 50 | +} |
0 commit comments