[partition] Stub of a test of scandevice

This commit is contained in:
Adriaan de Groot 2021-08-31 13:16:45 +02:00
parent e294221a2d
commit 22ba21f937
2 changed files with 62 additions and 5 deletions

View File

@ -52,9 +52,6 @@ calamares_add_test(
CreateLayoutsTests.cpp
LIBRARIES
kpmcore
calamares
calamaresui
Qt5::Gui
DEFINITIONS ${_partition_defs}
)
@ -63,6 +60,10 @@ calamares_add_test(
SOURCES
${PartitionModule_SOURCE_DIR}/jobs/AutoMountManagementJob.cpp
AutoMountTests.cpp
LIBRARIES
calamares
)
calamares_add_test(
partitiondevicestest
SOURCES
DevicesTests.cpp
)

View File

@ -0,0 +1,56 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#include "core/DeviceList.h"
#include "utils/Logger.h"
#include <QObject>
#include <QtTest/QtTest>
class DevicesTests : public QObject
{
Q_OBJECT
public:
DevicesTests();
private Q_SLOTS:
void testKPMScanDevices();
void testPartUtilScanDevices();
};
DevicesTests::DevicesTests() {}
void
DevicesTests::testKPMScanDevices()
{
Logger::setupLogLevel( Logger::LOGVERBOSE );
#if defined( WITH_KPMCORE4API )
cDebug() << "Getting devices via KPMCore";
CoreBackend* backend = CoreBackendManager::self()->backend();
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
cDebug() << Logger::SubEntry << "Done getting devices.";
#else
cWarning() << "Test skipped; use KPMCore4";
#endif
}
void
DevicesTests::testPartUtilScanDevices()
{
Logger::setupLogLevel( Logger::LOGVERBOSE );
cDebug() << "Getting devices via PartUtils";
auto l = PartUtils::getDevices();
cDebug() << Logger::SubEntry << "Done getting devices.";
QVERIFY( l.count() > 0 );
}