comparison ui/tests/binverifytest.cpp @ 869:b1df9621c89c

Add a test for text signature creation with createinstallerdialog
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 05 Aug 2014 17:45:03 +0200
parents 44fa5de02b52
children 317ee9dc4684
comparison
equal deleted inserted replaced
868:ae571e7ecdc9 869:b1df9621c89c
5 * and comes with ABSOLUTELY NO WARRANTY! 5 * and comes with ABSOLUTELY NO WARRANTY!
6 * See LICENSE.txt for details. 6 * See LICENSE.txt for details.
7 */ 7 */
8 #include "binverify.h" 8 #include "binverify.h"
9 #include "binverifytest.h" 9 #include "binverifytest.h"
10 #include "createinstallerdialog.h"
11 #include "common.h"
12 #include "mainwindow.h"
10 13
11 #include <QTest> 14 #include <QtTest>
15 #include <QSettings>
16 #include <QTemporaryFile>
12 17
13 #ifdef Q_OS_WIN 18 #ifdef Q_OS_WIN
14 # define EXE_SUFFIX ".exe" 19 # define EXE_SUFFIX ".exe"
15 #else 20 #else
16 # define EXE_SUFFIX "" 21 # define EXE_SUFFIX ""
22 #endif
23
24 #ifdef Q_OS_WIN
25 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
26 #else
27 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
17 #endif 28 #endif
18 29
19 /* Some general robustness checks */ 30 /* Some general robustness checks */
20 void BinVerifyTest::testMiscErrors() 31 void BinVerifyTest::testMiscErrors()
21 { 32 {
69 { 80 {
70 QVERIFY (VerifyValid == verify_binary ("fakeinst-signed" EXE_SUFFIX, 81 QVERIFY (VerifyValid == verify_binary ("fakeinst-signed" EXE_SUFFIX,
71 strlen("fakeinst-signed" EXE_SUFFIX))); 82 strlen("fakeinst-signed" EXE_SUFFIX)));
72 } 83 }
73 84
74 QTEST_GUILESS_MAIN (BinVerifyTest); 85 void BinVerifyTest::testSignatureCreation()
86 {
87 QSettings testsettings;
88 testsettings.setValue("CodeSignCert", SOURCE_DIR"/data/codesign/codesigning-combined.pem");
89 testsettings.sync();
90 CreateInstallerDialog *theDialog = new CreateInstallerDialog(NULL);
91 QString garbage = getRandomDataFile(21*1024*1024);
92 QTemporaryFile outfile;
93 outfile.open();
94 outfile.close();
95 bool ret = theDialog->appendTextSignatureToFile (garbage, outfile.fileName());
96 QVERIFY(QFile::remove(garbage));
97 QVERIFY(ret == true);
98 QVERIFY(VerifyValid == verify_binary (outfile.fileName().toUtf8().constData(),
99 outfile.fileName().toUtf8().size()));
100 }
101
102 QTEST_MAIN (BinVerifyTest);

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