File indexing completed on 2024-04-21 15:55:31

0001 /*************************************************************************************
0002   Copyright (C) 2004 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)
0003                 2012-2022 by Michel Ludwig (michel.ludwig@kdemail.net)
0004  *************************************************************************************/
0005 
0006 /***************************************************************************
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 #include "configtester.h"
0016 
0017 #include <okular/interfaces/viewerinterface.h>
0018 
0019 #include <QTimer>
0020 
0021 #include <KAboutData>
0022 #include <KConfig>
0023 #include <KIO/CopyJob>
0024 #include <KJob>
0025 #include <KLocalizedString>
0026 #include <KPluginFactory>
0027 #include <KProcess>
0028 
0029 #include <QTemporaryDir>
0030 
0031 #include "documentinfo.h"
0032 #include "kiledebug.h"
0033 #include "kiledocmanager.h"
0034 #include "kiletoolmanager.h"
0035 #include "kileinfo.h"
0036 #include "kileconfig.h"
0037 #include "kiletool.h"
0038 #include "kiletool_enums.h"
0039 #include "kileversion.h"
0040 #include "utilities.h"
0041 
0042 ConfigTest::ConfigTest(const QString& testGroup, const QString &name, bool isCritical)
0043     : m_testGroup(testGroup)
0044     , m_name(name)
0045     , m_isCritical(isCritical)
0046     , m_isSilent(false)
0047     , m_status(NotRun)
0048 {
0049 }
0050 
0051 ConfigTest::~ConfigTest()
0052 {
0053 }
0054 
0055 int ConfigTest::status() const
0056 {
0057     return m_status;
0058 }
0059 
0060 QString ConfigTest::name() const
0061 {
0062     return m_name;
0063 }
0064 
0065 QString ConfigTest::testGroup() const
0066 {
0067     return m_testGroup;
0068 }
0069 
0070 QString ConfigTest::resultText() const
0071 {
0072     return m_resultText;
0073 }
0074 
0075 void ConfigTest::addDependency(ConfigTest *test)
0076 {
0077     m_dependencyTestList.push_back(test);
0078 }
0079 
0080 bool ConfigTest::allDependenciesSucceeded() const
0081 {
0082     for(ConfigTest *test : m_dependencyTestList) {
0083         if(test->status() != Success) {
0084             return false;
0085         }
0086     }
0087     return true;
0088 }
0089 
0090 bool ConfigTest::isCritical() const
0091 {
0092     return m_isCritical;
0093 }
0094 
0095 bool ConfigTest::isSilent() const
0096 {
0097     return m_isSilent;
0098 }
0099 
0100 void ConfigTest::setSilent(bool b)
0101 {
0102     m_isSilent = b;
0103 }
0104 
0105 void ConfigTest::setName(const QString& name)
0106 {
0107     m_name = name;
0108 }
0109 
0110 Tester::Tester(KileInfo *kileInfo, QObject *parent)
0111     : QObject(parent),
0112       m_ki(kileInfo),
0113       m_tempDir(Q_NULLPTR),
0114       m_testsDone(0)
0115 {
0116     m_tempDir = new QTemporaryDir();
0117 
0118     setupTests();
0119     m_nextTestIterator = m_testList.begin();
0120 }
0121 
0122 Tester::~Tester()
0123 {
0124     if (m_tempDir) m_tempDir->remove();
0125     delete m_tempDir;
0126     qDeleteAll(m_testList);
0127 }
0128 
0129 void Tester::runTests()
0130 {
0131     const QString& destinationDirectory = m_tempDir->path();
0132     const QString& testDirectory =
0133 #ifdef Q_OS_WIN
0134         KileUtilities::locate(QStandardPaths::AppDataLocation, "kile/test", QStandardPaths::LocateDirectory);
0135 #else
0136         KileUtilities::locate(QStandardPaths::AppDataLocation, "test", QStandardPaths::LocateDirectory);
0137 #endif
0138     KIO::CopyJob *copyJob = KIO::copyAs(QUrl::fromLocalFile(testDirectory), QUrl::fromLocalFile(destinationDirectory), KIO::HideProgressInfo | KIO::Overwrite);
0139     connect(copyJob, SIGNAL(result(KJob*)), this, SLOT(handleFileCopyResult(KJob*)));
0140     emit(percentageDone(0));
0141 }
0142 
0143 void Tester::handleFileCopyResult(KJob* job)
0144 {
0145     if(job->error()) {
0146         emit(finished(false));
0147     }
0148     else {
0149         startNextTest();
0150     }
0151 }
0152 
0153 void Tester::addResult(const QString &tool, ConfigTest* testResult)
0154 {
0155     m_results[tool].push_back(testResult);
0156 }
0157 
0158 QStringList Tester::testGroups()
0159 {
0160     return m_results.keys();
0161 }
0162 
0163 QList<ConfigTest*> Tester::resultForGroup(const QString & tool)
0164 {
0165     return m_results[tool];
0166 }
0167 
0168 // 'isCritical' is set to true iff one tool that failed was critical
0169 int Tester::statusForGroup(const QString &testGroup, bool *isCritical)
0170 {
0171     if(isCritical) {
0172         *isCritical = false;
0173     }
0174     QList<ConfigTest*> tests = m_results[testGroup];
0175     int status = ConfigTest::Success;
0176     for(int i = 0; i < tests.count(); ++i) {
0177         if(tests[i]->status() == ConfigTest::Failure) {
0178             if(isCritical && tests[i]->isCritical()) {
0179                 *isCritical = true;
0180             }
0181             status = ConfigTest::Failure;
0182         }
0183     }
0184     return status;
0185 }
0186 
0187 void Tester::startNextTest()
0188 {
0189     KILE_DEBUG_MAIN;
0190     if(m_nextTestIterator != m_testList.end()) {
0191         m_currentTest = *m_nextTestIterator;
0192         ++m_nextTestIterator;
0193         if(!m_currentTest->allDependenciesSucceeded()) {
0194             QTimer::singleShot(0, this, SLOT(startNextTest()));
0195             return;
0196         }
0197         // we want events to be handled inbetween tests -> QueuedConnection
0198         connect(m_currentTest, SIGNAL(testComplete(ConfigTest*)), this, SLOT(handleTestComplete(ConfigTest*)), Qt::QueuedConnection);
0199         m_currentTest->call();
0200     }
0201     else {
0202         emit(percentageDone(100));
0203         emit(finished(true));
0204     }
0205 }
0206 
0207 void Tester::handleTestComplete(ConfigTest *test)
0208 {
0209     KILE_DEBUG_MAIN;
0210     if(!test->isSilent()) {
0211         addResult(test->testGroup(), test);
0212     }
0213     ++m_testsDone;
0214     emit(percentageDone((m_testsDone / (float) m_testList.size()) * 100.0));
0215     startNextTest();
0216 }
0217 
0218 
0219 TestToolInKileTest::TestToolInKileTest(const QString& testGroup, KileInfo *kileInfo, const QString& toolName,
0220                                        const QString& filePath,
0221                                        bool isCritical)
0222     : ConfigTest(testGroup, i18n("Running in Kile"), isCritical),
0223       m_ki(kileInfo),
0224       m_toolName(toolName),
0225       m_filePath(filePath)
0226 {
0227 }
0228 
0229 TestToolInKileTest::~TestToolInKileTest()
0230 {
0231 }
0232 
0233 void TestToolInKileTest::call()
0234 {
0235     KileDocument::TextInfo *textInfo = m_ki->docManager()->fileOpen(QUrl::fromLocalFile(m_filePath));
0236     if(!textInfo) {
0237         reportFailure();
0238         return;
0239     }
0240     m_documentUrl = textInfo->url();
0241 
0242     KileTool::Base *tool = m_ki->toolManager()->createTool(m_toolName, QString(), false);
0243     if(!tool) {
0244         m_ki->docManager()->fileClose(m_documentUrl);
0245         m_status = Failure;
0246         m_resultText = i18n("Tool not found.\n"
0247                             "Kile is not configured correctly. Go to Settings->Configure Kile->Tools "
0248                             "and either fix the problem or change to the default settings."
0249                            );
0250         emit(testComplete(this));
0251         return;
0252     }
0253     // We don't want the tool to spawn subtools (especially, for LaTeX-style tools).
0254     // If we did, we might come into the situation that a subtool is launched before the
0255     // parsing is complete, which could trigger a "root document not found" error message.
0256     tool->setEntry("autoRun", "no");
0257     connect(tool, SIGNAL(done(KileTool::Base*,int,bool)), this, SLOT(handleToolExit(KileTool::Base*,int,bool)), Qt::UniqueConnection);
0258     connect(tool, SIGNAL(failedToRun(KileTool::Base*,int)), this, SLOT(reportFailure()));
0259     m_ki->toolManager()->run(tool);
0260 }
0261 
0262 void TestToolInKileTest::reportSuccess()
0263 {
0264     m_ki->docManager()->fileClose(m_documentUrl);
0265     m_documentUrl.clear();
0266 
0267     m_status = Success;
0268     m_resultText = i18n("Passed");
0269     emit(testComplete(this));
0270 }
0271 
0272 void TestToolInKileTest::reportFailure()
0273 {
0274     m_ki->docManager()->fileClose(m_documentUrl);
0275     m_documentUrl.clear();
0276 
0277     m_status = Failure;
0278     m_resultText = i18n("Failed");
0279     emit(testComplete(this));
0280 }
0281 
0282 
0283 void TestToolInKileTest::handleToolExit(KileTool::Base *tool, int status, bool childToolSpawned)
0284 {
0285     Q_UNUSED(tool);
0286     Q_UNUSED(childToolSpawned);
0287 
0288     if(status == KileTool::Success) {
0289         reportSuccess();
0290     }
0291     else {
0292         reportFailure();
0293     }
0294 }
0295 
0296 OkularVersionTest::OkularVersionTest(const QString& testGroup, bool isCritical)
0297     : ConfigTest(testGroup, i18n("Version"), isCritical)
0298 {
0299 }
0300 
0301 OkularVersionTest::~OkularVersionTest()
0302 {
0303 }
0304 
0305 void OkularVersionTest::call()
0306 {
0307     QPluginLoader pluginLoader(OKULAR_LIBRARY_NAME);
0308     KPluginFactory *factory = qobject_cast<KPluginFactory *>(pluginLoader.instance());
0309 
0310     if (!factory) {
0311         m_status = Failure;
0312     }
0313     else {
0314         KParts::ReadOnlyPart *part = factory->create<KParts::ReadOnlyPart>();
0315         Okular::ViewerInterface *viewerInterface = dynamic_cast<Okular::ViewerInterface*>(part);
0316 
0317         if(!viewerInterface) {
0318             // OkularPart doesn't provide the ViewerInterface
0319             m_status = Failure;
0320         }
0321         else {
0322             m_status = Success;
0323             // it seems that the version of OkularPart cannot be detected, so we don't try it
0324             m_resultText = i18n("Embedding of Okular is supported");
0325         }
0326         delete part;
0327     }
0328 
0329     pluginLoader.unload();
0330 
0331     emit(testComplete(this));
0332 }
0333 
0334 
0335 FindProgramTest::FindProgramTest(const QString& testGroup, const QString& programName, bool isCritical)
0336     : ConfigTest(testGroup, i18n("Binary"), isCritical),
0337       m_programName(programName)
0338 {
0339 }
0340 
0341 FindProgramTest::~FindProgramTest()
0342 {
0343 }
0344 
0345 void FindProgramTest::call()
0346 {
0347     QString execPath = QStandardPaths::findExecutable(m_programName);
0348 #ifdef Q_OS_WIN
0349     if(execPath.isEmpty()) {
0350         execPath = QStandardPaths::findExecutable(m_programName, QStringList(QCoreApplication::applicationDirPath()));
0351     }
0352 #endif
0353     bool thisIsWindowsConvertExe = false;
0354 #ifdef Q_OS_WIN
0355     QFileInfo execPathInfo(execPath);
0356     thisIsWindowsConvertExe = (m_programName == "convert") && (execPathInfo.dir().dirName() == "system32");
0357 #endif
0358     if(execPath.isEmpty() || thisIsWindowsConvertExe) {
0359         m_status = Failure;
0360         if(!m_additionalFailureMessage.isEmpty()) {
0361             if(isCritical()) {
0362                 m_resultText = i18nc("additional failure message given as argument",
0363                                      "Could not find the binary for this essential tool. %1", m_additionalFailureMessage);
0364             }
0365             else {
0366                 m_resultText = i18nc("additional failure message given as argument",
0367                                      "No executable '%1' found. %2", m_programName, m_additionalFailureMessage);
0368             }
0369         }
0370         else {
0371             if(isCritical()) {
0372                 m_resultText = i18n("Could not find the binary for this essential tool");
0373             }
0374             else {
0375                 m_resultText = i18n("No executable '%1' found", m_programName);
0376             }
0377         }
0378     }
0379     else {
0380         m_status = Success;
0381         m_resultText = i18nc("executable => path", "Found (%1 => %2)", m_programName, execPath);
0382     }
0383     emit(testComplete(this));
0384 }
0385 
0386 void FindProgramTest::setAdditionalFailureMessage(const QString& s)
0387 {
0388     m_additionalFailureMessage = s;
0389 }
0390 
0391 ProgramTest::ProgramTest(const QString& testGroup, const QString& programName, const QString& workingDir,
0392                          const QString& arg0,
0393                          const QString& arg1,
0394                          const QString& arg2,
0395                          bool isCritical)
0396     : ConfigTest(testGroup, i18n("Simple Test"), isCritical),
0397       m_testProcess(Q_NULLPTR),
0398       m_programName(programName),
0399       m_workingDir(workingDir),
0400       m_arg0(arg0),
0401       m_arg1(arg1),
0402       m_arg2(arg2)
0403 {
0404 }
0405 
0406 ProgramTest::~ProgramTest()
0407 {
0408     delete m_testProcess;
0409 }
0410 
0411 void ProgramTest::call()
0412 {
0413     m_testProcess = new KProcess();
0414     m_testProcess->setWorkingDirectory(m_workingDir);
0415     QStringList argList;
0416     if(!m_arg0.isEmpty()) {
0417         argList.push_back(m_arg0);
0418     }
0419     if(!m_arg1.isEmpty()) {
0420         argList.push_back(m_arg1);
0421     }
0422     if(!m_arg2.isEmpty()) {
0423         argList.push_back(m_arg2);
0424     }
0425     m_testProcess->setProgram(m_programName, argList);
0426     if (!KileConfig::teXPaths().isEmpty()) {
0427         m_testProcess->setEnv("TEXINPUTS", KileInfo::expandEnvironmentVars(KileConfig::teXPaths() + ":$TEXINPUTS"));
0428     }
0429     connect(m_testProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
0430             this, SLOT(handleTestProcessFinished(int,QProcess::ExitStatus)));
0431     connect(m_testProcess, SIGNAL(error(QProcess::ProcessError)),
0432             this, SLOT(handleTestProcessError(QProcess::ProcessError)));
0433     m_testProcess->start();
0434 }
0435 
0436 void ProgramTest::handleTestProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
0437 {
0438     m_testProcess->deleteLater();
0439     m_testProcess = Q_NULLPTR;
0440 
0441     if(exitStatus == QProcess::NormalExit && exitCode == 0) {
0442         processFinishedSuccessfully();
0443     }
0444     else {
0445         reportFailure();
0446     }
0447 }
0448 
0449 void ProgramTest::processFinishedSuccessfully()
0450 {
0451     reportSuccess();
0452 }
0453 
0454 void ProgramTest::handleTestProcessError(QProcess::ProcessError error)
0455 {
0456     Q_UNUSED(error);
0457 
0458     m_testProcess->deleteLater();
0459     m_testProcess = Q_NULLPTR;
0460     reportFailure();
0461 }
0462 
0463 void ProgramTest::reportSuccess()
0464 {
0465     m_resultText = i18n("Passed");
0466     m_status = Success;
0467     emit(testComplete(this));
0468 }
0469 
0470 void ProgramTest::reportFailure()
0471 {
0472     if(isCritical()) {
0473         m_resultText = i18n("This essential tool does not work; please check your installation.");
0474     }
0475     else {
0476         m_resultText = i18n("Failed");
0477     }
0478     m_status = Failure;
0479     emit(testComplete(this));
0480 }
0481 
0482 
0483 LaTeXSrcSpecialsSupportTest::LaTeXSrcSpecialsSupportTest(const QString& testGroup, const QString& workingDir,
0484         const QString& fileBaseName)
0485     : ProgramTest(testGroup, "latex", workingDir, "-src-specials", "--interaction=nonstopmode", fileBaseName + ".tex", false),
0486       m_fileBaseName(fileBaseName)
0487 {
0488     setName(i18n("Source Specials Switch"));
0489 }
0490 
0491 LaTeXSrcSpecialsSupportTest::~LaTeXSrcSpecialsSupportTest()
0492 {
0493 }
0494 
0495 void LaTeXSrcSpecialsSupportTest::processFinishedSuccessfully()
0496 {
0497     // before we can report success, we still have to perform the
0498     // following check:
0499     // src-specials are supported if the created file contains source
0500     // information (LaTeX doesn't report unknown command line flags as
0501     // errors). Hence, we now check whether the created file contains
0502     // the string 'src:'.
0503     QFile file(m_workingDir + '/' + m_fileBaseName + ".dvi");
0504     if (!file.open(QIODevice::ReadOnly)) {
0505         reportFailure();
0506         return;
0507     }
0508     // we read everything as it's a small file
0509     QByteArray array = file.readAll();
0510     file.close();
0511     if(!array.contains("src:")) {
0512         reportFailure();
0513         return;
0514     }
0515     reportSuccess();
0516 }
0517 
0518 void LaTeXSrcSpecialsSupportTest::reportSuccess()
0519 {
0520     m_resultText = i18n("Supported, use the 'Modern' configuration for (La)TeX to auto-enable inverse and forward search capabilities.");
0521     m_status = Success;
0522     emit(testComplete(this));
0523 }
0524 
0525 void LaTeXSrcSpecialsSupportTest::reportFailure()
0526 {
0527     m_resultText = i18n("Not supported, use the srcltx package to enable the inverse and forward search capabilities.");
0528     m_status = Failure;
0529     emit(testComplete(this));
0530 }
0531 
0532 
0533 SyncTeXSupportTest::SyncTeXSupportTest(const QString& testGroup, const QString& toolName, const QString& workingDir,
0534                                        const QString& fileBaseName)
0535     : ProgramTest(testGroup, toolName, workingDir, "-synctex=1", "--interaction=nonstopmode", fileBaseName + ".tex", false),
0536       m_fileBaseName(fileBaseName)
0537 {
0538     setName(i18n("SyncTeX Support"));
0539 }
0540 
0541 SyncTeXSupportTest::~SyncTeXSupportTest()
0542 {
0543 }
0544 
0545 void SyncTeXSupportTest::reportSuccess()
0546 {
0547     m_resultText = i18n("Supported, use the 'Modern' configuration for PDFLaTeX and XeLaTeX to auto-enable inverse and forward search capabilities.");
0548     m_status = Success;
0549     emit(testComplete(this));
0550 }
0551 
0552 void SyncTeXSupportTest::reportFailure()
0553 {
0554     m_resultText = i18n("Not supported");
0555     m_status = Failure;
0556     emit(testComplete(this));
0557 }
0558 
0559 void SyncTeXSupportTest::processFinishedSuccessfully()
0560 {
0561     // before we can report success, we still have to check
0562     // whether a .synctex.gz file has been generated
0563     QFile file(m_workingDir + '/' + m_fileBaseName + ".synctex.gz");
0564     if (!file.exists()) {
0565         reportFailure();
0566         return;
0567     }
0568     reportSuccess();
0569 }
0570 
0571 void Tester::installConsecutivelyDependentTests(ConfigTest *t1, ConfigTest *t2, ConfigTest *t3, ConfigTest *t4)
0572 {
0573     if(!t1) {
0574         return;
0575     }
0576     m_testList.push_back(t1);
0577     if(!t2) {
0578         return;
0579     }
0580     t2->addDependency(t1);
0581     m_testList.push_back(t2);
0582     if(!t3) {
0583         return;
0584     }
0585     t3->addDependency(t2);
0586     m_testList.push_back(t3);
0587     if(!t4) {
0588         return;
0589     }
0590     t4->addDependency(t3);
0591     m_testList.push_back(t4);
0592 }
0593 
0594 void Tester::setupTests()
0595 {
0596 
0597     /*
0598     testFile=test_plain.tex
0599     echo "opening $basedir/$testFile"
0600     $openDoc"$basedir/$testFile"
0601 
0602     echo "starting test: TeX"
0603     setTool TeX
0604     tool="tex --interaction=nonstopmode"
0605     setKey mustpass "where,basic,kile"
0606     setKey executable tex
0607     setKey where `which tex`
0608     setKey version `getTeXVersion tex`
0609     performTest basic "$tool test_plain.tex"
0610     performKileTest kile "run TeX"
0611     */
0612     installConsecutivelyDependentTests(
0613         new FindProgramTest("TeX", "tex", true),
0614         new ProgramTest("TeX", "tex", m_tempDir->path(), "--interaction=nonstopmode",  "test_plain.tex", "", true),
0615         new TestToolInKileTest("TeX", m_ki, "TeX", m_tempDir->path() + '/' + "test_plain.tex", true));
0616     /*
0617     echo "starting test: PDFTeX"
0618     setTool PDFTeX
0619     tool="pdftex --interaction=nonstopmode"
0620     setKey mustpass ""
0621     setKey executable pdftex
0622     setKey where `which pdftex`
0623     performTest basic "$tool test_plain.tex"
0624     performKileTest kile "run PDFTeX"
0625     $closeDoc
0626     */
0627     installConsecutivelyDependentTests(
0628         new FindProgramTest("PDFTeX", "pdftex", false),
0629         new ProgramTest("PDFTeX", "pdftex", m_tempDir->path(), "--interaction=nonstopmode",  "test_plain.tex", "", false),
0630         new TestToolInKileTest("PDFTeX", m_ki, "PDFTeX", m_tempDir->path() + '/' + "test_plain.tex", false));
0631     /*
0632     testFileBase="test"
0633     testFile=$testFileBase.tex
0634     echo "opening $basedir/$testFile"
0635     $openDoc"$basedir/$testFile"
0636     echo "starting test: LaTeX"
0637     setTool LaTeX
0638     tool="latex --interaction=nonstopmode"
0639     setKey mustpass "where,basic,kile"
0640     setKey executable latex
0641     setKey where `which latex`
0642     performTest basic "$tool $testFile"
0643     performKileTest kile "run LaTeX"
0644     performTest src "$tool -src $testFile"
0645     */
0646     ProgramTest *latexProgramTest = new ProgramTest("LaTeX", "latex", m_tempDir->path(), "--interaction=nonstopmode",  "test.tex", "", true);
0647     m_laTeXSrcSpecialsSupportTest = new LaTeXSrcSpecialsSupportTest("LaTeX", m_tempDir->path(), "test");
0648     installConsecutivelyDependentTests(
0649         new FindProgramTest("LaTeX", "latex", true),
0650         latexProgramTest,
0651         new TestToolInKileTest("LaTeX", m_ki, "LaTeX", m_tempDir->path() + '/' + "test.tex", true),
0652         m_laTeXSrcSpecialsSupportTest);
0653     /*
0654     echo "starting test: PDFLaTeX"
0655     setTool PDFLaTeX
0656     setKey mustpass ""
0657     setKey executable pdflatex
0658     setKey where `which pdflatex`
0659     performTest basic "pdflatex $testFile"
0660     performKileTest kile "run PDFLaTeX"
0661     */
0662     m_pdfLaTeXSyncTeXSupportTest = new SyncTeXSupportTest("PDFLaTeX", "pdflatex", m_tempDir->path(), "test");
0663     installConsecutivelyDependentTests(
0664         new FindProgramTest("PDFLaTeX", "pdflatex", false),
0665         new ProgramTest("PDFLaTeX", "pdflatex", m_tempDir->path(), "--interaction=nonstopmode",  "test.tex", "", false),
0666         new TestToolInKileTest("PDFLaTeX", m_ki, "PDFLaTeX", m_tempDir->path() + '/' + "test.tex", false),
0667         m_pdfLaTeXSyncTeXSupportTest);
0668     /*
0669     echo "starting test: DVItoPS"
0670     setTool DVItoPS
0671     setKey mustpass ""
0672     setKey executable dvips
0673     setKey where `which dvips`
0674     if [ -r $testFileBase.dvi ]; then performKileTest kile "run DVItoPS"; fi
0675     */
0676     TestToolInKileTest *dvipsKileTest = new TestToolInKileTest("DVItoPS", m_ki, "DVItoPS", m_tempDir->path() + '/' + "test.tex", false);
0677     dvipsKileTest->addDependency(latexProgramTest);
0678     installConsecutivelyDependentTests(
0679         new FindProgramTest("DVItoPS", "dvips", false),
0680         dvipsKileTest);
0681     /*
0682     echo "starting test: DVItoPDF"
0683     setTool DVItoPDF
0684     setKey mustpass ""
0685     setKey executable dvipdfmx
0686     setKey where `which dvipdfmx`
0687     if [ -r $testFileBase.dvi ]; then performKileTest kile "run DVItoPDF"; fi
0688     */
0689     TestToolInKileTest *dvipdfmxKileTest = new TestToolInKileTest("DVItoPDF", m_ki, "DVItoPDF", m_tempDir->path() + '/' + "test.tex", false);
0690     dvipdfmxKileTest->addDependency(latexProgramTest);
0691     installConsecutivelyDependentTests(
0692         new FindProgramTest("DVItoPDF", "dvipdfmx", false),
0693         dvipdfmxKileTest);
0694     /*
0695     echo "starting test: PStoPDF"
0696     setTool PStoPDF
0697     setKey mustpass ""
0698     setKey executable ps2pdf
0699     setKey where `which ps2pdf`
0700     if [ -r $testFileBase.ps ]; then performKileTest kile "run PStoPDF"; fi
0701     $closeDoc
0702     */
0703     TestToolInKileTest *ps2pdfKileTest = new TestToolInKileTest("PStoPDF", m_ki, "PStoPDF", m_tempDir->path() + '/' + "test.tex", false);
0704     ps2pdfKileTest->addDependency(dvipsKileTest);
0705     installConsecutivelyDependentTests(
0706         new FindProgramTest("PStoPDF", "ps2pdf", false),
0707         ps2pdfKileTest);
0708     /*
0709     echo "starting test: BibTeX"
0710     setTool BibTeX
0711     setKey mustpass ""
0712     setKey executable bibtex
0713     setKey where `which bibtex`
0714     if [ -r "test.dvi" ] #LaTeX is working
0715     then
0716         testFileBase=test_bib
0717         testFile=$testFileBase.tex
0718         $openDoc"$basedir/$testFile"
0719         latex --interaction=nonstopmode $testFile
0720         performTest basic "bibtex $testFileBase"
0721         performKileTest kile "run BibTeX"
0722         $closeDoc
0723     fi
0724     */
0725     TestToolInKileTest *latexForBibTeX = new TestToolInKileTest("BibTeX", m_ki, "LaTeX", m_tempDir->path() + '/' + "test_bib.tex", false);
0726     latexForBibTeX->addDependency(latexProgramTest);
0727     latexForBibTeX->setSilent(true);
0728     ProgramTest *bibtexProgramTest = new ProgramTest("BibTeX", "bibtex", m_tempDir->path(), "test_bib",  "", "", false);
0729     bibtexProgramTest->addDependency(latexForBibTeX);
0730     TestToolInKileTest *bibtexKileTest = new TestToolInKileTest("BibTeX", m_ki, "BibTeX", m_tempDir->path() + '/' + "test_bib.tex", false);
0731     bibtexKileTest->addDependency(latexProgramTest);
0732     installConsecutivelyDependentTests(
0733         new FindProgramTest("BibTeX", "bibtex", false),
0734         latexForBibTeX,
0735         bibtexProgramTest,
0736         bibtexKileTest);
0737     /*
0738     echo "starting test: MakeIndex"
0739     setTool MakeIndex
0740     setKey mustpass ""
0741     setKey executable makeindex
0742     setKey where `which makeindex`
0743 
0744     if [ -r "test.dvi" ] #LaTeX is working
0745     then
0746         testFileBase=test_index
0747         testFile=$testFileBase.tex
0748         $openDoc"$basedir/$testFile"
0749         latex --interaction=nonstopmode $testFile
0750         performTest basic "makeindex $testFileBase"
0751         performKileTest kile "run MakeIndex"
0752         $closeDoc
0753     fi
0754     */
0755     TestToolInKileTest *latexForMakeIndex = new TestToolInKileTest("MakeIndex", m_ki, "LaTeX", m_tempDir->path() + '/' + "test_index.tex", false);
0756     latexForMakeIndex->addDependency(latexProgramTest);
0757     latexForMakeIndex->setSilent(true);
0758     ProgramTest *makeIndexProgramTest = new ProgramTest("MakeIndex", "makeindex", m_tempDir->path(), "test_index",  "", "", false);
0759     makeIndexProgramTest->addDependency(latexProgramTest);
0760     TestToolInKileTest *makeindexKileTest = new TestToolInKileTest("MakeIndex", m_ki, "MakeIndex", m_tempDir->path() + '/' + "test_index.tex", false);
0761     makeindexKileTest->addDependency(latexProgramTest);
0762     installConsecutivelyDependentTests(
0763         new FindProgramTest("MakeIndex", "makeindex", false),
0764         latexForMakeIndex,
0765         makeIndexProgramTest,
0766         makeindexKileTest);
0767     /*
0768     echo "starting test: Okular"
0769     setTool Okular
0770     setKey mustpass "where"
0771     setKey executable okular
0772     setKey version `getOkularVersion okular`
0773     performTest okular "isTheOkularVersionRecentEnough"
0774     setKey where `which okular`
0775     */
0776     m_okularVersionTest = new OkularVersionTest("Okular", false);
0777     installConsecutivelyDependentTests(
0778         new FindProgramTest("Okular", "okular", false),
0779         m_okularVersionTest);
0780     /*
0781     echo "starting test: Acroread"
0782     setTool Acroread
0783     setKey mustpass ""
0784     setKey executable acroread
0785     setKey where `which acroread`
0786     */
0787 
0788     /*
0789     echo "starting test: DVItoPNG"
0790     setTool DVItoPNG
0791     setKey mustpass ""
0792     setKey executable dvipng
0793     setKey where `which dvipng`
0794     */
0795     FindProgramTest *dvipngProgramTest = new FindProgramTest("DVItoPNG", "dvipng", false);
0796     dvipngProgramTest->setAdditionalFailureMessage(i18n("PNG previews cannot be used for mathgroups in the bottom preview pane"));
0797     m_testList.push_back(dvipngProgramTest);
0798     /*
0799     echo "starting test: Convert"
0800     setTool Convert
0801     setKey mustpass ""
0802     setKey executable convert
0803     setKey where `which convert`
0804     */
0805     FindProgramTest *convertProgramTest = new FindProgramTest("Convert", "convert", false);
0806     convertProgramTest->setAdditionalFailureMessage(i18n("PNG previews cannot be used with conversions 'dvi->ps->png' and 'pdf->png' in the bottom preview pane"));
0807     m_testList.push_back(convertProgramTest);
0808 }
0809 
0810 bool Tester::isSyncTeXSupportedForPDFLaTeX()
0811 {
0812     return (m_pdfLaTeXSyncTeXSupportTest->status() == ConfigTest::Success);
0813 }
0814 
0815 bool Tester::isViewerModeSupportedInOkular()
0816 {
0817     return (m_okularVersionTest->status() == ConfigTest::Success);
0818 }
0819 
0820 bool Tester::areSrcSpecialsSupportedForLaTeX()
0821 {
0822     return (m_laTeXSrcSpecialsSupportTest->status() == ConfigTest::Success);
0823 }
0824