From ba1209000a3175ce3b8f88829485c7c01efcc852 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 1 Dec 2015 10:50:22 +0200 Subject: Allow defining non-checkable items This change will introduce new element 'Checkable' for package. Setting checkable to false will hide checkbox. Useful if use case is to install one sub item instead of all sub items. Change-Id: I8c731e77353b6da539dddcecdc8495b28ef5f7ea Task-number: QTIFW-773 Reviewed-by: Niels Weber Reviewed-by: Iikka Eklund --- .../auto/installer/componentmodel/data/updates.xml | 46 ++++++++++ .../componentmodel/tst_componentmodel.cpp | 98 +++++++++++++--------- 2 files changed, 103 insertions(+), 41 deletions(-) (limited to 'tests') diff --git a/tests/auto/installer/componentmodel/data/updates.xml b/tests/auto/installer/componentmodel/data/updates.xml index cfd756a5c..2341866ee 100644 --- a/tests/auto/installer/componentmodel/data/updates.xml +++ b/tests/auto/installer/componentmodel/data/updates.xml @@ -131,4 +131,50 @@ file="license.txt"/> + + com.vendor.fourth.product.checkable + A checkable root component + Install this example. + 0.1.0-1 + 2010-09-21 + true + false + + + + + + + + com.vendor.fifth.product.noncheckable + A non-checkable root component + Install this example. + 0.1.0-1 + 2010-09-21 + + false + + + + + + + com.vendor.fifth.product.noncheckable.sub + A sub component for non-checkable root component + Install this example. + 0.1.0-1 + 2010-09-21 + + 0 + + + + + diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp index ea76bb2e6..5d86103a9 100644 --- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp +++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp @@ -9,8 +9,8 @@ using namespace KDUpdater; using namespace QInstaller; -#define EXPECTED_COUNT_VIRTUALS_VISIBLE 8 -#define EXPECTED_COUNT_VIRTUALS_INVISIBLE 7 +#define EXPECTED_COUNT_VIRTUALS_VISIBLE 11 +#define EXPECTED_COUNT_VIRTUALS_INVISIBLE 10 static const char vendorProduct[] = "com.vendor.product"; static const char vendorSecondProduct[] = "com.vendor.second.product"; @@ -20,6 +20,9 @@ static const char vendorSecondProductVirtual[] = "com.vendor.second.product.virt static const char vendorSecondProductSubnode[] = "com.vendor.second.product.subnode"; static const char vendorSecondProductSubnodeSub[] = "com.vendor.second.product.subnode.sub"; static const char vendorThirdProductVirtual[] = "com.vendor.third.product.virtual"; +static const char vendorFourthProductCheckable[] = "com.vendor.fourth.product.checkable"; +static const char vendorFifthProductNonCheckable[] = "com.vendor.fifth.product.noncheckable"; +static const char vendorFifthProductSub[] = "com.vendor.fifth.product.noncheckable.sub"; static const QMap rootComponentDisplayNames = { {"", QLatin1String("The root component")}, @@ -45,7 +48,9 @@ private slots: m_defaultChecked << vendorProduct << vendorSecondProductSub; m_defaultPartially << vendorSecondProduct; m_defaultUnchecked << vendorSecondProductSub1 << vendorSecondProductSubnode - << vendorSecondProductSubnodeSub; + << vendorSecondProductSubnodeSub << vendorFourthProductCheckable + << vendorFifthProductSub; + m_uncheckable << vendorFifthProductNonCheckable; } void testNameToIndexAndIndexToName() @@ -61,7 +66,7 @@ private slots: // all names should be resolvable, virtual components are not indexed if they are not visible QStringList all; - all << m_defaultChecked << m_defaultPartially << m_defaultUnchecked; + all << m_defaultChecked << m_defaultPartially << m_defaultUnchecked << m_uncheckable; foreach (const QString &name, all) { QVERIFY(model.indexFromComponentName(name).isValid()); QVERIFY(model.componentFromIndex(model.indexFromComponentName(name)) != 0); @@ -85,8 +90,8 @@ private slots: // all names should be resolvable, including virtual components QStringList all; - all << m_defaultChecked << m_defaultPartially << m_defaultUnchecked << vendorSecondProductVirtual - << vendorThirdProductVirtual; + all << m_defaultChecked << m_defaultPartially << m_defaultUnchecked << m_uncheckable + << vendorSecondProductVirtual << vendorThirdProductVirtual; foreach (const QString &name, all) { QVERIFY(model.indexFromComponentName(name).isValid()); QVERIFY(model.componentFromIndex(model.indexFromComponentName(name)) != 0); @@ -111,7 +116,8 @@ private slots: QCOMPARE(model.core(), &m_core); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked + + m_uncheckable); foreach (Component *const component, rootComponents) delete component; @@ -130,9 +136,10 @@ private slots: testDefaultInheritedModelBehavior(&model, 1); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); - // the virtual components are not checked - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked - + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); + // the virtual and non-checkable components are not checked + testModelState(&model, m_defaultChecked, m_defaultPartially, + m_defaultUnchecked + m_uncheckable + + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); foreach (Component *const component, rootComponents) delete component; @@ -151,7 +158,8 @@ private slots: testDefaultInheritedModelBehavior(&model, 1); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked + + m_uncheckable); foreach (Component *const component, rootComponents) delete component; @@ -171,7 +179,8 @@ private slots: QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); // the virtual components are not checked - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked + testModelState(&model, m_defaultChecked, m_defaultPartially, + m_defaultUnchecked + m_uncheckable + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); foreach (Component *const component, rootComponents) @@ -190,23 +199,24 @@ private slots: model.setRootComponents(rootComponents); testDefaultInheritedModelBehavior(&model, 1); - // select all possible components + // select all possible components. As one is uncheckable should result in partial check. model.setCheckedState(ComponentModel::AllChecked); - QCOMPARE(model.checkedState(), ComponentModel::AllChecked); - testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked, QStringList() - , QStringList()); + QCOMPARE(model.checkedState(), ComponentModel::PartiallyChecked); + testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked, + QStringList(), m_uncheckable); // deselect all possible components // as the first root is a forced install, should result in partially checked state model.setCheckedState(ComponentModel::AllUnchecked); QCOMPARE(model.checkedState(), ComponentModel::PartiallyChecked); testModelState(&model, QStringList() << vendorProduct, QStringList(), m_defaultPartially - + m_defaultUnchecked + QStringList(vendorSecondProductSub)); + + m_defaultUnchecked + QStringList(vendorSecondProductSub) + m_uncheckable); // reset all possible components model.setCheckedState(ComponentModel::DefaultChecked); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, + m_defaultUnchecked + m_uncheckable); foreach (Component *const component, rootComponents) delete component; @@ -224,25 +234,26 @@ private slots: model.setRootComponents(rootComponents); testDefaultInheritedModelBehavior(&model, 1); - // select all possible components + // select all possible components. As one is uncheckable should result to partially check model.setCheckedState(ComponentModel::AllChecked); - QCOMPARE(model.checkedState(), ComponentModel::AllChecked); + QCOMPARE(model.checkedState(), ComponentModel::PartiallyChecked); testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual, QStringList(), - QStringList()); + m_uncheckable); // deselect all possible components // as the first root is a forced install, should result in partially checked state model.setCheckedState(ComponentModel::AllUnchecked); QCOMPARE(model.checkedState(), ComponentModel::PartiallyChecked); testModelState(&model, QStringList() << vendorProduct, QStringList(), m_defaultPartially - + m_defaultUnchecked + QStringList(vendorSecondProductSub) << vendorSecondProductVirtual - << vendorThirdProductVirtual); + + m_defaultUnchecked + m_uncheckable + QStringList(vendorSecondProductSub) + << vendorSecondProductVirtual << vendorThirdProductVirtual); // reset all possible components model.setCheckedState(ComponentModel::DefaultChecked); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked + testModelState(&model, m_defaultChecked, m_defaultPartially, + m_defaultUnchecked + m_uncheckable + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); foreach (Component *const component, rootComponents) @@ -261,22 +272,24 @@ private slots: model.setRootComponents(rootComponents); testDefaultInheritedModelBehavior(&model, 1); - // select all possible components + // select all possible components. As one is uncheckable should result to partially check model.setCheckedState(ComponentModel::AllChecked); - QCOMPARE(model.checkedState(), ComponentModel::AllChecked); - testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked, QStringList() - , QStringList()); + QCOMPARE(model.checkedState(), ComponentModel::PartiallyChecked); + testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked, + QStringList(), m_uncheckable); // deselect all possible components model.setCheckedState(ComponentModel::AllUnchecked); QCOMPARE(model.checkedState(), ComponentModel::AllUnchecked); - testModelState(&model, QStringList(), QStringList(), m_defaultPartially + m_defaultUnchecked + testModelState(&model, QStringList(), QStringList(), m_defaultPartially + + m_defaultUnchecked + m_uncheckable + QStringList(vendorSecondProductSub) << vendorProduct); // reset all possible components model.setCheckedState(ComponentModel::DefaultChecked); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); - testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, + m_defaultUnchecked + m_uncheckable); foreach (Component *const component, rootComponents) delete component; @@ -294,25 +307,26 @@ private slots: model.setRootComponents(rootComponents); testDefaultInheritedModelBehavior(&model, 1); - // select all possible components + // select all possible components. As one is uncheckable should result to partially check model.setCheckedState(ComponentModel::AllChecked); - QCOMPARE(model.checkedState(), ComponentModel::AllChecked); + QCOMPARE(model.checkedState(), ComponentModel::PartiallyChecked); testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual, QStringList(), - QStringList()); + m_uncheckable); // deselect all possible components model.setCheckedState(ComponentModel::AllUnchecked); QCOMPARE(model.checkedState(), ComponentModel::AllUnchecked); - testModelState(&model, QStringList(), QStringList(), m_defaultPartially + m_defaultUnchecked - + QStringList(vendorSecondProductSub) << vendorSecondProductVirtual << vendorProduct - << vendorThirdProductVirtual); + testModelState(&model, QStringList(), QStringList(), m_defaultPartially + + m_defaultUnchecked + m_uncheckable + QStringList(vendorSecondProductSub) + << vendorSecondProductVirtual << vendorProduct << vendorThirdProductVirtual); // reset all possible components model.setCheckedState(ComponentModel::DefaultChecked); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked - + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); + + m_uncheckable + QStringList(vendorSecondProductVirtual) + << vendorThirdProductVirtual); foreach (Component *const component, rootComponents) delete component; @@ -352,8 +366,8 @@ private: void testComponentsLoaded(const QList &rootComponents) const { - // we need to have three root components - QCOMPARE(rootComponents.count(), 3); + // we need to have five root components + QCOMPARE(rootComponents.count(), 5); QList components = rootComponents; foreach (Component *const component, rootComponents) @@ -368,9 +382,9 @@ private: { // row count with invalid model index should return: if (m_core.virtualComponentsVisible()) - QCOMPARE(model->rowCount(), 3); // 3 (2 non virtual and 1 virtual root component) + QCOMPARE(model->rowCount(), 5); // 5 (4 non virtual and 1 virtual root component) else - QCOMPARE(model->rowCount(), 2); // 2 (the 2 non virtual root components) + QCOMPARE(model->rowCount(), 4); // 4 (the 4 non virtual root components) QCOMPARE(model->columnCount(), columnCount); const QModelIndex firstParent = model->indexFromComponentName(vendorProduct); @@ -460,6 +474,7 @@ private: component->setValue("Default", info.data.value("Default").toString()); component->setValue("Virtual", info.data.value("Virtual").toString()); component->setValue("DisplayName", info.data.value("DisplayName").toString()); + component->setValue("Checkable", info.data.value("Checkable").toString()); QString forced = info.data.value("ForcedInstallation", scFalse).toString().toLower(); if (m_core.noForceInstallation()) @@ -499,6 +514,7 @@ private: QStringList m_defaultChecked; QStringList m_defaultPartially; QStringList m_defaultUnchecked; + QStringList m_uncheckable; }; Q_DECLARE_OPERATORS_FOR_FLAGS(tst_ComponentModel::Options) -- cgit v1.2.3