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(); }
|
HANDLE eventHandle() const { return notifier.handle(); }
|
||||||
int numberOfTimesActivated() const { return activatedCount; }
|
int numberOfTimesActivated() const { return activatedCount; }
|
||||||
void setEnabled(bool b) { notifier.setEnabled(b); }
|
void setEnabled(bool b) { notifier.setEnabled(b); }
|
||||||
|
bool isEnabled() const { return notifier.isEnabled(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activated();
|
void activated();
|
||||||
@ -218,8 +219,9 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot()
|
|||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
events[i].reset(new EventWithNotifier);
|
events[i].reset(new EventWithNotifier);
|
||||||
|
|
||||||
auto isActivatedOrNull = [&events](int i) {
|
auto isActivatedOrDisabled = [&events](int i) {
|
||||||
return !events.at(i) || events.at(i)->numberOfTimesActivated() > 0;
|
return !events.at(i) || !events.at(i)->isEnabled()
|
||||||
|
|| events.at(i)->numberOfTimesActivated() > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto &e : events) {
|
for (auto &e : events) {
|
||||||
@ -230,8 +232,10 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot()
|
|||||||
else
|
else
|
||||||
events.at(i)->setEnabled(false);
|
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()));
|
QTimer::singleShot(0, &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (int i : notifiersToSignal)
|
for (int i : notifiersToSignal)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user