summaryrefslogtreecommitdiff
path: root/src/components/include/test/utils/test_async_waiter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/include/test/utils/test_async_waiter.h')
-rw-r--r--src/components/include/test/utils/test_async_waiter.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/components/include/test/utils/test_async_waiter.h b/src/components/include/test/utils/test_async_waiter.h
index 12d6cd04b7..6ad9ca12c5 100644
--- a/src/components/include/test/utils/test_async_waiter.h
+++ b/src/components/include/test/utils/test_async_waiter.h
@@ -48,17 +48,15 @@ namespace test {
*
* Usage example:
* TEST() {
- * TestAsyncWaiter waiter;
+ * auto waiter = TestAsyncWaiter::createInstance();
* EXPECT_CALL(mock, InterestingCall())
* .Times(n)
- * .WillRepeatedly(NotifyTestAsyncWaiter(&waiter));
- * EXPECT_TRUE(waiter.WaitFor(n, 1000));
+ * .WillRepeatedly(NotifyTestAsyncWaiter(waiter));
+ * EXPECT_TRUE(waiter->WaitFor(n, 1000));
* }
*/
class TestAsyncWaiter {
public:
- TestAsyncWaiter() : notified_(false), count_(0), lock_(), cond_var_() {}
-
/**
* @brief WaitFor
* Waits for specified number of notifications but not longer
@@ -80,6 +78,10 @@ class TestAsyncWaiter {
return true;
}
+ static std::shared_ptr<TestAsyncWaiter> createInstance() {
+ return std::shared_ptr<TestAsyncWaiter>(new TestAsyncWaiter());
+ }
+
/**
* @brief Notify
* Notifies async waiter
@@ -92,6 +94,8 @@ class TestAsyncWaiter {
}
private:
+ TestAsyncWaiter() : notified_(false), count_(0), lock_(), cond_var_() {}
+
bool notified_;
uint32_t count_;
sync_primitives::Lock lock_;