Skip to content

Commit

Permalink
Fix fetch handling in TestingALM
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Mar 1, 2023
1 parent 6e1d86f commit 50a8f9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
42 changes: 18 additions & 24 deletions test/activitylistmodeltestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,37 +430,31 @@ void TestingALM::startFetchJob()
job->start();
}

void TestingALM::insertOrRemoveDummyFetchingActivity()
{
OCC::ActivityListModel::insertOrRemoveDummyFetchingActivity();
}

void TestingALM::slotProcessReceivedActivities()
{
if (rowCount() > _numRowsPrev) {
auto finalListCopy = finalList();
for (int i = _numRowsPrev; i < rowCount(); ++i) {
const auto modelIndex = index(i, 0);
auto activity = finalListCopy.at(modelIndex.row());
if (activity._links.isEmpty()) {
const auto activityJsonObject = FakeRemoteActivityStorage::instance()->activityById(activity._id);

if (!activityJsonObject.isNull()) {
// because "_links" are normally populated within the notificationhandler.cpp, which we don't run as part of this unit test, we have to fill them here
// TODO: move the logic to populate "_links" to "activitylistmodel.cpp"
auto actions = activityJsonObject.toObject().value("actions").toArray();
foreach (auto action, actions) {
activity._links.append(OCC::ActivityLink::createFomJsonObject(action.toObject()));
}

finalListCopy[modelIndex.row()] = activity;
auto finalListCopy = finalList();
for (int i = _numRowsPrev; i < rowCount(); ++i) {
const auto modelIndex = index(i, 0);
auto activity = finalListCopy.at(modelIndex.row());
if (activity._links.isEmpty()) {
const auto activityJsonObject = FakeRemoteActivityStorage::instance()->activityById(activity._id);

if (!activityJsonObject.isNull()) {
// because "_links" are normally populated within the notificationhandler.cpp, which we don't run as part of this unit test, we have to fill them here
// TODO: move the logic to populate "_links" to "activitylistmodel.cpp"
const auto actions = activityJsonObject.toObject().value("actions").toArray();
for (const auto &action : actions) {
activity._links.append(OCC::ActivityLink::createFomJsonObject(action.toObject()));
}
}
}

setFinalList(finalListCopy);
finalListCopy[modelIndex.row()] = activity;
qDebug() << activity._subject << activity._subjectDisplay;
}
_numRowsPrev = rowCount();

setFinalList(finalListCopy);

setAndRefreshCurrentlyFetching(false);
emit activitiesProcessed();
}
Expand Down
1 change: 0 additions & 1 deletion test/activitylistmodeltestutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class TestingALM : public OCC::ActivityListModel
TestingALM() = default;

void startFetchJob() override;
void insertOrRemoveDummyFetchingActivity();

public slots:
void slotProcessReceivedActivities();
Expand Down

0 comments on commit 50a8f9b

Please sign in to comment.