changeset 294:d95fd88f6616

Prepare cinstprocesstest to be executed on Windows
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 02 Apr 2014 15:41:31 +0000
parents 3ae8b3ab3eab
children 02df89a275a6
files ui/tests/cinstprocesstest.cpp ui/tests/cinstprocesstest.h ui/tests/data/testdata.qrc
diffstat 3 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ui/tests/cinstprocesstest.cpp	Wed Apr 02 15:40:39 2014 +0000
+++ b/ui/tests/cinstprocesstest.cpp	Wed Apr 02 15:41:31 2014 +0000
@@ -7,11 +7,24 @@
 #include <QFile>
 #include <QProcess>
 
-#define RELATIVE_CINST_PATH "../../cinst/cinst"
+#define CINST_PATH_CANDIDATES "../../cinst/cinst" << \
+    "cinst" << "../../cinst/cinst.exe" << "cinst.exe";
 
-QProcess *CinstProcessTest::startCinstProcess() {
+QProcess *CinstProcessTest::startCinstProcess(const QStringList& args) {
+    QStringList cinstCandidates;
+    cinstCandidates << CINST_PATH_CANDIDATES;
+    QString processPath;
+    foreach (const QString& candidate, cinstCandidates) {
+        QFileInfo fi(candidate);
+        if (fi.isExecutable()) {
+            processPath = candidate;
+            break;
+        }
+    }
+
     QProcess *installerProcess = new QProcess();
-    installerProcess->setProgram(RELATIVE_CINST_PATH);
+    installerProcess->setArguments(args);
+    installerProcess->setProgram(processPath);
     installerProcess->start();
     installerProcess->waitForStarted();
     return installerProcess;
--- a/ui/tests/cinstprocesstest.h	Wed Apr 02 15:40:39 2014 +0000
+++ b/ui/tests/cinstprocesstest.h	Wed Apr 02 15:41:31 2014 +0000
@@ -6,7 +6,9 @@
  */
 
 #include <QObject>
+#include <QStringList>
 #include <QProcess>
+#include <QTemporaryFile>
 #include <QTest>
 #include "certificatelist.h"
 
@@ -15,7 +17,10 @@
     Q_OBJECT
 
 private:
-    QProcess* startCinstProcess();
+    QProcess* startCinstProcess(const QStringList& args = QStringList());
+    QTemporaryFile validListFile;
+    QTemporaryFile otherListFile;
+    QTemporaryFile invalidListFile;
     CertificateList validList;
     CertificateList otherList;
     CertificateList invalidList;
--- a/ui/tests/data/testdata.qrc	Wed Apr 02 15:40:39 2014 +0000
+++ b/ui/tests/data/testdata.qrc	Wed Apr 02 15:41:31 2014 +0000
@@ -1,6 +1,8 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource>
     <file>list-valid-signed.txt</file>
+    <file>list-invalid-signed.txt</file>
+    <file>list-valid-other-signature.txt</file>
 </qresource>
 </RCC>
 

http://wald.intevation.org/projects/trustbridge/