File indexing completed on 2024-12-22 05:00:58

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "commandlineinfotest.h"
0008 #include "commandlineinfo.h"
0009 #include <QTest>
0010 
0011 QTEST_GUILESS_MAIN(CommandLineInfoTest)
0012 CommandLineInfoTest::CommandLineInfoTest(QObject *parent)
0013     : QObject{parent}
0014 {
0015 }
0016 
0017 void CommandLineInfoTest::shouldHaveDefaultValues()
0018 {
0019     CommandLineInfo w;
0020     QVERIFY(w.customHeaders().isEmpty());
0021     QVERIFY(w.attachURLs().isEmpty());
0022     QVERIFY(w.to().isEmpty());
0023     QVERIFY(w.cc().isEmpty());
0024     QVERIFY(w.bcc().isEmpty());
0025     QVERIFY(w.subject().isEmpty());
0026     QVERIFY(w.body().isEmpty());
0027     QVERIFY(w.inReplyTo().isEmpty());
0028     QVERIFY(w.replyTo().isEmpty());
0029     QVERIFY(w.identity().isEmpty());
0030     QVERIFY(w.messageFile().isEmpty());
0031     QVERIFY(!w.startInTray());
0032     QVERIFY(!w.mailto());
0033     QVERIFY(!w.checkMail());
0034     QVERIFY(!w.viewOnly());
0035     QVERIFY(!w.calledWithSession());
0036 }
0037 
0038 void CommandLineInfoTest::parseCommandLineInfo_data()
0039 {
0040     QTest::addColumn<QStringList>("args");
0041     QTest::addColumn<QString>("workingDir");
0042     QTest::addColumn<CommandLineInfo>("output");
0043     {
0044         QStringList args;
0045         args << QStringLiteral("kmail");
0046         QTest::newRow("empty") << args << QString() << CommandLineInfo();
0047     }
0048     {
0049         QStringList args;
0050         args << QStringLiteral("kmail");
0051         args << QStringLiteral(
0052             "mailto:rostedt@goodmis.org?In-Reply-To=%3C20231105160139.660634360@goodmis.org%3E&Cc=akaher%40vmware.com%2Cakpm%40linux-foundation.org%2Cgregkh%"
0053             "40linuxfoundation.org%2Clinux-kernel%40vger.kernel.org%2Cmark.rutland%40arm.com%2Cmhiramat%40kernel.org%2Cstable%40vger.kernel.org&Subject=Re%3A%"
0054             "20%5Bv6.6%5D%5BPATCH%203%2F5%5D%20eventfs%3A%20Save%20ownership%20and%20mode");
0055         CommandLineInfo info;
0056         info.setSubject(QStringLiteral("Re: [v6.6][PATCH 3/5] eventfs: Save ownership and mode"));
0057         info.setTo(QStringLiteral("rostedt@goodmis.org"));
0058         info.setCc(
0059             QStringLiteral("akaher@vmware.com,akpm@linux-foundation.org,gregkh@linuxfoundation.org,linux-kernel@vger.kernel.org,mark.rutland@arm.com,mhiramat@"
0060                            "kernel.org,stable@vger.kernel.org, "));
0061         info.setInReplyTo(QStringLiteral("<20231105160139.660634360@goodmis.org>"));
0062         info.setMailto(true);
0063         QTest::newRow("test1") << args << QString() << info;
0064     }
0065 }
0066 
0067 void CommandLineInfoTest::parseCommandLineInfo()
0068 {
0069     QFETCH(QStringList, args);
0070     QFETCH(QString, workingDir);
0071     QFETCH(CommandLineInfo, output);
0072     CommandLineInfo input;
0073     input.parseCommandLine(args, workingDir);
0074     QCOMPARE(input, output);
0075 }
0076 
0077 #include "moc_commandlineinfotest.cpp"