зеркало из https://github.com/nextcloud/desktop.git
Move creation of example activities from testactivitylistmodel to activitylistmodeltestutils
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Родитель
e42f5cf33e
Коммит
06a42908f7
|
@ -72,6 +72,71 @@ QNetworkReply *almTestQnamOverride(FakeQNAM * const fakeQnam,
|
|||
return reply;
|
||||
}
|
||||
|
||||
// Activity comparison is done by checking type, id, and accName
|
||||
// We need an activity with these details, at least
|
||||
|
||||
OCC::Activity exampleNotificationActivity(const QString &accountName, const int id)
|
||||
{
|
||||
OCC::Activity testNotificationActivity;
|
||||
|
||||
testNotificationActivity._accName = accountName;
|
||||
testNotificationActivity._id = id;
|
||||
testNotificationActivity._type = OCC::Activity::NotificationType;
|
||||
testNotificationActivity._dateTime = QDateTime::currentDateTime();
|
||||
testNotificationActivity._subject = QStringLiteral("Sample notification text");
|
||||
|
||||
return testNotificationActivity;
|
||||
}
|
||||
|
||||
OCC::Activity exampleSyncResultErrorActivity(const QString &accountName, const int id)
|
||||
{
|
||||
OCC::Activity testSyncResultErrorActivity;
|
||||
|
||||
testSyncResultErrorActivity._id = id;
|
||||
testSyncResultErrorActivity._type = OCC::Activity::SyncResultType;
|
||||
testSyncResultErrorActivity._syncResultStatus = OCC::SyncResult::Error;
|
||||
testSyncResultErrorActivity._dateTime = QDateTime::currentDateTime();
|
||||
testSyncResultErrorActivity._subject = QStringLiteral("Sample failed sync text");
|
||||
testSyncResultErrorActivity._message = QStringLiteral("/path/to/thingy");
|
||||
testSyncResultErrorActivity._link = QStringLiteral("/path/to/thingy");
|
||||
testSyncResultErrorActivity._accName = accountName;
|
||||
|
||||
return testSyncResultErrorActivity;
|
||||
}
|
||||
|
||||
OCC::Activity exampleSyncFileItemActivity(const QString &accountName, const QUrl &link, const int id)
|
||||
{
|
||||
OCC::Activity testSyncFileItemActivity;
|
||||
|
||||
testSyncFileItemActivity._id = id;
|
||||
testSyncFileItemActivity._type = OCC::Activity::SyncFileItemType; //client activity
|
||||
testSyncFileItemActivity._syncFileItemStatus = OCC::SyncFileItem::Success;
|
||||
testSyncFileItemActivity._dateTime = QDateTime::currentDateTime();
|
||||
testSyncFileItemActivity._message = QStringLiteral("Sample file successfully synced text");
|
||||
testSyncFileItemActivity._link = link;
|
||||
testSyncFileItemActivity._accName = accountName;
|
||||
testSyncFileItemActivity._file = QStringLiteral("xyz.pdf");
|
||||
|
||||
return testSyncFileItemActivity;
|
||||
}
|
||||
|
||||
OCC::Activity exampleFileIgnoredActivity(const QString &accountName, const QUrl &link, const int id)
|
||||
{
|
||||
OCC::Activity testFileIgnoredActivity;
|
||||
|
||||
testFileIgnoredActivity._id = id;
|
||||
testFileIgnoredActivity._type = OCC::Activity::SyncFileItemType;
|
||||
testFileIgnoredActivity._syncFileItemStatus = OCC::SyncFileItem::FileIgnored;
|
||||
testFileIgnoredActivity._dateTime = QDateTime::currentDateTime();
|
||||
testFileIgnoredActivity._subject = QStringLiteral("Sample ignored file sync text");
|
||||
testFileIgnoredActivity._link = link;
|
||||
testFileIgnoredActivity._accName = accountName;
|
||||
testFileIgnoredActivity._folder = QStringLiteral("thingy");
|
||||
testFileIgnoredActivity._file = QStringLiteral("test.txt");
|
||||
|
||||
return testFileIgnoredActivity;
|
||||
}
|
||||
|
||||
FakeRemoteActivityStorage *FakeRemoteActivityStorage::_instance = nullptr;
|
||||
|
||||
FakeRemoteActivityStorage* FakeRemoteActivityStorage::instance()
|
||||
|
|
|
@ -38,6 +38,11 @@ namespace ActivityListModelTestUtils
|
|||
const int searchResultsReplyDelay = 0,
|
||||
QIODevice * const device = nullptr);
|
||||
|
||||
[[nodiscard]] OCC::Activity exampleNotificationActivity(const QString &accountName, const int id = 1);
|
||||
[[nodiscard]] OCC::Activity exampleSyncResultErrorActivity(const QString &accountName, const int id = 2);
|
||||
[[nodiscard]] OCC::Activity exampleSyncFileItemActivity(const QString &accountName, const QUrl &link, const int id = 3);
|
||||
[[nodiscard]] OCC::Activity exampleFileIgnoredActivity(const QString &accountName, const QUrl &link = {}, const int id = 4);
|
||||
|
||||
class FakeRemoteActivityStorage
|
||||
{
|
||||
FakeRemoteActivityStorage() = default;
|
||||
|
|
|
@ -108,41 +108,13 @@ private slots:
|
|||
|
||||
OCC::AccountManager::instance()->addAccount(account);
|
||||
|
||||
// Activity comparison is done by checking type, id, and accName
|
||||
// We need an activity with these details, at least
|
||||
testNotificationActivity._accName = accountState->account()->displayName();
|
||||
testNotificationActivity._id = 1;
|
||||
testNotificationActivity._type = OCC::Activity::NotificationType;
|
||||
testNotificationActivity._dateTime = QDateTime::currentDateTime();
|
||||
testNotificationActivity._subject = QStringLiteral("Sample notification text");
|
||||
const auto accName = accountState->account()->displayName();
|
||||
const auto accUrl = accountState->account()->url();
|
||||
|
||||
testSyncResultErrorActivity._id = 2;
|
||||
testSyncResultErrorActivity._type = OCC::Activity::SyncResultType;
|
||||
testSyncResultErrorActivity._syncResultStatus = OCC::SyncResult::Error;
|
||||
testSyncResultErrorActivity._dateTime = QDateTime::currentDateTime();
|
||||
testSyncResultErrorActivity._subject = QStringLiteral("Sample failed sync text");
|
||||
testSyncResultErrorActivity._message = QStringLiteral("/path/to/thingy");
|
||||
testSyncResultErrorActivity._link = QStringLiteral("/path/to/thingy");
|
||||
testSyncResultErrorActivity._accName = accountState->account()->displayName();
|
||||
|
||||
testSyncFileItemActivity._id = 3;
|
||||
testSyncFileItemActivity._type = OCC::Activity::SyncFileItemType; //client activity
|
||||
testSyncFileItemActivity._syncFileItemStatus = OCC::SyncFileItem::Success;
|
||||
testSyncFileItemActivity._dateTime = QDateTime::currentDateTime();
|
||||
testSyncFileItemActivity._message = QStringLiteral("Sample file successfully synced text");
|
||||
testSyncFileItemActivity._link = accountState->account()->url();
|
||||
testSyncFileItemActivity._accName = accountState->account()->displayName();
|
||||
testSyncFileItemActivity._file = QStringLiteral("xyz.pdf");
|
||||
|
||||
testFileIgnoredActivity._id = 4;
|
||||
testFileIgnoredActivity._type = OCC::Activity::SyncFileItemType;
|
||||
testFileIgnoredActivity._syncFileItemStatus = OCC::SyncFileItem::FileIgnored;
|
||||
testFileIgnoredActivity._dateTime = QDateTime::currentDateTime();
|
||||
testFileIgnoredActivity._subject = QStringLiteral("Sample ignored file sync text");
|
||||
testFileIgnoredActivity._link = accountState->account()->url();
|
||||
testFileIgnoredActivity._accName = accountState->account()->displayName();
|
||||
testFileIgnoredActivity._folder = QStringLiteral("thingy");
|
||||
testFileIgnoredActivity._file = QStringLiteral("test.txt");
|
||||
testNotificationActivity = exampleNotificationActivity(accName);
|
||||
testSyncResultErrorActivity = exampleSyncResultErrorActivity(accName);
|
||||
testSyncFileItemActivity = exampleSyncFileItemActivity(accName, accUrl);
|
||||
testFileIgnoredActivity = exampleFileIgnoredActivity(accName, accUrl);
|
||||
};
|
||||
|
||||
// Test receiving activity from server
|
||||
|
|
Загрузка…
Ссылка в новой задаче