summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2014-05-06 18:33:10 +0200
committerDaniel Teske <daniel.teske@digia.com>2014-05-12 14:54:36 +0200
commitce1a691abe0475a6f75ff6d6059df8b25a775fe9 (patch)
treedfde08065b0562f4ceb47784ae99a8f65dd85dcc /tests
parent248964789a9eb7a759be63cabf68a3df3e56c023 (diff)
downloadqt-creator-ce1a691abe0475a6f75ff6d6059df8b25a775fe9.tar.gz
PluginManager: Introduce a getObjects() function taking a predicate
Change-Id: I8a822d76a3dc358de48e96801e4e531f3bbb8669 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/extensionsystem/pluginmanager/tst_pluginmanager.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/extensionsystem/pluginmanager/tst_pluginmanager.cpp b/tests/auto/extensionsystem/pluginmanager/tst_pluginmanager.cpp
index e8169795e0..9e3ce28cdb 100644
--- a/tests/auto/extensionsystem/pluginmanager/tst_pluginmanager.cpp
+++ b/tests/auto/extensionsystem/pluginmanager/tst_pluginmanager.cpp
@@ -138,6 +138,9 @@ void tst_PluginManager::getObject()
{
MyClass2 *object2 = new MyClass2;
MyClass11 *object11 = new MyClass11;
+ MyClass2 *object2b = new MyClass2;
+ const QString objectName = QLatin1String("OBJECTNAME");
+ object2b->setObjectName(objectName);
m_pm->addObject(object2);
QCOMPARE(m_pm->getObject<MyClass11>(), (MyClass11*)0);
QCOMPARE(m_pm->getObject<MyClass1>(), (MyClass1*)0);
@@ -146,10 +149,17 @@ void tst_PluginManager::getObject()
QCOMPARE(m_pm->getObject<MyClass11>(), object11);
QCOMPARE(m_pm->getObject<MyClass1>(), qobject_cast<MyClass1*>(object11));
QCOMPARE(m_pm->getObject<MyClass2>(), object2);
+ QCOMPARE(m_pm->getObjectByName(objectName), (QObject*)0);
+ m_pm->addObject(object2b);
+ QCOMPARE(m_pm->getObjectByName(objectName), object2b);
+ QCOMPARE(m_pm->getObject<MyClass2>(
+ [&objectName](MyClass2 *obj) { return obj->objectName() == objectName;}), object2b);
m_pm->removeObject(object2);
m_pm->removeObject(object11);
+ m_pm->removeObject(object2b);
delete object2;
delete object11;
+ delete object2b;
}
void tst_PluginManager::getObjects()
@@ -172,6 +182,12 @@ void tst_PluginManager::getObjects()
QCOMPARE(m_pm->getObjects<MyClass1>(), QList<MyClass1*>() << object11 << object1);
QCOMPARE(m_pm->getObjects<MyClass2>(), QList<MyClass2*>() << object2);
QCOMPARE(m_pm->allObjects(), QList<QObject*>() << object2 << object11 << object1);
+
+ QCOMPARE(m_pm->getObjects<MyClass1>(
+ [](MyClass1 *o){
+ return !qobject_cast<MyClass11 *>(o);} ),
+ QList<MyClass1 *>() << object1);
+
m_pm->removeObject(object2);
m_pm->removeObject(object11);
m_pm->removeObject(object1);