summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlibrary/tst_qlibrary.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-06-04 09:10:47 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-06-04 09:14:37 (GMT)
commit397295f1a91c782f905374213b85ef1108c357e3 (patch)
tree0ad3844c94c302121377ccb25a3e33f2b284d3c1 /tests/auto/qlibrary/tst_qlibrary.cpp
parent3a3a3964c001112738890dde897a2f024baf8825 (diff)
downloadQt-397295f1a91c782f905374213b85ef1108c357e3.zip
Qt-397295f1a91c782f905374213b85ef1108c357e3.tar.gz
Qt-397295f1a91c782f905374213b85ef1108c357e3.tar.bz2
Qt now really unloads plugins and libraries when exiting an app
It also means that when creating a QPluginLoader or a QLibrary for a dynamic lib already loaded, isLoaded will return true immediately after the creation of the instance of QPluginLoader or QLibrary. Reviewed-By: Jan-Arve Saether
Diffstat (limited to 'tests/auto/qlibrary/tst_qlibrary.cpp')
-rw-r--r--tests/auto/qlibrary/tst_qlibrary.cpp66
1 files changed, 43 insertions, 23 deletions
diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp
index 3d26e0b..99e6de3 100644
--- a/tests/auto/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/qlibrary/tst_qlibrary.cpp
@@ -203,6 +203,7 @@ void tst_QLibrary::version()
VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion");
QVERIFY(fnVersion);
QCOMPARE(fnVersion(), resultversion);
+ QVERIFY(library.unload());
#else
Q_UNUSED(lib);
Q_UNUSED(loadversion);
@@ -249,6 +250,7 @@ void tst_QLibrary::load()
bool ok = library.load();
if ( result ) {
QVERIFY( ok );
+ QVERIFY(library.unload());
} else {
QVERIFY( !ok );
}
@@ -338,6 +340,7 @@ void tst_QLibrary::resolve()
} else {
QVERIFY( func == 0 );
}
+ library.unload();
}
void tst_QLibrary::library_data()
@@ -469,7 +472,9 @@ void tst_QLibrary::errorString()
break;
}
QRegExp re(errorString);
- QVERIFY2(re.exactMatch(lib.errorString()), qPrintable(lib.errorString()));
+ QString libErrorString = lib.errorString();
+ QVERIFY(!lib.isLoaded() || lib.unload());
+ QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString));
QCOMPARE(ok, success);
}
@@ -525,6 +530,7 @@ void tst_QLibrary::loadHints()
bool ok = library.load();
if ( result ) {
QVERIFY( ok );
+ QVERIFY(library.unload());
} else {
QVERIFY( !ok );
}
@@ -565,6 +571,7 @@ void tst_QLibrary::fileName()
#else
QCOMPARE(lib.fileName(), expectedFilename);
#endif
+ QVERIFY(lib.unload());
}
@@ -576,29 +583,42 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QString lib = QDir::currentPath() + "/mylib";
#endif
- QLibrary lib1(lib);
- QLibrary lib2(lib);
- QCOMPARE(lib1.isLoaded(), false);
- QCOMPARE(lib2.isLoaded(), false);
- lib1.load();
- QCOMPARE(lib1.isLoaded(), true);
- QCOMPARE(lib2.isLoaded(), true);
- QCOMPARE(lib1.unload(), true);
- QCOMPARE(lib1.isLoaded(), false);
- QCOMPARE(lib2.isLoaded(), false);
- lib1.load();
- lib2.load();
- QCOMPARE(lib1.isLoaded(), true);
- QCOMPARE(lib2.isLoaded(), true);
- QCOMPARE(lib1.unload(), false);
- QCOMPARE(lib1.isLoaded(), true);
- QCOMPARE(lib2.isLoaded(), true);
- QCOMPARE(lib2.unload(), true);
- QCOMPARE(lib1.isLoaded(), false);
- QCOMPARE(lib2.isLoaded(), false);
+ {
+ QLibrary lib1(lib);
+ QLibrary lib2(lib);
+ QCOMPARE(lib1.isLoaded(), false);
+ QCOMPARE(lib2.isLoaded(), false);
+ lib1.load();
+ QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib1.unload(), true);
+ QCOMPARE(lib1.isLoaded(), false);
+ QCOMPARE(lib2.isLoaded(), false);
+ lib1.load();
+ lib2.load();
+ QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib1.unload(), false);
+ QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib2.unload(), true);
+ QCOMPARE(lib1.isLoaded(), false);
+ QCOMPARE(lib2.isLoaded(), false);
+
+ // Finally; unload on that is already unloaded
+ QCOMPARE(lib1.unload(), false);
+ }
- // Finally; unload on that is already unloaded
- QCOMPARE(lib1.unload(), false);
+ //now let's try with a 3rd one that will go out of scope
+ {
+ QLibrary lib1(lib);
+ QCOMPARE(lib1.isLoaded(), false);
+ lib1.load();
+ QCOMPARE(lib1.isLoaded(), true);
+ }
+ QLibrary lib2(lib);
+ //lib2 should be loaded because lib1 was loaded and never unloaded
+ QCOMPARE(lib2.isLoaded(), true);
/*
lib1.setLoadHints(QLibrary::ResolveAllSymbolsHint);