1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(cleanup): Minor cleanup to contact management test

* Fix compile error on macOS by marking GroupWidget::widgetIsVisible as
override
* Mark mock functions override for consistency
* Change QWARN to QVERIFY since logs will be missed in CI
* Uncomment add of offline and online friends in testSortByActivity
* Add out-of-line method definition to anchor vtable
This commit is contained in:
Anthony Bilinski 2022-02-10 01:16:02 -08:00
parent 0a9e121811
commit a1ebf297d3
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
2 changed files with 33 additions and 25 deletions

View File

@ -47,7 +47,7 @@ public:
bool isGroup() const final;
QString getNameItem() const final;
bool isOnline() const final;
bool widgetIsVisible() const;
bool widgetIsVisible() const final;
QDateTime getLastActivity() const final;
QWidget* getWidget() final;
void setWidgetVisible(bool visible) final;

View File

@ -35,16 +35,18 @@ public:
lastActivity(lastAct),
online(onlineRes) {}
bool isFriend() const { return true; }
bool isGroup() const { return false; }
bool isOnline() const { return online; }
bool widgetIsVisible() const { return visible; }
~MockFriend();
QString getNameItem() const { return name; }
QDateTime getLastActivity() const { return lastActivity; }
QWidget* getWidget() { return nullptr; }
bool isFriend() const override { return true; }
bool isGroup() const override { return false; }
bool isOnline() const override { return online; }
bool widgetIsVisible() const override { return visible; }
void setWidgetVisible(bool v) { visible = v; }
QString getNameItem() const override { return name; }
QDateTime getLastActivity() const override { return lastActivity; }
QWidget* getWidget() override { return nullptr; }
void setWidgetVisible(bool v) override { visible = v; }
private:
QString name;
@ -54,6 +56,8 @@ private:
};
MockFriend::~MockFriend() = default;
class MockGroup : public IFriendListItem
{
public:
@ -63,22 +67,26 @@ public:
MockGroup(const QString& nameStr)
:name(nameStr) {}
bool isFriend() const { return false; }
bool isGroup() const { return true; }
bool isOnline() const { return true; }
bool widgetIsVisible() const { return visible; }
~MockGroup();
QString getNameItem() const { return name; }
QDateTime getLastActivity() const { return QDateTime::currentDateTime(); }
QWidget* getWidget() { return nullptr; }
bool isFriend() const override { return false; }
bool isGroup() const override { return true; }
bool isOnline() const override { return true; }
bool widgetIsVisible() const override { return visible; }
void setWidgetVisible(bool v) { visible = v; }
QString getNameItem() const override { return name; }
QDateTime getLastActivity() const override { return QDateTime::currentDateTime(); }
QWidget* getWidget() override { return nullptr; }
void setWidgetVisible(bool v) override { visible = v; }
private:
QString name;
bool visible = true;
};
MockGroup::~MockGroup() = default;
class FriendItemsBuilder
{
public:
@ -242,7 +250,7 @@ private:
void checkDifferentNames() {
for (auto name : sortedByNameOnlineFriends) {
if (sortedByNameOfflineFriends.contains(name, Qt::CaseInsensitive)) {
QWARN("Names in sortedByNameOnlineFriends and sortedByNameOfflineFriends "
QFAIL("Names in sortedByNameOnlineFriends and sortedByNameOfflineFriends "
"should be different");
break;
}
@ -344,10 +352,10 @@ void TestFriendListManager::testSortByName()
void TestFriendListManager::testSortByActivity()
{
FriendItemsBuilder listBuilder;
auto unsortedVec = listBuilder./*addOfflineFriends()
->addOnlineFriends()->*/addGroups()->buildUnsorted();
auto sortedVec = listBuilder./*addOfflineFriends()
->addOnlineFriends()->*/addGroups()->buildSortedByActivity();
auto unsortedVec = listBuilder.addOfflineFriends()
->addOnlineFriends()->addGroups()->buildUnsorted();
auto sortedVec = listBuilder.addOfflineFriends()
->addOnlineFriends()->addGroups()->buildSortedByActivity();
std::unique_ptr<FriendListManager> manager = createManagerWithItems(unsortedVec);
manager->sortByActivity();