summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-12-22 09:53:36 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-12-30 11:10:05 +0200
commit7be83635627ca1384862a8826de2d85979cdfc8e (patch)
tree5d25666643ae7de865f73b93ffa80bf3c97d594f /tests
parenta606c9915b8ff1d6001a83aa350400d6286706ff (diff)
Allow disabling undo of GlobalSettings during uninstall
Task-number: QTIFW-1973 Change-Id: I89f15c8ed7d56c3e1bc72d3c740e9054363f9390 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/globalsettingsoperation/globalsettingsoperation.pro10
-rw-r--r--tests/auto/installer/globalsettingsoperation/tst_globalsettingsoperation.cpp95
-rw-r--r--tests/auto/installer/installer.pro3
3 files changed, 107 insertions, 1 deletions
diff --git a/tests/auto/installer/globalsettingsoperation/globalsettingsoperation.pro b/tests/auto/installer/globalsettingsoperation/globalsettingsoperation.pro
new file mode 100644
index 000000000..ddae3b1d7
--- /dev/null
+++ b/tests/auto/installer/globalsettingsoperation/globalsettingsoperation.pro
@@ -0,0 +1,10 @@
+include(../../qttest.pri)
+
+QT -= gui
+QT += testlib
+
+SOURCES = tst_globalsettingsoperation.cpp
+
+RESOURCES += \
+ ..\shared\config.qrc
+
diff --git a/tests/auto/installer/globalsettingsoperation/tst_globalsettingsoperation.cpp b/tests/auto/installer/globalsettingsoperation/tst_globalsettingsoperation.cpp
new file mode 100644
index 000000000..009673f24
--- /dev/null
+++ b/tests/auto/installer/globalsettingsoperation/tst_globalsettingsoperation.cpp
@@ -0,0 +1,95 @@
+/**************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#include "../shared/packagemanager.h"
+
+#include <globalsettingsoperation.h>
+#include <environment.h>
+#include <packagemanagercore.h>
+
+#include <QSettings>
+#include <QTest>
+
+using namespace QInstaller;
+using namespace KDUpdater;
+
+class tst_globalsettingsoperation : public QObject
+{
+ Q_OBJECT
+
+private:
+ void cleanSettings()
+ {
+ QSettings testSettings("QtProject", "QtProject.QtIfwTest");
+ testSettings.setValue("QtIfwTestKey", "");
+ }
+
+
+private slots:
+ void initTestCase()
+ {
+ cleanSettings();
+ }
+
+ void cleanupTestCase()
+ {
+ cleanSettings();
+ }
+
+ void setGlobalSettingsValue()
+ {
+ GlobalSettingsOperation settingsOperation(nullptr);
+ settingsOperation.setArguments(QStringList() << "QtProject" << "QtProject.QtIfwTest" << "QtIfwTestKey" << "QtIfwTestValue");
+ settingsOperation.backup();
+ QVERIFY2(settingsOperation.performOperation(), settingsOperation.errorString().toLatin1());
+
+ QSettings testSettings("QtProject", "QtProject.QtIfwTest");
+ QCOMPARE("QtIfwTestValue", testSettings.value("QtIfwTestKey"));
+ QVERIFY2(settingsOperation.undoOperation(), settingsOperation.errorString().toLatin1());
+ QCOMPARE("", testSettings.value("QtIfwTestKey"));
+ }
+
+ void setGlobalSettingsValueNoUndo()
+ {
+
+ GlobalSettingsOperation settingsOperation(nullptr);
+ settingsOperation.setArguments(QStringList() << "QtProject" << "QtProject.QtIfwTest" << "QtIfwTestKey" << "QtIfwTestValue" << "UNDOOPERATION" << "");
+ settingsOperation.backup();
+ QVERIFY2(settingsOperation.performOperation(), settingsOperation.errorString().toLatin1());
+
+ QSettings testSettings("QtProject", "QtProject.QtIfwTest");
+ QCOMPARE("QtIfwTestValue", testSettings.value("QtIfwTestKey"));
+ QVERIFY2(settingsOperation.undoOperation(), settingsOperation.errorString().toLatin1());
+ QCOMPARE("QtIfwTestValue", testSettings.value("QtIfwTestKey"));
+ }
+};
+
+QTEST_MAIN(tst_globalsettingsoperation)
+
+#include "tst_globalsettingsoperation.moc"
+
diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro
index 81def2f76..2c55de40c 100644
--- a/tests/auto/installer/installer.pro
+++ b/tests/auto/installer/installer.pro
@@ -35,7 +35,8 @@ SUBDIRS += \
commandlineupdate \
moveoperation \
environmentvariableoperation \
- licenseagreement
+ licenseagreement \
+ globalsettingsoperation
win32 {
SUBDIRS += registerfiletypeoperation \