瀏覽代碼

Enable more ConfigAdmin tests.

Sascha Zelzer 14 年之前
父節點
當前提交
26540fca00

+ 1 - 4
Libs/PluginFramework/Testing/ConfigAdminTest/ctkConfigAdminTestActivator.cpp

@@ -74,7 +74,7 @@ void ctkConfigAdminTestActivator::start(ctkPluginContext* context)
   managedServiceFactoryTestSuite = new ctkManagedServiceFactoryTestSuite(context, cmPluginId);
   props.clear();
   props.insert(ctkPluginConstants::SERVICE_PID, managedServiceFactoryTestSuite->metaObject()->className());
-  //context->registerService<ctkTestSuiteInterface>(managedServiceFactoryTestSuite, props);
+  context->registerService<ctkTestSuiteInterface>(managedServiceFactoryTestSuite, props);
 
   configPluginTestSuite = new ctkConfigurationPluginTestSuite(context, cmPluginId);
   props.clear();
@@ -90,9 +90,6 @@ void ctkConfigAdminTestActivator::start(ctkPluginContext* context)
 void ctkConfigAdminTestActivator::stop(ctkPluginContext* context)
 {
   Q_UNUSED(context);
-
-  //delete frameworkTestSuite;
-  //delete serviceListenerTestSuite;
 }
 
 Q_EXPORT_PLUGIN2(org_commontk_configadmintest, ctkConfigAdminTestActivator)

+ 71 - 71
Libs/PluginFramework/Testing/ConfigAdminTest/ctkManagedServiceFactoryTestSuite.cpp

@@ -120,74 +120,74 @@ void ctkManagedServiceFactoryTestSuite::testSamePidManagedServiceFactory()
   config->remove();
 }
 
-//void ctkManagedServiceFactoryTestSuite::testGeneralManagedServiceFactory()
-//{
-//  updateCount = 0;
-//  _ManagedServiceFactoryUpdateTest msf(this);
-
-//  ctkDictionary dict;
-//  dict.insert(ctkPluginConstants::SERVICE_PID, "test");
-
-//  ctkServiceRegistration reg;
-//  {
-//    QMutexLocker l(&mutex);
-//    reg = context->registerService<ctkManagedServiceFactory>(&msf, dict);
-//    locked = true;
-//    lock.wait(&mutex, 100);
-//    QVERIFY(locked);
-//    QCOMPARE(0, updateCount);
-//    locked = false;
-//  }
-
-//  ctkConfigurationPtr config = cm->createFactoryConfiguration("test");
-//  QVERIFY(config->getProperties().isEmpty());
-//  ctkDictionary props;
-//  props.insert("testkey", "testvalue");
-
-//  {
-//    QMutexLocker l(&mutex);
-//    config->update(props);
-//    locked = true;
-//    lock.wait(&mutex, 5000);
-//    if (locked)
-//      QFAIL("should have updated");
-//    QCOMPARE(1, updateCount);
-//  }
-
-//  dict.remove(ctkPluginConstants::SERVICE_PID);
-//  {
-//    QMutexLocker l(&mutex);
-//    reg.setProperties(dict);
-//    props.insert("testkey", "testvalue2");
-//    config->update(props);
-//    locked = true;
-//    lock.wait(&mutex, 100);
-//    QVERIFY(locked);
-//    QCOMPARE(1, updateCount);
-//    locked = false;
-//  }
-
-//  config->remove();
-//  config = cm->createFactoryConfiguration("test2");
-//  dict.insert(ctkPluginConstants::SERVICE_PID, "test2");
-//  {
-//    QMutexLocker l(&mutex);
-//    reg.setProperties(dict);
-//    locked = true;
-//    lock.wait(&mutex, 5000);
-//    if (locked)
-//      QFAIL("should have updated");
-//    QCOMPARE(2, updateCount);
-//  }
-
-//  {
-//    QMutexLocker l(&mutex);
-//    config->remove();
-//    locked = true;
-//    lock.wait(&mutex, 5000);
-//    if (locked)
-//      QFAIL("should have updated");
-//    QCOMPARE(3, updateCount);
-//  }
-//  reg.unregister();
-//}
+void ctkManagedServiceFactoryTestSuite::testGeneralManagedServiceFactory()
+{
+  updateCount = 0;
+  _ManagedServiceFactoryUpdateTest msf(this);
+
+  ctkDictionary dict;
+  dict.insert(ctkPluginConstants::SERVICE_PID, "test");
+
+  ctkServiceRegistration reg;
+  {
+    QMutexLocker l(&mutex);
+    reg = context->registerService<ctkManagedServiceFactory>(&msf, dict);
+    locked = true;
+    lock.wait(&mutex, 100);
+    QVERIFY(locked);
+    QCOMPARE(0, updateCount);
+    locked = false;
+  }
+
+  ctkConfigurationPtr config = cm->createFactoryConfiguration("test");
+  QVERIFY(config->getProperties().isEmpty());
+  ctkDictionary props;
+  props.insert("testkey", "testvalue");
+
+  {
+    QMutexLocker l(&mutex);
+    config->update(props);
+    locked = true;
+    lock.wait(&mutex, 5000);
+    if (locked)
+      QFAIL("should have updated");
+    QCOMPARE(1, updateCount);
+  }
+
+  dict.remove(ctkPluginConstants::SERVICE_PID);
+  {
+    QMutexLocker l(&mutex);
+    reg.setProperties(dict);
+    props.insert("testkey", "testvalue2");
+    config->update(props);
+    locked = true;
+    lock.wait(&mutex, 100);
+    QVERIFY(locked);
+    QCOMPARE(1, updateCount);
+    locked = false;
+  }
+
+  config->remove();
+  config = cm->createFactoryConfiguration("test2");
+  dict.insert(ctkPluginConstants::SERVICE_PID, "test2");
+  {
+    QMutexLocker l(&mutex);
+    reg.setProperties(dict);
+    locked = true;
+    lock.wait(&mutex, 5000);
+    if (locked)
+      QFAIL("should have updated");
+    QCOMPARE(2, updateCount);
+  }
+
+  {
+    QMutexLocker l(&mutex);
+    config->remove();
+    locked = true;
+    lock.wait(&mutex, 5000);
+    if (locked)
+      QFAIL("should have updated");
+    QCOMPARE(3, updateCount);
+  }
+  reg.unregister();
+}

+ 1 - 1
Libs/PluginFramework/Testing/ConfigAdminTest/ctkManagedServiceFactoryTestSuite_p.h

@@ -69,7 +69,7 @@ private slots:
   void cleanup();
 
   void testSamePidManagedServiceFactory();
-  //void testGeneralManagedServiceFactory();
+  void testGeneralManagedServiceFactory();
 
 private: