Skip to content

Commit

Permalink
Stabilize tst_QAccessibilityMac
Browse files Browse the repository at this point in the history
Introduce a TRY_EXPECT macro that uses qWaitFor, and use it whenever
EXPECT was used after a call to processEvents.

Fixes: QTBUG-94036
Pick-to: 6.2 5.15
Change-Id: Ia935444d529c2798637bf9b4a56e47a8dc9d75d2
Reviewed-by: Mitch Curtis <[email protected]>
  • Loading branch information
vohi committed Nov 26, 2021
1 parent 7e11ddc commit 24022bc
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ explicit AXErrorTag(AXError theErr) : err(theErr) {}
return false; \
} \

#define TRY_EXPECT(cond) EXPECT(QTest::qWaitFor([&]{ return (cond); }))

@interface TestAXObject : NSObject
{
Expand Down Expand Up @@ -546,21 +547,17 @@ bool notifications(QWidget *w)

EXPECT(notificationList.length() == 0);
le2->setFocus();
QCoreApplication::processEvents();
EXPECT(notificationList.length() == 1);
EXPECT(notificationList.at(0) == QAccessible::Focus);
TRY_EXPECT(notificationList.length() == 1);
TRY_EXPECT(notificationList.at(0) == QAccessible::Focus);
le1->setFocus();
QCoreApplication::processEvents();
EXPECT(notificationList.length() == 2);
EXPECT(notificationList.at(1) == QAccessible::Focus);
TRY_EXPECT(notificationList.length() == 2);
TRY_EXPECT(notificationList.at(1) == QAccessible::Focus);
le1->setText("hello");
QCoreApplication::processEvents();
EXPECT(notificationList.length() == 3);
EXPECT(notificationList.at(2) == QAccessible::ValueChanged);
TRY_EXPECT(notificationList.length() == 3);
TRY_EXPECT(notificationList.at(2) == QAccessible::ValueChanged);
le1->setText("foo");
QCoreApplication::processEvents();
EXPECT(notificationList.length() == 4);
EXPECT(notificationList.at(3) == QAccessible::ValueChanged);
TRY_EXPECT(notificationList.length() == 4);
TRY_EXPECT(notificationList.at(3) == QAccessible::ValueChanged);

return true;
}
Expand Down

0 comments on commit 24022bc

Please sign in to comment.