refactor: make a single MessageBuilder (#5548)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "controllers/filters/lang/Filter.hpp"
|
||||
#include "controllers/filters/lang/Types.hpp"
|
||||
#include "controllers/highlights/HighlightController.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "mocks/Channel.hpp"
|
||||
#include "mocks/ChatterinoBadges.hpp"
|
||||
#include "mocks/EmptyApplication.hpp"
|
||||
@@ -11,7 +12,6 @@
|
||||
#include "providers/ffz/FfzBadges.hpp"
|
||||
#include "providers/seventv/SeventvBadges.hpp"
|
||||
#include "providers/twitch/TwitchBadge.hpp"
|
||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "Test.hpp"
|
||||
|
||||
@@ -280,7 +280,7 @@ TEST_F(FiltersF, TypingContextChecks)
|
||||
|
||||
QString originalMessage = privmsg->content();
|
||||
|
||||
TwitchMessageBuilder builder(&channel, privmsg, MessageParseArgs{});
|
||||
MessageBuilder builder(&channel, privmsg, MessageParseArgs{});
|
||||
|
||||
auto msg = builder.build();
|
||||
EXPECT_NE(msg.get(), nullptr);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
|
||||
#include "common/Channel.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "controllers/highlights/HighlightController.hpp"
|
||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "mocks/Channel.hpp"
|
||||
#include "mocks/ChatterinoBadges.hpp"
|
||||
#include "mocks/DisabledStreamerMode.hpp"
|
||||
@@ -16,6 +14,7 @@
|
||||
#include "providers/twitch/TwitchBadge.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "Test.hpp"
|
||||
#include "util/IrcHelpers.hpp"
|
||||
|
||||
#include <IrcConnection>
|
||||
#include <QDebug>
|
||||
@@ -115,7 +114,7 @@ public:
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(TwitchMessageBuilder, CommaSeparatedListTagParsing)
|
||||
TEST(MessageBuilder, CommaSeparatedListTagParsing)
|
||||
{
|
||||
struct TestCase {
|
||||
QString input;
|
||||
@@ -151,14 +150,14 @@ TEST(TwitchMessageBuilder, CommaSeparatedListTagParsing)
|
||||
|
||||
for (const auto &test : testCases)
|
||||
{
|
||||
auto output = TwitchMessageBuilder::slashKeyValue(test.input);
|
||||
auto output = slashKeyValue(test.input);
|
||||
|
||||
EXPECT_EQ(output, test.expectedOutput)
|
||||
<< "Input " << test.input << " failed";
|
||||
}
|
||||
}
|
||||
|
||||
class TestTwitchMessageBuilder : public ::testing::Test
|
||||
class TestMessageBuilder : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
@@ -174,7 +173,7 @@ protected:
|
||||
std::unique_ptr<MockApplication> mockApplication;
|
||||
};
|
||||
|
||||
TEST(TwitchMessageBuilder, BadgeInfoParsing)
|
||||
TEST(MessageBuilder, BadgeInfoParsing)
|
||||
{
|
||||
struct TestCase {
|
||||
QByteArray input;
|
||||
@@ -235,12 +234,11 @@ TEST(TwitchMessageBuilder, BadgeInfoParsing)
|
||||
Communi::IrcPrivateMessage::fromData(test.input, nullptr);
|
||||
|
||||
auto outputBadgeInfo =
|
||||
TwitchMessageBuilder::parseBadgeInfoTag(privmsg->tags());
|
||||
MessageBuilder::parseBadgeInfoTag(privmsg->tags());
|
||||
EXPECT_EQ(outputBadgeInfo, test.expectedBadgeInfo)
|
||||
<< "Input for badgeInfo " << test.input << " failed";
|
||||
|
||||
auto outputBadges =
|
||||
SharedMessageBuilder::parseBadgeTag(privmsg->tags());
|
||||
auto outputBadges = MessageBuilder::parseBadgeTag(privmsg->tags());
|
||||
EXPECT_EQ(outputBadges, test.expectedBadges)
|
||||
<< "Input for badges " << test.input << " failed";
|
||||
|
||||
@@ -248,7 +246,7 @@ TEST(TwitchMessageBuilder, BadgeInfoParsing)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestTwitchMessageBuilder, ParseTwitchEmotes)
|
||||
TEST_F(TestMessageBuilder, ParseTwitchEmotes)
|
||||
{
|
||||
struct TestCase {
|
||||
QByteArray input;
|
||||
@@ -416,7 +414,7 @@ TEST_F(TestTwitchMessageBuilder, ParseTwitchEmotes)
|
||||
QString originalMessage = privmsg->content();
|
||||
|
||||
// TODO: Add tests with replies
|
||||
auto actualTwitchEmotes = TwitchMessageBuilder::parseTwitchEmotes(
|
||||
auto actualTwitchEmotes = MessageBuilder::parseTwitchEmotes(
|
||||
privmsg->tags(), originalMessage, 0);
|
||||
|
||||
EXPECT_EQ(actualTwitchEmotes, test.expectedTwitchEmotes)
|
||||
@@ -426,7 +424,7 @@ TEST_F(TestTwitchMessageBuilder, ParseTwitchEmotes)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestTwitchMessageBuilder, ParseMessage)
|
||||
TEST_F(TestMessageBuilder, ParseMessage)
|
||||
{
|
||||
MockChannel channel("pajlada");
|
||||
|
||||
@@ -484,7 +482,7 @@ TEST_F(TestTwitchMessageBuilder, ParseMessage)
|
||||
|
||||
QString originalMessage = privmsg->content();
|
||||
|
||||
TwitchMessageBuilder builder(&channel, privmsg, MessageParseArgs{});
|
||||
MessageBuilder builder(&channel, privmsg, MessageParseArgs{});
|
||||
|
||||
auto msg = builder.build();
|
||||
EXPECT_NE(msg.get(), nullptr);
|
||||
@@ -493,7 +491,7 @@ TEST_F(TestTwitchMessageBuilder, ParseMessage)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestTwitchMessageBuilder, IgnoresReplace)
|
||||
TEST_F(TestMessageBuilder, IgnoresReplace)
|
||||
{
|
||||
struct TestCase {
|
||||
std::vector<IgnorePhrase> phrases;
|
||||
@@ -619,8 +617,7 @@ TEST_F(TestTwitchMessageBuilder, IgnoresReplace)
|
||||
{
|
||||
auto message = test.input;
|
||||
auto emotes = test.twitchEmotes;
|
||||
TwitchMessageBuilder::processIgnorePhrases(test.phrases, message,
|
||||
emotes);
|
||||
MessageBuilder::processIgnorePhrases(test.phrases, message, emotes);
|
||||
|
||||
EXPECT_EQ(message, test.expectedMessage)
|
||||
<< "Message not equal for input '" << test.input
|
||||
Reference in New Issue
Block a user