diff --git a/autotests/mentiontest.cpp b/autotests/mentiontest.cpp index 61822bd1..52cbe32c 100644 --- a/autotests/mentiontest.cpp +++ b/autotests/mentiontest.cpp @@ -1,28 +1,35 @@ /* Copyright (c) 2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mentiontest.h" #include "mention.h" #include QTEST_GUILESS_MAIN(MentionTest) MentionTest::MentionTest(QObject *parent) : QObject(parent) { } + +void MentionTest::shouldHaveDefaultValue() +{ + Mention m; + QVERIFY(m.message().isEmpty()); + QVERIFY(m.messageId().isEmpty()); +} diff --git a/autotests/mentiontest.h b/autotests/mentiontest.h index 5b40afe9..5bf4bdbf 100644 --- a/autotests/mentiontest.h +++ b/autotests/mentiontest.h @@ -1,33 +1,35 @@ /* Copyright (c) 2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MENTIONTEST_H #define MENTIONTEST_H #include class MentionTest : public QObject { Q_OBJECT public: explicit MentionTest(QObject *parent = nullptr); ~MentionTest() = default; +private Q_SLOTS: + void shouldHaveDefaultValue(); }; #endif // MENTIONTEST_H diff --git a/src/ruqolacore/mention.cpp b/src/ruqolacore/mention.cpp index 3d8db5d3..57d4dd77 100644 --- a/src/ruqolacore/mention.cpp +++ b/src/ruqolacore/mention.cpp @@ -1,36 +1,56 @@ /* Copyright (c) 2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mention.h" Mention::Mention() { } QDebug operator <<(QDebug d, const Mention &t) { + d << "Message: " << t.message(); //TODO return d; } bool Mention::operator ==(const Mention &other) const { - //return (mUserNames == other.userNames()) && (mReactionName == other.reactionName()); - return true; + return (mMessage == other.message()); +} + +QString Mention::message() const +{ + return mMessage; +} + +void Mention::setMessage(const QString &message) +{ + mMessage = message; +} + +QString Mention::messageId() const +{ + return mMessageId; +} + +void Mention::setMessageId(const QString &messageId) +{ + mMessageId = messageId; } diff --git a/src/ruqolacore/mention.h b/src/ruqolacore/mention.h index af643750..9ea04bf3 100644 --- a/src/ruqolacore/mention.h +++ b/src/ruqolacore/mention.h @@ -1,53 +1,47 @@ /* Copyright (c) 2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MENTION_H #define MENTION_H #include "libruqola_private_export.h" #include class LIBRUQOLACORE_TESTS_EXPORT Mention { Q_GADGET -// Q_PROPERTY(int count READ count CONSTANT) -// Q_PROPERTY(QString reactionName READ reactionName CONSTANT) -// Q_PROPERTY(QString convertedReactionName READ convertedReactionName CONSTANT) public: Mention(); -// Q_REQUIRED_RESULT QString reactionName() const; -// void setReactionName(const QString &reactionName); - -// Q_REQUIRED_RESULT QStringList userNames() const; -// void setUserNames(const QStringList &userNames); + Q_REQUIRED_RESULT bool operator ==(const Mention &other) const; -// Q_REQUIRED_RESULT int count() const; + Q_REQUIRED_RESULT QString message() const; + void setMessage(const QString &message); - Q_REQUIRED_RESULT bool operator ==(const Mention &other) const; + Q_REQUIRED_RESULT QString messageId() const; + void setMessageId(const QString &messageId); -// Q_REQUIRED_RESULT QString convertedReactionName() const; private: -// QString mReactionName; -// QStringList mUserNames; + QString mMessage; + QString mMessageId; }; Q_DECLARE_METATYPE(Mention) Q_DECLARE_TYPEINFO(Mention, Q_MOVABLE_TYPE); LIBRUQOLACORE_EXPORT QDebug operator <<(QDebug d, const Mention &t); #endif // MENTION_H