diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-05-05 13:31:32 +0300 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-05-26 15:08:51 +0300 |
commit | 17a4630886d4a91362f508f27022ae48e076d9c3 (patch) | |
tree | 6975e737ae17555de11605e515cfe79337aea760 /tests | |
parent | 0fcfdebf88372d527008ff0a080bf0f9eb493c9a (diff) |
CLI: Add new option --file-query to auto answer QFileDialog
QFileDialog.getExistingDirectory and QFileDialog.getOpenFileName
can be called from scipt. If command line interface is used, user must
type the correct directory or file name from command line during install.
With --file-query option user can give the values when running the
installer or maintenancetool with syntax --file-query
filedialogId=C:/temp,filedialogId2=C:/temp/file.txt.
Task-number: QTIFW-1631
Change-Id: I5e58be6b509cf00de832646ef31ec4eda90773be
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/installer/cliinterface/data/filequeryrepository/A/1.0.2-1meta.7z | bin | 0 -> 907 bytes | |||
-rw-r--r-- | tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml | 13 | ||||
-rw-r--r-- | tests/auto/installer/cliinterface/settings.qrc | 2 | ||||
-rw-r--r-- | tests/auto/installer/cliinterface/tst_cliinterface.cpp | 25 |
4 files changed, 40 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 000000000..a006c5c96 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/filequeryrepository/A/1.0.2-1meta.7z diff --git a/tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml b/tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml new file mode 100644 index 000000000..72b7938d9 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/filequeryrepository/Updates.xml @@ -0,0 +1,13 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>A component</Description> + <Version>1.0.2-1</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <Script>script.qs</Script> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/cliinterface/settings.qrc b/tests/auto/installer/cliinterface/settings.qrc index 85e344d1b..be97adfbe 100644 --- a/tests/auto/installer/cliinterface/settings.qrc +++ b/tests/auto/installer/cliinterface/settings.qrc @@ -19,6 +19,8 @@ <file>data/installPackagesRepository/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z</file> <file>data/installPackagesRepository/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z</file> <file>data/installPackagesRepository/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z</file> + <file>data/filequeryrepository/Updates.xml</file> + <file>data/filequeryrepository/A/1.0.2-1meta.7z</file> <file>data/componentsFromInstallPackagesRepository.xml</file> </qresource> </RCC> diff --git a/tests/auto/installer/cliinterface/tst_cliinterface.cpp b/tests/auto/installer/cliinterface/tst_cliinterface.cpp index 6040927ea..ebf63ff9d 100644 --- a/tests/auto/installer/cliinterface/tst_cliinterface.cpp +++ b/tests/auto/installer/cliinterface/tst_cliinterface.cpp @@ -351,6 +351,31 @@ private slots: << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt" << "installcontentB.txt" << "installcontentD.txt"); } + void testFileQuery() + { + PackageManagerCore *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); + + core->installDefaultComponentsSilently(); + + QVERIFY(core->containsFileDialogAutomaticAnswer("ValidFile")); + core->removeFileDialogAutomaticAnswer("ValidFile"); + QVERIFY(!core->containsFileDialogAutomaticAnswer("ValidFile")); + + QVERIFY(file.remove()); + core->deleteLater(); + } void init() { |