summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/treename/tst_treename.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/installer/treename/tst_treename.cpp')
-rw-r--r--tests/auto/installer/treename/tst_treename.cpp241
1 files changed, 239 insertions, 2 deletions
diff --git a/tests/auto/installer/treename/tst_treename.cpp b/tests/auto/installer/treename/tst_treename.cpp
index 2945d499a..974bc08cc 100644
--- a/tests/auto/installer/treename/tst_treename.cpp
+++ b/tests/auto/installer/treename/tst_treename.cpp
@@ -44,10 +44,20 @@ private slots:
void moveToSubItem();
void dependencyToMovedItem();
void autodependOnMovedItem();
- void moveToExistingItemAllowUnstableComponents();
+
+ void moveToExistingAllowUnstableComponents();
void moveToExistingItemNoUnstableComponents();
+ void moveWithChildrenChildConflictsAllowUnstable();
+ void moveWithChildrenChildConflictsNoUnstable();
+
+ void moveToRootWithChildren();
+ void moveToSubItemWithChildren();
+ void moveToAvailableParentItemWithChilren();
+ void dependencyToMovedSubItem();
+ void autoDependOnMovedSubItem();
void replaceComponentWithTreeName();
+ void replaceComponentWithTreeNameMoveChildren();
void init();
void cleanup();
@@ -114,7 +124,7 @@ void tst_TreeName::autodependOnMovedItem()
<< "componentASub2.txt" << "componentD.txt");
}
-void tst_TreeName::moveToExistingItemAllowUnstableComponents()
+void tst_TreeName::moveToExistingAllowUnstableComponents()
{
QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/invalid_repository"));
@@ -144,6 +154,233 @@ void tst_TreeName::replaceComponentWithTreeName()
QVERIFY(!core->componentByName("componentE"));
}
+void tst_TreeName::replaceComponentWithTreeNameMoveChildren()
+{
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/repository_children"));
+
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "componentM"));
+ QVERIFY(core->componentByName("componentM")->value(scTreeName).isEmpty());
+ QVERIFY(!core->componentByName("componentL"));
+
+ Component *component1 = core->componentByName("componentL.sub1");
+ QCOMPARE(component1->treeName(), component1->name());
+
+ Component *component2 = core->componentByName("componentL.sub2");
+ QCOMPARE(component2->treeName(), component2->name());
+}
+
+void tst_TreeName::moveWithChildrenChildConflictsAllowUnstable()
+{
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/invalid_repository"));
+ core->settings().setAllowUnstableComponents(true);
+
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "componentD"));
+ Component *const component = core->componentByName("componentD.sub1");
+ QVERIFY(component && component->isUnstable() && !component->isInstalled());
+}
+
+void tst_TreeName::moveWithChildrenChildConflictsNoUnstable()
+{
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/invalid_repository"));
+ core->settings().setAllowUnstableComponents(false);
+
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "componentD"));
+ QVERIFY(!core->componentByName("componentD.sub1"));
+}
+
+void tst_TreeName::moveToRootWithChildren()
+{
+ // componentF.subcomponent1 moved from sub item to root (FSub1ToRoot)
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/repository_children"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(
+ QStringList() << "componentF.subcomponent1"));
+ const QList<Component*> installedComponents = core->orderedComponentsToInstall();
+
+ QCOMPARE(installedComponents.count(), 3);
+
+ Component const *parent = installedComponents.at(0);
+ QCOMPARE(parent->name(), "componentF.subcomponent1");
+ QCOMPARE(parent->treeName(), "FSub1ToRoot");
+ QVERIFY(parent->value(scAutoTreeName).isEmpty());
+
+ Component const *child1 = installedComponents.at(1);
+ QCOMPARE(child1->name(), "componentF.subcomponent1.subsubcomponent1");
+ QCOMPARE(child1->treeName(), "FSub1ToRoot.subsubcomponent1");
+ QCOMPARE(child1->treeName(), child1->value(scAutoTreeName));
+
+ Component const *child2 = installedComponents.at(2);
+ QCOMPARE(child2->name(), "componentF.subcomponent1.subsubcomponent2");
+ QCOMPARE(child2->treeName(), "FSub1ToRoot.subsubcomponent2");
+ QCOMPARE(child2->treeName(), child2->value(scAutoTreeName));
+
+ QVERIFY(core->componentByName("componentF.subcomponent1"));
+ QVERIFY(!core->componentByName("FSub1ToRoot"));
+ QVERIFY(core->componentByName("componentF.subcomponent1.subsubcomponent1"));
+ QVERIFY(!core->componentByName("FSub1ToRoot.subsubcomponent1"));
+ QVERIFY(core->componentByName("componentF.subcomponent1.subsubcomponent2"));
+ QVERIFY(!core->componentByName("FSub1ToRoot.subsubcomponent2"));
+
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentF.subcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentF.subcomponent1.subsubcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentF.subcomponent1.subsubcomponent2", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentF_1.txt" << "installcontentF_1_1.txt" << "installcontentF_1_2.txt");
+}
+
+void tst_TreeName::moveToSubItemWithChildren()
+{
+ // componentF.subcomponent2 moved under componentE (componentE.sub1)
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/repository_children"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(
+ QStringList() << "componentF.subcomponent2"));
+ const QList<Component*> installedComponents = core->orderedComponentsToInstall();
+
+ QCOMPARE(installedComponents.count(), 4);
+
+ Component const *parent = installedComponents.at(1);
+ QCOMPARE(parent->name(), "componentF.subcomponent2");
+ QCOMPARE(parent->treeName(), "componentE.sub1");
+ QVERIFY(parent->value(scAutoTreeName).isEmpty());
+
+ Component const *child1 = installedComponents.at(2);
+ QCOMPARE(child1->name(), "componentF.subcomponent2.subsubcomponent1");
+ QCOMPARE(child1->treeName(), "componentE.sub1.subsubcomponent1");
+ QCOMPARE(child1->treeName(), child1->value(scAutoTreeName));
+
+ Component const *child2 = installedComponents.at(3);
+ QCOMPARE(child2->name(), "componentF.subcomponent2.subsubcomponent2");
+ QCOMPARE(child2->treeName(), "componentE.sub1.subsubcomponent2");
+ QCOMPARE(child2->treeName(), child2->value(scAutoTreeName));
+
+ QVERIFY(core->componentByName("componentF.subcomponent2"));
+ QVERIFY(!core->componentByName("componentE.sub1"));
+ QVERIFY(core->componentByName("componentF.subcomponent2.subsubcomponent1"));
+ QVERIFY(!core->componentByName("componentE.sub1.subsubcomponent1"));
+ QVERIFY(core->componentByName("componentF.subcomponent2.subsubcomponent2"));
+ QVERIFY(!core->componentByName("componentE.sub1.subsubcomponent2"));
+
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentF.subcomponent2", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentF.subcomponent2.subsubcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentF.subcomponent2.subsubcomponent2", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentE.txt" << "installcontentF_2.txt" << "installcontentF_2_1.txt"
+ << "installcontentF_2_2.txt");
+}
+
+void tst_TreeName::moveToAvailableParentItemWithChilren()
+{
+ // componentH moved to componentI
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/repository_children"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(
+ QStringList() << "componentH"));
+ const QList<Component*> installedComponents = core->orderedComponentsToInstall();
+
+ QCOMPARE(installedComponents.count(), 3);
+
+ Component const *parent = installedComponents.at(0);
+ QCOMPARE(parent->name(), "componentH");
+ QCOMPARE(parent->treeName(), "componentI");
+ QVERIFY(parent->value(scAutoTreeName).isEmpty());
+
+ Component const *child1 = installedComponents.at(1);
+ QCOMPARE(child1->name(), "componentH.subcomponent1");
+ QCOMPARE(child1->treeName(), "componentI.subcomponent1");
+ QCOMPARE(child1->treeName(), child1->value(scAutoTreeName));
+
+ Component const *child2 = installedComponents.at(2);
+ QCOMPARE(child2->name(), "componentI.subcomponent2");
+ QCOMPARE(child2->treeName(), child2->name());
+ QVERIFY(child2->value(scAutoTreeName).isEmpty());
+
+ QVERIFY(core->componentByName("componentH"));
+ QVERIFY(!core->componentByName("componentI"));
+ QVERIFY(core->componentByName("componentH.subcomponent1"));
+ QVERIFY(!core->componentByName("componentI.subcomponent1"));
+ QVERIFY(core->componentByName("componentI.subcomponent2"));
+
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentH", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentH.subcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentI.subcomponent2", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentH.txt" << "installcontentH_1.txt" << "installcontentI_2.txt");
+}
+
+void tst_TreeName::dependencyToMovedSubItem()
+{
+ // componentK has dependency to componentJ.subcomponent1, which has a parent with treename
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/repository_children"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(
+ QStringList() << "componentK"));
+ const QList<Component*> installedComponents = core->orderedComponentsToInstall();
+
+ QCOMPARE(installedComponents.count(), 2);
+
+ Component const *component1 = installedComponents.at(0);
+ QCOMPARE(component1->name(), "componentJ.subcomponent1");
+ QCOMPARE(component1->treeName(), "componentJNew.subcomponent1");
+ QCOMPARE(component1->treeName(), component1->value(scAutoTreeName));
+
+ Component const *component2 = installedComponents.at(1);
+ QCOMPARE(component2->name(), "componentK");
+ QCOMPARE(component2->treeName(), component2->name());
+ QVERIFY(component2->value(scAutoTreeName).isEmpty());
+
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentJ.subcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentK", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentJ_1.txt" << "installcontentK.txt");
+}
+
+void tst_TreeName::autoDependOnMovedSubItem()
+{
+ // componentB auto-depends on componentA.subcomponent1, which has a parent with treename
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir, ":///data/repository_children"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(
+ QStringList() << "componentA.subcomponent1"));
+ const QList<Component*> installedComponents = core->orderedComponentsToInstall();
+
+ QCOMPARE(installedComponents.count(), 3);
+
+ Component const *component1 = installedComponents.at(0);
+ QCOMPARE(component1->name(), "componentA");
+ QCOMPARE(component1->treeName(), "componentANew");
+ QVERIFY(component1->value(scAutoTreeName).isEmpty());
+
+ Component const *component2 = installedComponents.at(1);
+ QCOMPARE(component2->name(), "componentA.subcomponent1");
+ QCOMPARE(component2->treeName(), "componentANew.subcomponent1");
+ QCOMPARE(component2->treeName(), component2->value(scAutoTreeName));
+
+ Component const *component3 = installedComponents.at(2);
+ QCOMPARE(component3->name(), "componentB");
+ QCOMPARE(component3->treeName(), component3->name());
+
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir,
+ "componentA.subcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentA.txt" << "installcontentA_1.txt" << "installcontentB.txt");
+}
+
void tst_TreeName::init()
{
m_installDir = QInstaller::generateTemporaryFileName();