-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix view visibility check failing on cells in scrolled table view (#28)
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// ScrollableViewControllerTests.swift | ||
// HammerTests | ||
// | ||
// Created by Łukasz Rutkowski on 28/07/2021. | ||
// | ||
|
||
import Foundation | ||
import Hammer | ||
import XCTest | ||
|
||
final class TableViewControllerTests: XCTestCase { | ||
|
||
func testFindViewAfterScrolling() throws{ | ||
let viewController = TableViewController() | ||
let eventGenerator = try EventGenerator(viewController: viewController) | ||
try eventGenerator.waitUntilVisible("accessibilityId_0-1", timeout: 1) | ||
|
||
viewController.tableView.scrollToRow(at: IndexPath(row: 40, section: 0), at: .bottom, animated: false) | ||
XCTAssertTrue(eventGenerator.viewIsVisible("accessibilityId_0-35")) | ||
} | ||
} | ||
|
||
final class TableViewController: UITableViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "TableViewCell") | ||
} | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 1 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 50 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) | ||
let id = "\(indexPath.section)-\(indexPath.row)" | ||
cell.textLabel?.text = "title_\(id)" | ||
cell.accessibilityIdentifier = "accessibilityId_\(id)" | ||
return cell | ||
} | ||
} |