mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[contextualprocess] Add tests
- Tests showed issues with memory management, fixed in previous commits.
This commit is contained in:
parent
23a23a01f1
commit
713add5795
3 changed files with 127 additions and 0 deletions
|
@ -7,3 +7,22 @@ calamares_add_plugin( contextualprocess
|
||||||
calamares
|
calamares
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if( ECM_FOUND )
|
||||||
|
find_package( Qt5 COMPONENTS Test REQUIRED )
|
||||||
|
include( ECMAddTests )
|
||||||
|
|
||||||
|
ecm_add_test(
|
||||||
|
Tests.cpp
|
||||||
|
ContextualProcessJob.cpp # Builds it a second time
|
||||||
|
TEST_NAME
|
||||||
|
contextualprocesstest
|
||||||
|
LINK_LIBRARIES
|
||||||
|
${CALAMARES_LIBRARIES}
|
||||||
|
calamaresui
|
||||||
|
${YAMLCPP_LIBRARY}
|
||||||
|
Qt5::Core
|
||||||
|
Qt5::Test
|
||||||
|
)
|
||||||
|
set_target_properties( contextualprocesstest PROPERTIES AUTOMOC TRUE )
|
||||||
|
endif()
|
||||||
|
|
71
src/modules/contextualprocess/Tests.cpp
Normal file
71
src/modules/contextualprocess/Tests.cpp
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Tests.h"
|
||||||
|
#include "ContextualProcessJob.h"
|
||||||
|
|
||||||
|
#include "utils/CommandList.h"
|
||||||
|
#include "utils/YamlUtils.h"
|
||||||
|
|
||||||
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
QTEST_GUILESS_MAIN( ContextualProcessTests )
|
||||||
|
|
||||||
|
using CommandList = CalamaresUtils::CommandList;
|
||||||
|
|
||||||
|
ContextualProcessTests::ContextualProcessTests()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextualProcessTests::~ContextualProcessTests()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ContextualProcessTests::initTestCase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ContextualProcessTests::testProcessListSampleConfig()
|
||||||
|
{
|
||||||
|
YAML::Node doc;
|
||||||
|
|
||||||
|
QStringList dirs { "src/modules/contextualprocess", "." };
|
||||||
|
for ( const auto& dir : dirs )
|
||||||
|
{
|
||||||
|
QString filename = dir + "/contextualprocess.conf";
|
||||||
|
if ( QFileInfo::exists( filename ) )
|
||||||
|
{
|
||||||
|
doc = YAML::LoadFile( filename.toStdString() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextualProcessJob job;
|
||||||
|
job.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc ).toMap() );
|
||||||
|
|
||||||
|
QCOMPARE(job.count(), 1); // Only "firmwareType"
|
||||||
|
QCOMPARE(job.count("firmwareType"), 4);
|
||||||
|
}
|
||||||
|
|
37
src/modules/contextualprocess/Tests.h
Normal file
37
src/modules/contextualprocess/Tests.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TESTS_H
|
||||||
|
#define TESTS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class ContextualProcessTests : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ContextualProcessTests();
|
||||||
|
~ContextualProcessTests() override;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void initTestCase();
|
||||||
|
// Check the sample config file is processed correctly
|
||||||
|
void testProcessListSampleConfig();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue