QTest::WatchDog: Extract Method setExpectation()
Keeps the code DRY and enables a follow-up commit to fix QTBUG-109466. Task-number: QTBUG-109466 Change-Id: I2b904ea7b38286b07049524ba63c2c5028e680bb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 17a7e5cfddcbf33ef0fd1c2b7acc65b85159194e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c2118a461a
commit
cf573f97fc
@ -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…
x
Reference in New Issue
Block a user