File indexing completed on 2024-05-12 05:17:20
0001 /* 0002 Copyright (C) 2016 Daniel Vrátil <dvratil@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include <qtest.h> 0020 0021 #include "kimap2test/fakeserver.h" 0022 #include "kimap2/session.h" 0023 #include "kimap2/imapset.h" 0024 #include "../src/movejob.h" 0025 0026 #include <QtTest> 0027 0028 class MoveJobTest: public QObject 0029 { 0030 Q_OBJECT 0031 0032 private Q_SLOTS: 0033 0034 void testMove_data() 0035 { 0036 QTest::addColumn<bool>("uidBased"); 0037 QTest::addColumn<qint64>("id"); 0038 QTest::addColumn<qint64>("resultUid"); 0039 QTest::addColumn<QString>("mailbox"); 0040 QTest::addColumn< QList<QByteArray> >("scenario"); 0041 0042 QList<QByteArray> scenario; 0043 scenario << FakeServer::preauth() 0044 << "C: A000001 MOVE 3 \"foo\"" 0045 << "S: * OK [COPYUID 12345 3 7]" 0046 << "S: A000001 OK MOVE completed"; 0047 0048 QTest::newRow("not uid based") << false << qint64(3) << qint64(7) 0049 << QStringLiteral("foo") << scenario; 0050 0051 scenario.clear(); 0052 scenario << FakeServer::preauth() 0053 << "C: A000001 UID MOVE 1024 \"bar\"" 0054 << "S: * OK [COPYUID 12346 4 2048]" 0055 << "S: A000001 OK MOVE completed"; 0056 0057 QTest::newRow("uid based") << true << qint64(1024) << qint64(2048) 0058 << QStringLiteral("bar") << scenario; 0059 } 0060 0061 void testMove() 0062 { 0063 QFETCH(bool, uidBased); 0064 QFETCH(qint64, id); 0065 QFETCH(qint64, resultUid); 0066 QFETCH(QString, mailbox); 0067 QFETCH(QList<QByteArray>, scenario); 0068 0069 FakeServer fakeServer; 0070 fakeServer.setScenario(scenario); 0071 fakeServer.startAndWait(); 0072 0073 KIMAP2::Session session(QStringLiteral("127.0.0.1"), 5989); 0074 0075 auto job = new KIMAP2::MoveJob(&session); 0076 job->setMailBox(mailbox); 0077 job->setUidBased(uidBased); 0078 job->setSequenceSet(KIMAP2::ImapSet(id)); 0079 bool result = job->exec(); 0080 QVERIFY(result); 0081 QCOMPARE(job->resultingUids(), KIMAP2::ImapSet(resultUid)); 0082 0083 fakeServer.quit(); 0084 } 0085 0086 }; 0087 0088 QTEST_GUILESS_MAIN(MoveJobTest) 0089 0090 #include "movejobtest.moc" 0091