From 932bf8182e3e8717b941efc2933734479c60ba23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Wed, 20 Oct 2021 14:29:22 -0400 Subject: [PATCH] conversationRequest: fix testRemoveConversationRemoveSyncing acceptTrustRequest will set the conversation as ready. removeConversation should be done after Change-Id: I966cc2142d00bda880d63f11c52c36faceb11aa7 --- test/unitTest/conversation/conversationRequest.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/unitTest/conversation/conversationRequest.cpp b/test/unitTest/conversation/conversationRequest.cpp index 7c57716eb9..04e9a3f84f 100644 --- a/test/unitTest/conversation/conversationRequest.cpp +++ b/test/unitTest/conversation/conversationRequest.cpp @@ -880,7 +880,8 @@ ConversationRequestTest::testRemoveConversationRemoveSyncing() std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>> confHandlers; - bool conversationReady = false, requestReceived = false, conversationRemoved = false; + bool conversationReady = false, contactAdded = false, requestReceived = false, + conversationRemoved = false; std::string convId = ""; confHandlers.insert(DRing::exportable_callback<DRing::ConfigurationSignal::IncomingTrustRequest>( [&](const std::string& account_id, @@ -908,6 +909,13 @@ ConversationRequestTest::testRemoveConversationRemoveSyncing() } cv.notify_one(); })); + confHandlers.insert(DRing::exportable_callback<DRing::ConfigurationSignal::ContactAdded>( + [&](const std::string& accountId, const std::string& uri, bool confirmed) { + if (accountId == bobId && uri == aliceUri) { + contactAdded = true; + } + cv.notify_one(); + })); DRing::registerSignalHandlers(confHandlers); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); @@ -915,6 +923,8 @@ ConversationRequestTest::testRemoveConversationRemoveSyncing() Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); + CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(30), [&]() { return contactAdded; })); + // At this point the conversation should be there and syncing. CPPUNIT_ASSERT(DRing::getConversations(bobId).size() == 1); DRing::removeConversation(bobId, convId); -- GitLab