Skip to content

Commit

Permalink
test: Update notificationgenerator test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pigpog authored and iphydf committed Jan 22, 2025
1 parent 180664e commit a77a36d
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions test/model/notificationgenerator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <QObject>
#include <QtTest/QtTest>
#include <memory>

namespace {
class MockNotificationSettings : public INotificationSettings
Expand Down Expand Up @@ -154,11 +153,11 @@ void TestNotificationGenerator::testMultipleFriendMessages()
f.setName("friendName");
notificationGenerator->friendMessageNotification(&f, "test");
auto notificationData = notificationGenerator->friendMessageNotification(&f, "test2");
QCOMPARE(notificationData.title, "2 message(s) from friendName");
QCOMPARE(notificationData.title, "friendName");
QCOMPARE(notificationData.message, "test2");

notificationData = notificationGenerator->friendMessageNotification(&f, "test3");
QCOMPARE(notificationData.title, "3 message(s) from friendName");
QCOMPARE(notificationData.title, "friendName");
QCOMPARE(notificationData.message, "test3");
}

Expand Down Expand Up @@ -203,7 +202,7 @@ void TestNotificationGenerator::testMultipleConferenceMessages()
notificationGenerator->conferenceMessageNotification(&g, sender, "test1");

auto notificationData = notificationGenerator->conferenceMessageNotification(&g, sender2, "test2");
QCOMPARE(notificationData.title, "2 message(s) from conferenceName");
QCOMPARE(notificationData.title, "conferenceName");
QCOMPARE(notificationData.message, "sender2: test2");
}

Expand All @@ -218,25 +217,29 @@ void TestNotificationGenerator::testMultipleFriendSourceMessages()
notificationGenerator->friendMessageNotification(&f, "test1");
auto notificationData = notificationGenerator->friendMessageNotification(&f2, "test2");

QCOMPARE(notificationData.title, "2 message(s) from 2 chats");
QCOMPARE(notificationData.message, "friend1, friend2");
QCOMPARE(notificationData.title, "friend2");
QCOMPARE(notificationData.message, "test2");
}

void TestNotificationGenerator::testMultipleConferenceSourceMessages()
{
Conference g(0, ConferenceId(QByteArray(32, 0)), "conferenceName", false, "selfName",
*conferenceQuery, *coreIdHandler, *friendList);
Conference g1(0, ConferenceId(QByteArray(32, 0)), "conferenceName1", false, "selfName",
*conferenceQuery, *coreIdHandler, *friendList);
Conference g2(1, ConferenceId(QByteArray(32, 1)), "conferenceName2", false, "selfName",
*conferenceQuery, *coreIdHandler, *friendList);

auto sender = conferenceQuery->getConferencePeerPk(0, 0);
g.updateUsername(sender, "sender1");
auto sender_g1 = conferenceQuery->getConferencePeerPk(0, 1);
g1.updateUsername(sender_g1, "sender1");

notificationGenerator->conferenceMessageNotification(&g, sender, "test1");
auto notificationData = notificationGenerator->conferenceMessageNotification(&g2, sender, "test1");
auto sender_g2 = conferenceQuery->getConferencePeerPk(1, 1);
g2.updateUsername(sender_g2, "sender1");

notificationGenerator->conferenceMessageNotification(&g1, sender_g1, "test1");
auto notificationData =
notificationGenerator->conferenceMessageNotification(&g2, sender_g2, "test1");

QCOMPARE(notificationData.title, "2 message(s) from 2 chats");
QCOMPARE(notificationData.message, "conferenceName, conferenceName2");
QCOMPARE(notificationData.title, "conferenceName2");
QCOMPARE(notificationData.message, "sender1: test1");
}

void TestNotificationGenerator::testMixedSourceMessages()
Expand All @@ -253,12 +256,12 @@ void TestNotificationGenerator::testMixedSourceMessages()
notificationGenerator->friendMessageNotification(&f, "test1");
auto notificationData = notificationGenerator->conferenceMessageNotification(&g, sender, "test2");

QCOMPARE("2 message(s) from 2 chats", notificationData.title);
QCOMPARE("conference, friend", notificationData.message);
QCOMPARE("conference", notificationData.title);
QCOMPARE("sender1: test2", notificationData.message);

notificationData = notificationGenerator->fileTransferNotification(&f, "file", 0);
QCOMPARE("3 message(s) from 2 chats", notificationData.title);
QCOMPARE("conference, friend", notificationData.message);
QCOMPARE("friend - file transfer", notificationData.title);
QCOMPARE("file (0B)", notificationData.message);
}

void TestNotificationGenerator::testFileTransfer()
Expand All @@ -282,8 +285,8 @@ void TestNotificationGenerator::testFileTransferAfterMessage()
auto notificationData =
notificationGenerator->fileTransferNotification(&f, "file", 5 * 1024 * 1024 /* 5MB */);

QCOMPARE(notificationData.title, "2 message(s) from friend");
QCOMPARE(notificationData.message, "Incoming file transfer");
QCOMPARE(notificationData.title, "friend - file transfer");
QCOMPARE(notificationData.message, "file (5.00MiB)");
}

void TestNotificationGenerator::testConferenceInvitation()
Expand All @@ -306,7 +309,7 @@ void TestNotificationGenerator::testConferenceInviteUncounted()
notificationGenerator->conferenceInvitationNotification(&f);
auto notificationData = notificationGenerator->friendMessageNotification(&f, "test2");

QCOMPARE(notificationData.title, "2 message(s) from friend");
QCOMPARE(notificationData.title, "friend");
QCOMPARE(notificationData.message, "test2");
}

Expand All @@ -332,7 +335,7 @@ void TestNotificationGenerator::testFriendRequestUncounted()
notificationGenerator->friendRequestNotification(sender, "request");
auto notificationData = notificationGenerator->friendMessageNotification(&f, "test2");

QCOMPARE(notificationData.title, "2 message(s) from friend");
QCOMPARE(notificationData.title, "friend");
QCOMPARE(notificationData.message, "test2");
}

Expand Down Expand Up @@ -413,7 +416,7 @@ void TestNotificationGenerator::testSimpleMessageToggle()

auto notificationData = notificationGenerator->friendMessageNotification(&f, "test2");

QCOMPARE(notificationData.title, "2 message(s) from friend");
QCOMPARE(notificationData.title, "friend");
QCOMPARE(notificationData.message, "test2");
}

Expand Down

0 comments on commit a77a36d

Please sign in to comment.