Skip to content

Commit

Permalink
Increase test coverage (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
omaralbeik authored Jul 25, 2022
1 parent 5bb17db commit 7dd5a7b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/WindowViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ internal final class WindowViewController: UIViewController {
var window: UIWindow?
}

private extension UIApplication {
internal extension UIApplication {
var activeWindowScene: UIWindowScene? {
return connectedScenes
.compactMap { $0 as? UIWindowScene }
.first { $0.activationState == .foregroundActive }
}
}

private extension UIViewController {
internal extension UIViewController {
var top: UIViewController? {
if let controller = self as? UINavigationController {
return controller.topViewController?.top
Expand Down
22 changes: 22 additions & 0 deletions Tests/WindowViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ final class WindowViewControllerTests: XCTestCase {
XCTAssertNil(WindowViewController(coder: NSCoder()))
}

func testPreferredStatusBarStyle() {
let viewController = WindowViewController()
XCTAssertEqual(viewController.preferredStatusBarStyle, .default)
}

func testInstall() {
let viewController = WindowViewController()
viewController.install()
Expand All @@ -48,4 +53,21 @@ final class WindowViewControllerTests: XCTestCase {

XCTAssertNil(viewController.window)
}

func testTopViewController() {
let navController = UINavigationController()
XCTAssertEqual(navController.top, navController.topViewController)

let splitController = UISplitViewController()
let controller = UIViewController()
splitController.viewControllers = [controller]
XCTAssertEqual(splitController.top, controller)

let tabBarController = UITabBarController()
tabBarController.viewControllers = [controller]
tabBarController.selectedIndex = 0
XCTAssertEqual(tabBarController.top, controller)

XCTAssertEqual(controller.top, controller)
}
}

0 comments on commit 7dd5a7b

Please sign in to comment.