File indexing completed on 2024-05-12 05:17:19

0001 /*
0002    Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0003    Author: Kevin Ottens <kevin@kdab.com>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This program is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    General Public License for more details.
0014 
0015    You should have received a copy of the GNU General Public License
0016    along with this program; if not, write to the Free Software
0017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #include <qtest.h>
0021 
0022 #include "kimap2test/fakeserver.h"
0023 #include "kimap2/session.h"
0024 #include "kimap2/listjob.h"
0025 
0026 #include <QtTest>
0027 
0028 class FakeServerTest: public QObject
0029 {
0030     Q_OBJECT
0031 
0032 private Q_SLOTS:
0033 
0034     void testLoadScenario()
0035     {
0036         KIMAP2::MailBoxDescriptor descriptor;
0037         QList<KIMAP2::MailBoxDescriptor> listresult;
0038 
0039         descriptor.separator = QLatin1Char('/');
0040         descriptor.name = QStringLiteral("INBOX");
0041         listresult << descriptor;
0042         descriptor.separator = QLatin1Char('/');
0043         descriptor.name = QString::fromUtf8("INBOX/ä ö ü @ €");
0044         listresult << descriptor;
0045         descriptor.separator = QLatin1Char('/');
0046         descriptor.name = QStringLiteral("INBOX/lost+found");
0047         listresult << descriptor;
0048         descriptor.separator = QLatin1Char('/');
0049         descriptor.name = QStringLiteral("INBOX/lost+found/Calendar Public-20080128");
0050         listresult << descriptor;
0051 
0052         FakeServer fakeServer;
0053         fakeServer.addScenarioFromFile(QStringLiteral(TEST_DATA) + QStringLiteral("/fakeserverscenario.log"));
0054         fakeServer.startAndWait();
0055 
0056         KIMAP2::Session session(QStringLiteral("127.0.0.1"), 5989);
0057 
0058         KIMAP2::ListJob *job = new KIMAP2::ListJob(&session);
0059         job->setOption(KIMAP2::ListJob::IncludeUnsubscribed);
0060         QVERIFY(job->exec());
0061 
0062         fakeServer.quit();
0063     }
0064 
0065 };
0066 
0067 QTEST_GUILESS_MAIN(FakeServerTest)
0068 
0069 #include "fakeservertest.moc"