mirror of https://github.com/qt/qtbase.git
QTest::WatchDog: Extract Method setExpectation()
Keeps the code DRY and enables a follow-up commit to fix QTBUG-109466. Task-number: QTBUG-109466 Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I2b904ea7b38286b07049524ba63c2c5028e680bb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
6b5419f435
commit
17a7e5cfdd
|
@ -1233,6 +1233,13 @@ class WatchDog : public QThread
|
|||
Q_UNREACHABLE_RETURN(false);
|
||||
}
|
||||
|
||||
void setExpectation(Expectation e)
|
||||
{
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
expecting.store(e, std::memory_order_relaxed);
|
||||
waitCondition.notify_all();
|
||||
}
|
||||
|
||||
public:
|
||||
WatchDog()
|
||||
{
|
||||
|
@ -1245,26 +1252,18 @@ public:
|
|||
|
||||
~WatchDog()
|
||||
{
|
||||
{
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
expecting.store(ThreadEnd, std::memory_order_relaxed);
|
||||
waitCondition.notify_all();
|
||||
}
|
||||
setExpectation(ThreadEnd);
|
||||
wait();
|
||||
}
|
||||
|
||||
void beginTest()
|
||||
{
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
expecting.store(TestFunctionEnd, std::memory_order_relaxed);
|
||||
waitCondition.notify_all();
|
||||
setExpectation(TestFunctionEnd);
|
||||
}
|
||||
|
||||
void testFinished()
|
||||
{
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
expecting.store(TestFunctionStart, std::memory_order_relaxed);
|
||||
waitCondition.notify_all();
|
||||
setExpectation(TestFunctionStart);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
|
Loading…
Reference in New Issue