Mercurial > trustbridge
comparison ui/tests/cinstprocesstest.cpp @ 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 | 37c9653b8755 |
comparison
equal
deleted
inserted
replaced
150:a99339d0dce8 | 151:0df62decff90 |
---|---|
15 installerProcess->start(); | 15 installerProcess->start(); |
16 installerProcess->waitForStarted(); | 16 installerProcess->waitForStarted(); |
17 return installerProcess; | 17 return installerProcess; |
18 } | 18 } |
19 | 19 |
20 #define VERIFY_PROC_DEBUG(x) \ | |
21 if (! x ) { \ | |
22 qDebug() << "Stdout:" << proc->readAllStandardOutput(); \ | |
23 qDebug() << "Stderr:" << proc->readAllStandardError(); \ | |
24 qDebug() << "Exit code: " << proc->exitCode(); \ | |
25 } \ | |
26 QVERIFY(x) | |
27 | |
20 void finishVerify(QProcess *proc, int exitCode) { | 28 void finishVerify(QProcess *proc, int exitCode) { |
21 proc->closeWriteChannel(); | 29 proc->closeWriteChannel(); |
22 proc->waitForFinished(); | 30 proc->waitForFinished(); |
23 QVERIFY(proc->exitStatus() == QProcess::NormalExit); | 31 VERIFY_PROC_DEBUG(proc->exitStatus() == QProcess::NormalExit); |
24 QVERIFY(proc->exitCode() == exitCode); | 32 VERIFY_PROC_DEBUG(proc->exitCode() == exitCode); |
25 delete proc; | 33 delete proc; |
26 } | 34 } |
27 | 35 |
28 void CinstProcessTest::testValidInput() { | 36 void CinstProcessTest::testValidInput() { |
29 QProcess* installerProcess = startCinstProcess(); | 37 QProcess* installerProcess = startCinstProcess(); |
36 foreach (const Certificate &cert, validList.getInstallCertificates()) { | 44 foreach (const Certificate &cert, validList.getInstallCertificates()) { |
37 installerProcess->write(cert.base64Line().toLatin1()); | 45 installerProcess->write(cert.base64Line().toLatin1()); |
38 installerProcess->write("\r\n"); | 46 installerProcess->write("\r\n"); |
39 } | 47 } |
40 | 48 |
41 finishVerify(installerProcess, 0); | 49 finishVerify(installerProcess, NO_ERROR); |
42 } | 50 } |
43 | 51 |
44 void CinstProcessTest::initTestCase() { | 52 void CinstProcessTest::initTestCase() { |
45 QDir dataDir = QDir(SOURCE_DIR"/data/"); | 53 QDir dataDir = QDir(SOURCE_DIR"/data/"); |
46 QString fileName = dataDir.absoluteFilePath("list-valid-signed.txt"); | 54 QString fileName = dataDir.absoluteFilePath("list-valid-signed.txt"); |
104 | 112 |
105 void CinstProcessTest::testInvalidInstruction() { | 113 void CinstProcessTest::testInvalidInstruction() { |
106 QProcess* installerProcess = startCinstProcess(); | 114 QProcess* installerProcess = startCinstProcess(); |
107 QVERIFY(installerProcess->state() == QProcess::Running); | 115 QVERIFY(installerProcess->state() == QProcess::Running); |
108 | 116 |
109 /* I: as instruction */ | |
110 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); | 117 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); |
111 installerProcess->write(validList.rawData().toLatin1()); | 118 installerProcess->write(validList.rawData().toLatin1()); |
112 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); | 119 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); |
113 | 120 |
114 installerProcess->write("I:ABCDEF\r\n"); | 121 installerProcess->write("I:ABCDEF\r\n"); |
115 | 122 |
116 finishVerify(installerProcess, ERR_INVALID_INSTRUCTIONS); | 123 finishVerify(installerProcess, ERR_INVALID_INSTRUCTIONS); |
117 } | 124 } |
118 | 125 |
126 void CinstProcessTest::testUninstall() { | |
127 QProcess* installerProcess = startCinstProcess(); | |
128 QVERIFY(installerProcess->state() == QProcess::Running); | |
129 | |
130 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); | |
131 installerProcess->write(validList.rawData().toLatin1()); | |
132 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); | |
133 | |
134 installerProcess->write("UNINSTALL\r\n"); | |
135 | |
136 finishVerify(installerProcess, NO_ERROR); | |
137 } | |
138 | |
119 QTEST_GUILESS_MAIN (CinstProcessTest); | 139 QTEST_GUILESS_MAIN (CinstProcessTest); |