changeset 151:0df62decff90

Test if uninstall is handled as instruction
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 24 Mar 2014 17:45:09 +0000
parents a99339d0dce8
children dbbd761959ae
files common/errorcodes.h ui/tests/cinstprocesstest.cpp ui/tests/cinstprocesstest.h
diffstat 3 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/common/errorcodes.h	Mon Mar 24 17:23:42 2014 +0000
+++ b/common/errorcodes.h	Mon Mar 24 17:45:09 2014 +0000
@@ -1,6 +1,8 @@
 #ifndef ERRORCODES_H
 #define ERRORCODES_H
 
+/* No error */
+#define NO_ERROR 0
 /* No begin certificate / end certificate could be found */
 #define ERR_INVALID_INPUT_NO_LIST 2
 /* Too much input for the installer process */
--- a/ui/tests/cinstprocesstest.cpp	Mon Mar 24 17:23:42 2014 +0000
+++ b/ui/tests/cinstprocesstest.cpp	Mon Mar 24 17:45:09 2014 +0000
@@ -17,11 +17,19 @@
     return installerProcess;
 }
 
+#define VERIFY_PROC_DEBUG(x) \
+    if (! x ) { \
+        qDebug() << "Stdout:" << proc->readAllStandardOutput(); \
+        qDebug() << "Stderr:" << proc->readAllStandardError(); \
+        qDebug() << "Exit code: " << proc->exitCode(); \
+    } \
+    QVERIFY(x)
+
 void finishVerify(QProcess *proc, int exitCode) {
     proc->closeWriteChannel();
     proc->waitForFinished();
-    QVERIFY(proc->exitStatus() == QProcess::NormalExit);
-    QVERIFY(proc->exitCode() == exitCode);
+    VERIFY_PROC_DEBUG(proc->exitStatus() == QProcess::NormalExit);
+    VERIFY_PROC_DEBUG(proc->exitCode() == exitCode);
     delete proc;
 }
 
@@ -38,7 +46,7 @@
         installerProcess->write("\r\n");
     }
 
-    finishVerify(installerProcess, 0);
+    finishVerify(installerProcess, NO_ERROR);
 }
 
 void CinstProcessTest::initTestCase() {
@@ -106,7 +114,6 @@
     QProcess* installerProcess = startCinstProcess();
     QVERIFY(installerProcess->state() == QProcess::Running);
 
-    /* I: as instruction */
     installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n");
     installerProcess->write(validList.rawData().toLatin1());
     installerProcess->write("-----END CERTIFICATE LIST-----\r\n");
@@ -116,4 +123,17 @@
     finishVerify(installerProcess, ERR_INVALID_INSTRUCTIONS);
 }
 
+void CinstProcessTest::testUninstall() {
+    QProcess* installerProcess = startCinstProcess();
+    QVERIFY(installerProcess->state() == QProcess::Running);
+
+    installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n");
+    installerProcess->write(validList.rawData().toLatin1());
+    installerProcess->write("-----END CERTIFICATE LIST-----\r\n");
+
+    installerProcess->write("UNINSTALL\r\n");
+
+    finishVerify(installerProcess, NO_ERROR);
+}
+
 QTEST_GUILESS_MAIN (CinstProcessTest);
--- a/ui/tests/cinstprocesstest.h	Mon Mar 24 17:23:42 2014 +0000
+++ b/ui/tests/cinstprocesstest.h	Mon Mar 24 17:45:09 2014 +0000
@@ -28,6 +28,7 @@
     void testNoList();
     void testGarbageInput();
     void testNoInstructions();
+    void testUninstall();
 };
 #endif
 

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