From 6583436a37ca35c303d6136c39b34e13f4c1a351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Tue, 5 Mar 2024 12:12:38 -0500 Subject: [PATCH] test: fix ut_typers GitLab: #968 Change-Id: I9049d376984d480f686a369237b8dcab29144f45 --- src/jamidht/jamiaccount.cpp | 4 +- src/jamidht/typers.cpp | 1 - test/unitTest/conversation/conversation.cpp | 44 --------------------- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index dd4f4c3121..ea9d0b1022 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -2760,9 +2760,9 @@ JamiAccount::setIsComposing(const std::string& conversationUri, bool isWriting) if (auto cm = convModule(true)) { if (auto typer = cm->getTypers(conversationId)) { if (isWriting) - typer->addTyper(getUsername()); + typer->addTyper(getUsername(), true); else - typer->removeTyper(getUsername()); + typer->removeTyper(getUsername(), true); } } } diff --git a/src/jamidht/typers.cpp b/src/jamidht/typers.cpp index 71c9538770..0cc71584ca 100644 --- a/src/jamidht/typers.cpp +++ b/src/jamidht/typers.cpp @@ -76,7 +76,6 @@ Typers::addTyper(const std::string &typer, bool sendMessage) convId_, typer, 1); - return; } if (sendMessage) { // In this case we should emit for remote to update the timer diff --git a/test/unitTest/conversation/conversation.cpp b/test/unitTest/conversation/conversation.cpp index 69cf03cf1a..1fc3690f8b 100644 --- a/test/unitTest/conversation/conversation.cpp +++ b/test/unitTest/conversation/conversation.cpp @@ -64,7 +64,6 @@ struct UserData { bool registered {false}; bool stopped {false}; bool deviceAnnounced {false}; - bool composing {false}; bool sending {false}; bool sent {false}; bool searchFinished {false}; @@ -120,7 +119,6 @@ private: void testMergeTwoDifferentHeads(); void testSendMessageToMultipleParticipants(); void testPingPongMessages(); - void testIsComposing(); void testSetMessageDisplayedTwice(); void testSetMessageDisplayedPreference(); void testSetMessageDisplayedAfterClone(); @@ -174,7 +172,6 @@ private: CPPUNIT_TEST(testMergeTwoDifferentHeads); CPPUNIT_TEST(testSendMessageToMultipleParticipants); CPPUNIT_TEST(testPingPongMessages); - CPPUNIT_TEST(testIsComposing); CPPUNIT_TEST(testSetMessageDisplayedTwice); CPPUNIT_TEST(testSetMessageDisplayedPreference); CPPUNIT_TEST(testSetMessageDisplayedAfterClone); @@ -409,17 +406,6 @@ ConversationTest::connectSignals() carlaData.errorDetected = true; cv.notify_one(); })); - confHandlers.insert( - libjami::exportable_callback<libjami::ConfigurationSignal::ComposingStatusChanged>( - [&](const std::string& accountId, - const std::string& /*conversationId*/, - const std::string& /*peer*/, - bool state) { - if (accountId == bobId) { - bobData.composing = state; - } - cv.notify_one(); - })); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::AccountMessageStatusChanged>( [&](const std::string& accountId, @@ -958,36 +944,6 @@ ConversationTest::testPingPongMessages() })); } -void -ConversationTest::testIsComposing() -{ - std::cout << "\nRunning test: " << __func__ << std::endl; - connectSignals(); - - auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); - auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); - auto bobUri = bobAccount->getUsername(); - auto convId = libjami::startConversation(aliceId); - auto aliceMsgSize = aliceData.messages.size(); - libjami::addConversationMember(aliceId, convId, bobUri); - CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); - // Assert that repository exists - auto repoPath = fileutils::get_data_dir() / aliceId - / "conversations" / convId; - CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); - // Check created files - auto bobInvited = repoPath / "invited" / bobUri; - CPPUNIT_ASSERT(std::filesystem::is_regular_file(bobInvited)); - CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); - libjami::acceptConversationRequest(bobId, convId); - CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); - - aliceAccount->setIsComposing("swarm:" + convId, true); - CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.composing; })); - aliceAccount->setIsComposing("swarm:" + convId, false); - CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.composing; })); -} - void ConversationTest::testSetMessageDisplayedTwice() { -- GitLab