lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
246 stars 17 forks source link

25740585: Setting a picker view value when UI testing inconsistent with behaviour #11689

Open openradar-mirror opened 8 years ago

openradar-mirror commented 8 years ago

Description

Summary: The way that the UI testing code appears to be different to the way a user would use a UIPicker.

A user typically scrolls the picker to the value they way. The UIPicker only triggers delegate methods when the user stops scrolling and ends the touch.

UI testing's adjustToPickerWheelValue function on the other hand, behaves differently. It appears (after some testing) that adjustToPickerWheelValue calculates the number of picker values between the current value and the desired value, then issues the correct number of single value scrolls to move the picker to the desired result.

The problem with this is that this is effectively the same as the user selecting every single value between the current and desired one, trigger UIPicker delegate methods as it goes.

In addition, this causes faults in code when adjusts the picker when a value is selected. For example, in my code I have a picker value of "---" which I use to delimit sets of values in a picker. So my picker values might be as follows:

abc

def

ghi jkl

I have a picker delegate method that looks like this:

func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { var value = pickerValues[row] // Skip the delimiter. if value == "---" { pickerView.selectRow(++selectedRow, inComponent: 0, animated: true) return; } pickerValueDidChange() }

When the user scrolls to the "---" value, the picker automatically selects the next value -> "ghi". If they scroll to "ghi" directly, "---" is never actioned because the picker doesn't stop on that value.

But when UI testing does this, it ends up on the "jkl" value because it selects each value on the way to "ghi", including the "---" value which then adds an extra scroll.

It appears that the UI testing picker code is not checking where it is at and therefore is unaware of the change made by the app code.

Steps to Reproduce:

  1. Add a UIPicker with the values described above.
  2. Add a picker didSelectRow with the code above.
  3. Setup a UI test which tells the picker to goto value "ghi".
  4. Assert the value is current.

Expected Results: The assert passes with the picker showing "ghi" as the current value.

Actual Results: The assert fails with the picker showing "jkl" as the current value.

Version: 7.3

Notes:

Configuration:

Attachments:

Product Version: 7.3 Created: 2016-04-15T01:57:06.797550 Originated: 2016-04-15T00:00:00 Open Radar Link: http://www.openradar.me/25740585

openradar-mirror commented 8 years ago

Modified: 2016-04-15T01:57:06.797770