fix: close logging-channels when closing channels (#5592)

Co-authored-by: kornes <28986062+kornes@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2024-09-14 12:17:31 +02:00
committed by GitHub
parent 2afa227139
commit 694cc2dbff
13 changed files with 106 additions and 15 deletions
+35 -6
View File
@@ -1,6 +1,8 @@
#include "common/ChannelChatters.hpp"
#include "mocks/BaseApplication.hpp"
#include "mocks/Channel.hpp"
#include "mocks/Logging.hpp"
#include "Test.hpp"
#include <QColor>
@@ -9,9 +11,28 @@
using namespace chatterino;
using chatterino::mock::MockChannel;
// Ensure inserting the same user does not increase the size of the stored colors
TEST(ChatterChatters, insertSameUser)
namespace {
class MockApplication : public mock::BaseApplication
{
public:
MockApplication() = default;
ILogging *getChatLogger() override
{
return &this->logging;
}
mock::EmptyLogging logging;
};
} // namespace
// Ensure inserting the same user does not increase the size of the stored colors
TEST(ChannelChatters, insertSameUser)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -24,8 +45,10 @@ TEST(ChatterChatters, insertSameUser)
}
// Ensure we can update a chatters color
TEST(ChatterChatters, insertSameUserUpdatesColor)
TEST(ChannelChatters, insertSameUserUpdatesColor)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -37,8 +60,10 @@ TEST(ChatterChatters, insertSameUserUpdatesColor)
}
// Ensure getting a non-existant users color returns an invalid QColor
TEST(ChatterChatters, getNonExistantUser)
TEST(ChannelChatters, getNonExistantUser)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -47,8 +72,10 @@ TEST(ChatterChatters, getNonExistantUser)
}
// Ensure getting a user doesn't create an entry
TEST(ChatterChatters, getDoesNotCreate)
TEST(ChannelChatters, getDoesNotCreate)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -59,8 +86,10 @@ TEST(ChatterChatters, getDoesNotCreate)
}
// Ensure the least recently used entry is purged when we reach MAX_SIZE
TEST(ChatterChatters, insertMaxSize)
TEST(ChannelChatters, insertMaxSize)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
+1 -1
View File
@@ -55,11 +55,11 @@ public:
return &this->chatLogger;
}
mock::EmptyLogging chatLogger;
AccountController accounts;
CommandController commands;
mock::MockTwitchIrcServer twitch;
Emotes emotes;
mock::EmptyLogging chatLogger;
};
} // namespace
+7
View File
@@ -8,6 +8,7 @@
#include "mocks/Channel.hpp"
#include "mocks/ChatterinoBadges.hpp"
#include "mocks/EmptyApplication.hpp"
#include "mocks/Logging.hpp"
#include "mocks/TwitchIrcServer.hpp"
#include "mocks/UserData.hpp"
#include "providers/ffz/FfzBadges.hpp"
@@ -75,6 +76,12 @@ public:
return &this->highlights;
}
ILogging *getChatLogger() override
{
return &this->logging;
}
mock::EmptyLogging logging;
AccountController accounts;
Emotes emotes;
mock::UserDataController userData;
+9 -2
View File
@@ -8,6 +8,7 @@
#include "mocks/BaseApplication.hpp"
#include "mocks/Channel.hpp"
#include "mocks/Helix.hpp"
#include "mocks/Logging.hpp"
#include "mocks/TwitchIrcServer.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Paths.hpp"
@@ -69,6 +70,12 @@ public:
return &this->seventvEmotes;
}
ILogging *getChatLogger() override
{
return &this->logging;
}
mock::EmptyLogging logging;
AccountController accounts;
mock::MockTwitchIrcServer twitch;
Emotes emotes;
@@ -133,9 +140,9 @@ protected:
void TearDown() override
{
this->mockApplication.reset();
this->mockHelix.reset();
this->channelPtr.reset();
this->mockHelix.reset();
this->mockApplication.reset();
}
std::unique_ptr<MockApplication> mockApplication;
+7
View File
@@ -7,6 +7,7 @@
#include "mocks/Channel.hpp"
#include "mocks/ChatterinoBadges.hpp"
#include "mocks/DisabledStreamerMode.hpp"
#include "mocks/Logging.hpp"
#include "mocks/TwitchIrcServer.hpp"
#include "mocks/UserData.hpp"
#include "providers/ffz/FfzBadges.hpp"
@@ -91,6 +92,12 @@ public:
return &this->seventvEmotes;
}
ILogging *getChatLogger() override
{
return &this->logging;
}
mock::EmptyLogging logging;
AccountController accounts;
Emotes emotes;
mock::UserDataController userData;