File indexing completed on 2024-12-22 04:28:19

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "grammalecteresultjobtest.h"
0008 #include "grammalecte/grammalecteresultjob.h"
0009 #include <QStandardPaths>
0010 #include <QTest>
0011 QTEST_MAIN(GrammarResultJobTest)
0012 GrammarResultJobTest::GrammarResultJobTest(QObject *parent)
0013     : QObject(parent)
0014 {
0015     QStandardPaths::setTestModeEnabled(true);
0016 }
0017 
0018 void GrammarResultJobTest::shouldHaveDefaultValue()
0019 {
0020     TextGrammarCheck::GrammalecteResultJob job;
0021     QVERIFY(!job.canStart());
0022     QVERIFY(job.text().isEmpty());
0023     QVERIFY(job.pythonPath().isEmpty());
0024     QVERIFY(job.grammarlecteCliPath().isEmpty());
0025     QVERIFY(job.arguments().isEmpty());
0026 }
0027 
0028 void GrammarResultJobTest::shouldBeAbleToStart()
0029 {
0030     TextGrammarCheck::GrammalecteResultJob job;
0031     // Args can be empty if we use default values
0032     QVERIFY(!job.canStart());
0033     job.setText(QStringLiteral("ff"));
0034     QVERIFY(!job.canStart());
0035     job.setPythonPath(QStringLiteral("/usr/bin/"));
0036     QVERIFY(!job.canStart());
0037     job.setGrammarlecteCliPath(QStringLiteral("/usr/bin/ls"));
0038     QVERIFY(job.canStart());
0039     job.setArguments(QStringList() << QStringLiteral("ff"));
0040     QVERIFY(job.canStart());
0041 }
0042 
0043 #include "moc_grammalecteresultjobtest.cpp"