From 4121f9df29c85d45e0fe128d237c0009cded7574 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 16 Feb 2012 08:25:31 +1000 Subject: [PATCH] Changed qsslkey to work from installation directory - Changed to use TESTDATA and QFINDTESTDATA instead of SRCDIR Change-Id: I30bf175c2c9044e1f8556260a032467ca0dfc09f Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- tests/auto/network/ssl/qsslkey/qsslkey.pro | 21 +-------- .../auto/network/ssl/qsslkey/tst_qsslkey.cpp | 43 +++++-------------- 2 files changed, 12 insertions(+), 52 deletions(-) diff --git a/tests/auto/network/ssl/qsslkey/qsslkey.pro b/tests/auto/network/ssl/qsslkey/qsslkey.pro index 4af35487cd..d794c0faf0 100644 --- a/tests/auto/network/ssl/qsslkey/qsslkey.pro +++ b/tests/auto/network/ssl/qsslkey/qsslkey.pro @@ -6,23 +6,4 @@ QT = core network testlib TARGET = tst_qsslkey -win32 { - 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\\\" -} +TESTDATA += keys/* rsa-without-passphrase.pem rsa-with-passphrase.pem diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 657b91152f..e8941a2642 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -68,14 +68,8 @@ class tst_QSslKey : public QObject void createPlainTestRows(); -public: - tst_QSslKey(); - virtual ~tst_QSslKey(); - public slots: - void initTestCase_data(); - void init(); - void cleanup(); + void initTestCase(); #ifndef QT_NO_OPENSSL @@ -95,16 +89,17 @@ private slots: void passphraseChecks(); #endif +private: + QString testDataDir; }; -tst_QSslKey::tst_QSslKey() +void tst_QSslKey::initTestCase() { -#ifdef Q_OS_MAC - // applicationDirPath() points to a path inside the app bundle on Mac. - QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../keys")); -#else - QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds? -#endif + testDataDir = QFileInfo(QFINDTESTDATA("rsa-without-passphrase.pem")).absolutePath(); + if (testDataDir.isEmpty()) + testDataDir = QCoreApplication::applicationDirPath(); + + QDir dir(testDataDir + "/keys"); QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable); QRegExp rx(QLatin1String("^(rsa|dsa)-(pub|pri)-(\\d+)\\.(pem|der)$")); 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) { QFile file(absFilePath); @@ -368,7 +347,7 @@ void tst_QSslKey::toEncryptedPemOrDer() void tst_QSslKey::passphraseChecks() { { - QString fileName(SRCDIR "/rsa-with-passphrase.pem"); + QString fileName(testDataDir + "/rsa-with-passphrase.pem"); QFile keyFile(fileName); QVERIFY(keyFile.exists()); { @@ -407,7 +386,7 @@ void tst_QSslKey::passphraseChecks() { // 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); { if (!keyFile.isOpen())