1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* This software is in the public domain, furnished "as is", without technical
* support, and with no warranty, express or implied, as to its usefulness for
* any purpose.
*
*/
#include "gui/models/activitylistmodel.h"
#include "gui/accountmanager.h"
#include <QTest>
#include <QAbstractItemModelTester>
namespace OCC {
class TestActivityModel : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testInsert()
{
auto model = new ActivityListModel(this);
new QAbstractItemModelTester(model, this);
auto manager = AccountManager::instance();
auto createAcc = [&] {
// don't use the account manager to create the account, it would try to use widgets
auto acc = Account::create();
acc->setUrl(QUrl(QStringLiteral("http://admin:admin@localhost/owncloud")));
acc->setDavDisplayName(QStringLiteral("fakename") + acc->uuid().toString());
acc->setServerVersion(QStringLiteral("10.0.0"));
manager->addAccount(acc);
return acc;
};
auto acc1 = createAcc();
auto acc2 = createAcc();
model->setActivityList({
Activity { Activity::ActivityType, 1, acc1, "test", "test", "foo.cpp", QUrl::fromUserInput("https://owncloud.com"), QDateTime::currentDateTime() },
Activity { Activity::ActivityType, 2, acc1, "test", "test", "foo.cpp", QUrl::fromUserInput("https://owncloud.com"), QDateTime::currentDateTime() },
Activity { Activity::ActivityType, 4, acc2, "test", "test", "foo.cpp", QUrl::fromUserInput("https://owncloud.com"), QDateTime::currentDateTime() },
});
model->setActivityList({
Activity { Activity::ActivityType, 1, acc2, "test", "test", "foo.cpp", QUrl::fromUserInput("https://owncloud.com"), QDateTime::currentDateTime() },
Activity { Activity::ActivityType, 2, acc1, "test", "test", "foo.cpp", QUrl::fromUserInput("https://owncloud.com"), QDateTime::currentDateTime() },
Activity { Activity::ActivityType, 4, acc2, "test", "test", "foo.cpp", QUrl::fromUserInput("https://owncloud.com"), QDateTime::currentDateTime() },
});
model->slotRemoveAccount(manager->accounts().first().data());
}
};
}
QTEST_GUILESS_MAIN(OCC::TestActivityModel)
#include "testactivitymodel.moc"
|