Commit 58d38f97 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to create autotest for overriding config

parent 99174d65
Pipeline #26384 passed with stage
in 14 minutes and 1 second
......@@ -76,6 +76,16 @@ bool ImportAlarmJobInterface::isAConfigFile(const QString &name) const
|| name.contains(QLatin1String("akonadi_kalarm_dir_resource_")));
}
QString ImportAlarmJobInterface::configLocation() const
{
return installConfigLocation();
}
QString ImportAlarmJobInterface::installConfigLocation() const
{
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/');
}
void ImportAlarmJobInterface::restoreConfig()
{
increaseProgressDialog();
......@@ -84,13 +94,14 @@ void ImportAlarmJobInterface::restoreConfig()
const KArchiveEntry *kalarmrcentry = mArchiveDirectory->entry(Utils::configsPath() + kalarmStr);
if (kalarmrcentry && kalarmrcentry->isFile()) {
const KArchiveFile *kalarmrcFile = static_cast<const KArchiveFile *>(kalarmrcentry);
const QString kalarmrc = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + kalarmStr;
if (QFileInfo::exists(kalarmrc)) {
const QString searchExistingkalarmrc = configLocation() + kalarmStr;
const QString installPathkalarmrc = installConfigLocation() + kalarmStr;
if (QFileInfo::exists(searchExistingkalarmrc)) {
if (overwriteConfigMessageBox(kalarmStr)) {
importkalarmConfig(kalarmrcFile, kalarmrc, kalarmStr, Utils::configsPath());
importkalarmConfig(kalarmrcFile, installPathkalarmrc, kalarmStr, Utils::configsPath());
}
} else {
importkalarmConfig(kalarmrcFile, kalarmrc, kalarmStr, Utils::configsPath());
importkalarmConfig(kalarmrcFile, installPathkalarmrc, kalarmStr, Utils::configsPath());
}
}
restoreUiRcFile(QStringLiteral("kalarmui.rc"), QStringLiteral("kalarm"));
......
......@@ -39,10 +39,12 @@ protected:
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
void restoreResources();
virtual Q_REQUIRED_RESULT QString configLocation() const;
private:
Q_REQUIRED_RESULT bool isAConfigFile(const QString &name) const override;
void importkalarmConfig(const KArchiveFile *kalarmFile, const QString &kalarmrc, const QString &filename, const QString &prefix);
void restoreConfig();
Q_REQUIRED_RESULT QString installConfigLocation() const;
};
#endif // IMPORTALARMJOBINTERFACE_H
......@@ -46,14 +46,16 @@ void ImportAlarmJobInterfaceTest::importAlarmConfig()
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
QFETCH(Utils::StoredTypes, options);
TestImportFile *file = new TestImportFile(zipFilePath + testPath, this);
file->setPathConfig(zipFilePath + testPath);
const QString fullTestPath = zipFilePath + testPath;
TestImportFile *file = new TestImportFile(fullTestPath, this);
file->setPathConfig(fullTestPath);
file->setExtractPath(QDir::tempPath() + testPath);
file->setExcludePath(Utils::alarmPath());
ImportAlarmJobInterfaceTestImpl *impl = new ImportAlarmJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
impl->setPathConfig(file->pathConfig());
impl->setExtractPath(file->extractPath());
impl->setTempDirName(file->extractPath());
impl->setExistingPathConfig(fullTestPath + QStringLiteral("/existingconfig/"));
file->setAbstractImportExportJob(impl);
file->setLoggingFilePath(impl->loggingFilePath());
file->start();
......
......@@ -67,3 +67,13 @@ QString ImportAlarmJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResou
resourceConverterTest.setTestPath(mPathConfig);
return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath);
}
void ImportAlarmJobInterfaceTestImpl::setExistingPathConfig(const QString &path)
{
mExistingPathConfig = path;
}
QString ImportAlarmJobInterfaceTestImpl::configLocation() const
{
return mExistingPathConfig;
}
......@@ -31,12 +31,16 @@ public:
explicit ImportAlarmJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportAlarmJobInterfaceTestImpl();
void setExistingPathConfig(const QString &path);
protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree = false) override;
void synchronizeResource(const QStringList &lst) override;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
Q_REQUIRED_RESULT QString configLocation() const override;
private:
QString mExistingPathConfig;
};
#endif // IMPORTALARMJOBINTERFACETESTIMPL_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment