Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing for ActivityListModel #4135

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,12 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
return QVariant();
}

int ActivityListModel::rowCount(const QModelIndex &) const
int ActivityListModel::rowCount(const QModelIndex &parent) const
{
if(parent.isValid()) {
return 0;
}

return _finalList.count();
}

Expand Down Expand Up @@ -342,7 +346,6 @@ void ActivityListModel::activitiesReceived(const QJsonDocument &json, int status
a._icon = json.value(QStringLiteral("icon")).toString();

auto richSubjectData = json.value(QStringLiteral("subject_rich")).toArray();
Q_ASSERT(richSubjectData.size() > 1);

if(richSubjectData.size() > 1) {
a._subjectRich = richSubjectData[0].toString();
Expand Down Expand Up @@ -621,14 +624,8 @@ void ActivityListModel::combineActivityLists()
}

beginResetModel();
_finalList.clear();
_finalList = resultList;
endResetModel();

if (resultList.count() > 0) {
beginInsertRows(QModelIndex(), 0, resultList.count() - 1);
_finalList = resultList;
endInsertRows();
}
}

bool ActivityListModel::canFetchActivities() const
Expand All @@ -638,11 +635,8 @@ bool ActivityListModel::canFetchActivities() const

void ActivityListModel::fetchMore(const QModelIndex &)
{
if (canFetchActivities()) {
if (canFetchActivities() && !_currentlyFetching) {
startFetchJob();
} else {
_doneFetching = true;
combineActivityLists();
}
}

Expand Down Expand Up @@ -672,4 +666,6 @@ void ActivityListModel::slotRemoveAccount()
_totalActivitiesFetched = 0;
_showMoreActivitiesAvailableEntry = false;
}

}

4 changes: 1 addition & 3 deletions src/gui/tray/activitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ActivityListModel : public QAbstractListModel
public:
enum DataRole {
ActionIconRole = Qt::UserRole + 1,
UserIconRole,
AccountRole,
ObjectTypeRole,
ActionsLinksRole,
Expand All @@ -59,7 +58,6 @@ class ActivityListModel : public QAbstractListModel
LinkRole,
PointInTimeRole,
AccountConnectedRole,
SyncFileStatusRole,
DisplayActions,
ShareableRole,
};
Expand Down Expand Up @@ -90,6 +88,7 @@ class ActivityListModel : public QAbstractListModel
Q_INVOKABLE void triggerAction(int activityIndex, int actionIndex);

AccountState *accountState() const;
void setAccountState(AccountState *state);

public slots:
void slotRefreshActivity();
Expand All @@ -103,7 +102,6 @@ public slots:
void activitiesReceived(const QJsonDocument &json, int statusCode);
QHash<int, QByteArray> roleNames() const override;

void setAccountState(AccountState *state);
void setCurrentlyFetching(bool value);
bool currentlyFetching() const;
void setDoneFetching(bool value);
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ nextcloud_add_test(IconUtils)
nextcloud_add_test(NotificationCache)
nextcloud_add_test(SetUserStatusDialog)
nextcloud_add_test(UnifiedSearchListmodel)
nextcloud_add_test(ActivityListModel)

if( UNIX AND NOT APPLE )
nextcloud_add_test(InotifyWatcher)
Expand Down
Loading