Mercurial > trustbridge
comparison ui/tests/nsstest.cpp @ 330:1e6d1eab8395
Fix NSS unit test for Windows and change how instructions are written
This was supposed to fix the block on error. But it did not.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 08 Apr 2014 15:08:57 +0000 |
parents | ad28f6b60e6b |
children | a54925d41056 |
comparison
equal
deleted
inserted
replaced
329:b1059360a0c7 | 330:1e6d1eab8395 |
---|---|
8 #include "nsstest.h" | 8 #include "nsstest.h" |
9 #include "nssstore.h" | 9 #include "nssstore.h" |
10 #include "strhelp.h" | 10 #include "strhelp.h" |
11 | 11 |
12 #include <QTest> | 12 #include <QTest> |
13 #include <QTextCodec> | |
14 | |
15 #ifdef WIN32 | |
16 #define endl "\r\n" | |
17 #endif | |
13 | 18 |
14 QList<QByteArray> NSSTest::get_nss_certs (QTemporaryDir *nssDir) | 19 QList<QByteArray> NSSTest::get_nss_certs (QTemporaryDir *nssDir) |
15 { | 20 { |
16 CERTCertList *list; | 21 CERTCertList *list; |
17 CERTCertListNode *node; | 22 CERTCertListNode *node; |
38 } | 43 } |
39 | 44 |
40 void NSSTest::setupTestDir(QTemporaryDir *nssDir) | 45 void NSSTest::setupTestDir(QTemporaryDir *nssDir) |
41 { | 46 { |
42 /* Copy the empty nss db in the temporary dir */ | 47 /* Copy the empty nss db in the temporary dir */ |
43 QFile::copy(":/nss/cert8.db", nssDir->path() + "/" +"cert8.db"); | 48 QVERIFY(QFile::copy(":/nss/cert8.db", nssDir->path() + "/" +"cert8.db")); |
44 QFile::copy(":/nss/key3.db", nssDir->path() + "/" +"key3.db"); | 49 QVERIFY(QFile::copy(":/nss/key3.db", nssDir->path() + "/" +"key3.db")); |
45 QFile::copy(":/nss/secmod.db", nssDir->path() + "/" +"secmod.db"); | 50 QVERIFY(QFile::copy(":/nss/secmod.db", nssDir->path() + "/" +"secmod.db")); |
46 | 51 |
47 QVERIFY(QFile::setPermissions(nssDir->path() + "/" +"cert8.db", | 52 QVERIFY(QFile::setPermissions(nssDir->path() + "/" +"cert8.db", |
48 QFileDevice::ReadOwner | QFileDevice::WriteOwner)); | 53 QFileDevice::ReadOwner | QFileDevice::WriteOwner)); |
49 QVERIFY(QFile::setPermissions(nssDir->path() + "/" +"key3.db", | 54 QVERIFY(QFile::setPermissions(nssDir->path() + "/" +"key3.db", |
50 QFileDevice::ReadOwner | QFileDevice::WriteOwner)); | 55 QFileDevice::ReadOwner | QFileDevice::WriteOwner)); |
51 QVERIFY(QFile::setPermissions(nssDir->path() + "/" +"secmod.db", | 56 QVERIFY(QFile::setPermissions(nssDir->path() + "/" +"secmod.db", |
52 QFileDevice::ReadOwner | QFileDevice::WriteOwner)); | 57 QFileDevice::ReadOwner | QFileDevice::WriteOwner)); |
58 nssDir->setAutoRemove(false); | |
53 } | 59 } |
54 | 60 |
55 void NSSTest::initTestCase() { | 61 void NSSTest::initTestCase() { |
62 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); /* use system default */ | |
56 | 63 |
57 /* Set up a temporary list */ | 64 /* Set up a temporary list */ |
58 QFile res(":/list-valid-signed.txt"); | 65 QFile res(":/list-valid-signed.txt"); |
59 res.open(QIODevice::ReadOnly); | 66 res.open(QIODevice::ReadOnly); |
60 validListFile.open(); | 67 validListFile.open(); |
65 setupTestDir(&tbNSSDir); | 72 setupTestDir(&tbNSSDir); |
66 | 73 |
67 validList = CertificateList(validListFile.fileName().toLocal8Bit().data()); | 74 validList = CertificateList(validListFile.fileName().toLocal8Bit().data()); |
68 | 75 |
69 /* Create the profiles.ini `s set environment variables*/ | 76 /* Create the profiles.ini `s set environment variables*/ |
77 fakeHome.setAutoRemove(false); | |
70 #ifndef WIN32 | 78 #ifndef WIN32 |
71 QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); | 79 QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); |
72 fakeFirefoxDir = QDir(fakeHome.path() + "/.mozilla/firefox"); | 80 fakeFirefoxDir = QDir(fakeHome.path() + "/.mozilla/firefox"); |
73 fakeThunderbirdDir = QDir(fakeHome.path() + "/.thunderbird"); | 81 fakeThunderbirdDir = QDir(fakeHome.path() + "/.thunderbird"); |
74 #else | 82 #else |