From ef9ab1a4bd4e3545cfb1c23c002e58b3e078ed75 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 26 Mar 2019 14:42:06 +0100 Subject: tst_dialogbuttonbox.qml: use tryVerify() consistently to avoid flakiness Change-Id: Ic18cca692b09f55818b9c99379aae4be72ba4159 Fixes: QTBUG-74711 Reviewed-by: Richard Moe Gustavsen --- tests/auto/controls/data/tst_dialogbuttonbox.qml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml index 374b32ff..0e2566e9 100644 --- a/tests/auto/controls/data/tst_dialogbuttonbox.qml +++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml @@ -288,9 +288,12 @@ TestCase { verify(button) // The button should never go outside of the box. - var buttonPosInBox = button.mapToItem(control, 0, 0) - verify(buttonPosInBox.x >= 0) - verify(buttonPosInBox.x + button.width < control.width) + tryVerify(function() { return button.mapToItem(control, 0, 0).x >= 0 }, + 1000, "Expected left edge of button to be within left edge of DialogButtonBox (i.e. greater than or equal to 0)" + + ", but it's " + button.mapToItem(control, 0, 0).x) + tryVerify(function() { return button.mapToItem(control, 0, 0).x + button.width <= control.width }, + 1000, "Expected right edge of button to be within right edge of DialogButtonBox (i.e. less than or equal to " + + control.width + "), but it's " + (button.mapToItem(control, 0, 0).x + button.width)) } Component { @@ -333,11 +336,12 @@ TestCase { verify(button) // The button should never go outside of the box. - var buttonPosInBox = button.mapToItem(box, 0, 0) - verify(buttonPosInBox.x >= 0, "Expected button to be inside left edge " - + "of DialogButtonBox, but it's " + buttonPosInBox.x) - verify(buttonPosInBox.x + button.width <= box.width, "Expected button to be inside right edge " - + "of DialogButtonBox (" + box.width + "), but it's " + (buttonPosInBox.x + button.width)) + tryVerify(function() { return button.mapToItem(box, 0, 0).x >= 0 }, + 1000, "Expected left edge of button to be within left edge of DialogButtonBox (i.e. greater than or equal to 0)" + + ", but it's " + button.mapToItem(box, 0, 0).x) + tryVerify(function() { return button.mapToItem(box, 0, 0).x + button.width <= box.width }, + 1000, "Expected right edge of button to be within right edge of DialogButtonBox (i.e. less than or equal to " + + box.width + "), but it's " + (button.mapToItem(box, 0, 0).x + button.width)) compare(box.width, dialog.width) // There's a single button and we align it to the right. compare(box.contentItem.width, button.width) -- cgit v1.2.3