Files
EZ4Connect/tests/profilemanager_test.cpp
2026-08-10 19:04:20 +08:00

41 lines
1.0 KiB
C++

#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <QTemporaryDir>
#include "infrastructure/settings/profilemanager.h"
namespace
{
bool createsPhysicalFilesForEmptyProfiles()
{
QTemporaryDir directory;
ProfileManager manager(directory.path());
if (!manager.activeProfile().isEmpty()
|| !QFileInfo::exists(manager.profilePath(""))
|| !manager.setActiveProfile(""))
{
qCritical() << "default profile file was not created";
return false;
}
const QString profileId = manager.createProfile("empty");
if (profileId != "empty"
|| !QFileInfo::exists(manager.profilePath(profileId))
|| !manager.listProfiles().contains(profileId)
|| !manager.setActiveProfile(profileId))
{
qCritical() << "empty named profile file was not created";
return false;
}
return true;
}
}
int main(int argc, char *argv[])
{
QCoreApplication application(argc, argv);
return createsPhysicalFilesForEmptyProfiles() ? 0 : 1;
}