From fdfd2e381bd16a99822ef8c9dfdffb75ab29d142 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 2 Jun 2022 10:46:14 +0300 Subject: Convert possible test cases to data-driven tests Also rename the test to better correspond the test cases. Change-Id: Ic3f624fc8cf42724ff4df550cc85a52343ac6452 Reviewed-by: Arttu Tarkiainen --- tests/auto/installer/cliinterface/cliinterface.pro | 9 - .../installer/cliinterface/data/components.xml | 24 - .../componentsFromInstallPackagesRepository.xml | 160 ----- tests/auto/installer/cliinterface/data/config.xml | 8 - .../data/filequeryrepository/A/1.0.2-1meta.7z | Bin 945 -> 0 bytes .../data/filequeryrepository/Updates.xml | 13 - .../installPackagesDependencyChanged/Updates.xml | 72 -- .../componentA/2.0.0content.7z | Bin 259 -> 0 bytes .../componentB/1.0.0content.7z | Bin 241 -> 0 bytes .../componentC/1.0.0content.7z | Bin 241 -> 0 bytes .../componentD/1.0.0content.7z | Bin 241 -> 0 bytes .../componentF/1.0.0content.7z | Bin 241 -> 0 bytes .../componentH/1.0.0content.7z | Bin 209 -> 0 bytes .../data/installPackagesRepository/Updates.xml | 171 ----- .../componentA/1.0.0content.7z | Bin 259 -> 0 bytes .../componentB/1.0.0content.7z | Bin 241 -> 0 bytes .../componentC/1.0.0content.7z | Bin 241 -> 0 bytes .../componentD/1.0.0content.7z | Bin 241 -> 0 bytes .../componentE/1.0.0content.7z | Bin 241 -> 0 bytes .../1.0.0content.7z | Bin 249 -> 0 bytes .../1.0.0content.7z | Bin 249 -> 0 bytes .../componentF.subcomponent1/1.0.0content.7z | Bin 241 -> 0 bytes .../1.0.0content.7z | Bin 249 -> 0 bytes .../1.0.0content.7z | Bin 249 -> 0 bytes .../componentF.subcomponent2/1.0.0content.7z | Bin 241 -> 0 bytes .../componentF/1.0.0content.7z | Bin 241 -> 0 bytes .../componentG/1.0.0content.7z | Bin 241 -> 0 bytes .../componentG/1.0.0meta.7z | Bin 970 -> 0 bytes .../componentH/1.0.0content.7z | Bin 209 -> 0 bytes .../componentI/1.0.0content.7z | Bin 209 -> 0 bytes .../cliinterface/data/repository/Updates.xml | 69 -- .../uninstallableComponentsRepository/Updates.xml | 50 -- tests/auto/installer/cliinterface/settings.qrc | 35 - .../installer/cliinterface/tst_cliinterface.cpp | 602 ---------------- .../commandlineinstall/commandlineinstall.pro | 9 + .../commandlineinstall/data/components.xml | 24 + .../componentsFromInstallPackagesRepository.xml | 160 +++++ .../installer/commandlineinstall/data/config.xml | 8 + .../data/filequeryrepository/A/1.0.2-1meta.7z | Bin 0 -> 945 bytes .../data/filequeryrepository/Updates.xml | 13 + .../installPackagesDependencyChanged/Updates.xml | 72 ++ .../componentA/2.0.0content.7z | Bin 0 -> 259 bytes .../componentB/1.0.0content.7z | Bin 0 -> 241 bytes .../componentC/1.0.0content.7z | Bin 0 -> 241 bytes .../componentD/1.0.0content.7z | Bin 0 -> 241 bytes .../componentF/1.0.0content.7z | Bin 0 -> 241 bytes .../componentH/1.0.0content.7z | Bin 0 -> 209 bytes .../data/installPackagesRepository/Updates.xml | 173 +++++ .../componentA/1.0.0content.7z | Bin 0 -> 259 bytes .../componentB/1.0.0content.7z | Bin 0 -> 241 bytes .../componentC/1.0.0content.7z | Bin 0 -> 241 bytes .../componentD/1.0.0content.7z | Bin 0 -> 241 bytes .../componentE/1.0.0content.7z | Bin 0 -> 241 bytes .../1.0.0content.7z | Bin 0 -> 249 bytes .../1.0.0content.7z | Bin 0 -> 249 bytes .../componentF.subcomponent1/1.0.0content.7z | Bin 0 -> 241 bytes .../1.0.0content.7z | Bin 0 -> 249 bytes .../1.0.0content.7z | Bin 0 -> 249 bytes .../componentF.subcomponent2/1.0.0content.7z | Bin 0 -> 241 bytes .../componentF/1.0.0content.7z | Bin 0 -> 241 bytes .../componentG/1.0.0content.7z | Bin 0 -> 241 bytes .../componentG/1.0.0meta.7z | Bin 0 -> 970 bytes .../componentH/1.0.0content.7z | Bin 0 -> 209 bytes .../componentI/1.0.0content.7z | Bin 0 -> 209 bytes .../commandlineinstall/data/repository/Updates.xml | 69 ++ .../uninstallableComponentsRepository/Updates.xml | 50 ++ .../auto/installer/commandlineinstall/settings.qrc | 35 + .../commandlineinstall/tst_commandlineinstall.cpp | 764 +++++++++++++++++++++ tests/auto/installer/installer.pro | 2 +- 69 files changed, 1378 insertions(+), 1214 deletions(-) delete mode 100644 tests/auto/installer/cliinterface/cliinterface.pro delete mode 100644 tests/auto/installer/cliinterface/data/components.xml delete mode 100644 tests/auto/installer/cliinterface/data/componentsFromInstallPackagesRepository.xml delete mode 100644 tests/auto/installer/cliinterface/data/config.xml delete mode 100644 tests/auto/installer/cliinterface/data/filequeryrepository/A/1.0.2-1meta.7z delete mode 100644 tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/Updates.xml delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentA/2.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentB/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentC/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentD/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentF/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentH/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/Updates.xml delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentA/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentB/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentC/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentD/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentE/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentF/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0meta.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentH/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/installPackagesRepository/componentI/1.0.0content.7z delete mode 100644 tests/auto/installer/cliinterface/data/repository/Updates.xml delete mode 100644 tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml delete mode 100644 tests/auto/installer/cliinterface/settings.qrc delete mode 100644 tests/auto/installer/cliinterface/tst_cliinterface.cpp create mode 100644 tests/auto/installer/commandlineinstall/commandlineinstall.pro create mode 100644 tests/auto/installer/commandlineinstall/data/components.xml create mode 100644 tests/auto/installer/commandlineinstall/data/componentsFromInstallPackagesRepository.xml create mode 100644 tests/auto/installer/commandlineinstall/data/config.xml create mode 100644 tests/auto/installer/commandlineinstall/data/filequeryrepository/A/1.0.2-1meta.7z create mode 100644 tests/auto/installer/commandlineinstall/data/filequeryrepository/Updates.xml create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/Updates.xml create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentA/2.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentB/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentC/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentD/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentF/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentH/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/Updates.xml create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentA/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentB/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentC/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentD/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentE/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0meta.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentH/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentI/1.0.0content.7z create mode 100644 tests/auto/installer/commandlineinstall/data/repository/Updates.xml create mode 100644 tests/auto/installer/commandlineinstall/data/uninstallableComponentsRepository/Updates.xml create mode 100644 tests/auto/installer/commandlineinstall/settings.qrc create mode 100644 tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp diff --git a/tests/auto/installer/cliinterface/cliinterface.pro b/tests/auto/installer/cliinterface/cliinterface.pro deleted file mode 100644 index db2a3138a..000000000 --- a/tests/auto/installer/cliinterface/cliinterface.pro +++ /dev/null @@ -1,9 +0,0 @@ -include(../../qttest.pri) - -QT += qml - -SOURCES += tst_cliinterface.cpp - -RESOURCES += \ - settings.qrc \ - ../shared/config.qrc diff --git a/tests/auto/installer/cliinterface/data/components.xml b/tests/auto/installer/cliinterface/data/components.xml deleted file mode 100644 index d5102787f..000000000 --- a/tests/auto/installer/cliinterface/data/components.xml +++ /dev/null @@ -1,24 +0,0 @@ - - Online Installer Example - 1.0.0 - - A - A Title - Example component A - 1.0.2-1 - - 2020-02-13 - 74 - true - - - B - B Title - Example component B - 1.0.0-1 - - 2020-02-13 - 74 - true - - \ No newline at end of file diff --git a/tests/auto/installer/cliinterface/data/componentsFromInstallPackagesRepository.xml b/tests/auto/installer/cliinterface/data/componentsFromInstallPackagesRepository.xml deleted file mode 100644 index 18d6f11c3..000000000 --- a/tests/auto/installer/cliinterface/data/componentsFromInstallPackagesRepository.xml +++ /dev/null @@ -1,160 +0,0 @@ - - Dependency Solving Example - 1.0.0 - - componentA - Component A - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 158 - true - - - componentB - Component B - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentC - Component C (depends on A and B) - This component depends on Component A and Component B. Selecting this component for installation also marks Component A and Component B for installation, which in turn marks Component D, because it has an automatic dependency on Component A and Component B. - 1.0.0 - - 2020-03-23 - 99 - componentA,componentB - true - - - componentD - Component D (auto depends on A and B) - This component has an automatic dependency on Component A and Component B. If both A and B are marked for installation, this component is also installed. - 1.0.0 - - 2020-03-23 - 99 - componentA,componentB - true - - - componentE - Component E (forced) - This is a forced component that is always installed. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF - Component F - This component contains 2 subcomponents. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF.subcomponent1 - Subcomponent 1 - This component contains 2 leaf components. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF.subcomponent1.subsubcomponent1 - Subsubcomponent 1 - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF.subcomponent1.subsubcomponent2 - Subsubcomponent 2 - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF.subcomponent2 - Subcomponent 2 - This component contains 2 leaf components. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF.subcomponent2.subsubcomponent1 - Subsubcomponent 1 - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentF.subcomponent2.subsubcomponent2 - Subsubcomponent 2 - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 99 - true - - - componentG - Component G (default, depends on A, dependency added dynamically) - By default, this component is selected for installation. It depends on component A. Dependency is added from inside component script. - 1.0.0 - - 2020-03-23 - 99 - componentA - true - - - componentH - Component H - This component does not depend on any other component. - 1.0.0 - - 2020-03-23 - 99 - true - true - - - componentI - Component I - This component has an automatic dependency on Component C. If C is marked for installation, this component is also installed. - 1.0.0 - - 2020-03-23 - 99 - componentC - true - true - - diff --git a/tests/auto/installer/cliinterface/data/config.xml b/tests/auto/installer/cliinterface/data/config.xml deleted file mode 100644 index 041ce5062..000000000 --- a/tests/auto/installer/cliinterface/data/config.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Your application - 1.2.3 - - - - diff --git a/tests/auto/installer/cliinterface/data/filequeryrepository/A/1.0.2-1meta.7z b/tests/auto/installer/cliinterface/data/filequeryrepository/A/1.0.2-1meta.7z deleted file mode 100644 index 0b0b6ade6..000000000 Binary files a/tests/auto/installer/cliinterface/data/filequeryrepository/A/1.0.2-1meta.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml b/tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml deleted file mode 100644 index 72b7938d9..000000000 --- a/tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml +++ /dev/null @@ -1,13 +0,0 @@ - - {AnyApplication} - 1.0.0 - - A - A - A component - 1.0.2-1 - 2015-01-01 - true - - - diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/Updates.xml b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/Updates.xml deleted file mode 100644 index 72931954a..000000000 --- a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/Updates.xml +++ /dev/null @@ -1,72 +0,0 @@ - - {AnyApplication} - 1.0.0 - false - - componentA - Component A - New dependency added - 2.0.0 - 2014-08-25 - 100 - - content.7z - 92b02a74d0886bc1569ff8b3a7edd1f9d828e56c - componentF - - - componentB - Component B - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 90 - - content.7z - aedfaef53cdc0f52353a8680009be405fa767811 - - - componentC - Component C. Dependencies removed - This component dependencies on Component A and Component B are removed in update. - - 1.0.0 - 2014-08-25 - 80 - - content.7z - 20b9463a5e06f373182b3c7c4cf879806d429409 - - - componentD - Component D (auto depends on A and B) - This component has an automatic dependency on Component A and Component B. If both A and B are marked for installation, this component is also installed. - componentA, componentB - 1.0.0 - 2014-08-25 - 70 - - content.7z - 99cf24c71559c75dfae9933826ed16051fca6ea1 - - - componentF - Component F - This component contains 2 subcomponents. - 1.0.0 - 2014-08-25 - 40 - - content.7z - e6443a8b5a5651f63c0604cae6d32431ca617f1a - - - componentH - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 50 - content.7z - false - - diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentA/2.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentA/2.0.0content.7z deleted file mode 100644 index 4ddbe565b..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentA/2.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentB/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentB/1.0.0content.7z deleted file mode 100644 index f84ffcdc5..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentB/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentC/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentC/1.0.0content.7z deleted file mode 100644 index 9ad11e06f..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentC/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentD/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentD/1.0.0content.7z deleted file mode 100644 index 0c8c52e31..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentD/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentF/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentF/1.0.0content.7z deleted file mode 100644 index 4a04b1394..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentF/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentH/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentH/1.0.0content.7z deleted file mode 100644 index e1449ad29..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesDependencyChanged/componentH/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/Updates.xml b/tests/auto/installer/cliinterface/data/installPackagesRepository/Updates.xml deleted file mode 100644 index adabceab4..000000000 --- a/tests/auto/installer/cliinterface/data/installPackagesRepository/Updates.xml +++ /dev/null @@ -1,171 +0,0 @@ - - {AnyApplication} - 1.0.0 - false - - componentA - Component A - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 100 - - content.7z - 92b02a74d0886bc1569ff8b3a7edd1f9d828e56c - - - componentB - Component B - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 90 - - content.7z - aedfaef53cdc0f52353a8680009be405fa767811 - - - componentC - Component C (depends on A and B) - This component depends on Component A and Component B. Selecting this component for installation also marks Component A and Component B for installation, which in turn marks Component D, because it has an automatic dependency on Component A and Component B. - componentA, componentB - 1.0.0 - 2014-08-25 - 80 - - content.7z - 20b9463a5e06f373182b3c7c4cf879806d429409 - - - componentD - Component D (auto depends on A and B) - This component has an automatic dependency on Component A and Component B. If both A and B are marked for installation, this component is also installed. - componentA, componentB - 1.0.0 - 2014-08-25 - 70 - - content.7z - 99cf24c71559c75dfae9933826ed16051fca6ea1 - - - componentE - Component E (forced) - This is a forced component that is always installed. - true - 1.0.0 - 2014-08-25 - 60 - - content.7z - 926bf503ccdff93351744843a95e5e2172cad5ec - - - componentF - Component F - This component contains 2 subcomponents. - 1.0.0 - 2014-08-25 - 40 - - content.7z - e6443a8b5a5651f63c0604cae6d32431ca617f1a - - - componentF.subcomponent1 - Subcomponent 1 - This component contains 2 leaf components. - 1.0.0 - 2014-08-25 - 100 - - content.7z - a3bc5dce1c93add30c22e46436396c66b0b51001 - - - componentF.subcomponent1.subsubcomponent1 - Subsubcomponent 1 - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 100 - - content.7z - ebe4d69414a1675a7f46887e15d9bffc275b7cc4 - - - componentF.subcomponent1.subsubcomponent2 - Subsubcomponent 2 - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 50 - - content.7z - e4379d20320d4c173b2d8e228f5722e3f36e3114 - - - componentF.subcomponent2 - Subcomponent 2 - This component contains 2 leaf components. - 1.0.0 - 2014-08-25 - 50 - - content.7z - 6462be25912c490569a7c4f3931d978e78c69dc4 - - - componentF.subcomponent2.subsubcomponent1 - Subsubcomponent 1 - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 100 - - content.7z - 72b224bc8f3431210834ce6db373fc8d638a3546 - - - componentF.subcomponent2.subsubcomponent2 - Subsubcomponent 2 - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 50 - - content.7z - 3e2744edaef06af75b3248d5935523a6e2e61551 - - - componentG - Component G (default, depends on A, dependency added dynamically) - By default, this component is selected for installation. It depends on component A. Dependency is added from inside component script. - 1.0.0 - 2014-08-25 - - 30 - - content.7z - 8cba36dd589492c28e0d04942b4f8aa0a09f59cc - - - componentH - This component does not depend on any other component. - 1.0.0 - 2014-08-25 - 50 - content.7z - true - - - componentI - This component has an automatic dependency on Component C. If C is marked for installation, this component is also installed. - 1.0.0 - 2014-08-25 - 50 - componentC - content.7z - true - - diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentA/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentA/1.0.0content.7z deleted file mode 100644 index 4ddbe565b..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentA/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentB/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentB/1.0.0content.7z deleted file mode 100644 index f84ffcdc5..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentB/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentC/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentC/1.0.0content.7z deleted file mode 100644 index 9ad11e06f..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentC/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentD/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentD/1.0.0content.7z deleted file mode 100644 index 0c8c52e31..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentD/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentE/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentE/1.0.0content.7z deleted file mode 100644 index f5abacf81..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentE/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z deleted file mode 100644 index 3aced680f..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z deleted file mode 100644 index e5385a163..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z deleted file mode 100644 index 5bc549863..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z deleted file mode 100644 index da9e9f340..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z deleted file mode 100644 index d0b013706..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z deleted file mode 100644 index 74ab44033..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF/1.0.0content.7z deleted file mode 100644 index 4a04b1394..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentF/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0content.7z deleted file mode 100644 index 81fc02052..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0meta.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0meta.7z deleted file mode 100644 index 90bfe33a2..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentG/1.0.0meta.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentH/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentH/1.0.0content.7z deleted file mode 100644 index e1449ad29..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentH/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentI/1.0.0content.7z b/tests/auto/installer/cliinterface/data/installPackagesRepository/componentI/1.0.0content.7z deleted file mode 100644 index 651a29f94..000000000 Binary files a/tests/auto/installer/cliinterface/data/installPackagesRepository/componentI/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/installer/cliinterface/data/repository/Updates.xml b/tests/auto/installer/cliinterface/data/repository/Updates.xml deleted file mode 100644 index 52707d09d..000000000 --- a/tests/auto/installer/cliinterface/data/repository/Updates.xml +++ /dev/null @@ -1,69 +0,0 @@ - - {AnyApplication} - 1.0.0 - true - - A - A - Example component A - 1.0.2-1 - 2015-01-01 - true - - content.7z - 9d54e3a5adf3563913feee8ba23a99fb80d46590 - - - B - B - Example component B - 1.0.0-1 - 2015-01-01 - false - - content.7z - 9170d55a6af81c1a6a63d708a4ab6ed359775cd9 - - - C - C - Example component C - 1.0.0-1 - 2015-01-01 - true - - content.7z - 5b3939da1af492382c68388fc796837e4c36b876 - - - C.virt - Virtual subcomponent of C - Example virtual component - 1.0.0-1 - 2015-01-01 - true - - content.7z - 5b3939da1af492382c68388fc796837e4c36b876 - - - C.virt.subcomponent - Subcomponent of virtual component - Example subcomponent of virtual component - 1.0.0-1 - 2015-01-01 - - content.7z - 5b3939da1af492382c68388fc796837e4c36b876 - - - AB - AB - Example component AB - 1.0.2-1 - 2015-01-01 - true - - f75e65b1a0f68abb77fc41da08fc26dda5409a18 - - diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml deleted file mode 100644 index f0c724db8..000000000 --- a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml +++ /dev/null @@ -1,50 +0,0 @@ - - {AnyApplication} - 1.0.0 - true - - A - A - Example component A - 2.0.0 - 2015-01-01 - true - - content.7z - c1f340c9a7ad1edbef4cb6288c83c646211e5ccd - autoDep - - - AB - AB - Example component AB - 1.0.2-1 - 2015-01-01 - true - - 3c1470896a9db84092e00806b1303f3b5fa4f7ad - false - - - B - B - Example component B - 2.0.0 - 2015-01-01 - true - - content.7z - cfa136fa1d7a4196896c90af72d510727ba799ae - true - - - B.subcomponent - Subcomponent of B - Example non-virtual subcomponent of B - 2.0.0 - 2015-01-01 - - content.7z - cfa136fa1d7a4196896c90af72d510727ba799ae - - diff --git a/tests/auto/installer/cliinterface/settings.qrc b/tests/auto/installer/cliinterface/settings.qrc deleted file mode 100644 index 824517e1e..000000000 --- a/tests/auto/installer/cliinterface/settings.qrc +++ /dev/null @@ -1,35 +0,0 @@ - - - data/config.xml - data/repository/Updates.xml - data/uninstallableComponentsRepository/Updates.xml - data/components.xml - data/installPackagesRepository/Updates.xml - data/installPackagesRepository/componentA/1.0.0content.7z - data/installPackagesRepository/componentB/1.0.0content.7z - data/installPackagesRepository/componentC/1.0.0content.7z - data/installPackagesRepository/componentD/1.0.0content.7z - data/installPackagesRepository/componentE/1.0.0content.7z - data/installPackagesRepository/componentF/1.0.0content.7z - data/installPackagesRepository/componentG/1.0.0content.7z - data/installPackagesRepository/componentH/1.0.0content.7z - data/installPackagesRepository/componentI/1.0.0content.7z - data/installPackagesRepository/componentG/1.0.0meta.7z - data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z - data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z - data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z - data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z - data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z - data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z - data/installPackagesDependencyChanged/Updates.xml - data/installPackagesDependencyChanged/componentA/2.0.0content.7z - data/installPackagesDependencyChanged/componentB/1.0.0content.7z - data/installPackagesDependencyChanged/componentC/1.0.0content.7z - data/installPackagesDependencyChanged/componentD/1.0.0content.7z - data/installPackagesDependencyChanged/componentF/1.0.0content.7z - data/installPackagesDependencyChanged/componentH/1.0.0content.7z - data/filequeryrepository/Updates.xml - data/filequeryrepository/A/1.0.2-1meta.7z - data/componentsFromInstallPackagesRepository.xml - - diff --git a/tests/auto/installer/cliinterface/tst_cliinterface.cpp b/tests/auto/installer/cliinterface/tst_cliinterface.cpp deleted file mode 100644 index 8f1784543..000000000 --- a/tests/auto/installer/cliinterface/tst_cliinterface.cpp +++ /dev/null @@ -1,602 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2022 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 "../shared/verifyinstaller.h" - -#include -#include - -#include -#include -#include - -#include -#include - -using namespace QInstaller; - -class tst_CLIInterface : public QObject -{ - Q_OBJECT - -private slots: - void testListAvailablePackages() - { - QString loggingRules = (QLatin1String("ifw.* = false\n")); - - QTest::ignoreMessage(QtDebugMsg, "Operations sanity check succeeded."); - - QScopedPointer core(PackageManager::getPackageManager - (m_installDir, ":///data/repository")); - - QLoggingCategory::setFilterRules(loggingRules); - auto func = &PackageManagerCore::listAvailablePackages; - - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n"), func, QLatin1String("."), QHash()); - - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - " \n" - "\n"), func, QLatin1String("A"), QHash()); - - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - " \n" - "\n"), func, QLatin1String("A.*"), QHash()); - - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - "\n"), func, QLatin1String("^B"), QHash()); - - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - "\n"), func, QLatin1String("^B.*"), QHash()); - - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - "\n"), func, QLatin1String("^C"), QHash()); - - // Test with filters - QHash searchHash { - { "Version", "1.0.2" }, - { "DisplayName", "A" } - }; - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - " \n" - "\n"), func, QString(), searchHash); - - searchHash.clear(); - searchHash.insert("Default", "false"); - verifyListPackagesMessage(core.get(), QLatin1String("\n" - "\n" - " \n" - "\n"), func, QString(), searchHash); - - // Need to change rules here to catch messages - QLoggingCategory::setFilterRules("ifw.* = true\n"); - - QTest::ignoreMessage(QtDebugMsg, "No matching packages found."); - core->listAvailablePackages(QLatin1String("C.virt")); - - QTest::ignoreMessage(QtDebugMsg, "No matching packages found."); - core->listAvailablePackages(QLatin1String("C.virt.subcomponent")); - } - - void testInstallPackageFails() - { - QString loggingRules = (QLatin1String("ifw.* = false\n" - "ifw.installer.installlog = true\n")); - - QScopedPointer core(PackageManager::getPackageManager - (m_installDir, ":///data/uninstallableComponentsRepository")); - - QLoggingCategory::setFilterRules(loggingRules); - - QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); - QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install component A. Component " - "is installed only as automatic dependency to autoDep.\n")); - QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("A"))); - - QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); - QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install component AB. Component " - "is not checkable, meaning you have to select one of the subcomponents.\n")); - QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("AB"))); - - QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); - QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install B. Component is virtual.\n")); - QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("B"))); - - QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); - QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install B.subcomponent. Component " - "is a descendant of a virtual component B.\n")); - QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("B.subcomponent"))); - - QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); - QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install MissingComponent. " - "Component not found.\n")); - QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("MissingComponent"))); - QCOMPARE(PackageManagerCore::Canceled, core->status()); - } - - void testUninstallPackageFails() - { - QString loggingRules = (QLatin1String("ifw.installer.installog = true\n")); - PackageManagerCore core; - core.setPackageManager(); - QString appFilePath = QCoreApplication::applicationFilePath(); - core.setAllowedRunningProcesses(QStringList() << appFilePath); - QLoggingCategory::setFilterRules(loggingRules); - - m_installDir = QInstaller::generateTemporaryFileName(); - QVERIFY(QDir().mkpath(m_installDir)); - QVERIFY(QFile::copy(":/data/componentsFromInstallPackagesRepository.xml", m_installDir + "/components.xml")); - - core.setValue(scTargetDir, m_installDir); - QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall ForcedInstallation component componentE"); - QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() - << "componentE")); - - QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall component componentD because it is added as auto dependency to componentA,componentB"); - QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() - << "componentD")); - - QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall component MissingComponent. Component not found in install tree."); - QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() - << "MissingComponent")); - - QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall virtual component componentH"); - QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() - << "componentH")); - - QCOMPARE(PackageManagerCore::Success, core.status()); - } - - void testListInstalledPackages() - { - QString loggingRules = (QLatin1String("ifw.* = false\n")); - PackageManagerCore core; - core.setPackageManager(); - QLoggingCategory::setFilterRules(loggingRules); - auto func = &PackageManagerCore::listInstalledPackages; - - const QString testDirectory = QInstaller::generateTemporaryFileName(); - QVERIFY(QDir().mkpath(testDirectory)); - QVERIFY(QFile::copy(":/data/components.xml", testDirectory + "/components.xml")); - - core.setValue(scTargetDir, testDirectory); - - verifyListPackagesMessage(&core, QLatin1String("\n" - "\n" - " \n" - " \n" - "\n"), func, QString()); - - verifyListPackagesMessage(&core, QLatin1String("\n" - "\n" - " \n" - "\n"), func, QLatin1String("A")); - - QDir dir(testDirectory); - QVERIFY(dir.removeRecursively()); - } - - void testNoDefaultInstallations() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - core->setNoDefaultInstallation(true); - QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" - << "installcontentE.txt"); - core->setNoDefaultInstallation(false); - } - - void testInstallForcedPackageSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentE"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Depends on componentA - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); - } - - void testInstallPackageSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentA"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Depends on componentA - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); - } - - void testUninstallPackageSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentA"))); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentE.txt" - << "installcontentA.txt" << "installcontent.txt" << "installcontentG.txt"); - - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << QLatin1String("componentA"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentA"); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG"); //Depends on componentA - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentE.txt"); - } - - void testRemoveAllSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentA"))); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentE.txt" - << "installcontentA.txt" << "installcontent.txt" << "installcontentG.txt"); - - core->commitSessionOperations(); - core->setUninstaller(); - QCOMPARE(PackageManagerCore::Success, core->removeInstallationSilently()); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentA"); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentE"); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG"); - - // On Windows we have to settle for the resources check above as maintenance - // tool (if it would exists) and target directory are only removed later via - // started VBScript process. On Unix platforms the target directory should - // be removed in PackageManagerCorePrivate::runUninstaller(). -#if defined(Q_OS_UNIX) - QVERIFY(!QDir(m_installDir).exists()); -#endif - } - - void testInstallWithDependencySilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentC"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); //Dependency for componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Depends on componentA - VerifyInstaller::verifyInstallerResources(m_installDir, "componentI", "1.0.0content.txt"); //Virtual, depends on componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "1.0.0content.txt"); //Autodepend on componentA and componentB - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentC.txt" - << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" - << "installcontentD.txt"<< "installcontentE.txt" << "installcontentG.txt" << "installcontentI.txt"); - } - - void testUninstallWithDependencySilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentC"))); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentC.txt" - << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" - << "installcontentD.txt"<< "installcontentE.txt" << "installcontentG.txt" << "installcontentI.txt"); - - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << QLatin1String("componentC"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); //Dependency for componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Depends on componentA - VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "1.0.0content.txt"); //Autodepend on componentA and componentB - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentC"); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentI"); //Virtual, depends on componentC - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" - << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" - << "installcontentD.txt"<< "installcontentE.txt" << "installcontentG.txt"); - } - - void testInstallSubcomponentSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentF.subcomponent2.subsubcomponent2"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2.subsubcomponent2", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentF", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default install - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentF.txt" - << "installcontentF_2.txt" << "installcontentF_2_2.txt" - << "installcontent.txt" << "installcontentA.txt" - << "installcontentE.txt" << "installcontentG.txt"); - } - - void testUninstallSubcomponentSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentF.subcomponent2.subsubcomponent2"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentF.txt" - << "installcontentF_2.txt" << "installcontentF_2_2.txt" - << "installcontent.txt" << "installcontentA.txt" - << "installcontentE.txt" << "installcontentG.txt"); - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << QLatin1String("componentF.subcomponent2"))); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default install - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentF.subcomponent2.subsubcomponent2"); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentF.subcomponent2"); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentF"); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" - << "installcontent.txt" << "installcontentA.txt" - << "installcontentE.txt" << "installcontentG.txt"); - } - - void testInstallDefaultPackagesSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); - } - - void testInstallPackagesWithChangedRepository() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - core->setNoDefaultInstallation(true); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentC"))); - - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency to componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); //Dependency to componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentC", "1.0.0content.txt"); //Selected - VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "1.0.0content.txt"); //Autodepend on componentA,componentB - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //AutodependOn componentC - VerifyInstaller::verifyInstallerResources(m_installDir, "componentI", "1.0.0content.txt"); //Virtual dependency to componentC - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" - << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" - << "installcontentC.txt" << "installcontentD.txt" << "installcontentE.txt" - << "installcontentI.txt"); - - core->reset(); - core->cancelMetaInfoJob(); //Call cancel to reset metadata so that update repositories are fetched - - QSet repoList; - Repository repo = Repository::fromUserInput(":///data/installPackagesDependencyChanged"); - repoList.insert(repo); - core->settings().setDefaultRepositories(repoList); - - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << QLatin1String("componentH"))); - // New dependency is added in repository from componentA to componentF, check that it is not installed - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentF"); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" - << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" - << "installcontentC.txt" << "installcontentD.txt" << "installcontentE.txt" - << "installcontentI.txt" << "installcontentH.txt"); - core->setNoDefaultInstallation(false); - } - - void testUnInstallDefaultPackagesSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); - - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << "componentG")); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG"); - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt"); - } - - void testUninstallForcedPackagesSilenly() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); - QCOMPARE(PackageManagerCore::Success, core->status()); - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << "componentE")); - QCOMPARE(PackageManagerCore::Success, core->status()); - //Nothing is uninstalled as componentE is forced install and cannot be uninstalled - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); - } - - void testUninstallAutodependencyPackagesSilenly() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - << "componentA" << "componentB")); - QCOMPARE(PackageManagerCore::Success, core->status()); - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << "componentD")); - QCOMPARE(PackageManagerCore::Success, core->status()); - //Nothing is uninstalled as componentD is installed as autodependency to componentA and componentB - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "1.0.0content.txt"); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall - VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default - VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" - << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt" - << "installcontentB.txt" << "installcontentD.txt"); - } - - void testUninstallVirtualSetVisibleSilently() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit - (m_installDir, ":///data/installPackagesRepository")); - core->setVirtualComponentsVisible(true); - QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() - <<"componentH")); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResources(m_installDir, "componentH", "1.0.0content.txt"); - - core->commitSessionOperations(); - core->setPackageManager(); - QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() - << "componentH")); - QCOMPARE(PackageManagerCore::Success, core->status()); - VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentH"); - } - - void testFileQuery() - { - QScopedPointer core(PackageManager::getPackageManagerWithInit(m_installDir, - ":///data/filequeryrepository")); - core->setCommandLineInstance(true); - core->setFileDialogAutomaticAnswer("ValidDirectory", m_installDir); - - QString testFile = qApp->applicationDirPath() + QDir::toNativeSeparators("/test"); - QFile file(testFile); - QVERIFY(file.open(QIODevice::WriteOnly)); - core->setFileDialogAutomaticAnswer("ValidFile", testFile); - - //File dialog launched without ID - core->setFileDialogAutomaticAnswer("GetExistingDirectory", m_installDir); - core->setFileDialogAutomaticAnswer("GetExistingFile", testFile); - - QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); - QCOMPARE(PackageManagerCore::Success, core->status()); - - QVERIFY(core->containsFileDialogAutomaticAnswer("ValidFile")); - core->removeFileDialogAutomaticAnswer("ValidFile"); - QVERIFY(!core->containsFileDialogAutomaticAnswer("ValidFile")); - - QVERIFY(file.remove()); - core->deleteLater(); - } - - void init() - { - m_installDir = QInstaller::generateTemporaryFileName(); - QVERIFY(QDir().mkpath(m_installDir)); - } - - void initTestCase() - { - qSetGlobalQHashSeed(0); //Ensures the dom document deterministic behavior - } - - void cleanup() - { - QDir dir(m_installDir); - QVERIFY(dir.removeRecursively()); - } - -private: - template - void verifyListPackagesMessage(PackageManagerCore *core, const QString &message, - Func func, Args... args) - { - std::ostringstream stream; - std::streambuf *buf = std::cout.rdbuf(); - std::cout.rdbuf(stream.rdbuf()); - - (core->*func)(std::forward(args)...); - - std::cout.rdbuf(buf); - QVERIFY(stream && stream.str() == message.toStdString()); - } - -private: - QString m_installDir; -}; - - -QTEST_MAIN(tst_CLIInterface) - -#include "tst_cliinterface.moc" diff --git a/tests/auto/installer/commandlineinstall/commandlineinstall.pro b/tests/auto/installer/commandlineinstall/commandlineinstall.pro new file mode 100644 index 000000000..891830a97 --- /dev/null +++ b/tests/auto/installer/commandlineinstall/commandlineinstall.pro @@ -0,0 +1,9 @@ +include(../../qttest.pri) + +QT += qml + +SOURCES += tst_commandlineinstall.cpp + +RESOURCES += \ + settings.qrc \ + ../shared/config.qrc diff --git a/tests/auto/installer/commandlineinstall/data/components.xml b/tests/auto/installer/commandlineinstall/data/components.xml new file mode 100644 index 000000000..d5102787f --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/components.xml @@ -0,0 +1,24 @@ + + Online Installer Example + 1.0.0 + + A + A Title + Example component A + 1.0.2-1 + + 2020-02-13 + 74 + true + + + B + B Title + Example component B + 1.0.0-1 + + 2020-02-13 + 74 + true + + \ No newline at end of file diff --git a/tests/auto/installer/commandlineinstall/data/componentsFromInstallPackagesRepository.xml b/tests/auto/installer/commandlineinstall/data/componentsFromInstallPackagesRepository.xml new file mode 100644 index 000000000..18d6f11c3 --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/componentsFromInstallPackagesRepository.xml @@ -0,0 +1,160 @@ + + Dependency Solving Example + 1.0.0 + + componentA + Component A + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 158 + true + + + componentB + Component B + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentC + Component C (depends on A and B) + This component depends on Component A and Component B. Selecting this component for installation also marks Component A and Component B for installation, which in turn marks Component D, because it has an automatic dependency on Component A and Component B. + 1.0.0 + + 2020-03-23 + 99 + componentA,componentB + true + + + componentD + Component D (auto depends on A and B) + This component has an automatic dependency on Component A and Component B. If both A and B are marked for installation, this component is also installed. + 1.0.0 + + 2020-03-23 + 99 + componentA,componentB + true + + + componentE + Component E (forced) + This is a forced component that is always installed. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF + Component F + This component contains 2 subcomponents. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF.subcomponent1 + Subcomponent 1 + This component contains 2 leaf components. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF.subcomponent1.subsubcomponent1 + Subsubcomponent 1 + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF.subcomponent1.subsubcomponent2 + Subsubcomponent 2 + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF.subcomponent2 + Subcomponent 2 + This component contains 2 leaf components. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF.subcomponent2.subsubcomponent1 + Subsubcomponent 1 + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentF.subcomponent2.subsubcomponent2 + Subsubcomponent 2 + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 99 + true + + + componentG + Component G (default, depends on A, dependency added dynamically) + By default, this component is selected for installation. It depends on component A. Dependency is added from inside component script. + 1.0.0 + + 2020-03-23 + 99 + componentA + true + + + componentH + Component H + This component does not depend on any other component. + 1.0.0 + + 2020-03-23 + 99 + true + true + + + componentI + Component I + This component has an automatic dependency on Component C. If C is marked for installation, this component is also installed. + 1.0.0 + + 2020-03-23 + 99 + componentC + true + true + + diff --git a/tests/auto/installer/commandlineinstall/data/config.xml b/tests/auto/installer/commandlineinstall/data/config.xml new file mode 100644 index 000000000..041ce5062 --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/config.xml @@ -0,0 +1,8 @@ + + + Your application + 1.2.3 + + + + diff --git a/tests/auto/installer/commandlineinstall/data/filequeryrepository/A/1.0.2-1meta.7z b/tests/auto/installer/commandlineinstall/data/filequeryrepository/A/1.0.2-1meta.7z new file mode 100644 index 000000000..0b0b6ade6 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/filequeryrepository/A/1.0.2-1meta.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/filequeryrepository/Updates.xml b/tests/auto/installer/commandlineinstall/data/filequeryrepository/Updates.xml new file mode 100644 index 000000000..72b7938d9 --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/filequeryrepository/Updates.xml @@ -0,0 +1,13 @@ + + {AnyApplication} + 1.0.0 + + A + A + A component + 1.0.2-1 + 2015-01-01 + true + + + diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/Updates.xml b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/Updates.xml new file mode 100644 index 000000000..72931954a --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/Updates.xml @@ -0,0 +1,72 @@ + + {AnyApplication} + 1.0.0 + false + + componentA + Component A + New dependency added + 2.0.0 + 2014-08-25 + 100 + + content.7z + 92b02a74d0886bc1569ff8b3a7edd1f9d828e56c + componentF + + + componentB + Component B + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 90 + + content.7z + aedfaef53cdc0f52353a8680009be405fa767811 + + + componentC + Component C. Dependencies removed + This component dependencies on Component A and Component B are removed in update. + + 1.0.0 + 2014-08-25 + 80 + + content.7z + 20b9463a5e06f373182b3c7c4cf879806d429409 + + + componentD + Component D (auto depends on A and B) + This component has an automatic dependency on Component A and Component B. If both A and B are marked for installation, this component is also installed. + componentA, componentB + 1.0.0 + 2014-08-25 + 70 + + content.7z + 99cf24c71559c75dfae9933826ed16051fca6ea1 + + + componentF + Component F + This component contains 2 subcomponents. + 1.0.0 + 2014-08-25 + 40 + + content.7z + e6443a8b5a5651f63c0604cae6d32431ca617f1a + + + componentH + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 50 + content.7z + false + + diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentA/2.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentA/2.0.0content.7z new file mode 100644 index 000000000..4ddbe565b Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentA/2.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentB/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentB/1.0.0content.7z new file mode 100644 index 000000000..f84ffcdc5 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentB/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentC/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentC/1.0.0content.7z new file mode 100644 index 000000000..9ad11e06f Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentC/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentD/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentD/1.0.0content.7z new file mode 100644 index 000000000..0c8c52e31 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentD/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentF/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentF/1.0.0content.7z new file mode 100644 index 000000000..4a04b1394 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentF/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentH/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentH/1.0.0content.7z new file mode 100644 index 000000000..e1449ad29 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesDependencyChanged/componentH/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/Updates.xml b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/Updates.xml new file mode 100644 index 000000000..81831ed5b --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/Updates.xml @@ -0,0 +1,173 @@ + + {AnyApplication} + 1.0.0 + false + + componentA + Component A + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 100 + + content.7z + 92b02a74d0886bc1569ff8b3a7edd1f9d828e56c + + + componentB + Component B + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 90 + + content.7z + aedfaef53cdc0f52353a8680009be405fa767811 + + + componentC + Component C (depends on A and B) + This component depends on Component A and Component B. Selecting this component for installation also marks Component A and Component B for installation, which in turn marks Component D, because it has an automatic dependency on Component A and Component B. + componentA, componentB + 1.0.0 + 2014-08-25 + 80 + + content.7z + 20b9463a5e06f373182b3c7c4cf879806d429409 + + + componentD + Component D (auto depends on A and B) + This component has an automatic dependency on Component A and Component B. If both A and B are marked for installation, this component is also installed. + componentA, componentB + 1.0.0 + 2014-08-25 + 70 + + content.7z + 99cf24c71559c75dfae9933826ed16051fca6ea1 + + + componentE + Component E (forced) + This is a forced component that is always installed. + true + 1.0.0 + 2014-08-25 + 60 + + content.7z + 926bf503ccdff93351744843a95e5e2172cad5ec + + + componentF + Component F + This component contains 2 subcomponents. + 1.0.0 + 2014-08-25 + 40 + + content.7z + e6443a8b5a5651f63c0604cae6d32431ca617f1a + + + componentF.subcomponent1 + Subcomponent 1 + This component contains 2 leaf components. + 1.0.0 + 2014-08-25 + 100 + + content.7z + a3bc5dce1c93add30c22e46436396c66b0b51001 + + + componentF.subcomponent1.subsubcomponent1 + Subsubcomponent 1 + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 100 + + content.7z + ebe4d69414a1675a7f46887e15d9bffc275b7cc4 + + + componentF.subcomponent1.subsubcomponent2 + Subsubcomponent 2 + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 50 + + content.7z + e4379d20320d4c173b2d8e228f5722e3f36e3114 + + + componentF.subcomponent2 + Subcomponent 2 + This component contains 2 leaf components. + 1.0.0 + 2014-08-25 + 50 + + content.7z + 6462be25912c490569a7c4f3931d978e78c69dc4 + + + componentF.subcomponent2.subsubcomponent1 + Subsubcomponent 1 + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 100 + + content.7z + 72b224bc8f3431210834ce6db373fc8d638a3546 + + + componentF.subcomponent2.subsubcomponent2 + Subsubcomponent 2 + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 50 + + content.7z + 3e2744edaef06af75b3248d5935523a6e2e61551 + + + componentG + Component G (default, depends on A, dependency added dynamically) + By default, this component is selected for installation. It depends on component A. Dependency is added from inside component script. + 1.0.0 + 2014-08-25 + + 30 + + content.7z + 8cba36dd589492c28e0d04942b4f8aa0a09f59cc + + + componentH + component H + This component does not depend on any other component. + 1.0.0 + 2014-08-25 + 50 + content.7z + true + + + componentI + component I + This component has an automatic dependency on Component C. If C is marked for installation, this component is also installed. + 1.0.0 + 2014-08-25 + 50 + componentC + content.7z + true + + diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentA/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentA/1.0.0content.7z new file mode 100644 index 000000000..4ddbe565b Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentA/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentB/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentB/1.0.0content.7z new file mode 100644 index 000000000..f84ffcdc5 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentB/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentC/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentC/1.0.0content.7z new file mode 100644 index 000000000..9ad11e06f Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentC/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentD/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentD/1.0.0content.7z new file mode 100644 index 000000000..0c8c52e31 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentD/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentE/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentE/1.0.0content.7z new file mode 100644 index 000000000..f5abacf81 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentE/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z new file mode 100644 index 000000000..3aced680f Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z new file mode 100644 index 000000000..e5385a163 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z new file mode 100644 index 000000000..5bc549863 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z new file mode 100644 index 000000000..da9e9f340 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z new file mode 100644 index 000000000..d0b013706 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z new file mode 100644 index 000000000..74ab44033 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF/1.0.0content.7z new file mode 100644 index 000000000..4a04b1394 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentF/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0content.7z new file mode 100644 index 000000000..81fc02052 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0meta.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0meta.7z new file mode 100644 index 000000000..90bfe33a2 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentG/1.0.0meta.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentH/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentH/1.0.0content.7z new file mode 100644 index 000000000..e1449ad29 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentH/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentI/1.0.0content.7z b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentI/1.0.0content.7z new file mode 100644 index 000000000..651a29f94 Binary files /dev/null and b/tests/auto/installer/commandlineinstall/data/installPackagesRepository/componentI/1.0.0content.7z differ diff --git a/tests/auto/installer/commandlineinstall/data/repository/Updates.xml b/tests/auto/installer/commandlineinstall/data/repository/Updates.xml new file mode 100644 index 000000000..52707d09d --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/repository/Updates.xml @@ -0,0 +1,69 @@ + + {AnyApplication} + 1.0.0 + true + + A + A + Example component A + 1.0.2-1 + 2015-01-01 + true + + content.7z + 9d54e3a5adf3563913feee8ba23a99fb80d46590 + + + B + B + Example component B + 1.0.0-1 + 2015-01-01 + false + + content.7z + 9170d55a6af81c1a6a63d708a4ab6ed359775cd9 + + + C + C + Example component C + 1.0.0-1 + 2015-01-01 + true + + content.7z + 5b3939da1af492382c68388fc796837e4c36b876 + + + C.virt + Virtual subcomponent of C + Example virtual component + 1.0.0-1 + 2015-01-01 + true + + content.7z + 5b3939da1af492382c68388fc796837e4c36b876 + + + C.virt.subcomponent + Subcomponent of virtual component + Example subcomponent of virtual component + 1.0.0-1 + 2015-01-01 + + content.7z + 5b3939da1af492382c68388fc796837e4c36b876 + + + AB + AB + Example component AB + 1.0.2-1 + 2015-01-01 + true + + f75e65b1a0f68abb77fc41da08fc26dda5409a18 + + diff --git a/tests/auto/installer/commandlineinstall/data/uninstallableComponentsRepository/Updates.xml b/tests/auto/installer/commandlineinstall/data/uninstallableComponentsRepository/Updates.xml new file mode 100644 index 000000000..f0c724db8 --- /dev/null +++ b/tests/auto/installer/commandlineinstall/data/uninstallableComponentsRepository/Updates.xml @@ -0,0 +1,50 @@ + + {AnyApplication} + 1.0.0 + true + + A + A + Example component A + 2.0.0 + 2015-01-01 + true + + content.7z + c1f340c9a7ad1edbef4cb6288c83c646211e5ccd + autoDep + + + AB + AB + Example component AB + 1.0.2-1 + 2015-01-01 + true + + 3c1470896a9db84092e00806b1303f3b5fa4f7ad + false + + + B + B + Example component B + 2.0.0 + 2015-01-01 + true + + content.7z + cfa136fa1d7a4196896c90af72d510727ba799ae + true + + + B.subcomponent + Subcomponent of B + Example non-virtual subcomponent of B + 2.0.0 + 2015-01-01 + + content.7z + cfa136fa1d7a4196896c90af72d510727ba799ae + + diff --git a/tests/auto/installer/commandlineinstall/settings.qrc b/tests/auto/installer/commandlineinstall/settings.qrc new file mode 100644 index 000000000..824517e1e --- /dev/null +++ b/tests/auto/installer/commandlineinstall/settings.qrc @@ -0,0 +1,35 @@ + + + data/config.xml + data/repository/Updates.xml + data/uninstallableComponentsRepository/Updates.xml + data/components.xml + data/installPackagesRepository/Updates.xml + data/installPackagesRepository/componentA/1.0.0content.7z + data/installPackagesRepository/componentB/1.0.0content.7z + data/installPackagesRepository/componentC/1.0.0content.7z + data/installPackagesRepository/componentD/1.0.0content.7z + data/installPackagesRepository/componentE/1.0.0content.7z + data/installPackagesRepository/componentF/1.0.0content.7z + data/installPackagesRepository/componentG/1.0.0content.7z + data/installPackagesRepository/componentH/1.0.0content.7z + data/installPackagesRepository/componentI/1.0.0content.7z + data/installPackagesRepository/componentG/1.0.0meta.7z + data/installPackagesRepository/componentF.subcomponent1/1.0.0content.7z + data/installPackagesRepository/componentF.subcomponent2/1.0.0content.7z + data/installPackagesRepository/componentF.subcomponent1.subsubcomponent1/1.0.0content.7z + data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z + data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z + data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z + data/installPackagesDependencyChanged/Updates.xml + data/installPackagesDependencyChanged/componentA/2.0.0content.7z + data/installPackagesDependencyChanged/componentB/1.0.0content.7z + data/installPackagesDependencyChanged/componentC/1.0.0content.7z + data/installPackagesDependencyChanged/componentD/1.0.0content.7z + data/installPackagesDependencyChanged/componentF/1.0.0content.7z + data/installPackagesDependencyChanged/componentH/1.0.0content.7z + data/filequeryrepository/Updates.xml + data/filequeryrepository/A/1.0.2-1meta.7z + data/componentsFromInstallPackagesRepository.xml + + diff --git a/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp b/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp new file mode 100644 index 000000000..89f6153ed --- /dev/null +++ b/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp @@ -0,0 +1,764 @@ +/************************************************************************** +** +** Copyright (C) 2022 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 "../shared/verifyinstaller.h" + +#include +#include + +#include +#include +#include + +#include +#include + +using namespace QInstaller; + +typedef QList > ComponentResourceHash; +typedef QPair ComponentResource; + +class tst_CommandLineInstall : public QObject +{ + Q_OBJECT + +private slots: + void testListAvailablePackages() + { + QString loggingRules = (QLatin1String("ifw.* = false\n")); + + QTest::ignoreMessage(QtDebugMsg, "Operations sanity check succeeded."); + + QScopedPointer core(PackageManager::getPackageManager + (m_installDir, ":///data/repository")); + + QLoggingCategory::setFilterRules(loggingRules); + auto func = &PackageManagerCore::listAvailablePackages; + + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + " \n" + " \n" + " \n" + "\n"), func, QLatin1String("."), QHash()); + + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + " \n" + "\n"), func, QLatin1String("A"), QHash()); + + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + " \n" + "\n"), func, QLatin1String("A.*"), QHash()); + + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + "\n"), func, QLatin1String("^B"), QHash()); + + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + "\n"), func, QLatin1String("^B.*"), QHash()); + + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + "\n"), func, QLatin1String("^C"), QHash()); + + // Test with filters + QHash searchHash { + { "Version", "1.0.2" }, + { "DisplayName", "A" } + }; + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + " \n" + "\n"), func, QString(), searchHash); + + searchHash.clear(); + searchHash.insert("Default", "false"); + verifyListPackagesMessage(core.get(), QLatin1String("\n" + "\n" + " \n" + "\n"), func, QString(), searchHash); + + // Need to change rules here to catch messages + QLoggingCategory::setFilterRules("ifw.* = true\n"); + + QTest::ignoreMessage(QtDebugMsg, "No matching packages found."); + core->listAvailablePackages(QLatin1String("C.virt")); + + QTest::ignoreMessage(QtDebugMsg, "No matching packages found."); + core->listAvailablePackages(QLatin1String("C.virt.subcomponent")); + } + + void testInstallPackageFails() + { + QString loggingRules = (QLatin1String("ifw.* = false\n" + "ifw.installer.installlog = true\n")); + + QScopedPointer core(PackageManager::getPackageManager + (m_installDir, ":///data/uninstallableComponentsRepository")); + + QLoggingCategory::setFilterRules(loggingRules); + + QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); + QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install component A. Component " + "is installed only as automatic dependency to autoDep.\n")); + QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() + << QLatin1String("A"))); + + QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); + QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install component AB. Component " + "is not checkable, meaning you have to select one of the subcomponents.\n")); + QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() + << QLatin1String("AB"))); + + QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); + QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install B. Component is virtual.\n")); + QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() + << QLatin1String("B"))); + + QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); + QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install B.subcomponent. Component " + "is a descendant of a virtual component B.\n")); + QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() + << QLatin1String("B.subcomponent"))); + + QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download..."); + QTest::ignoreMessage(QtDebugMsg, QRegularExpression("Cannot install MissingComponent. " + "Component not found.\n")); + QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList() + << QLatin1String("MissingComponent"))); + QCOMPARE(PackageManagerCore::Canceled, core->status()); + } + + void testUninstallPackageFails() + { + QString loggingRules = (QLatin1String("ifw.installer.installog = true\n")); + PackageManagerCore core; + core.setPackageManager(); + QString appFilePath = QCoreApplication::applicationFilePath(); + core.setAllowedRunningProcesses(QStringList() << appFilePath); + QLoggingCategory::setFilterRules(loggingRules); + + QVERIFY(QFile::copy(":/data/componentsFromInstallPackagesRepository.xml", m_installDir + "/components.xml")); + + core.setValue(scTargetDir, m_installDir); + QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall ForcedInstallation component componentE"); + QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() + << "componentE")); + + QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall component componentD because it is added as auto dependency to componentA,componentB"); + QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() + << "componentD")); + + QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall component MissingComponent. Component not found in install tree."); + QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() + << "MissingComponent")); + + QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall virtual component componentH"); + QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList() + << "componentH")); + + QCOMPARE(PackageManagerCore::Success, core.status()); + } + + void testListInstalledPackages() + { + QString loggingRules = (QLatin1String("ifw.* = false\n")); + PackageManagerCore core; + core.setPackageManager(); + QLoggingCategory::setFilterRules(loggingRules); + auto func = &PackageManagerCore::listInstalledPackages; + + const QString testDirectory = QInstaller::generateTemporaryFileName(); + QVERIFY(QDir().mkpath(testDirectory)); + QVERIFY(QFile::copy(":/data/components.xml", testDirectory + "/components.xml")); + + core.setValue(scTargetDir, testDirectory); + + verifyListPackagesMessage(&core, QLatin1String("\n" + "\n" + " \n" + " \n" + "\n"), func, QString()); + + verifyListPackagesMessage(&core, QLatin1String("\n" + "\n" + " \n" + "\n"), func, QLatin1String("A")); + + QDir dir(testDirectory); + QVERIFY(dir.removeRecursively()); + } + + void testInstall_data() + { + QTest::addColumn("repository"); + QTest::addColumn("installComponents"); + QTest::addColumn("status"); + QTest::addColumn("componentResources"); + QTest::addColumn("installedFiles"); + + /*********** Forced installation **********/ + ComponentResourceHash componentResources; + componentResources.append(ComponentResource("componentA", "1.0.0content.txt")); + componentResources.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + componentResources.append(ComponentResource("componentG", "1.0.0content.txt")); //Depends on componentA + + QTest::newRow("Forced installation") + << ":///data/installPackagesRepository" + << (QStringList() << "componentE") + << PackageManagerCore::Success + << componentResources + << (QStringList() << "components.xml" << "installcontent.txt" + << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); + + /*********** Simple installation **********/ + componentResources.clear(); + componentResources.append(ComponentResource("componentA", "1.0.0content.txt")); + componentResources.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + componentResources.append(ComponentResource("componentG", "1.0.0content.txt")); //Depends on componentA + + QTest::newRow("Simple installation") + << ":///data/installPackagesRepository" + << (QStringList() << "componentA") + << PackageManagerCore::Success + << componentResources + << (QStringList() << "components.xml" << "installcontent.txt" + << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); + + /*********** Install with dependency **********/ + componentResources.clear(); + componentResources.append(ComponentResource("componentA", "1.0.0content.txt")); //Dependency for componentC + componentResources.append(ComponentResource("componentB", "1.0.0content.txt")); //Dependency for componentC + componentResources.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + componentResources.append(ComponentResource("componentG", "1.0.0content.txt")); //Depends on componentA + componentResources.append(ComponentResource("componentI", "1.0.0content.txt")); //Virtual, depends on componentC + componentResources.append(ComponentResource("componentD", "1.0.0content.txt")); //Autodepend on componentA and componentB + + QTest::newRow("Install with dependency") + << ":///data/installPackagesRepository" + << (QStringList() << "componentC") + << PackageManagerCore::Success + << componentResources + << (QStringList() << "components.xml" << "installcontentC.txt" + << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" + << "installcontentD.txt"<< "installcontentE.txt" << "installcontentG.txt" + << "installcontentI.txt"); + + /*********** Install with subcomponents **********/ + componentResources.clear(); + componentResources.append(ComponentResource("componentF.subcomponent2.subsubcomponent2", "1.0.0content.txt")); + componentResources.append(ComponentResource("componentF.subcomponent2", "1.0.0content.txt")); + componentResources.append(ComponentResource("componentF", "1.0.0content.txt")); + componentResources.append(ComponentResource("componentA", "1.0.0content.txt")); //Dependency for componentG + componentResources.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + componentResources.append(ComponentResource("componentG", "1.0.0content.txt")); //Default install + + QTest::newRow("Install with subcomponents") + << ":///data/installPackagesRepository" + << (QStringList() << "componentF.subcomponent2.subsubcomponent2") + << PackageManagerCore::Success + << componentResources + << (QStringList() << "components.xml" << "installcontentF.txt" + << "installcontentF_2.txt" << "installcontentF_2_2.txt" + << "installcontent.txt" << "installcontentA.txt" + << "installcontentE.txt" << "installcontentG.txt"); + } + + void testInstall() + { + QFETCH(QString, repository); + QFETCH(QStringList, installComponents); + QFETCH(PackageManagerCore::Status, status); + QFETCH(ComponentResourceHash, componentResources); + QFETCH(QStringList, installedFiles); + + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, repository)); + + QCOMPARE(status, core->installSelectedComponentsSilently(QStringList() << installComponents)); + for (const ComponentResource &resource : componentResources) + VerifyInstaller::verifyInstallerResources(m_installDir, resource.first, resource.second); + VerifyInstaller::verifyFileExistence(m_installDir, installedFiles); + } + + void testUninstall_data() + { + QTest::addColumn("repository"); + QTest::addColumn("installComponents"); + QTest::addColumn("status"); + QTest::addColumn("componentResources"); + QTest::addColumn("installedFiles"); + QTest::addColumn("uninstallComponents"); + QTest::addColumn("uninstallStatus"); + QTest::addColumn("componentResourcesAfterUninstall"); + QTest::addColumn("installedFilesAfterUninstall"); + QTest::addColumn("deletedComponentResources"); + QTest::addColumn("virtualSetVisible"); + + /*********** Uninstallation **********/ + ComponentResourceHash componentResourcesAfterUninstall; + componentResourcesAfterUninstall.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + + ComponentResourceHash deletedComponentResources; + deletedComponentResources.append(ComponentResource("componentA", "1.0.0content.txt")); + deletedComponentResources.append(ComponentResource("componentG", "1.0.0content.txt")); + + ComponentResourceHash componentResourceAfterInstall; + componentResourceAfterInstall << deletedComponentResources << componentResourcesAfterUninstall; + + QStringList filesAfterUninstall; + filesAfterUninstall << "components.xml" << "installcontentE.txt"; + + QStringList filesAfterInstall; + filesAfterInstall << filesAfterUninstall << "installcontent.txt" + << "installcontentA.txt" << "installcontentG.txt"; + + QTest::newRow("Test uninstall") + << ":///data/installPackagesRepository" + << (QStringList() << "componentA") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterInstall + << (QStringList() << "componentA") + << PackageManagerCore::Success + << componentResourcesAfterUninstall + << filesAfterUninstall + << deletedComponentResources; + + /*********** Uninstall with dependency **********/ + componentResourcesAfterUninstall.clear(); + componentResourcesAfterUninstall.append(ComponentResource("componentA", "1.0.0content.txt")); + componentResourcesAfterUninstall.append(ComponentResource("componentB", "1.0.0content.txt")); + componentResourcesAfterUninstall.append(ComponentResource("componentE", "1.0.0content.txt")); + componentResourcesAfterUninstall.append(ComponentResource("componentG", "1.0.0content.txt")); + componentResourcesAfterUninstall.append(ComponentResource("componentD", "1.0.0content.txt")); + + deletedComponentResources.clear(); + deletedComponentResources.append(ComponentResource("componentC", "1.0.0content.txt")); //Unselected + deletedComponentResources.append(ComponentResource("componentI", "1.0.0content.txt")); //Autodepends on componentC + + componentResourceAfterInstall.clear(); + componentResourceAfterInstall << deletedComponentResources << componentResourcesAfterUninstall; + + filesAfterUninstall.clear(); + filesAfterUninstall << "components.xml" + << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" + << "installcontentD.txt"<< "installcontentE.txt" << "installcontentG.txt"; + + filesAfterInstall.clear(); + filesAfterInstall << filesAfterUninstall << "installcontentC.txt" + << "installcontentI.txt"; + + + QTest::newRow("Uninstall with dependency") + << ":///data/installPackagesRepository" + << (QStringList() << "componentC") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterInstall + << (QStringList() << "componentC") + << PackageManagerCore::Success + << componentResourcesAfterUninstall + << filesAfterUninstall + << deletedComponentResources; + + /*********** Uninstall with subcomponents **********/ + componentResourcesAfterUninstall.clear(); + componentResourcesAfterUninstall.append(ComponentResource("componentA", "1.0.0content.txt")); + componentResourcesAfterUninstall.append(ComponentResource("componentE", "1.0.0content.txt")); + componentResourcesAfterUninstall.append(ComponentResource("componentG", "1.0.0content.txt")); + + deletedComponentResources.clear(); + deletedComponentResources.append(ComponentResource("componentF.subcomponent2.subsubcomponent2", "1.0.0content.txt")); + deletedComponentResources.append(ComponentResource("componentF.subcomponent2", "1.0.0content.txt")); + deletedComponentResources.append(ComponentResource("componentF", "1.0.0content.txt")); + + componentResourceAfterInstall.clear(); + componentResourceAfterInstall << deletedComponentResources << componentResourcesAfterUninstall; + + filesAfterInstall.clear(); + filesAfterInstall << "components.xml" << "installcontentF.txt" + << "installcontentF_2.txt" << "installcontentF_2_2.txt" + << "installcontent.txt" << "installcontentA.txt" + << "installcontentE.txt" << "installcontentG.txt"; + + filesAfterUninstall.clear(); + filesAfterUninstall << "components.xml" + << "installcontent.txt" << "installcontentA.txt" + << "installcontentE.txt" << "installcontentG.txt"; + + QTest::newRow("Uninstall with subcomponents") + << ":///data/installPackagesRepository" + << (QStringList() << "componentF.subcomponent2.subsubcomponent2") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterInstall + << (QStringList() << "componentF.subcomponent2") + << PackageManagerCore::Success + << componentResourcesAfterUninstall + << filesAfterUninstall + << deletedComponentResources; + + /*********** Uninstall forced packages **********/ + componentResourceAfterInstall.clear(); + componentResourceAfterInstall.append(ComponentResource("componentA", "1.0.0content.txt")); //ComponentG depends + componentResourceAfterInstall.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + componentResourceAfterInstall.append(ComponentResource("componentG", "1.0.0content.txt")); //Default + + componentResourcesAfterUninstall.clear(); + componentResourcesAfterUninstall = componentResourceAfterInstall; //forced packages cannot be uninstalled + + deletedComponentResources.clear(); + + filesAfterInstall.clear(); + filesAfterInstall << "components.xml" << "installcontent.txt" + << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"; + + filesAfterUninstall.clear(); + filesAfterUninstall = filesAfterInstall; + + QTest::newRow("Uninstall forced packages") + << ":///data/installPackagesRepository" + << (QStringList() << "componentG") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterInstall + << (QStringList() << "componentE") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterUninstall + << deletedComponentResources; + + /*********** Uninstall autodependency packages **********/ + componentResourceAfterInstall.clear(); + componentResourceAfterInstall.append(ComponentResource("componentA", "1.0.0content.txt")); //ComponentG depends + componentResourceAfterInstall.append(ComponentResource("componentB", "1.0.0content.txt")); //Dependency for componentC + componentResourceAfterInstall.append(ComponentResource("componentD", "1.0.0content.txt")); //Autodepend on componentA and componentB + componentResourceAfterInstall.append(ComponentResource("componentE", "1.0.0content.txt")); //ForcedInstall + componentResourceAfterInstall.append(ComponentResource("componentG", "1.0.0content.txt")); //Default + + componentResourcesAfterUninstall.clear(); + componentResourcesAfterUninstall = componentResourceAfterInstall; //autodependency packages cannot be uninstalled + + deletedComponentResources.clear(); + + filesAfterInstall.clear(); + filesAfterInstall << "components.xml" << "installcontent.txt" + << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt" + << "installcontentB.txt" << "installcontentD.txt"; + filesAfterUninstall.clear(); + filesAfterUninstall = filesAfterInstall; + + QTest::newRow("Uninstall autodependency packages") + << ":///data/installPackagesRepository" + << (QStringList() << "componentA" << "componentB") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterInstall + << (QStringList() << "componentD") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterUninstall + << deletedComponentResources; + } + + void testUninstall() + { + QFETCH(QString, repository); + QFETCH(QStringList, installComponents); + QFETCH(PackageManagerCore::Status, status); + QFETCH(ComponentResourceHash, componentResources); + QFETCH(QStringList, installedFiles); + QFETCH(QStringList, uninstallComponents); + QFETCH(PackageManagerCore::Status, uninstallStatus); + QFETCH(ComponentResourceHash, componentResourcesAfterUninstall); + QFETCH(QStringList, installedFilesAfterUninstall); + QFETCH(ComponentResourceHash, deletedComponentResources); + + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, repository)); + + QCOMPARE(status, core->installSelectedComponentsSilently(QStringList() << installComponents)); + for (const ComponentResource &resource : componentResources) + VerifyInstaller::verifyInstallerResources(m_installDir, resource.first, resource.second); + VerifyInstaller::verifyFileExistence(m_installDir, installedFiles); + core->commitSessionOperations(); + core->setPackageManager(); + + QCOMPARE(uninstallStatus, core->uninstallComponentsSilently(QStringList() + << uninstallComponents)); + QCOMPARE(uninstallStatus, core->status()); + for (const ComponentResource &resource : componentResourcesAfterUninstall) + VerifyInstaller::verifyInstallerResources(m_installDir, resource.first, resource.second); + for (const ComponentResource &resource : deletedComponentResources) + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, resource.first, resource.second); + VerifyInstaller::verifyFileExistence(m_installDir, installedFilesAfterUninstall); + } + + void addToExistingInstall_data() + { + QTest::addColumn("repository"); + QTest::addColumn("installComponents"); + QTest::addColumn("status"); + QTest::addColumn("componentResources"); + QTest::addColumn("installedFiles"); + QTest::addColumn("newRepository"); + QTest::addColumn("installNewComponents"); + QTest::addColumn("reinstallStatus"); + QTest::addColumn("componentResourcesAfterReinstall"); + QTest::addColumn("installedFilesAfterReinstall"); + QTest::addColumn("deletedComponentResources"); + + /*********** New dependency in repository **********/ + ComponentResourceHash componentResourceAfterInstall; + componentResourceAfterInstall.append(ComponentResource("componentA", "1.0.0content.txt")); //ComponentC depends on + componentResourceAfterInstall.append(ComponentResource("componentB", "1.0.0content.txt")); //ComponentC depends on + componentResourceAfterInstall.append(ComponentResource("componentC", "1.0.0content.txt")); //Selected + componentResourceAfterInstall.append(ComponentResource("componentD", "1.0.0content.txt")); //Autodepend on componentA,componentB + componentResourceAfterInstall.append(ComponentResource("componentE", "1.0.0content.txt")); //Forced + componentResourceAfterInstall.append(ComponentResource("componentG", "1.0.0content.txt")); //Default + componentResourceAfterInstall.append(ComponentResource("componentI", "1.0.0content.txt")); //Autodepend componentC + + ComponentResourceHash componentResourcesAfterReinstall; + componentResourcesAfterReinstall = componentResourceAfterInstall; + componentResourcesAfterReinstall.append(ComponentResource("componentH", "1.0.0content.txt")); + + ComponentResourceHash deletedComponentResources; + // New dependency is added in repository from componentA to componentF, check that it is not installed + deletedComponentResources.append(ComponentResource("componentF", "1.0.0content.txt")); + + QStringList filesAfterInstall; + filesAfterInstall << "components.xml" + << "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt" + << "installcontentC.txt" << "installcontentD.txt" << "installcontentE.txt" + << "installcontentG.txt" << "installcontentI.txt"; + + QStringList filesAfterReinstall; + filesAfterReinstall = filesAfterInstall; + filesAfterReinstall << "installcontentH.txt"; + + QTest::newRow("New dependency in repository") + << ":///data/installPackagesRepository" + << (QStringList() << "componentC") + << PackageManagerCore::Success + << componentResourceAfterInstall + << filesAfterInstall + << ":///data/installPackagesDependencyChanged" + << (QStringList() << "componentH") + << PackageManagerCore::Success + << componentResourcesAfterReinstall + << filesAfterReinstall + << deletedComponentResources; + } + + void addToExistingInstall() + { + QFETCH(QString, repository); + QFETCH(QStringList, installComponents); + QFETCH(PackageManagerCore::Status, status); + QFETCH(ComponentResourceHash, componentResources); + QFETCH(QStringList, installedFiles); + QFETCH(QString, newRepository); + QFETCH(QStringList, installNewComponents); + QFETCH(PackageManagerCore::Status, reinstallStatus); + QFETCH(ComponentResourceHash, componentResourcesAfterReinstall); + QFETCH(QStringList, installedFilesAfterReinstall); + QFETCH(ComponentResourceHash, deletedComponentResources); + + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, repository)); + QCOMPARE(status, core->installSelectedComponentsSilently(installComponents)); + QCOMPARE(status, core->status()); + + for (const ComponentResource &resource : componentResources) + VerifyInstaller::verifyInstallerResources(m_installDir, resource.first, resource.second); + VerifyInstaller::verifyFileExistence(m_installDir, installedFiles); + + core->reset(); + core->cancelMetaInfoJob(); //Call cancel to reset metadata so that update repositories are fetched + + QSet repoList; + Repository repo = Repository::fromUserInput(newRepository); + repoList.insert(repo); + core->settings().setDefaultRepositories(repoList); + + QCOMPARE(reinstallStatus, core->installSelectedComponentsSilently(installNewComponents)); + + for (const ComponentResource &resource : deletedComponentResources) + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, resource.first, resource.second); + for (const ComponentResource &resource : componentResourcesAfterReinstall) + VerifyInstaller::verifyInstallerResources(m_installDir, resource.first, resource.second); + VerifyInstaller::verifyFileExistence(m_installDir, installedFilesAfterReinstall); + } + + void testInstallDefaultPackagesSilently() + { + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository")); + QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); + QCOMPARE(PackageManagerCore::Success, core->status()); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG + VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall + VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt" + << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"); + } + + + void testNoDefaultInstallations() + { + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository")); + core->setNoDefaultInstallation(true); + QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); + QCOMPARE(PackageManagerCore::Success, core->status()); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "installcontentE.txt"); + core->setNoDefaultInstallation(false); + } + + void testRemoveAllSilently() + { + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository")); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() + << QLatin1String("componentA"))); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentE.txt" + << "installcontentA.txt" << "installcontent.txt" << "installcontentG.txt"); + + core->commitSessionOperations(); + core->setUninstaller(); + QCOMPARE(PackageManagerCore::Success, core->removeInstallationSilently()); + QCOMPARE(PackageManagerCore::Success, core->status()); + VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentA"); + VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentE"); + VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG"); + + // On Windows we have to settle for the resources check above as maintenance + // tool (if it would exists) and target directory are only removed later via + // started VBScript process. On Unix platforms the target directory should + // be removed in PackageManagerCorePrivate::runUninstaller(). +#if defined(Q_OS_UNIX) + QVERIFY(!QDir(m_installDir).exists()); +#endif + } + + void testUninstallVirtualSetVisibleSilently() + { + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository")); + core->setVirtualComponentsVisible(true); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() + <<"componentH")); + QCOMPARE(PackageManagerCore::Success, core->status()); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentH", "1.0.0content.txt"); + + core->commitSessionOperations(); + core->setPackageManager(); + QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() + << "componentH")); + QCOMPARE(PackageManagerCore::Success, core->status()); + VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentH"); + } + + void testFileQuery() + { + QScopedPointer core(PackageManager::getPackageManagerWithInit(m_installDir, + ":///data/filequeryrepository")); + core->setCommandLineInstance(true); + core->setFileDialogAutomaticAnswer("ValidDirectory", m_installDir); + + QString testFile = qApp->applicationDirPath() + QDir::toNativeSeparators("/test"); + QFile file(testFile); + QVERIFY(file.open(QIODevice::WriteOnly)); + core->setFileDialogAutomaticAnswer("ValidFile", testFile); + + //File dialog launched without ID + core->setFileDialogAutomaticAnswer("GetExistingDirectory", m_installDir); + core->setFileDialogAutomaticAnswer("GetExistingFile", testFile); + + QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently()); + QCOMPARE(PackageManagerCore::Success, core->status()); + + QVERIFY(core->containsFileDialogAutomaticAnswer("ValidFile")); + core->removeFileDialogAutomaticAnswer("ValidFile"); + QVERIFY(!core->containsFileDialogAutomaticAnswer("ValidFile")); + + QVERIFY(file.remove()); + } + + void init() + { + m_installDir = QInstaller::generateTemporaryFileName(); + QVERIFY(QDir().mkpath(m_installDir)); + } + + void initTestCase() + { + qSetGlobalQHashSeed(0); //Ensures the dom document deterministic behavior + } + + void cleanup() + { + QDir dir(m_installDir); + QVERIFY(dir.removeRecursively()); + } + +private: + template + void verifyListPackagesMessage(PackageManagerCore *core, const QString &message, + Func func, Args... args) + { + std::ostringstream stream; + std::streambuf *buf = std::cout.rdbuf(); + std::cout.rdbuf(stream.rdbuf()); + + (core->*func)(std::forward(args)...); + + std::cout.rdbuf(buf); + QVERIFY(stream && stream.str() == message.toStdString()); + } + +private: + QString m_installDir; +}; + + +QTEST_MAIN(tst_CommandLineInstall) + +#include "tst_commandlineinstall.moc" diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index eb5fa6d2e..5d93f2132 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -25,7 +25,7 @@ SUBDIRS += \ factory \ replaceoperation \ brokeninstaller \ - cliinterface \ + commandlineinstall \ linereplaceoperation \ metadatajob \ appendfileoperation \ -- cgit v1.2.3