From 7be83635627ca1384862a8826de2d85979cdfc8e Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 22 Dec 2020 09:53:36 +0200 Subject: Allow disabling undo of GlobalSettings during uninstall Task-number: QTIFW-1973 Change-Id: I89f15c8ed7d56c3e1bc72d3c740e9054363f9390 Reviewed-by: Arttu Tarkiainen --- .../globalsettingsoperation.pro | 10 +++ .../tst_globalsettingsoperation.cpp | 95 ++++++++++++++++++++++ tests/auto/installer/installer.pro | 3 +- 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 tests/auto/installer/globalsettingsoperation/globalsettingsoperation.pro create mode 100644 tests/auto/installer/globalsettingsoperation/tst_globalsettingsoperation.cpp (limited to 'tests') 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 +#include +#include + +#include +#include + +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 \ -- cgit v1.2.3