Add Fedora Tools settings module
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "toolmodel.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
class ToolModelTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void mergesInstalledAndAvailablePackages()
|
||||
{
|
||||
ToolModel model;
|
||||
const PackageRecord installed{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-5.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};
|
||||
const PackageRecord available{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-6.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};
|
||||
|
||||
model.setPackages({installed}, {available}, {QStringLiteral("touchpad-hold-tap")});
|
||||
|
||||
QCOMPARE(model.rowCount(), 1);
|
||||
const QModelIndex index = model.index(0);
|
||||
QCOMPARE(model.data(index, ToolModel::InstalledRole).toBool(), true);
|
||||
QCOMPARE(model.data(index, ToolModel::AvailableRole).toBool(), true);
|
||||
QCOMPARE(model.data(index, ToolModel::UpdateAvailableRole).toBool(), true);
|
||||
QCOMPARE(model.mayInstall(QStringLiteral("touchpad-hold-tap")), true);
|
||||
}
|
||||
|
||||
void doesNotGuessUpdatesFromDifferentVersionStrings()
|
||||
{
|
||||
ToolModel model;
|
||||
const PackageRecord installed{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-7.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};
|
||||
const PackageRecord available{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-6.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};
|
||||
|
||||
model.setPackages({installed}, {available});
|
||||
|
||||
QCOMPARE(model.data(model.index(0), ToolModel::UpdateAvailableRole).toBool(), false);
|
||||
}
|
||||
|
||||
void makesFingerprintControllerConfigurable()
|
||||
{
|
||||
ToolModel model;
|
||||
const PackageRecord package{QStringLiteral("plasma-fingerprint-workaround"), QStringLiteral("0.1.0-2.fc44"), QStringLiteral("noarch"), QStringLiteral("Fingerprint")};
|
||||
model.setPackages({package}, {package});
|
||||
|
||||
QCOMPARE(model.data(model.index(0), ToolModel::ConfigurableRole).toBool(), true);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(ToolModelTest)
|
||||
|
||||
#include "test-toolmodel.moc"
|
||||
Reference in New Issue
Block a user