diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/installer/componentmodel/componentmodel.pro | 8 | ||||
-rw-r--r-- | tests/auto/installer/componentmodel/components.qrc | 5 | ||||
-rw-r--r-- | tests/auto/installer/componentmodel/data/updates.xml | 132 | ||||
-rw-r--r-- | tests/auto/installer/componentmodel/tst_componentmodel.cpp | 478 | ||||
-rw-r--r-- | tests/auto/installer/installer.pro | 1 | ||||
-rw-r--r-- | tests/auto/installer/settings/data/full_config.xml | 126 | ||||
-rw-r--r-- | tests/auto/installer/settings/tst_settings.cpp | 10 | ||||
-rw-r--r-- | tests/downloadspeed/main.cpp | 25 |
8 files changed, 641 insertions, 144 deletions
diff --git a/tests/auto/installer/componentmodel/componentmodel.pro b/tests/auto/installer/componentmodel/componentmodel.pro new file mode 100644 index 000000000..442986a96 --- /dev/null +++ b/tests/auto/installer/componentmodel/componentmodel.pro @@ -0,0 +1,8 @@ +include(../../qttest.pri) + +QT -= gui +QT += network xml + +SOURCES += tst_componentmodel.cpp + +RESOURCES += components.qrc diff --git a/tests/auto/installer/componentmodel/components.qrc b/tests/auto/installer/componentmodel/components.qrc new file mode 100644 index 000000000..a2b530f13 --- /dev/null +++ b/tests/auto/installer/componentmodel/components.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>data/updates.xml</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/componentmodel/data/updates.xml b/tests/auto/installer/componentmodel/data/updates.xml new file mode 100644 index 000000000..e1f72de10 --- /dev/null +++ b/tests/auto/installer/componentmodel/data/updates.xml @@ -0,0 +1,132 @@ +<Updates> + <ApplicationName>Your application</ApplicationName> + <ApplicationVersion>1.2.3</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>com.vendor.product</Name> + <DisplayName>The root component</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Default>true</Default> + <Script>installscript.qs</Script> + <SortingPriority>1</SortingPriority> + <ForcedInstallation>true</ForcedInstallation> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.second.product</Name> + <DisplayName>The second root component</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Default>false</Default> + <Script>installscript.qs</Script> + <SortingPriority>1</SortingPriority> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.second.product.subnode</Name> + <DisplayName>A sub node component for the second root</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Default>false</Default> + <Script>installscript.qs</Script> + <SortingPriority>1</SortingPriority> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.second.product.subnode.sub</Name> + <DisplayName>A subcomponent for the second sub node of the second root</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Default>false</Default> + <Script>installscript.qs</Script> + <SortingPriority>1</SortingPriority> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.second.product.sub</Name> + <DisplayName>A subcomponent for the second root</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Script>installscript.qs</Script> + <Default>true</Default> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.second.product.sub1</Name> + <DisplayName>A subcomponent for the second root</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Default>false</Default> + <Script>installscript.qs</Script> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.second.product.virtual</Name> + <DisplayName>A virtual subcomponent for the second root</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Script>installscript.qs</Script> + <Virtual>true</Virtual> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> + <PackageUpdate> + <Name>com.vendor.third.product.virtual</Name> + <DisplayName>A virtual root component</DisplayName> + <Description>Install this example.</Description> + <Version>0.1.0-1</Version> + <ReleaseDate>2010-09-21</ReleaseDate> + <Default>true</Default> + <Script>installscript.qs</Script> + <SortingPriority>0</SortingPriority> + <Virtual>true</Virtual> + <UpdateFile UncompressedSize="61" + CompressedSize="61"/> + <Licenses> + <License name="Beer Public License Agreement" + file="license.txt"/> + </Licenses> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp new file mode 100644 index 000000000..89e6be3d8 --- /dev/null +++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp @@ -0,0 +1,478 @@ +#include "component.h" +#include "componentmodel.h" + +#include "kdupdaterupdatesinfo_p.h" +#include "kdupdaterupdatesourcesinfo.h" + +#include "packagemanagercore.h" + +#include <QTest> + +using namespace KDUpdater; +using namespace QInstaller; + +#define EXPECTED_COUNT_VIRTUALS_VISIBLE 8 +#define EXPECTED_COUNT_VIRTUALS_INVISIBLE 7 + +static const char vendorProduct[] = "com.vendor.product"; +static const char vendorSecondProduct[] = "com.vendor.second.product"; +static const char vendorSecondProductSub[] = "com.vendor.second.product.sub"; +static const char vendorSecondProductSub1[] = "com.vendor.second.product.sub1"; +static const char vendorSecondProductVirtual[] = "com.vendor.second.product.virtual"; +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"; + +class tst_ComponentModel : public QObject +{ + Q_OBJECT + +public: + enum Option { + NoFlags = 0x00, + VirtualsVisible = 0x01, + NoForcedInstallation = 0x02 + }; + Q_DECLARE_FLAGS(Options, Option); + +private slots: + void initTestCase() + { + m_defaultChecked << vendorProduct << vendorSecondProductSub; + m_defaultPartially << vendorSecondProduct; + m_defaultUnchecked << vendorSecondProductSub1 << vendorSecondProductSubnode + << vendorSecondProductSubnodeSub; + } + + void testNameToIndexAndIndexToName() + { + setPackageManagerOptions(NoFlags); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + + // all names should be resolvable, virtual components are not indexed if they are not visible + QStringList all; + all << m_defaultChecked << m_defaultPartially << m_defaultUnchecked; + foreach (const QString &name, all) { + QVERIFY(model.indexFromComponentName(name).isValid()); + QVERIFY(model.componentFromIndex(model.indexFromComponentName(name)) != 0); + QCOMPARE(model.componentFromIndex(model.indexFromComponentName(name))->name(), name); + } + + foreach (Component *const component, rootComponents) + delete component; + } + + void testNameToIndexAndIndexToNameVirtualsVisible() + { + setPackageManagerOptions(VirtualsVisible); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + + // all names should be resolvable, including virtual components + QStringList all; + all << m_defaultChecked << m_defaultPartially << m_defaultUnchecked << vendorSecondProductVirtual + << vendorThirdProductVirtual; + foreach (const QString &name, all) { + QVERIFY(model.indexFromComponentName(name).isValid()); + QVERIFY(model.componentFromIndex(model.indexFromComponentName(name)) != 0); + QCOMPARE(model.componentFromIndex(model.indexFromComponentName(name))->name(), name); + } + + foreach (Component *const component, rootComponents) + delete component; + } + + void testDefault() + { + setPackageManagerOptions(NoFlags); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + QCOMPARE(model.core(), &m_core); + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testVirtualsVisible() + { + setPackageManagerOptions(VirtualsVisible); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + 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); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testNoForcedInstallation() + { + setPackageManagerOptions(NoForcedInstallation); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testVirtualsVisibleNoForcedInstallation() + { + setPackageManagerOptions(Options(VirtualsVisible | NoForcedInstallation)); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + 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); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testSelect() + { + setPackageManagerOptions(NoFlags); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + // select all possible components + model.setCheckedState(ComponentModel::AllChecked); + QCOMPARE(model.checkedState(), ComponentModel::AllChecked); + testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked, QStringList() + , QStringList()); + + // 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)); + + // reset all possible components + model.setCheckedState(ComponentModel::DefaultChecked); + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testSelectVirtualsVisible() + { + setPackageManagerOptions(VirtualsVisible); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + // select all possible components + model.setCheckedState(ComponentModel::AllChecked); + QCOMPARE(model.checkedState(), ComponentModel::AllChecked); + testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked + + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual, QStringList(), + QStringList()); + + // 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); + + // reset all possible components + model.setCheckedState(ComponentModel::DefaultChecked); + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked + + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testSelectNoForcedInstallation() + { + setPackageManagerOptions(NoForcedInstallation); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + // select all possible components + model.setCheckedState(ComponentModel::AllChecked); + QCOMPARE(model.checkedState(), ComponentModel::AllChecked); + testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked, QStringList() + , QStringList()); + + // deselect all possible components + model.setCheckedState(ComponentModel::AllUnchecked); + QCOMPARE(model.checkedState(), ComponentModel::AllUnchecked); + testModelState(&model, QStringList(), QStringList(), m_defaultPartially + m_defaultUnchecked + + QStringList(vendorSecondProductSub) << vendorProduct); + + // reset all possible components + model.setCheckedState(ComponentModel::DefaultChecked); + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked); + + foreach (Component *const component, rootComponents) + delete component; + } + + void testSelectVirtualsVisibleNoForcedInstallation() + { + setPackageManagerOptions(Options(VirtualsVisible | NoForcedInstallation)); + + QList<Component*> rootComponents = loadComponents(); + testComponentsLoaded(rootComponents); + + // setup the model with 1 column + ComponentModel model(1, &m_core); + model.setRootComponents(rootComponents); + testDefaultInheritedModelBehavior(&model, 1); + + // select all possible components + model.setCheckedState(ComponentModel::AllChecked); + QCOMPARE(model.checkedState(), ComponentModel::AllChecked); + testModelState(&model, m_defaultChecked + m_defaultPartially + m_defaultUnchecked + + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual, QStringList(), + QStringList()); + + // 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); + + // reset all possible components + model.setCheckedState(ComponentModel::DefaultChecked); + QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); + testModelState(&model, m_defaultChecked, m_defaultPartially, m_defaultUnchecked + + QStringList(vendorSecondProductVirtual) << vendorThirdProductVirtual); + + foreach (Component *const component, rootComponents) + delete component; + } + +private: + void setPackageManagerOptions(Options flags) const + { + m_core.setNoForceInstallation(flags.testFlag(NoForcedInstallation)); + m_core.setVirtualComponentsVisible(flags.testFlag(VirtualsVisible)); + } + + void testComponentsLoaded(const QList<Component *> &rootComponents) const + { + // we need to have three root components + QCOMPARE(rootComponents.count(), 3); + + QList<Component*> components = rootComponents; + foreach (Component *const component, rootComponents) + components.append(component->childItems()); + + // will differ between 6 and 7 components, (2 root nodes, 1 sub node, 3 non virtual and 1 virtual) + QCOMPARE(components.count(), m_core.virtualComponentsVisible() ? EXPECTED_COUNT_VIRTUALS_VISIBLE + : EXPECTED_COUNT_VIRTUALS_INVISIBLE); + } + + void testDefaultInheritedModelBehavior(ComponentModel *model, int columnCount) const + { + // 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) + else + QCOMPARE(model->rowCount(), 2); // 2 (the 2 non virtual root components) + QCOMPARE(model->columnCount(), columnCount); + + const QModelIndex firstParent = model->indexFromComponentName(vendorProduct); + const QModelIndex secondParent = model->indexFromComponentName(vendorSecondProduct); + const QModelIndex thirdParent = model->indexFromComponentName(vendorThirdProductVirtual); + + // return invalid indexes, as they are the root components + QCOMPARE(model->parent(firstParent), QModelIndex()); + QCOMPARE(model->parent(secondParent), QModelIndex()); + QCOMPARE(model->parent(thirdParent), QModelIndex()); + + // test valid indexes + QVERIFY(firstParent.isValid()); + QVERIFY(secondParent.isValid()); + QVERIFY(model->indexFromComponentName(vendorSecondProductSub).isValid()); + QVERIFY(model->indexFromComponentName(vendorSecondProductSub1).isValid()); + QVERIFY(model->indexFromComponentName(vendorSecondProductSubnode).isValid()); + QVERIFY(model->indexFromComponentName(vendorSecondProductSubnodeSub).isValid()); + + // they should have the same parent + QCOMPARE(model->parent(model->indexFromComponentName(vendorSecondProductSub)), secondParent); + QCOMPARE(model->parent(model->indexFromComponentName(vendorSecondProductSub1)), secondParent); + QCOMPARE(model->parent(model->indexFromComponentName(vendorSecondProductSubnode)), secondParent); + + const QModelIndex forthParent = model->indexFromComponentName(vendorSecondProductSubnode); + QCOMPARE(model->parent(model->indexFromComponentName(vendorSecondProductSubnodeSub)), forthParent); + + // row count should be 0, as they have no children + QCOMPARE(model->rowCount(firstParent), 0); + QCOMPARE(model->rowCount(model->indexFromComponentName(vendorSecondProductSub)), 0); + QCOMPARE(model->rowCount(model->indexFromComponentName(vendorSecondProductSub1)), 0); + QCOMPARE(model->rowCount(model->indexFromComponentName(vendorSecondProductSubnodeSub)), 0); + + if (m_core.virtualComponentsVisible()) { + // test valid index + QVERIFY(thirdParent.isValid()); + QCOMPARE(model->rowCount(thirdParent), 0); + + QVERIFY(model->indexFromComponentName(vendorSecondProductVirtual).isValid()); + QCOMPARE(model->rowCount(model->indexFromComponentName(vendorSecondProductVirtual)), 0); + QCOMPARE(model->parent(model->indexFromComponentName(vendorSecondProductVirtual)), secondParent); + // row count should be 4, (2 standard, 1 virtual, 1 sub node) + QCOMPARE(model->rowCount(secondParent), 4); + } else { + // test invalid index + QVERIFY(!thirdParent.isValid()); + + // row count should be 3, (2 standard, 1 sub node, omit the virtual) + QCOMPARE(model->rowCount(secondParent), 3); + } + // row count should be 1, 1 sub node + QCOMPARE(model->rowCount(model->indexFromComponentName(vendorSecondProductSubnode)), 1); + } + + void testModelState(ComponentModel *model, const QStringList &checked, const QStringList &partially, + const QStringList &unchecked) const + { + QCOMPARE(model->checked().count(), checked.count()); + QCOMPARE(model->partially().count(), partially.count()); + QCOMPARE(model->unchecked().count(), unchecked.count()); + + // these components should have checked state + foreach (Component *const component, model->checked()) + QVERIFY(checked.contains(component->name())); + + // these components should not have partially checked state + foreach (Component *const component, model->partially()) + QVERIFY(partially.contains(component->name())); + + // these components should not have checked state + foreach (Component *const component, model->unchecked()) + QVERIFY(unchecked.contains(component->name())); + } + + QList<Component*> loadComponents() const + { + UpdatesInfo updatesInfo; + updatesInfo.setFileName(":///data/updates.xml"); + const QList<UpdateInfo> updateInfos = updatesInfo.updatesInfo(PackageUpdate); + + QHash<QString, Component*> components; + foreach (const UpdateInfo &info, updateInfos) { + Component *component = new Component(const_cast<PackageManagerCore *>(&m_core)); + + // 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()); + component->setValue("Virtual", info.data.value("Virtual").toString()); + component->setValue("DisplayName", info.data.value("DisplayName").toString()); + + QString forced = info.data.value("ForcedInstallation", scFalse).toString().toLower(); + if (m_core.noForceInstallation()) + forced = scFalse; + component->setValue("ForcedInstallation", forced); + if (forced == scTrue) { + component->setEnabled(false); + component->setCheckable(false); + component->setCheckState(Qt::Checked); + } + components.insert(component->name(), component); + } + + QList <Component*> rootComponents; + foreach (QString id, components.keys()) { + QInstaller::Component *component = components.value(id); + while (!id.isEmpty() && component->parentComponent() == 0) { + id = id.section(QLatin1Char('.'), 0, -2); + if (components.contains(id)) + components[id]->appendComponent(component); + } + } + + foreach (QInstaller::Component *component, components) { + if (component->parentComponent() == 0) + rootComponents.append(component); + + if (component->isCheckable() && component->isDefault() && (!component->isTristate())) + component->setCheckState(Qt::Checked); + } + return rootComponents; + } + +private: + PackageManagerCore m_core; + + QStringList m_defaultChecked; + QStringList m_defaultPartially; + QStringList m_defaultUnchecked; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(tst_ComponentModel::Options) + +QTEST_MAIN(tst_ComponentModel) + +#include "tst_componentmodel.moc" diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index 911e1ad75..67a454db7 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -3,4 +3,5 @@ TEMPLATE = subdirs SUBDIRS += \ settings \ repository \ + componentmodel \ fakestopprocessforupdateoperation diff --git a/tests/auto/installer/settings/data/full_config.xml b/tests/auto/installer/settings/data/full_config.xml index cde9f6310..4e1b82c8a 100644 --- a/tests/auto/installer/settings/data/full_config.xml +++ b/tests/auto/installer/settings/data/full_config.xml @@ -15,8 +15,11 @@ File should contain all elements we allow in a config.xml <AdminTargetDir>@rootDir@InstallationDirectory</AdminTargetDir> <Icon>icon</Icon> + <InstallerApplicationIcon>icon</InstallerApplicationIcon> + <InstallerWindowIcon>icon</InstallerWindowIcon> <Logo>logo</Logo> <Watermark>watermark</Watermark> + <Banner>banner</Banner> <Background>background</Background> <StartMenuDir>Super App</StartMenuDir> @@ -26,6 +29,7 @@ File should contain all elements we allow in a config.xml <RemoveTargetDir>true</RemoveTargetDir> <RunProgram>myapp</RunProgram> + <RunProgramArguments>foo bar</RunProgramArguments> <RunProgramDescription>Launch MyApp</RunProgramDescription> <DependsOnLocalInstallerBinary>true</DependsOnLocalInstallerBinary> @@ -42,126 +46,4 @@ File should contain all elements we allow in a config.xml <Password>password</Password> </Repository> </RemoteRepositories> - - <Pages> - <Page name="IntroductionPage"> - <Title> - <Default>Introduction Page Title</Default> - </Title> - <SubTitle> - <Default>Introduction Page Sub Title</Default> - </SubTitle> - <MessageLabel>Introduction Page Message Label</MessageLabel> - </Page> - <Page name="LicenseAgreementPage"> - <Title> - <Default>License Agreement Page Title</Default> - </Title> - <SubTitle> - <Default>License Agreement Page Sub Title</Default> - </SubTitle> - <AcceptLicenseLabel>Accept License Radio Button</AcceptLicenseLabel> - <RejectLicenseLabel>Reject License Radio Button</RejectLicenseLabel> - </Page> - <Page name="ComponentSelectionPage"> - <Title> - <Default>Component Selection Page Title</Default> - <Updater>Component Selection Page Sub Title Updater</Updater> - <Installer>Component Selection Page Sub Title Installer</Installer> - <Uninstaller>Component Selection Page Sub Title Uninstaller</Uninstaller> - <PackageManager>Component Selection Page Sub Title Package Manager</PackageManager> - </Title> - <SubTitle> - <Default>Component Selection Page Sub Title</Default> - <Updater>Component Selection Page Sub Title Updater</Updater> - <Installer>Component Selection Page Sub Title Installer</Installer> - <Uninstaller>Component Selection Page Sub Title Uninstaller</Uninstaller> - <PackageManager>Component Selection Page Sub Title Package Manager</PackageManager> - </SubTitle> - <SelectDefaultComponentsButton>Default Button</SelectDefaultComponentsButton> - <SelectAllComponentsButton>Select All Button</SelectAllComponentsButton> - <DeselectAllComponentsButton>Deselect All Button</DeselectAllComponentsButton> - <ComponentSizeLabel>Component Size Label</ComponentSizeLabel> - </Page> - <Page name="TargetDirectoryPage"> - <Title> - <Default>Target Directory Page Title</Default> - </Title> - <SubTitle> - <Default>Target Directory Page Sub Title</Default> - </SubTitle> - <MessageLabel>Target Directory Page Message Label</MessageLabel> - <BrowseDirectoryButton>Browse Directory Button</BrowseDirectoryButton> - <EmptyTargetDirectoryMessage>Empty Target Directory Message</EmptyTargetDirectoryMessage> - <ForbiddenTargetDirectoryMessage>Forbidden Target Directory Message</ForbiddenTargetDirectoryMessage> - <OverwriteTargetDirectoryMessage>Overwrite Target Directory Message</OverwriteTargetDirectoryMessage> - <SelectInstallationFolderCaption>Select Installation Folder Caption</SelectInstallationFolderCaption> - </Page> - <Page name="StartMenuDirectoryPage"> - <Title> - <Default>Start Menu Directory Page Title</Default> - </Title> - <SubTitle> - <Default>Start Menu Directory Page Sub Title</Default> - </SubTitle> - </Page> - <Page name="ReadyForInstallationPage"> - <Title> - <Default>Ready for Installation Page Title</Default> - <Updater>Ready for Installation Page Title Updater</Updater> - <Installer>Ready for Installation Page Title Installer</Installer> - <Uninstaller>Ready for Installation Page Title Uninstaller</Uninstaller> - <PackageManager>Ready for Installation Page Title Package Manager</PackageManager> - </Title> - <SubTitle> - <Default>Ready for Installation Page Sub Title</Default> - <Updater>Ready for Installation Page Sub Title Updater</Updater> - <Installer>Ready for Installation Page Sub Title Installer</Installer> - <Uninstaller>Ready for Installation Page Sub Title Uninstaller</Uninstaller> - <PackageManager>Ready for Installation Page Sub Title Package Manager</PackageManager> - </SubTitle> - <MessageLabel>Ready for Installation Page Message Label</MessageLabel> - </Page> - <Page name="PerformInstallationPage"> - <Title> - <Default>Perform Installation Page Title</Default> - <Updater>Perform Installation Page Title Updater</Updater> - <Installer>Perform Installation Page Title Installer</Installer> - <Uninstaller>Perform Installation Page Title Uninstaller</Uninstaller> - <PackageManager>Perform Installation Page Title Package Manager</PackageManager> - </Title> - <SubTitle> - <Default>Perform Installation Page Sub Title</Default> - <Updater>Perform Installation Page Sub Title Updater</Updater> - <Installer>Perform Installation Page Sub Title Installer</Installer> - <Uninstaller>Perform Installation Page Sub Title Uninstaller</Uninstaller> - <PackageManager>Perform Installation Page Sub Title Package Manager</PackageManager> - </SubTitle> - </Page> - <Page name ="FinishedPage"> - <Title> - <Default>Finished Page Title</Default> - <Updater>Finished Page Title Updater</Updater> - <Installer>Finished Page Title Installer</Installer> - <Uninstaller>Finished Page Title Uninstaller</Uninstaller> - <PackageManager>Finished Page Title Package Manager</PackageManager> - </Title> - <SubTitle> - <Default>Finished Page Sub Title</Default> - <Updater>Finished Page Sub Title Updater</Updater> - <Installer>Finished Page Sub Title Installer</Installer> - <Uninstaller>Finished Page Sub Title Uninstaller</Uninstaller> - <PackageManager>Finished Page Sub Title Package Manager</PackageManager> - </SubTitle> - <MessageLabel>Finished Page Message Label</MessageLabel> - </Page> - <Page name="RestartPage"> - <Title> - <Default>Restart Page Title</Default> - </Title> - <SubTitle> - <Default>Restart Page Sub Title</Default> - </SubTitle> - </Page> - </Pages> </Installer> diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp index dff789d2b..8db9edb11 100644 --- a/tests/auto/installer/settings/tst_settings.cpp +++ b/tests/auto/installer/settings/tst_settings.cpp @@ -38,15 +38,23 @@ void tst_Settings::loadTutorialConfig() QCOMPARE(settings.logo(), QLatin1String(":///data/")); QCOMPARE(settings.url(), QString()); QCOMPARE(settings.watermark(), QLatin1String(":///data/")); + QCOMPARE(settings.banner(), QLatin1String(":///data/")); QCOMPARE(settings.background(), QLatin1String(":///data/")); #if defined(Q_OS_WIN) QCOMPARE(settings.icon(), QLatin1String(":/installer.ico")); + QCOMPARE(settings.installerApplicationIcon(), QLatin1String(":/installer.ico")); + QCOMPARE(settings.installerWindowIcon(), QLatin1String(":/installer.ico")); #elif defined(Q_OS_MAC) QCOMPARE(settings.icon(), QLatin1String(":/installer.icns")); + QCOMPARE(settings.installerApplicationIcon(), QLatin1String(":/installer.icns")); + QCOMPARE(settings.installerWindowIcon(), QLatin1String(":/installer.icns")); #else QCOMPARE(settings.icon(), QLatin1String(":/installer.png")); + QCOMPARE(settings.installerApplicationIcon(), QLatin1String(":/installer.png")); + QCOMPARE(settings.installerWindowIcon(), QLatin1String(":/installer.png")); #endif QCOMPARE(settings.runProgram(), QString()); + QCOMPARE(settings.runProgramArguments(), QString()); QCOMPARE(settings.runProgramDescription(), QString()); QCOMPARE(settings.adminTargetDir(), QString()); QCOMPARE(settings.removeTargetDir(), QLatin1String("true")); @@ -72,7 +80,7 @@ void tst_Settings::loadTutorialConfig() void tst_Settings::loadFullConfig() { - QTest::ignoreMessage(QtWarningMsg, "Deprecated element 'Pages'. "); + QTest::ignoreMessage(QtWarningMsg, "Deprecated element 'Icon'. "); Settings settings = Settings::fromFileAndPrefix(":///data/full_config.xml", ":///data"); } diff --git a/tests/downloadspeed/main.cpp b/tests/downloadspeed/main.cpp index 6611ec17a..5a5b685aa 100644 --- a/tests/downloadspeed/main.cpp +++ b/tests/downloadspeed/main.cpp @@ -42,6 +42,8 @@ #include <kdupdaterfiledownloader.h> #include <kdupdaterfiledownloaderfactory.h> +#include <fileutils.h> + #include <QtCore/QCoreApplication> #include <QtCore/QDebug> #include <QtCore/QObject> @@ -49,26 +51,6 @@ #include <QtNetwork/QNetworkProxy> -static QString humanReadableSize(quint64 intSize) -{ - QString unit; - double size; - - if (intSize < 1024 * 1024) { - size = 1. + intSize / 1024.; - unit = QObject::tr("kB"); - } else if (intSize < 1024 * 1024 * 1024) { - size = 1. + intSize / 1024. / 1024.; - unit = QObject::tr("MB"); - } else { - size = 1. + intSize / 1024. / 1024. / 1024.; - unit = QObject::tr("GB"); - } - - size = qRound(size * 10) / 10.0; - return QString::fromLatin1("%L1 %2").arg(size, 0, 'g', 4).arg(unit); -} - // -- Receiver class Receiver : public QObject @@ -100,7 +82,8 @@ public slots: void downloadSpeed(qint64 speed) { - qDebug() << "Download speed:" << humanReadableSize(speed) + QLatin1String("/sec"); + qDebug() << "Download speed:" << + QInstaller::humanReadableSize(speed) + QLatin1String("/sec"); } void downloadProgress(double progress) |