diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-11-18 17:12:09 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-18 08:58:45 +0100 |
commit | 105ca907fd1156ab93fc1afad3b5cadeb58b9109 (patch) | |
tree | 7b0a958de795938280bf1265eaea6799d4a312ba /tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | |
parent | 7a65dd310852037642d94a59566d1528315ea624 (diff) |
Improve QPluginLoader autotest diagnostics.
Previously, the user had to recompile the test with an additional define
to see the plugin loader error string. By re-ordering the verification
statements, we can ensure that the error string is visible in the test
results whenever its value is not the expected value, thus eliminating
the need for conditional diagnostics.
Change-Id: Iae9ef0b7cbad551fd56f0e0439eaad034f2420e3
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp')
-rw-r--r-- | tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 69 |
1 files changed, 16 insertions, 53 deletions
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index f15aa82f97..1759eb3ba7 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -115,8 +115,6 @@ private slots: void loadGarbage(); }; -//#define SHOW_ERRORS 1 - void tst_QPluginLoader::errorString() { #if defined(Q_OS_WINCE) @@ -129,95 +127,62 @@ void tst_QPluginLoader::errorString() { QPluginLoader loader; // default constructed bool loaded = loader.load(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(loaded, false); QCOMPARE(loader.errorString(), unknown); + QVERIFY(!loaded); QObject *obj = loader.instance(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(obj, static_cast<QObject*>(0)); QCOMPARE(loader.errorString(), unknown); + QCOMPARE(obj, static_cast<QObject*>(0)); bool unloaded = loader.unload(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(unloaded, false); QCOMPARE(loader.errorString(), unknown); + QVERIFY(!unloaded); } { QPluginLoader loader( sys_qualifiedLibraryName("tst_qpluginloaderlib")); //not a plugin bool loaded = loader.load(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(loaded, false); QVERIFY(loader.errorString() != unknown); + QVERIFY(!loaded); QObject *obj = loader.instance(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(obj, static_cast<QObject*>(0)); QVERIFY(loader.errorString() != unknown); + QCOMPARE(obj, static_cast<QObject*>(0)); bool unloaded = loader.unload(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(unloaded, false); QVERIFY(loader.errorString() != unknown); + QVERIFY(!unloaded); } { QPluginLoader loader( sys_qualifiedLibraryName("nosuchfile")); //not a file bool loaded = loader.load(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(loaded, false); QVERIFY(loader.errorString() != unknown); + QVERIFY(!loaded); QObject *obj = loader.instance(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(obj, static_cast<QObject*>(0)); QVERIFY(loader.errorString() != unknown); + QCOMPARE(obj, static_cast<QObject*>(0)); bool unloaded = loader.unload(); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif - QCOMPARE(unloaded, false); QVERIFY(loader.errorString() != unknown); + QVERIFY(!unloaded); } #if !defined Q_OS_WIN && !defined Q_OS_MAC && !defined Q_OS_HPUX { QPluginLoader loader( sys_qualifiedLibraryName("almostplugin")); //a plugin with unresolved symbols loader.setLoadHints(QLibrary::ResolveAllSymbolsHint); - QCOMPARE(loader.load(), false); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif + bool loaded = loader.load(); QVERIFY(loader.errorString() != unknown); + QVERIFY(!loaded); - QCOMPARE(loader.instance(), static_cast<QObject*>(0)); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif + QObject *obj = loader.instance(); QVERIFY(loader.errorString() != unknown); + QCOMPARE(obj, static_cast<QObject*>(0)); - QCOMPARE(loader.unload(), false); -#ifdef SHOW_ERRORS - qDebug() << loader.errorString(); -#endif + bool unloaded = loader.unload(); QVERIFY(loader.errorString() != unknown); + QVERIFY(!unloaded); } #endif @@ -323,9 +288,7 @@ void tst_QPluginLoader::loadGarbage() for (int i=0; i<5; i++) { QPluginLoader lib(QString(SRCDIR "elftest/garbage%1.so").arg(i)); QCOMPARE(lib.load(), false); -#ifdef SHOW_ERRORS - qDebug() << lib.errorString(); -#endif + QVERIFY(lib.errorString() != QString("Unknown error")); } #endif } |