Changed qsslkey to work from installation directory

- Changed to use TESTDATA and QFINDTESTDATA instead of SRCDIR

Change-Id: I30bf175c2c9044e1f8556260a032467ca0dfc09f
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
This commit is contained in:
Kurt Korbatits 2012-02-16 08:25:31 +10:00 committed by Qt by Nokia
parent 20f6dc615a
commit 4121f9df29
2 changed files with 12 additions and 52 deletions

View File

@ -6,23 +6,4 @@ QT = core network testlib
TARGET = tst_qsslkey TARGET = tst_qsslkey
win32 { TESTDATA += keys/* rsa-without-passphrase.pem rsa-with-passphrase.pem
CONFIG(debug, debug|release) {
DESTDIR = debug
} else {
DESTDIR = release
}
}
wince* {
keyFiles.files = keys
keyFiles.path = .
passphraseFiles.files = rsa-without-passphrase.pem rsa-with-passphrase.pem
passphraseFiles.path = .
DEPLOYMENT += keyFiles passphraseFiles
DEFINES += SRCDIR=\\\".\\\"
} else {
DEFINES+= SRCDIR=\\\"$$PWD\\\"
}

View File

@ -68,14 +68,8 @@ class tst_QSslKey : public QObject
void createPlainTestRows(); void createPlainTestRows();
public:
tst_QSslKey();
virtual ~tst_QSslKey();
public slots: public slots:
void initTestCase_data(); void initTestCase();
void init();
void cleanup();
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
@ -95,16 +89,17 @@ private slots:
void passphraseChecks(); void passphraseChecks();
#endif #endif
private:
QString testDataDir;
}; };
tst_QSslKey::tst_QSslKey() void tst_QSslKey::initTestCase()
{ {
#ifdef Q_OS_MAC testDataDir = QFileInfo(QFINDTESTDATA("rsa-without-passphrase.pem")).absolutePath();
// applicationDirPath() points to a path inside the app bundle on Mac. if (testDataDir.isEmpty())
QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../keys")); testDataDir = QCoreApplication::applicationDirPath();
#else
QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds? QDir dir(testDataDir + "/keys");
#endif
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable); QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
QRegExp rx(QLatin1String("^(rsa|dsa)-(pub|pri)-(\\d+)\\.(pem|der)$")); QRegExp rx(QLatin1String("^(rsa|dsa)-(pub|pri)-(\\d+)\\.(pem|der)$"));
foreach (QFileInfo fileInfo, fileInfoList) { foreach (QFileInfo fileInfo, fileInfoList) {
@ -118,22 +113,6 @@ tst_QSslKey::tst_QSslKey()
} }
} }
tst_QSslKey::~tst_QSslKey()
{
}
void tst_QSslKey::initTestCase_data()
{
}
void tst_QSslKey::init()
{
}
void tst_QSslKey::cleanup()
{
}
static QByteArray readFile(const QString &absFilePath) static QByteArray readFile(const QString &absFilePath)
{ {
QFile file(absFilePath); QFile file(absFilePath);
@ -368,7 +347,7 @@ void tst_QSslKey::toEncryptedPemOrDer()
void tst_QSslKey::passphraseChecks() void tst_QSslKey::passphraseChecks()
{ {
{ {
QString fileName(SRCDIR "/rsa-with-passphrase.pem"); QString fileName(testDataDir + "/rsa-with-passphrase.pem");
QFile keyFile(fileName); QFile keyFile(fileName);
QVERIFY(keyFile.exists()); QVERIFY(keyFile.exists());
{ {
@ -407,7 +386,7 @@ void tst_QSslKey::passphraseChecks()
{ {
// be sure and check a key without passphrase too // be sure and check a key without passphrase too
QString fileName(SRCDIR "/rsa-without-passphrase.pem"); QString fileName(testDataDir + "/rsa-without-passphrase.pem");
QFile keyFile(fileName); QFile keyFile(fileName);
{ {
if (!keyFile.isOpen()) if (!keyFile.isOpen())