diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-23 20:49:37 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-23 20:52:33 -0600 |
commit | 9efd56c64fe848b4557dccbdac244571d97bfc77 (patch) | |
tree | 7ffd4b14ac21766155d7a3986b0a8b4351a45530 /accounts/maildir/tests/settingstest.cpp | |
parent | c06438012eb09563daeeb82cacf937efd724cb55 (diff) | |
download | kube-9efd56c64fe848b4557dccbdac244571d97bfc77.tar.gz kube-9efd56c64fe848b4557dccbdac244571d97bfc77.zip |
A single test for all accountsettings.
Only the imaptest was working anyways and all of them tested the same
things.
Diffstat (limited to 'accounts/maildir/tests/settingstest.cpp')
-rw-r--r-- | accounts/maildir/tests/settingstest.cpp | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/accounts/maildir/tests/settingstest.cpp b/accounts/maildir/tests/settingstest.cpp deleted file mode 100644 index bf041e3c..00000000 --- a/accounts/maildir/tests/settingstest.cpp +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | #include <QTest> | ||
2 | #include <QDebug> | ||
3 | #include <QSignalSpy> | ||
4 | #include <functional> | ||
5 | #include <QStandardPaths> | ||
6 | #include <QDir> | ||
7 | #include <sink/test.h> | ||
8 | #include <sink/store.h> | ||
9 | |||
10 | #include "maildirsettings.h" | ||
11 | |||
12 | class SettingsTest : public QObject | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | private slots: | ||
16 | |||
17 | void initTestCase() | ||
18 | { | ||
19 | Sink::Test::initTest(); | ||
20 | } | ||
21 | |||
22 | void testLoad() | ||
23 | { | ||
24 | auto accountId = "accountid"; | ||
25 | auto maildirPath = QDir::tempPath(); | ||
26 | auto smtpServer = QString("smtpserver"); | ||
27 | auto smtpUsername = QString("username"); | ||
28 | auto smtpPassword = QString("password"); | ||
29 | auto username = QString("username"); | ||
30 | auto emailAddress = QString("emailAddress"); | ||
31 | |||
32 | MaildirSettings settings; | ||
33 | settings.setAccountIdentifier(accountId); | ||
34 | settings.setPath(maildirPath); | ||
35 | settings.setProperty("smtpServer", smtpServer); | ||
36 | settings.setProperty("smtpUsername", smtpUsername); | ||
37 | settings.setProperty("smtpPassword", smtpPassword); | ||
38 | settings.setProperty("userName", username); | ||
39 | settings.setProperty("emailAddress", emailAddress); | ||
40 | settings.save(); | ||
41 | |||
42 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).then([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | ||
43 | QCOMPARE(resources.size(), 2); | ||
44 | }) | ||
45 | .exec().waitForFinished(); | ||
46 | |||
47 | //Ensure we can read back all the information using the accountid | ||
48 | { | ||
49 | MaildirSettings readSettings; | ||
50 | QSignalSpy spy(&readSettings, &MaildirSettings::pathChanged); | ||
51 | QSignalSpy spy1(&readSettings, &MaildirSettings::smtpResourceChanged); | ||
52 | readSettings.setAccountIdentifier(accountId); | ||
53 | //Once for clear and once for once for the new setting | ||
54 | QTRY_COMPARE(spy.count(), 2); | ||
55 | QTRY_COMPARE(spy1.count(), 2); | ||
56 | QVERIFY(!readSettings.accountIdentifier().isEmpty()); | ||
57 | QCOMPARE(readSettings.path().toString(), maildirPath); | ||
58 | QCOMPARE(readSettings.property("smtpServer").toString(), smtpServer); | ||
59 | QCOMPARE(readSettings.property("smtpUsername").toString(), smtpUsername); | ||
60 | QCOMPARE(readSettings.property("smtpPassword").toString(), smtpPassword); | ||
61 | QCOMPARE(readSettings.property("userName").toString(), smtpUsername); | ||
62 | QCOMPARE(readSettings.property("emailAddress").toString(), emailAddress); | ||
63 | } | ||
64 | |||
65 | { | ||
66 | MaildirSettings settings; | ||
67 | QSignalSpy spy(&settings, &MaildirSettings::pathChanged); | ||
68 | settings.setAccountIdentifier(accountId); | ||
69 | QTRY_COMPARE(spy.count(), 2); | ||
70 | settings.remove(); | ||
71 | } | ||
72 | |||
73 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).then([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | ||
74 | QCOMPARE(resources.size(), 0); | ||
75 | }) | ||
76 | .exec().waitForFinished(); | ||
77 | } | ||
78 | }; | ||
79 | |||
80 | QTEST_GUILESS_MAIN(SettingsTest) | ||
81 | #include "settingstest.moc" | ||