mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-27 18:24:33 +00:00
addee more ported tests
This commit is contained in:
parent
617f03cc0d
commit
ba8baf2d75
45
tests/units/binprefixtest.cpp
Normal file
45
tests/units/binprefixtest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
}
|
23
tests/units/binprefixtest.h
Normal file
23
tests/units/binprefixtest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class BinPrefixTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // BIN_PREFIX_TEST_H
|
35
tests/units/deploygeneralfilestest.cpp
Normal file
35
tests/units/deploygeneralfilestest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
23
tests/units/deploygeneralfilestest.h
Normal file
23
tests/units/deploygeneralfilestest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class DeployGeneralFilesTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // DEPLOY_GENERAL_FILES_TEST_H
|
64
tests/units/disablerunscripttest.cpp
Normal file
64
tests/units/disablerunscripttest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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
|
||||
|
||||
}
|
23
tests/units/disablerunscripttest.h
Normal file
23
tests/units/disablerunscripttest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class DisableRunScriptTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // DIABLE_RUN_SCRIPT_TEST_H
|
46
tests/units/disableshortcutstest.cpp
Normal file
46
tests/units/disableshortcutstest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
}
|
23
tests/units/disableshortcutstest.h
Normal file
23
tests/units/disableshortcutstest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class DisableShortcutsTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // DIABLE_SHORTCUTS_TEST_H
|
37
tests/units/emptypackagestest.cpp
Normal file
37
tests/units/emptypackagestest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
}
|
23
tests/units/emptypackagestest.h
Normal file
23
tests/units/emptypackagestest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class EmptyPackagesTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // EMPTY_PACKAGES_TEST_H
|
136
tests/units/iconstest.cpp
Normal file
136
tests/units/iconstest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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
|
||||
}
|
23
tests/units/iconstest.h
Normal file
23
tests/units/iconstest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class IconsTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // ICONS_TEST_H
|
69
tests/units/md5test.cpp
Normal file
69
tests/units/md5test.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
}
|
23
tests/units/md5test.h
Normal file
23
tests/units/md5test.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class MD5Test: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // MD5_TEST_H
|
78
tests/units/overridingtemplatedebtest.cpp
Normal file
78
tests/units/overridingtemplatedebtest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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
|
||||
|
||||
}
|
26
tests/units/overridingtemplatedebtest.h
Normal file
26
tests/units/overridingtemplatedebtest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class OverridingDefaultTemplateDEBTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
StripTest();
|
||||
~StripTest();
|
||||
|
||||
void test();
|
||||
|
||||
};
|
||||
|
||||
#endif // OVERRIDE_TEMPLATE_DEB_TEST_H
|
100
tests/units/overridingtemplateqifwtest.cpp
Normal file
100
tests/units/overridingtemplateqifwtest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
}
|
24
tests/units/overridingtemplateqifwtest.h
Normal file
24
tests/units/overridingtemplateqifwtest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class OverridingDefaultTemplateQIFWTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
|
||||
void test();
|
||||
|
||||
};
|
||||
|
||||
#endif // OVERRIDE_TEMPLATE_QIFW_TEST_H
|
85
tests/units/pathutilstest.cpp
Normal file
85
tests/units/pathutilstest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
void PathUtilsTest::test() {
|
||||
|
||||
// test getName
|
||||
QMap<QString, QString> 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<QString, Result> 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);
|
||||
}
|
||||
}
|
23
tests/units/pathutilstest.h
Normal file
23
tests/units/pathutilstest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class PathUtilsTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // PATH_UTILS_TEST_H
|
60
tests/units/runscriptstest.cpp
Normal file
60
tests/units/runscriptstest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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
|
||||
|
||||
}
|
23
tests/units/runscriptstest.h
Normal file
23
tests/units/runscriptstest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class RunScriptsTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // RUN_SCRIPTS_TEST_H
|
36
tests/units/trtest.cpp
Normal file
36
tests/units/trtest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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"));
|
||||
}
|
23
tests/units/trtest.h
Normal file
23
tests/units/trtest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class TrTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // TR_TEST_H
|
32
tests/units/virtualkeybordtest.cpp
Normal file
32
tests/units/virtualkeybordtest.cpp
Normal file
@ -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 <configparser.h>
|
||||
#include <dependenciesscanner.h>
|
||||
#include <filemanager.h>
|
||||
#include <packing.h>
|
||||
#include <pluginsparser.h>
|
||||
|
||||
|
||||
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);
|
||||
}
|
23
tests/units/virtualkeybordtest.h
Normal file
23
tests/units/virtualkeybordtest.h
Normal file
@ -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 <QtTest>
|
||||
|
||||
class VirtualKeyBoardTest: public TestBase, protected TestUtils
|
||||
{
|
||||
public:
|
||||
void test() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // VIRTUAL_KEYBORD_TEST_H
|
Loading…
x
Reference in New Issue
Block a user