From d65744b1fc34c127c97de1c926f19ac58b502b1a Mon Sep 17 00:00:00 2001 From: David Leeds Date: Fri, 7 May 2021 06:22:07 -0700 Subject: [PATCH] Enable default construction of PendingAsyncCall (#180) This is helpful in use cases where a user defined class wants to store a PendingAsyncCall as a member variable, or in a STL container. --- include/sdbus-c++/IProxy.h | 2 ++ tests/integrationtests/DBusAsyncMethodsTests.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/sdbus-c++/IProxy.h b/include/sdbus-c++/IProxy.h index 0594bf2..0d00131 100644 --- a/include/sdbus-c++/IProxy.h +++ b/include/sdbus-c++/IProxy.h @@ -293,6 +293,8 @@ namespace sdbus { class PendingAsyncCall { public: + PendingAsyncCall() = default; + /*! * @brief Cancels the delivery of the pending asynchronous call result * diff --git a/tests/integrationtests/DBusAsyncMethodsTests.cpp b/tests/integrationtests/DBusAsyncMethodsTests.cpp index 7c185f4..cb0f5cc 100644 --- a/tests/integrationtests/DBusAsyncMethodsTests.cpp +++ b/tests/integrationtests/DBusAsyncMethodsTests.cpp @@ -201,6 +201,22 @@ TEST_F(SdbusTestObject, AnswersThatAsyncCallIsNotPendingAfterItHasBeenCompleted) ASSERT_TRUE(waitUntil([&call](){ return !call.isPending(); })); } +TEST_F(SdbusTestObject, AnswersThatDefaultConstructedAsyncCallIsNotPending) +{ + sdbus::PendingAsyncCall call; + + ASSERT_FALSE(call.isPending()); +} + +TEST_F(SdbusTestObject, SupportsAsyncCallCopyAssignment) +{ + sdbus::PendingAsyncCall call; + + call = m_proxy->doOperationClientSideAsync(100); + + ASSERT_TRUE(call.isPending()); +} + TEST_F(SdbusTestObject, InvokesErroneousMethodAsynchronouslyOnClientSide) { std::promise promise;