From 0fcfdebf88372d527008ff0a080bf0f9eb493c9a Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Fri, 15 May 2020 10:51:37 +0300 Subject: Add new no-default-installations option This option can be used both from CLI and from GUI. Option will overwrite Default true in component.xml, which means that in GUI the components are not selected by default, and in CLI the components are not installed unless those are given as argument to install -command. Task-number:QTIFW-1630 Change-Id: I5dc16b14fc136f421980a55bb5fc6a74213309dc Reviewed-by: Iikka Eklund --- .../componentmodel/tst_componentmodel.cpp | 56 +++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp index d5cae916c..220aa73e3 100644 --- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp +++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp @@ -1,3 +1,31 @@ +/************************************************************************** +** +** 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 "component.h" #include "componentmodel.h" #include "updatesinfo_p.h" @@ -38,7 +66,8 @@ public: enum Option { NoFlags = 0x00, VirtualsVisible = 0x01, - NoForcedInstallation = 0x02 + NoForcedInstallation = 0x02, + NoDefaultInstallation = 0x04 }; Q_DECLARE_FLAGS(Options, Option); @@ -358,11 +387,30 @@ private slots: } } + void testNoDefaultInstallation() + { + setPackageManagerOptions(NoDefaultInstallation); + + QList rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + model.setCheckedState(ComponentModel::DefaultChecked); + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, QStringList() << vendorProduct, QStringList(), m_defaultUnchecked + + m_uncheckable + m_defaultPartially + QStringList() << vendorSecondProductSub); + } + private: void setPackageManagerOptions(Options flags) const { m_core.setNoForceInstallation(flags.testFlag(NoForcedInstallation)); m_core.setVirtualComponentsVisible(flags.testFlag(VirtualsVisible)); + m_core.setNoDefaultInstallation(flags.testFlag(NoDefaultInstallation)); } void testComponentsLoaded(const QList &rootComponents) const @@ -472,7 +520,10 @@ private: // we need at least these to be able to test the model component->setValue("Name", info.data.value("Name").toString()); - component->setValue("Default", info.data.value("Default").toString()); + QString isDefault = info.data.value("Default").toString(); + if (m_core.noDefaultInstallation()) + isDefault = scFalse; + component->setValue("Default", isDefault); component->setValue("Virtual", info.data.value("Virtual").toString()); component->setValue("DisplayName", info.data.value("DisplayName").toString()); component->setValue("Checkable", info.data.value("Checkable").toString()); @@ -516,6 +567,7 @@ private: QStringList m_defaultPartially; QStringList m_defaultUnchecked; QStringList m_uncheckable; + QStringList m_defaultNoChecked; }; Q_DECLARE_OPERATORS_FOR_FLAGS(tst_ComponentModel::Options) -- cgit v1.2.3