-
Notifications
You must be signed in to change notification settings - Fork 1
Components
- UIAlertController
- UICollectionView
- UIDatePicker
- UIPickerView
- UISegmentedControl
- UISlider
- UIStepper
- UISwitch
- UITabBar / UITabBarController
- UITableView
Calls handler associated with specified UIAlertAction in a given UIAlertController instance and dismisses UIAlertController
func tapButton(withTitle title: String, fromAlertController alertController: UIAlertController)Parameters
title: Title for UIAlertAction
alertController: The UIAlertController instance that contains the UIAlertAction
Example
tap(viewController.showAlert)
let alertController: UIAlertController = waitForPresentedViewController()
tapButton(withTitle: "Close", fromAlertController: alertController)
waitForDismissedViewController()
XCTAssertNil(viewController.presentedViewController)Returns typed cell from given indexPath in a UICollectionView instance
func selectCell<A: UICollectionViewCell>(atIndex indexPath: IndexPath, fromCollectionView collectionView: UICollectionView) -> AParameters
indexPath: IndexPath where the UICollectionViewCell is located
collectionView: The UICollectionView that contains the cell
returns: The typed cell at given indexPath
Example
for row in 0..<viewController.myCollectionView.numberOfItems(inSection: 0) {
let index = IndexPath(row: row, section: 0)
scroll(to: index, in: viewController.myCollectionView)
let cell: MyCollectionViewCell = selectCell(atIndex: index, fromCollectionView: viewController.myCollectionView)
tap(cell.checkmarkButton)
}Sets the date for a given UIDatePicker instance
func selectDate(_ date: Date, fromDatePicker datePicker: UIDatePicker, animated: Bool)Parameters
date: Date to be set in UIDatePicker
datePicker: UIDatePicker instance to set date on
animated: Default true. Set to false to disable animation of date selection.
Example
tap(viewController.dateTextInput)
let datePickerVC: DatePickerViewController = waitForPresentedViewController()
selectDate(date, fromDatePicker: datePickerVC.datePicker, animated: animated)
XCTAssertEqual(date, datePickerVC.datePicker.date)Selects item at row for a given UIDatePicker instance
func selectItem(atRow row: Int, fromPicker picker: UIPickerView, animated: Bool)Parameters
row: Item's row within picker
picker: The UIPickerView where item is located
animated: Default true. Set to false to disable animation of item selection
Example
selectItem(atRow: 1, fromPicker: viewController.pickerView, animated: true)
XCTAssertEqual(viewController.pickerView.selectedRow(inComponent: 0), 1)Selects the segment at index of given UISegmentedControl
func selectSegment(_ segmentedControl: UISegmentedControl, atIndex index: Int)Parameters
segmentedControl: UISegmentedControl instance to update
index: Index of segment to be selected
Example
let index = 1
selectSegment(viewController.segmentedControl, atIndex: index)
XCTAssertEqual(viewController.segmentedControl.selectedSegmentIndex, index)Selects the segment with title within given UISegmentedControl
func selectSegment(_ segmentedControl: UISegmentedControl, withTitle title: String)Parameters
segmentedControl: UISegmentedControl instance to update
title: Title of segment to tap
Example
let title = "Second"
selectSegment(viewController.segmentedControl, withTitle: title)
XCTAssertEqual(viewController.segmentedControl.titleForSegment(at: viewController.segmentedControl.selectedSegmentIndex), title)Selects the segment with specified image of given UISegmentedControl
func selectSegment(_ segmentedControl: UISegmentedControl, withImage image: UIImage)Parameters
segmentedControl: UISegmentedControl instance to update
image: Image of segment to tap
Example
let image = UIImage.lock()
selectSegment(viewController.segmentedControl, withImage: image)
XCTAssertEqual(viewController.segmentedControl.imageForSegment(at: 1), image)Updates the provided UISlider instance with the given normalized value
func slide(_ slider: UISlider, toNormalizedValue value: Float, animated: Bool)Parameters
slider: The provided UISlider instance to update
value: The normalized value to slide to
animated: Default true. Set to false to disable animation of sliding action
Example
viewController.slider.minimumValue = 0
viewController.slider.maximumValue = 100
slide(viewController.slider, toNormalizedValue: 0.5)
XCTAssertEqual(viewController.slider.value, 50)Increments the given UIStepper by the default stepValue
func increment(_ stepper: UIStepper)Parameters
stepper: The UIStepper instance to be incremented
Example
let originalValue = viewController.stepper.value
increment(viewController.stepper)
XCTAssertEqual(viewController.stepper.value, originalValue + viewController.stepper.stepValue )Decrements the given UIStepper by the default stepValue
func decrement(_ stepper: UIStepper)Parameters
stepper: The UIStepper instance to be decremented
Example
let originalValue = viewController.stepper.value
decrement(viewController.stepper)
XCTAssertEqual(viewController.stepper.value, originalValue - viewController.stepper.stepValue )Toggles the isOn property of the given UISwitch instance
func toggle(_ aSwitch: UISwitch, animated: Bool)Parameters
aSwitch: UISwitch instance to toggle
animated: Default true. Set to false to disable animation of UISwitch toggle
Example
let initialState = viewController.backgroundSwitch.isOn
toggle(viewController.backgroundSwitch)
XCTAssertNotEqual(viewController.backgroundSwitch.isOn, initialState)Returns typed cell from given indexPath in a UITableView instance
func selectCell<A: UITableViewCell>(atIndex indexPath: IndexPath, fromTableView tableView: UITableView) -> AParameters
indexPath: IndexPath where the UITableViewCell is located
tableView: The UITableView that contains the cell
returns: The typed cell at given indexPath
Example
for row in 0..<viewController.myTableView.numberOfRows(inSection: 0) {
let index = IndexPath(row: row, section: 0)
scroll(to: index, in: viewController.myTableView)
let cell: MyTableViewCell = selectCell(atIndex: index, fromTableView: viewController.myTableView)
tap(cell.checkmarkButton)
}