feat: add the ability to unit test some aspects of SplitInput (#5179)

This commit is contained in:
pajlada
2024-02-17 13:26:54 +01:00
committed by GitHub
parent 4b48774cbb
commit 32d269dffc
8 changed files with 142 additions and 4 deletions
+5
View File
@@ -525,6 +525,11 @@ const IndirectChannel &TwitchIrcServer::getWatchingChannel() const
return this->watchingChannel;
}
QString TwitchIrcServer::getLastUserThatWhisperedMe() const
{
return this->lastUserThatWhisperedMe.get();
}
void TwitchIrcServer::reloadBTTVGlobalEmotes()
{
getIApp()->getBttvEmotes()->loadEmotes();
+4
View File
@@ -29,6 +29,8 @@ public:
virtual const IndirectChannel &getWatchingChannel() const = 0;
virtual QString getLastUserThatWhisperedMe() const = 0;
// Update this interface with TwitchIrcServer methods as needed
};
@@ -81,6 +83,8 @@ public:
const IndirectChannel &getWatchingChannel() const override;
QString getLastUserThatWhisperedMe() const override;
protected:
void initializeConnection(IrcConnection *connection,
ConnectionType type) override;
+9 -4
View File
@@ -78,7 +78,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
void SplitInput::initLayout()
{
auto *app = getApp();
auto *app = getIApp();
LayoutCreator<SplitInput> layoutCreator(this);
auto layout =
@@ -202,7 +202,7 @@ void SplitInput::initLayout()
void SplitInput::scaleChangedEvent(float scale)
{
auto *app = getApp();
auto *app = getIApp();
// update the icon size of the buttons
this->updateEmoteButton();
this->updateCancelReplyButton();
@@ -919,9 +919,14 @@ bool SplitInput::isHidden() const
return this->hidden;
}
void SplitInput::setInputText(const QString &newInputText)
{
this->ui_.textEdit->setPlainText(newInputText);
}
void SplitInput::editTextChanged()
{
auto *app = getApp();
auto *app = getIApp();
// set textLengthLabel value
QString text = this->ui_.textEdit->toPlainText();
@@ -936,7 +941,7 @@ void SplitInput::editTextChanged()
if (text.startsWith("/r ", Qt::CaseInsensitive) &&
this->split_->getChannel()->isTwitchChannel())
{
QString lastUser = app->twitch->lastUserThatWhisperedMe.get();
auto lastUser = app->getTwitch()->getLastUserThatWhisperedMe();
if (!lastUser.isEmpty())
{
this->ui_.textEdit->setPlainText("/w " + lastUser + text.mid(2));
+7
View File
@@ -66,6 +66,13 @@ public:
**/
bool isHidden() const;
/**
* @brief Sets the text of this input
*
* This method should only be used in tests
*/
void setInputText(const QString &newInputText);
pajlada::Signals::Signal<const QString &> textChanged;
pajlada::Signals::NoArgSignal selectionChanged;