tst_QWinEventNotifier: fix flakiness
disableNotifiersInActivatedSlot(disable_signaled2) fails, if a signaled state of the event #2 is detected prior to the event #1. In this case, we get a timeout on waiting for event #1 which was disabled by the first notification. So, accept a disabled state of the notifier in condition for successful exit from the loop. Change-Id: I8a2fe76f8ec9362556d1ca1fe0be39a93ed58977 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
69948f4899
commit
927db42882
@ -125,6 +125,7 @@ public:
|
||||
HANDLE eventHandle() const { return notifier.handle(); }
|
||||
int numberOfTimesActivated() const { return activatedCount; }
|
||||
void setEnabled(bool b) { notifier.setEnabled(b); }
|
||||
bool isEnabled() const { return notifier.isEnabled(); }
|
||||
|
||||
signals:
|
||||
void activated();
|
||||
@ -218,8 +219,9 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot()
|
||||
for (int i = 0; i < count; ++i)
|
||||
events[i].reset(new EventWithNotifier);
|
||||
|
||||
auto isActivatedOrNull = [&events](int i) {
|
||||
return !events.at(i) || events.at(i)->numberOfTimesActivated() > 0;
|
||||
auto isActivatedOrDisabled = [&events](int i) {
|
||||
return !events.at(i) || !events.at(i)->isEnabled()
|
||||
|| events.at(i)->numberOfTimesActivated() > 0;
|
||||
};
|
||||
|
||||
for (auto &e : events) {
|
||||
@ -230,8 +232,10 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot()
|
||||
else
|
||||
events.at(i)->setEnabled(false);
|
||||
}
|
||||
if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), isActivatedOrNull))
|
||||
if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(),
|
||||
isActivatedOrDisabled)) {
|
||||
QTimer::singleShot(0, &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
}
|
||||
});
|
||||
}
|
||||
for (int i : notifiersToSignal)
|
||||
|
Loading…
x
Reference in New Issue
Block a user