test: fix ut_typers

GitLab: #968
Change-Id: I9049d376984d480f686a369237b8dcab29144f45
This commit is contained in:
Sébastien Blin
2024-03-05 12:12:38 -05:00
parent b307501a7b
commit 6583436a37
3 changed files with 2 additions and 47 deletions

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -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()
{