Commit cdf5c36f authored by Robert Loehning's avatar Robert Loehning
Browse files

Squish: Let ensureChecked() handle tristate checkboxes



Change-Id: Iecb18400512ec6525757b442cf3b984d22302009
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 0143d600
......@@ -52,19 +52,28 @@ def verifyChecked(objectName):
return object
def ensureChecked(objectName, shouldBeChecked = True, timeout=20000):
object = waitForObject(objectName, timeout)
# synchronize to avoid false positives
waitFor('object.checked == shouldBeChecked', 1000)
if object.checked ^ shouldBeChecked:
clickButton(object)
if shouldBeChecked:
targetState = Qt.Checked
state = "checked"
else:
targetState = Qt.Unchecked
state = "unchecked"
widget = waitForObject(objectName, timeout)
try:
# needed for transition Qt::PartiallyChecked -> Qt::Checked -> Qt::Unchecked
clicked = 0
while not waitFor('widget.checkState() == targetState', 1000) and clicked < 2:
clickButton(widget)
clicked += 1
test.verify(waitFor("widget.checkState() == targetState", 1000))
except:
# widgets not derived from QCheckbox don't have checkState()
if not waitFor('widget.checked == shouldBeChecked', 1000):
clickButton(widget)
test.verify(waitFor("widget.checked == shouldBeChecked", 1000))
test.log("New state for QCheckBox: %s" % state,
str(objectName))
test.verify(waitFor("object.checked == shouldBeChecked", 1000))
return object
return widget
# verify that an object is in an expected enable state. Returns the object.
# param objectSpec specifies the object to check. It can either be a string determining an object
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment