File indexing completed on 2024-05-12 05:17:10
0001 /* 0002 SPDX-FileCopyrightText: 2020 Daniel Vrátil <dvratil@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <QTest> 0008 0009 #include "kimap/closejob.h" 0010 #include "kimap/session.h" 0011 #include "kimaptest/fakeserver.h" 0012 0013 #include <QTest> 0014 0015 class CloseJobTest : public QObject 0016 { 0017 Q_OBJECT 0018 0019 private Q_SLOTS: 0020 0021 void testClose_data() 0022 { 0023 QTest::addColumn<QList<QByteArray>>("scenario"); 0024 QTest::addColumn<quint64>("highestModSeq"); 0025 0026 QList<QByteArray> scenario; 0027 scenario << FakeServer::preauth() << "C: A000001 CLOSE" 0028 << "S: A000001 OK Closed"; 0029 QTest::newRow("good") << scenario << 0ULL; 0030 0031 scenario.clear(); 0032 scenario << FakeServer::preauth() << "C: A000001 CLOSE" 0033 << "S: A000001 BAD No mailbox selected"; 0034 QTest::newRow("bad") << scenario << 0ULL; 0035 0036 scenario.clear(); 0037 scenario << FakeServer::preauth() << "C: A000001 CLOSE" 0038 << "S: A000001 OK [HIGHESTMODSEQ 123456789] Closed."; 0039 QTest::newRow("qresync") << scenario << 123456789ULL; 0040 } 0041 0042 void testClose() 0043 { 0044 QFETCH(QList<QByteArray>, scenario); 0045 QFETCH(quint64, highestModSeq); 0046 0047 FakeServer fakeServer; 0048 fakeServer.setScenario(scenario); 0049 fakeServer.startAndWait(); 0050 0051 KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989); 0052 0053 auto job = new KIMAP::CloseJob(&session); 0054 bool result = job->exec(); 0055 QEXPECT_FAIL("bad", "Expected failure on BAD response", Continue); 0056 QVERIFY(result); 0057 if (result) { 0058 QCOMPARE(job->newHighestModSeq(), highestModSeq); 0059 } 0060 0061 fakeServer.quit(); 0062 } 0063 }; 0064 0065 QTEST_GUILESS_MAIN(CloseJobTest) 0066 0067 #include "closejobtest.moc"