diff --git a/tools/cutehmi.daemon.1/tests/test_cutehmi_daemon.cpp b/tools/cutehmi.daemon.1/tests/test_cutehmi_daemon.cpp index 74cdccaa..f4ed9feb 100644 --- a/tools/cutehmi.daemon.1/tests/test_cutehmi_daemon.cpp +++ b/tools/cutehmi.daemon.1/tests/test_cutehmi_daemon.cpp @@ -1,117 +1,117 @@ #include #include #include namespace cutehmi { namespace daemon { class test_cutehmi_daemon: public QObject { Q_OBJECT private slots: void initTestCase(); void helpOption(); void versionOption(); void countDaemonExample(); private: QString m_installDir; QString m_programPath; }; void test_cutehmi_daemon::initTestCase() { QString m_installDir = qEnvironmentVariable("CUTEHMI_INSTALL_DIR"); QVERIFY(!m_installDir.isEmpty()); QString toolInstallSubdir = qEnvironmentVariable("CUTEHMI_TOOLS_INSTALL_SUBDIR"); if (!toolInstallSubdir.isEmpty()) m_installDir += "/" + toolInstallSubdir; m_programPath = m_installDir + "/cutehmi.daemon.1"; #ifndef CUTEHMI_NDEBUG m_programPath += ".debug"; #endif std::cout << "toolInstallSubdir: " << toolInstallSubdir; - std::cout << "installDir: " << m_installDir); - std::cout << "m_programPath: " << m_programPath); + std::cout << "installDir: " << m_installDir; + std::cout << "m_programPath: " << m_programPath; } void test_cutehmi_daemon::helpOption() { QList argumentsList; argumentsList << QStringList({"--help"}) << QStringList({"--h"}); for (auto arguments : argumentsList) { QProcess process; process.start(m_programPath, arguments); process.waitForFinished(1000); QCOMPARE(process.error(), QProcess::UnknownError); QVERIFY(!process.readAllStandardError().contains("Unknown option")); QVERIFY(!process.readAllStandardOutput().isEmpty()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), EXIT_SUCCESS); } } void test_cutehmi_daemon::versionOption() { QList argumentsList; argumentsList << QStringList({"--version"}) << QStringList({"--v"}); for (auto arguments : argumentsList) { QProcess process; process.start(m_programPath, arguments); process.waitForFinished(1000); QCOMPARE(process.error(), QProcess::UnknownError); QVERIFY(!process.readAllStandardError().contains("Unknown option")); QVERIFY(!process.readAllStandardOutput().isEmpty()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), EXIT_SUCCESS); } } void test_cutehmi_daemon::countDaemonExample() { QProcess process; QStringList arguments { {"--app"}, {"--project=examples/cutehmi.daemon.1/CountDaemon/Main.qml"} }; process.start(m_programPath, arguments); QVERIFY(process.waitForFinished()); QString stdOut = QString::fromLocal8Bit(process.readAllStandardOutput()); QString stdErr = QString::fromLocal8Bit(process.readAllStandardError()); QVERIFY(!stdErr.contains("Unknown option")); { QRegExp rx(".*(Project file .* does not exist).*"); QVERIFY2(!rx.exactMatch(stdErr), rx.cap(1).toLocal8Bit().constData()); } QVERIFY(stdErr.contains("I can count")); QCOMPARE(process.error(), QProcess::UnknownError); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), EXIT_SUCCESS); } } } QTEST_MAIN(cutehmi::daemon::test_cutehmi_daemon) #include "test_cutehmi_daemon.moc" //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see .