Mercurial > trustbridge
annotate ui/tests/cinstprocesstest.cpp @ 296:0b1453070561
Fix test no list
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 02 Apr 2014 15:44:57 +0000 |
parents | 02df89a275a6 |
children | 56507c3d5f1e |
rev | line source |
---|---|
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #include "cinstprocesstest.h" |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #include "certificatelist.h" |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 #include "errorcodes.h" |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 #include <QDebug> |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 #include <QDir> |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 #include <QFile> |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 #include <QProcess> |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 |
294
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
10 #define CINST_PATH_CANDIDATES "../../cinst/cinst" << \ |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
11 "cinst" << "../../cinst/cinst.exe" << "cinst.exe"; |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 |
294
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
13 QProcess *CinstProcessTest::startCinstProcess(const QStringList& args) { |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
14 QStringList cinstCandidates; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
15 cinstCandidates << CINST_PATH_CANDIDATES; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
16 QString processPath; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
17 foreach (const QString& candidate, cinstCandidates) { |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
18 QFileInfo fi(candidate); |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
19 if (fi.isExecutable()) { |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
20 processPath = candidate; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
21 break; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
22 } |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
23 } |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
24 |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
25 QProcess *installerProcess = new QProcess(); |
294
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
26 installerProcess->setArguments(args); |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
27 installerProcess->setProgram(processPath); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 installerProcess->start(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 installerProcess->waitForStarted(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 return installerProcess; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
33 #define VERIFY_PROC_DEBUG(x) \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
34 if (! x ) { \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
35 qDebug() << "Stdout:" << proc->readAllStandardOutput(); \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
36 qDebug() << "Stderr:" << proc->readAllStandardError(); \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
37 qDebug() << "Exit code: " << proc->exitCode(); \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
38 } \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
39 QVERIFY(x) |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
40 |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 void finishVerify(QProcess *proc, int exitCode) { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 proc->closeWriteChannel(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 proc->waitForFinished(); |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
44 VERIFY_PROC_DEBUG(proc->exitStatus() == QProcess::NormalExit); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
45 VERIFY_PROC_DEBUG(proc->exitCode() == exitCode); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 delete proc; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 void CinstProcessTest::testValidInput() { |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
50 QStringList args; |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
51 args << "list=" + validListFile.fileName(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
52 |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
53 QTemporaryFile instructions; |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
54 instructions.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
55 foreach (const Certificate &cert, validList.getCertificates()) { |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
56 instructions.write(cert.base64Line().toLatin1()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
57 instructions.write("\n"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
58 } |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
59 instructions.close(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
60 |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
61 args << "instructions=" + instructions.fileName(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
62 |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
63 QProcess* installerProcess = startCinstProcess(args); |
159
37c9653b8755
Rename NO_ERROR as NO_ERROR is already defined in windows.h
Andre Heinecke <aheinecke@intevation.de>
parents:
151
diff
changeset
|
64 finishVerify(installerProcess, ERR_NO_ERROR); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
65 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
66 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
67 void CinstProcessTest::initTestCase() { |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
68 QFile valid(":/list-valid-signed.txt"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
69 valid.open(QIODevice::ReadOnly); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
70 validListFile.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
71 validListFile.write(valid.readAll()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
72 valid.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
73 validListFile.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
74 validList = CertificateList(validListFile.fileName().toLocal8Bit().data()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
75 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
76 QVERIFY(validList.isValid()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
77 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
78 QFile invalid(":/list-invalid-signed.txt"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
79 invalid.open(QIODevice::ReadOnly); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
80 invalidListFile.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
81 invalidListFile.write(invalid.readAll()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
82 invalid.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
83 invalidListFile.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
84 invalidList = CertificateList(invalidListFile.fileName().toLocal8Bit().data()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
85 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
86 QVERIFY(!invalidList.isValid()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
87 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
88 QFile other(":/list-valid-other-signature.txt"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
89 other.open(QIODevice::ReadOnly); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
90 otherListFile.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
91 otherListFile.write(other.readAll()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
92 other.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
93 otherListFile.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
94 otherList = CertificateList(otherListFile.fileName().toLocal8Bit().data()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
95 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
96 QVERIFY(!otherList.isValid()); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
97 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
98 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
99 void CinstProcessTest::testNoList() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
100 /* No list */ |
296 | 101 QTemporaryFile emptyFile; |
102 emptyFile.open(); | |
103 emptyFile.close(); | |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
104 |
296 | 105 QStringList args; |
106 args << "list=" + emptyFile.fileName(); | |
107 | |
108 QTemporaryFile instructions; | |
109 instructions.open(); | |
249
6a7eb102716d
Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents:
159
diff
changeset
|
110 foreach (const Certificate &cert, validList.getCertificates()) { |
296 | 111 instructions.write(cert.base64Line().toLatin1()); |
112 instructions.write("\n"); | |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
113 } |
296 | 114 instructions.close(); |
115 | |
116 args << "instructions=" + instructions.fileName(); | |
117 | |
118 QProcess* installerProcess = startCinstProcess(args); | |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
119 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
122 void CinstProcessTest::testGarbageInput() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
123 QProcess* installerProcess = startCinstProcess(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
124 QVERIFY(installerProcess->state() == QProcess::Running); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
125 /* Garbage */ |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
126 installerProcess = startCinstProcess(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
127 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
128 int retval=0; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
129 int bytesWritten=0; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
130 do { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
131 char garbage[1030]; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
132 for (int i = 0; i < 1030; i++) { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
133 garbage[i] = (char) qrand() % 255; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
134 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
135 retval = installerProcess->write(garbage, 1030); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
136 bytesWritten += retval; |
115
5ed770c41a73
Change garbage input to invalid input. Fix InvalidInstructions test.
Andre Heinecke <aheinecke@intevation.de>
parents:
100
diff
changeset
|
137 } while (retval != -1 && bytesWritten < 15 *1024 *1024 ); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
138 |
115
5ed770c41a73
Change garbage input to invalid input. Fix InvalidInstructions test.
Andre Heinecke <aheinecke@intevation.de>
parents:
100
diff
changeset
|
139 finishVerify(installerProcess, ERR_INVALID_INPUT); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
140 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
141 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
142 void CinstProcessTest::testNoInput() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
143 QProcess* installerProcess = startCinstProcess(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
144 QVERIFY(installerProcess->state() == QProcess::Running); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
145 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
146 /* Nothing */ |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
147 installerProcess = startCinstProcess(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
148 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
149 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
150 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
151 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
152 void CinstProcessTest::testNoInstructions() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
153 /* No instructions */ |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
154 QProcess* installerProcess = startCinstProcess(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
155 QVERIFY(installerProcess->state() == QProcess::Running); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
156 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
157 installerProcess->write(validList.rawData().toLatin1()); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
158 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
159 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
160 finishVerify(installerProcess, ERR_NO_INSTRUCTIONS); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
161 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
162 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
163 void CinstProcessTest::testInvalidInstruction() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
164 QProcess* installerProcess = startCinstProcess(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
165 QVERIFY(installerProcess->state() == QProcess::Running); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
166 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
167 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
168 installerProcess->write(validList.rawData().toLatin1()); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
169 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
170 |
150
a99339d0dce8
Fix test for invalid instructions
Andre Heinecke <aheinecke@intevation.de>
parents:
141
diff
changeset
|
171 installerProcess->write("I:ABCDEF\r\n"); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
172 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
173 finishVerify(installerProcess, ERR_INVALID_INSTRUCTIONS); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
174 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
175 |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
176 void CinstProcessTest::testUninstall() { |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
177 QProcess* installerProcess = startCinstProcess(); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
178 QVERIFY(installerProcess->state() == QProcess::Running); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
179 |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
180 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
181 installerProcess->write(validList.rawData().toLatin1()); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
182 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
183 |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
184 installerProcess->write("UNINSTALL\r\n"); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
185 |
159
37c9653b8755
Rename NO_ERROR as NO_ERROR is already defined in windows.h
Andre Heinecke <aheinecke@intevation.de>
parents:
151
diff
changeset
|
186 finishVerify(installerProcess, ERR_NO_ERROR); |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
187 } |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
188 |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
189 QTEST_GUILESS_MAIN (CinstProcessTest); |