-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from Shopify/selection-fix
Selection fix
- Loading branch information
Showing
6 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Tests/FunctionalTableDataTests/Helpers/WindowWithTableViewMounted.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import UIKit | ||
|
||
|
||
|
||
final class WindowWithTableViewMounted { | ||
|
||
private var rootWindow: UIWindow! | ||
let tableView = UITableView() | ||
private let tableViewController : TableViewControllerWithTableViewMounted | ||
|
||
init() { | ||
self.tableViewController = TableViewControllerWithTableViewMounted(tableView) | ||
setUpWindowWithTableView() | ||
presentWindow() | ||
} | ||
|
||
private func setUpWindowWithTableView() { | ||
rootWindow = UIWindow(frame: UIScreen.main.bounds) | ||
rootWindow.rootViewController = tableViewController | ||
} | ||
|
||
private func presentWindow() { | ||
rootWindow.isHidden = false | ||
tableViewController.viewWillAppear(false) | ||
tableViewController.viewDidAppear(false) | ||
} | ||
|
||
func tearDownWindow() { | ||
tableViewController.viewWillDisappear(false) | ||
tableViewController.viewDidDisappear(false) | ||
rootWindow.rootViewController = nil | ||
rootWindow.isHidden = true | ||
self.rootWindow = nil | ||
} | ||
} | ||
|
||
|
||
private final class TableViewControllerWithTableViewMounted: UIViewController { | ||
let tableView : UITableView | ||
|
||
init(_ tableView: UITableView) { | ||
self.tableView = tableView | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func loadView() { | ||
super.loadView() | ||
setupTableView() | ||
} | ||
|
||
func setupTableView() { | ||
view.addSubview(tableView) | ||
tableView.translatesAutoresizingMaskIntoConstraints = false | ||
tableView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true | ||
tableView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true | ||
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true | ||
tableView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters