# HG changeset patch # User Andre Heinecke # Date 1395683109 0 # Node ID 0df62decff90117ce6e03fee9ff3f9c714837c92 # Parent a99339d0dce8e8100a8f046b712900be2c4548ee Test if uninstall is handled as instruction diff -r a99339d0dce8 -r 0df62decff90 common/errorcodes.h --- 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 */ diff -r a99339d0dce8 -r 0df62decff90 ui/tests/cinstprocesstest.cpp --- 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); diff -r a99339d0dce8 -r 0df62decff90 ui/tests/cinstprocesstest.h --- 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