From ba8baf2d75d651130600ad3efe84b8bf6619d8f8 Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 10 Aug 2022 16:46:14 +0300 Subject: [PATCH] addee more ported tests --- tests/units/binprefixtest.cpp | 45 +++++++ tests/units/binprefixtest.h | 23 ++++ tests/units/deploygeneralfilestest.cpp | 35 ++++++ tests/units/deploygeneralfilestest.h | 23 ++++ tests/units/disablerunscripttest.cpp | 64 ++++++++++ tests/units/disablerunscripttest.h | 23 ++++ tests/units/disableshortcutstest.cpp | 46 +++++++ tests/units/disableshortcutstest.h | 23 ++++ tests/units/emptypackagestest.cpp | 37 ++++++ tests/units/emptypackagestest.h | 23 ++++ tests/units/iconstest.cpp | 136 +++++++++++++++++++++ tests/units/iconstest.h | 23 ++++ tests/units/md5test.cpp | 69 +++++++++++ tests/units/md5test.h | 23 ++++ tests/units/overridingtemplatedebtest.cpp | 78 ++++++++++++ tests/units/overridingtemplatedebtest.h | 26 ++++ tests/units/overridingtemplateqifwtest.cpp | 100 +++++++++++++++ tests/units/overridingtemplateqifwtest.h | 24 ++++ tests/units/pathutilstest.cpp | 85 +++++++++++++ tests/units/pathutilstest.h | 23 ++++ tests/units/runscriptstest.cpp | 60 +++++++++ tests/units/runscriptstest.h | 23 ++++ tests/units/trtest.cpp | 36 ++++++ tests/units/trtest.h | 23 ++++ tests/units/virtualkeybordtest.cpp | 32 +++++ tests/units/virtualkeybordtest.h | 23 ++++ 26 files changed, 1126 insertions(+) create mode 100644 tests/units/binprefixtest.cpp create mode 100644 tests/units/binprefixtest.h create mode 100644 tests/units/deploygeneralfilestest.cpp create mode 100644 tests/units/deploygeneralfilestest.h create mode 100644 tests/units/disablerunscripttest.cpp create mode 100644 tests/units/disablerunscripttest.h create mode 100644 tests/units/disableshortcutstest.cpp create mode 100644 tests/units/disableshortcutstest.h create mode 100644 tests/units/emptypackagestest.cpp create mode 100644 tests/units/emptypackagestest.h create mode 100644 tests/units/iconstest.cpp create mode 100644 tests/units/iconstest.h create mode 100644 tests/units/md5test.cpp create mode 100644 tests/units/md5test.h create mode 100644 tests/units/overridingtemplatedebtest.cpp create mode 100644 tests/units/overridingtemplatedebtest.h create mode 100644 tests/units/overridingtemplateqifwtest.cpp create mode 100644 tests/units/overridingtemplateqifwtest.h create mode 100644 tests/units/pathutilstest.cpp create mode 100644 tests/units/pathutilstest.h create mode 100644 tests/units/runscriptstest.cpp create mode 100644 tests/units/runscriptstest.h create mode 100644 tests/units/trtest.cpp create mode 100644 tests/units/trtest.h create mode 100644 tests/units/virtualkeybordtest.cpp create mode 100644 tests/units/virtualkeybordtest.h diff --git a/tests/units/binprefixtest.cpp b/tests/units/binprefixtest.cpp new file mode 100644 index 0000000..c9c2fc3 --- /dev/null +++ b/tests/units/binprefixtest.cpp @@ -0,0 +1,45 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "binprefixtest.h" +#include +#include +#include +#include +#include + + +void BinPrefixTest::test() { + TestUtils utils; + +#ifdef Q_OS_UNIX + auto comapareTree = utils.createTree( + { + "./" + DISTRO_DIR + "/TestOnlyC.sh", + "./" + DISTRO_DIR + "/bin/TestOnlyC", + "./" + DISTRO_DIR + "/bin/qt.conf" + }); + QString target = TestBinDir + "TestOnlyC"; + QString targetWithoutPrefix = "TestOnlyC"; + +#else + auto comapareTree = utils.createTree( + {"./" + DISTRO_DIR + "/TestOnlyC.exe", + "./" + DISTRO_DIR + "/TestOnlyC.bat", + "./" + DISTRO_DIR + "/qt.conf"}); + QString target = TestBinDir + "TestOnlyC.exe"; + QString targetWithoutPrefix = "TestOnlyC.exe"; + +#endif + + runTestParams({"-bin", target, "force-clear"}, &comapareTree); + + runTestParams({"-bin", targetWithoutPrefix, + "-binPrefix", TestBinDir, + "force-clear"}, &comapareTree); +} diff --git a/tests/units/binprefixtest.h b/tests/units/binprefixtest.h new file mode 100644 index 0000000..ff886d4 --- /dev/null +++ b/tests/units/binprefixtest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef BIN_PREFIX_TEST_H +#define BIN_PREFIX_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class BinPrefixTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // BIN_PREFIX_TEST_H diff --git a/tests/units/deploygeneralfilestest.cpp b/tests/units/deploygeneralfilestest.cpp new file mode 100644 index 0000000..86ad3f1 --- /dev/null +++ b/tests/units/deploygeneralfilestest.cpp @@ -0,0 +1,35 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "deploygeneralfilestest.h" +#include +#include +#include +#include +#include + + +void DeployGeneralFilesTest::test() { + TestUtils utils; + + QString bin = TestBinDir + "/../../CMakeLists.txt"; + + auto comapareTree = utils.createTree( + { + "./" + DISTRO_DIR + "/bin/CMakeLists.txt", + "./" + DISTRO_DIR + "/bin/qt.conf", + + }); + + runTestParams( + {"-bin", bin, + "-binOut", "bin", + "force-clear" + }, &comapareTree); + +} diff --git a/tests/units/deploygeneralfilestest.h b/tests/units/deploygeneralfilestest.h new file mode 100644 index 0000000..30f256b --- /dev/null +++ b/tests/units/deploygeneralfilestest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef DEPLOY_GENERAL_FILES_TEST_H +#define DEPLOY_GENERAL_FILES_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class DeployGeneralFilesTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // DEPLOY_GENERAL_FILES_TEST_H diff --git a/tests/units/disablerunscripttest.cpp b/tests/units/disablerunscripttest.cpp new file mode 100644 index 0000000..dfae9b4 --- /dev/null +++ b/tests/units/disablerunscripttest.cpp @@ -0,0 +1,64 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "disablerunscripttest.h" +#include +#include +#include +#include +#include + + +void DisableRunScriptTest::test() { + + TestUtils utils; + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; +#else + QString bin = TestBinDir + "TestOnlyC.exe"; +#endif + + auto comapareTreeqif = TestModule.onlyC(); + comapareTreeqif -= utils.createTree({DISTRO_DIR + "/TestOnlyC.sh", + DISTRO_DIR + "/TestOnlyC.bat"}); + // Run deploy installer + runTestParams({"-bin", bin, "clear", "-libDir", TestQtDir + "/bin", + "-disableRunScript", "TestOnlyC"}, &comapareTreeqif); +} + +void deploytest::testQifOut() { + TestUtils utils; + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; +#else + QString bin = TestBinDir + "TestOnlyC.exe"; +#endif + +#ifdef Q_OS_UNIX + auto result = utils.createTree({{DISTRO_DIR + "/QIF_OUT.exe"}, {DISTRO_DIR + "/QIF_OUT.exe.md5"}, + {DISTRO_DIR + "/DEB_OUT.deb"}, {DISTRO_DIR + "/DEB_OUT.deb.md5"}, + {DISTRO_DIR + "/ZIP_OUT.zip"}, {DISTRO_DIR + "/ZIP_OUT.zip.md5"}}); + + // Run deploy installer + runTestParams({"-bin", bin, "clear", + "qif", "-qifOut", "QIF_OUT.exe", + "deb", "-debOut", "DEB_OUT.deb", + "zip", "-zipOut", "ZIP_OUT.zip"}, &result); +#else + auto result = utils.createTree({{DISTRO_DIR + "/QIF_OUT.exe"}, {DISTRO_DIR + "/QIF_OUT.exe.md5"}, + {DISTRO_DIR + "/ZIP_OUT.zip"}, {DISTRO_DIR + "/ZIP_OUT.zip.md5"}}); + + // Run deploy installer + runTestParams({"-bin", bin, "clear", + "qif", "-qifOut", "QIF_OUT.exe", + "zip", "-zipOut", "ZIP_OUT.zip"}, &result); +#endif + +} diff --git a/tests/units/disablerunscripttest.h b/tests/units/disablerunscripttest.h new file mode 100644 index 0000000..1c220ea --- /dev/null +++ b/tests/units/disablerunscripttest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef DIABLE_RUN_SCRIPT_TEST_H +#define DIABLE_RUN_SCRIPT_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class DisableRunScriptTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // DIABLE_RUN_SCRIPT_TEST_H diff --git a/tests/units/disableshortcutstest.cpp b/tests/units/disableshortcutstest.cpp new file mode 100644 index 0000000..38afed0 --- /dev/null +++ b/tests/units/disableshortcutstest.cpp @@ -0,0 +1,46 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "disableshortcutstest.h" +#include +#include +#include +#include +#include + + +void DisableShortcutsTest::test() { + + TestUtils utils; + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; +#else + QString bin = TestBinDir + "TestOnlyC.exe"; +#endif + + auto cb = [](const DeployConfig * config){ + const auto list = config->getTargetsListByFilter("TestOnlyC"); + // Check shrtcut option. all targets should be return false. + for (auto target: list) { + QVERIFY(!target->getShortCut()); + } + }; + + // Run deploy installer + runTestParams({"-bin", bin, "clear", + "-disableShortCut", "TestOnlyC", + "qif", "qifFromSystem"}, + nullptr, + false, + false, + exitCodes::Good, + cb); + + +} diff --git a/tests/units/disableshortcutstest.h b/tests/units/disableshortcutstest.h new file mode 100644 index 0000000..48ee471 --- /dev/null +++ b/tests/units/disableshortcutstest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef DIABLE_SHORTCUTS_TEST_H +#define DIABLE_SHORTCUTS_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class DisableShortcutsTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // DIABLE_SHORTCUTS_TEST_H diff --git a/tests/units/emptypackagestest.cpp b/tests/units/emptypackagestest.cpp new file mode 100644 index 0000000..af1c43c --- /dev/null +++ b/tests/units/emptypackagestest.cpp @@ -0,0 +1,37 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "emptypackagestest.h" +#include +#include +#include +#include +#include + + +void EmptyPackagesTest::test() { + + TestUtils utils; + auto comapareTree = TestModule.onlyC(); + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; +#else + QString bin = TestBinDir + "TestOnlyC.exe"; +#endif + + runTestParams({"-bin", bin, "force-clear", + "-prefix", "package;prefix"}, nullptr, false, false, + exitCodes::PrepareError); + + runTestParams({"-bin", bin, "force-clear", + "-targetPackage", "/package/;NONE", + "-libDir", TestQtDir + "bin", + "-prefix", "package;prefix", + "allowEmptyPackages"}, &comapareTree); +} diff --git a/tests/units/emptypackagestest.h b/tests/units/emptypackagestest.h new file mode 100644 index 0000000..a3fd40a --- /dev/null +++ b/tests/units/emptypackagestest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef EMPTY_PACKAGES_TEST_H +#define EMPTY_PACKAGES_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class EmptyPackagesTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // EMPTY_PACKAGES_TEST_H diff --git a/tests/units/iconstest.cpp b/tests/units/iconstest.cpp new file mode 100644 index 0000000..c65864f --- /dev/null +++ b/tests/units/iconstest.cpp @@ -0,0 +1,136 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "iconstest.h" +#include +#include +#include +#include +#include + + +void IconsTest::test() { + TestUtils utils; + + auto initTargets = [](ConfigParser * deploy, const QStringList& params) { + QVERIFY(QuasarAppUtils::Params::parseParams(params)); + + auto bin = QuasarAppUtils::Params::getArg("bin"). + split(DeployCore::getSeparator(0), splitbehavior); + + + QVERIFY(deploy->setTargets(bin)); + + deploy->configureTargets(); + }; + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; + QStringList binMulti = {TestBinDir + "TestOnlyC" , TestBinDir + "TestCPPOnly"}; + +#else + QString bin = TestBinDir + "TestOnlyC.exe"; + QStringList binMulti = {TestBinDir + "TestOnlyC.exe" , TestBinDir + "TestCPPOnly.exe"}; + +#endif + + FileManager file; + DependenciesScanner scan; + Packing pac(&file); + PluginsParser _pluginParser; + + + // Test default icons + ConfigParser *deploy = new ConfigParser(&file, &_pluginParser, &scan, &pac); + + initTargets(deploy, {"-bin", bin, + "force-clear", + }); + + auto targetsMap = deploy->_config.getTargetsListByFilter("TestOnlyC"); + auto targetinfo = targetsMap.begin().value(); + QVERIFY(targetinfo->getName().contains("TestOnlyC")); + auto icon = QFileInfo(targetinfo->getIcon()); + +#ifdef Q_OS_UNIX + QVERIFY(icon.fileName() == "Icon.png"); +#else + QVERIFY(icon.fileName() == "Icon.ico"); + +#endif + delete deploy; + + // Test multiple targets icons (sets for all targets on icon) + deploy = new ConfigParser(&file, &_pluginParser, &scan, &pac); + + initTargets(deploy, {"-bin", binMulti.join(","), + "force-clear", + "-icon", ":/testResurces/testRes/TestIcon.png", + }); + + for (const auto &target : qAsConst(binMulti)) { + QFileInfo tarInfo(target); + + targetsMap = deploy->_config.getTargetsListByFilter(tarInfo.baseName()); + targetinfo = targetsMap.begin().value(); + QVERIFY(targetinfo->getName().contains(tarInfo.baseName())); + icon = QFileInfo(targetinfo->getIcon()); + + QVERIFY(icon.fileName() == "TestIcon.png"); + } + + delete deploy; + + + // Test multiple targets icons (sets only one icon) + deploy = new ConfigParser(&file, &_pluginParser, &scan, &pac); + + initTargets(deploy, {"-bin", binMulti.join(","), + "force-clear", + "-icon", "TestOnlyC;:/testResurces/testRes/TestIcon.png", + }); + + + targetsMap = deploy->_config.getTargetsListByFilter("TestOnlyC"); + targetinfo = targetsMap.begin().value(); + QVERIFY(targetinfo->getName().contains("TestOnlyC")); + icon = QFileInfo(targetinfo->getIcon()); + + QVERIFY(icon.fileName() == "TestIcon.png"); + + + delete deploy; + + // manual tests +#ifdef QT_DEBUG +#ifdef Q_OS_UNIX + bin = TestBinDir + "TestOnlyC," + TestBinDir + "TestCPPOnly"; + + auto comapareTree = utils.createTree({ + "./" + DISTRO_DIR + "/InstallerTest.run", + "./" + DISTRO_DIR + "/InstallerTest.run.md5", + }); + +#else + bin = TestBinDir + "TestOnlyC.exe," + TestBinDir + "TestCPPOnly.exe"; + + auto comapareTree = utils.createTree({ + "./" + DISTRO_DIR + "/InstallerTest.exe", + "./" + DISTRO_DIR + "/InstallerTest.exe.md5", + + }); + +#endif + + runTestParams({"-bin", bin, "clear" , + "qif", "qifFromSystem", "-name", "Test", + "-targetPackage", "testPackage;TestOnlyC;TestCPPOnly", + "-icon", "TestOnlyC;:/testResurces/testRes/TestIcon.png,TestCPPOnly;:/testResurces/testRes/TestTr.qm"}, &comapareTree, true); + +#endif +} diff --git a/tests/units/iconstest.h b/tests/units/iconstest.h new file mode 100644 index 0000000..a12591d --- /dev/null +++ b/tests/units/iconstest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef ICONS_TEST_H +#define ICONS_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class IconsTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // ICONS_TEST_H diff --git a/tests/units/md5test.cpp b/tests/units/md5test.cpp new file mode 100644 index 0000000..a028c24 --- /dev/null +++ b/tests/units/md5test.cpp @@ -0,0 +1,69 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "md5test.h" +#include +#include +#include +#include +#include + + +void MD5Test::test() { + // This test will check hashes + + TestUtils utils; + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; + auto outFile = "./" + DISTRO_DIR + "/InstallerTestOnlyC.run"; + +#else + QString bin = TestBinDir + "TestOnlyC.exe"; + auto outFile = "./" + DISTRO_DIR + "/InstallerTestOnlyC.exe"; + +#endif + + auto comapareTreeqif = utils.createTree( + { + outFile, + outFile + ".md5" + }); + + // Run deploy installer + runTestParams({"-bin", bin, + "force-clear", + "qif", + "qifFromSystem"}, &comapareTreeqif); + + QFile file(outFile); + QVERIFY(file.open(QIODevice::ReadOnly)); + auto binaryData = file.readAll(); + file.close(); + + file.setFileName(outFile + ".md5"); + QVERIFY(file.open(QIODevice::ReadOnly)); + auto hash = file.readAll(); + file.close(); + + // Compare hash sum of the installer with realy hash sum of the object. + QVERIFY(QCryptographicHash::hash(binaryData, QCryptographicHash::Md5).toHex() == hash); + + + comapareTreeqif = utils.createTree( + { + outFile, + }); + + // Check noHashSum option. CQtDeployer must be skip calculating a hash sum of an installer. + runTestParams({"-bin", bin, + "force-clear", + "noHashSum", + "qif", + "qifFromSystem"}, &comapareTreeqif); +} diff --git a/tests/units/md5test.h b/tests/units/md5test.h new file mode 100644 index 0000000..664d4fb --- /dev/null +++ b/tests/units/md5test.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef MD5_TEST_H +#define MD5_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class MD5Test: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // MD5_TEST_H diff --git a/tests/units/overridingtemplatedebtest.cpp b/tests/units/overridingtemplatedebtest.cpp new file mode 100644 index 0000000..594b82c --- /dev/null +++ b/tests/units/overridingtemplatedebtest.cpp @@ -0,0 +1,78 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "overridingtemplatedebtest.h" +#include +#include +#include +#include +#include + + +void OverridingDefaultTemplateDEBTest::test() { + TestUtils utils; + + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC" + "," + TestBinDir + "TestCPPOnly"; + QString qmake = TestQtDir + "bin/qmake"; + + QDir tempalteDir("temaplate"); + if (!tempalteDir.isEmpty()) { + tempalteDir.removeRecursively(); + }; + + auto comapareTree = utils.createTree( + { + "temaplate/defaultDEBTemplate/Test/DEBIAN/control", + "temaplate/defaultDEBTemplate/Test/DEBIAN/postinst", + "temaplate/defaultDEBTemplate/Test/DEBIAN/prerm" + }); + QFile appScript("temaplate/defaultDEBTemplate/Test/DEBIAN/control"); + appScript.remove(); + + runTestParams( + {"force-clear", + "getDefaultTemplate", + "-name", "Test", + "deb", + "-targetDir", "temaplate", + "-targetPackage", "MyApp" + }, &comapareTree); + + comapareTree = utils.createTree( + { + "./" + DISTRO_DIR + "/Test.deb", + "./" + DISTRO_DIR + "/Test.deb.md5", + + }); + + runTestParams( + {"force-clear", + "-deb", "temaplate/defaultDEBTemplate", + "-targetPackage", "MyApp", + "-name", "Test", + "-qmake", qmake + }, &comapareTree, false, false); + + + QVERIFY(appScript.open(QIODevice::WriteOnly)); + QVERIFY(appScript.write(QByteArray{"ERROR"})); + appScript.close(); + + runTestParams( + {"-bin", bin, + "force-clear", + "-deb", "temaplate/defaultDEBTemplate", + "-targetPackage", "MyApp", + "-name", "Test", + "-qmake", qmake + }, nullptr, false, false, exitCodes::PackingError); +#endif + +} diff --git a/tests/units/overridingtemplatedebtest.h b/tests/units/overridingtemplatedebtest.h new file mode 100644 index 0000000..09497cb --- /dev/null +++ b/tests/units/overridingtemplatedebtest.h @@ -0,0 +1,26 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef OVERRIDE_TEMPLATE_DEB_TEST_H +#define OVERRIDE_TEMPLATE_DEB_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class OverridingDefaultTemplateDEBTest: public TestBase, protected TestUtils +{ +public: + StripTest(); + ~StripTest(); + + void test(); + +}; + +#endif // OVERRIDE_TEMPLATE_DEB_TEST_H diff --git a/tests/units/overridingtemplateqifwtest.cpp b/tests/units/overridingtemplateqifwtest.cpp new file mode 100644 index 0000000..55859f5 --- /dev/null +++ b/tests/units/overridingtemplateqifwtest.cpp @@ -0,0 +1,100 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "overridingtemplateqifwtest.h" +#include +#include +#include +#include +#include + + +void OverridingDefaultTemplateQIFWTest::test() { + TestUtils utils; + // Prepare bin and qmake values +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC" + "," + TestBinDir + "TestCPPOnly"; + QString qmake = TestQtDir + "bin/qmake"; + +#else + QString bin = TestBinDir + "TestOnlyC.exe" + "," + TestBinDir + "TestCPPOnly.exe"; + QString qmake = TestQtDir + "bin/qmake.exe"; + +#endif + QDir tempalteDir("temaplate"); + if (!tempalteDir.isEmpty()) { + tempalteDir.removeRecursively(); + }; + + // QIF case. prepare default template. + auto comapareTree = utils.createTree( + { + "temaplate/defaultQIFWTemplate/config/config.xml", + "temaplate/defaultQIFWTemplate/config/controlScript.qs", + "temaplate/defaultQIFWTemplate/packages/MyApp/meta/installscript.qs", + "temaplate/defaultQIFWTemplate/packages/MyApp/meta/package.xml" + }); + QFile appScript("temaplate/defaultQIFWTemplate/packages/MyApp/meta/installscript.qs"); + appScript.remove(); + + // This command shold be deploy default template in the template folder + runTestParams( + {"-bin", bin, + "force-clear", + "getDefaultTemplate", + "-name", "Test", + "qif", + "-targetDir", "temaplate", + "-targetPackage", "MyApp" + }, &comapareTree); + +#ifdef Q_OS_UNIX + comapareTree = utils.createTree( + { + "./" + DISTRO_DIR + "/InstallerTest.run", + "./" + DISTRO_DIR + "/InstallerTest.run.md5", + }); + +#else + comapareTree = utils.createTree( + { + "./" + DISTRO_DIR + "/InstallerTest.exe", + "./" + DISTRO_DIR + "/InstallerTest.exe.md5", + }); + +#endif + + // check deploy application with custom template + runTestParams( + {"-bin", bin, + "force-clear", + "-qif", "temaplate/defaultQIFWTemplate", + "-targetPackage", "MyApp", + "-name", "Test", + "-qmake", qmake, + "qifFromSystem" + }, &comapareTree, false, false); + + QVERIFY(appScript.open(QIODevice::WriteOnly)); + QVERIFY(appScript.write(QByteArray{"ERROR"})); + appScript.close(); + + // Shold be failde because we added error string into template files. + runTestParams( + {"-bin", bin, + "force-clear", + "-qif", "temaplate/defaultQIFWTemplate", + "-targetPackage", "MyApp", + "-name", "Test", + "-qmake", qmake, + "qifFromSystem" + }, nullptr, false, false, exitCodes::PackingError); + + + +} diff --git a/tests/units/overridingtemplateqifwtest.h b/tests/units/overridingtemplateqifwtest.h new file mode 100644 index 0000000..6833195 --- /dev/null +++ b/tests/units/overridingtemplateqifwtest.h @@ -0,0 +1,24 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef OVERRIDE_TEMPLATE_QIFW_TEST_H +#define OVERRIDE_TEMPLATE_QIFW_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class OverridingDefaultTemplateQIFWTest: public TestBase, protected TestUtils +{ +public: + + void test(); + +}; + +#endif // OVERRIDE_TEMPLATE_QIFW_TEST_H diff --git a/tests/units/pathutilstest.cpp b/tests/units/pathutilstest.cpp new file mode 100644 index 0000000..17c2221 --- /dev/null +++ b/tests/units/pathutilstest.cpp @@ -0,0 +1,85 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "pathutilstest.h" +#include +#include +#include +#include +#include + + +void PathUtilsTest::test() { + + // test getName + QMap cases = { + {"",""}, + {"test","test"}, + {"t","t"}, + {"/","/"}, + {"/test","test"}, + {"/t","t"}, + {"/test/","test"}, + {"/t/","t"}, + + {"/check/test","test"}, + {"/check/t","t"}, + {"/check/test/","test"}, + {"/check/t/","t"}, + + {"C:\\","C:"}, + {"\\","/"}, + {"\\test","test"}, + {"\\t","t"}, + {"\\test\\","test"}, + {"\\t\\","t"}, + + }; + + for (auto it = cases.begin(); it != cases.end(); ++it) { + if (PathUtils::getName(it.key()) != it.value()) + QVERIFY(false); + } + + struct Result { + QString result; + QString newPath; + }; + + // test popItem + QMap popItemCases = { + {"", {"", ""}}, + {"test", {"test", ""}}, + {"t", {"t", ""}}, + {"/", {"/", ""}}, + {"/test", {"test", "/"}}, + {"/t", {"t", "/"}}, + {"/test/", {"test", "/"}}, + {"/t/", {"t", "/"} }, + + {"/check/test", {"test", "/check/"}}, + {"/check/t", {"t", "/check/"}}, + {"/check/test/", {"test", "/check/"}}, + {"/check/t/", {"t", "/check/"}}, + + {"C:\\", {"C:", ""}}, + {"\\", {"/", ""}}, + {"\\test", {"test", "/"}}, + {"\\t", {"t", "/"}}, + {"\\test\\", {"test", "/"}}, + {"\\t\\", {"t", "/"}}, + + }; + + for (auto it = popItemCases.begin(); it != popItemCases.end(); ++it) { + QString path = it.key(); + QString result = PathUtils::popItem(path); + if (path != it.value().newPath || result != it.value().result) + QVERIFY(false); + } +} diff --git a/tests/units/pathutilstest.h b/tests/units/pathutilstest.h new file mode 100644 index 0000000..eb7c8d7 --- /dev/null +++ b/tests/units/pathutilstest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef PATH_UTILS_TEST_H +#define PATH_UTILS_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class PathUtilsTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // PATH_UTILS_TEST_H diff --git a/tests/units/runscriptstest.cpp b/tests/units/runscriptstest.cpp new file mode 100644 index 0000000..d3030fa --- /dev/null +++ b/tests/units/runscriptstest.cpp @@ -0,0 +1,60 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "runscriptstest.h" +#include +#include +#include +#include +#include + + +void RunScriptsTest::test() { + + TestUtils utils; + auto comapareTree = TestModule.onlyC(); + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; + + QFile f(":/testResurces/testRes/customRunScript.sh"); + QVERIFY(f.open(QIODevice::ReadOnly)); + auto etalonData = f.readAll(); + f.close(); + + runTestParams({"-bin", bin, + "force-clear", + "-libOut", "lib", + "-runScript", "TestOnlyC;:/testResurces/testRes/customRunScript.sh"}, &comapareTree); + + f.setFileName(DISTRO_DIR + "/TestOnlyC.sh"); + QVERIFY(f.open(QIODevice::ReadOnly)); + auto deployData = f.readAll(); + + QVERIFY(deployData == etalonData); +#else + QString bin = TestBinDir + "TestOnlyC.exe"; + + QFile f(":/testResurces/testRes/customRunScript.sh"); + QVERIFY(f.open(QIODevice::ReadOnly)); + auto etalonData = f.readAll(); + f.close(); + + runTestParams({"-bin", bin, + "force-clear", + "-libOut", "lib", + "-runScript", "TestOnlyC.exe;:/testResurces/testRes/customRunScript.sh"}, nullptr); + + f.setFileName(DISTRO_DIR + "/TestOnlyC.bat"); + QVERIFY(f.open(QIODevice::ReadOnly)); + auto deployData = f.readAll(); + + QVERIFY(deployData == etalonData); +#endif + +} diff --git a/tests/units/runscriptstest.h b/tests/units/runscriptstest.h new file mode 100644 index 0000000..c7096f9 --- /dev/null +++ b/tests/units/runscriptstest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef RUN_SCRIPTS_TEST_H +#define RUN_SCRIPTS_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class RunScriptsTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // RUN_SCRIPTS_TEST_H diff --git a/tests/units/trtest.cpp b/tests/units/trtest.cpp new file mode 100644 index 0000000..37e5087 --- /dev/null +++ b/tests/units/trtest.cpp @@ -0,0 +1,36 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "trtest.h" +#include +#include +#include +#include +#include + + +void TrTest::test() { + TestUtils utils; +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "TestOnlyC"; + +#else + QString bin = TestBinDir + "TestOnlyC.exe"; + +#endif + + runTestParams({"-bin", bin, "clear" , + "-tr", ":/testResurces/testRes/TestTr.qm",}); + + QVERIFY(QFile::exists("./" + DISTRO_DIR + "/translations/TestTr.qm")); + + runTestParams({"-bin", bin, "clear" , + "-tr", ":/testResurces/testRes/"}); + + QVERIFY(QFile::exists("./" + DISTRO_DIR + "/translations/TestTr.qm")); +} diff --git a/tests/units/trtest.h b/tests/units/trtest.h new file mode 100644 index 0000000..e549816 --- /dev/null +++ b/tests/units/trtest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef TR_TEST_H +#define TR_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class TrTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // TR_TEST_H diff --git a/tests/units/virtualkeybordtest.cpp b/tests/units/virtualkeybordtest.cpp new file mode 100644 index 0000000..bdb2a7c --- /dev/null +++ b/tests/units/virtualkeybordtest.cpp @@ -0,0 +1,32 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "virtualkeybordtest.h" +#include +#include +#include +#include +#include + + +void VirtualKeyBoardTest::test() { + TestUtils utils; + +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "basic"; + QString qmake = TestQtDir + "bin/qmake"; +#else + QString bin = TestBinDir + "basic.exe"; + QString qmake = TestQtDir + "bin/qmake.exe"; +#endif + auto comapareTree = TestModule.qmlVirtualKeyBoadrLibs(); + + runTestParams({"-bin", bin, "clear" , + "-qmake", qmake, + "-qmlDir", TestBinDir + "/../virtualkeyboard"}, &comapareTree); +} diff --git a/tests/units/virtualkeybordtest.h b/tests/units/virtualkeybordtest.h new file mode 100644 index 0000000..39bc09c --- /dev/null +++ b/tests/units/virtualkeybordtest.h @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef VIRTUAL_KEYBORD_TEST_H +#define VIRTUAL_KEYBORD_TEST_H +#include "testbase.h" +#include "testutils.h" + +#include + +class VirtualKeyBoardTest: public TestBase, protected TestUtils +{ +public: + void test() override; + +}; + +#endif // VIRTUAL_KEYBORD_TEST_H