Browse Source

Fix [DICOM]Core tests to be runnable without GUI

These tests were failing on linux when no X server is running.
Julien Finet 14 years ago
parent
commit
58fd1ed12c

+ 2 - 2
Libs/Core/Testing/Cpp/ctkAbstractFactoryTest1.cpp

@@ -19,7 +19,7 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
+#include <QCoreApplication>
 
 // CTK includes
 #include "ctkAbstractFactory.h"
@@ -62,7 +62,7 @@ struct Item{
 //-----------------------------------------------------------------------------
 int ctkAbstractFactoryTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   ctkAbstractFactory<Item> abstractFactory;
   abstractFactory.printAdditionalInfo();

+ 2 - 3
Libs/Core/Testing/Cpp/ctkAbstractLibraryFactoryTest1.cpp

@@ -19,8 +19,7 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
-#include <QPushButton>
+#include <QCoreApplication>
 
 // CTK includes
 #include "ctkAbstractLibraryFactory.h"
@@ -66,7 +65,7 @@ protected:
 //-----------------------------------------------------------------------------
 int ctkAbstractLibraryFactoryTest1(int argc, char * argv [])
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   if (argc <= 1)
     {

+ 2 - 2
Libs/Core/Testing/Cpp/ctkAbstractObjectFactoryTest1.cpp

@@ -19,7 +19,7 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
+#include <QCoreApplication>
 
 // CTK includes
 #include "ctkAbstractObjectFactory.h"
@@ -37,7 +37,7 @@ public:
 //-----------------------------------------------------------------------------
 int ctkAbstractObjectFactoryTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   ctkAbstractObjectFactory< BaseClassHelper > ctkObject;
 

+ 6 - 6
Libs/Core/Testing/Cpp/ctkAbstractPluginFactoryTest1.cpp

@@ -19,8 +19,8 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
-#include <QPushButton>
+#include <QCoreApplication>
+#include <QTimer>
 
 // CTK includes
 #include "ctkAbstractPluginFactory.h"
@@ -33,7 +33,7 @@
 //-----------------------------------------------------------------------------
 int ctkAbstractPluginFactoryTest1(int argc, char * argv [])
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   if (argc <= 1)
     {
@@ -103,7 +103,7 @@ int ctkAbstractPluginFactoryTest1(int argc, char * argv [])
   pluginFactory.uninstantiate("lib");
   
   // ctkDummyPlugin is not a QPushButton, it should fail then.
-  ctkAbstractPluginFactory< QPushButton > buttonPluginFactory;
+  ctkAbstractPluginFactory< QTimer > buttonPluginFactory;
   buttonPluginFactory.setVerbose(true);
   // it should register but fail while instanciating
   res = buttonPluginFactory.registerFileItem("foo", file);
@@ -112,8 +112,8 @@ int ctkAbstractPluginFactoryTest1(int argc, char * argv [])
     std::cerr << "ctkAbstractPluginFactory::registerLibrary() failed" << std::endl;
     return EXIT_FAILURE;
     }
-  QPushButton* button = buttonPluginFactory.instantiate("foo");
-  if (button != 0)
+  QTimer* timer = buttonPluginFactory.instantiate("foo");
+  if (timer != 0)
     {
     std::cerr << "ctkAbstractPluginFactory::instantiate() failed" << std::endl;
     return EXIT_FAILURE;

+ 2 - 2
Libs/Core/Testing/Cpp/ctkAbstractQObjectFactoryTest1.cpp

@@ -19,7 +19,7 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
+#include <QCoreApplication>
 
 // CTK includes
 #include "ctkAbstractQObjectFactory.h"
@@ -32,7 +32,7 @@
 //-----------------------------------------------------------------------------
 int ctkAbstractQObjectFactoryTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   ctkAbstractQObjectFactory< ctkModelTester > ctkObject;
 

+ 2 - 3
Libs/Core/Testing/Cpp/ctkCheckableModelHelperTest1.cpp

@@ -19,10 +19,9 @@
 =========================================================================*/
 
 // Qt includes
+#include <QCoreApplication>
 #include <QDebug>
-#include <QApplication>
 #include <QFocusEvent>
-#include <QTableView>
 #include <QStandardItem>
 #include <QStandardItemModel>
 #include <QTimer>
@@ -37,7 +36,7 @@
 //-----------------------------------------------------------------------------
 int ctkCheckableModelHelperTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   QStandardItemModel model;
   QList<QStandardItem*> row0;

+ 30 - 24
Libs/Core/Testing/Cpp/ctkModelTesterTest1.cpp

@@ -20,10 +20,11 @@
 
 // Qt includes
 #include <QAbstractItemModel>
-#include <QApplication>
+#include <QCoreApplication>
 #include <QList>
 #include <QModelIndex>
-#include <QTreeWidget>
+#include <QStandardItem>
+#include <QStandardItemModel>
 
 // CTK includes
 #include "ctkModelTester.h"
@@ -46,7 +47,7 @@ public:
 //-----------------------------------------------------------------------------
 int ctkModelTesterTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
   QAbstractItemModelHelper * item = new QAbstractItemModelHelper;
   QObject * object = new QObject; 
@@ -57,30 +58,35 @@ int ctkModelTesterTest1(int argc, char * argv [] )
 
   try
     {
-    // as we can infer that QTreeWidget is correct, ctkModelTester shall not fail
-    // for any of the actions on QTreeWidget.
-    QTreeWidget treeWidget(0);
-    ctkModelTester treeModelTester(treeWidget.model());
-    treeWidget.setColumnCount(1);
-    QList<QTreeWidgetItem *> items;
+    // as we can infer that QStandardItemModel is correct,
+    // ctkModelTester shall not fail for any of the actions on the model.
+    // Please note here that takeRow() doesn't delete the items so we end up
+    // with mem leaks.
+    QStandardItemModel model;
+    ctkModelTester treeModelTester(&model);
+    QList<QStandardItem*> items;
+    items << new QStandardItem("col1") << new QStandardItem("col2");
+    model.appendRow(items);
+    QList<QStandardItem*> items2  = model.takeRow(0);
+    if (items2 != items)
+      {
+      std::cerr << "Error" << std::endl;
+      return EXIT_FAILURE;
+      }
+    items2.clear();
+    model.appendRow(items);
     for (int i = 0; i < 10; ++i)
       {
-      items.append(new QTreeWidgetItem(
-          reinterpret_cast<QTreeWidget*>(0), QStringList(QString("item: %1").arg(i))));
+      model.appendRow(QList<QStandardItem*>() << new QStandardItem("col1") << new QStandardItem("col2"));
       }
-    treeWidget.addTopLevelItems(items);
-    treeWidget.takeTopLevelItem(0);
-    treeWidget.takeTopLevelItem(treeWidget.topLevelItemCount() / 2 );
-    treeWidget.takeTopLevelItem(treeWidget.topLevelItemCount() - 1);
-    treeWidget.insertTopLevelItem(0, new QTreeWidgetItem(&treeWidget, QStringList("new item 0")));
-    treeWidget.insertTopLevelItem(treeWidget.topLevelItemCount() / 2, new QTreeWidgetItem(
-        reinterpret_cast<QTreeWidget*>(0), QStringList("new item 1")));
-    treeWidget.insertTopLevelItem(treeWidget.topLevelItemCount(), new QTreeWidgetItem(
-        reinterpret_cast<QTreeWidget*>(0), QStringList("new item 2")));
-    new QTreeWidgetItem(treeWidget.topLevelItem(0), QStringList("new item 3"));
-    QAbstractItemModel* model = treeWidget.model();
-    model->setData(model->index(0,0),QString("foo"));
-    treeWidget.sortItems(0, Qt::DescendingOrder);
+    model.takeRow(0);
+    model.takeRow(model.rowCount() / 2 );
+    model.takeRow(model.rowCount() - 1);
+    items2 << new QStandardItem("col1") << new QStandardItem("col2");
+    items2[0]->appendRow(QList<QStandardItem*>() << new QStandardItem("subcol1") << new QStandardItem("subcol2"));
+    items2[0]->appendRow(QList<QStandardItem*>() << new QStandardItem("subcol1") << new QStandardItem("subcol2"));
+    model.setData(model.index(0,0), QString("foo"));
+    model.sort(0);
     }
   catch (const char* error)
     {

+ 2 - 2
Libs/Core/Testing/Cpp/ctkPimplTest1.cpp

@@ -19,7 +19,7 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
+#include <QCoreApplication>
 
 // CTK includes
 #include <ctkPimpl.h>
@@ -38,7 +38,7 @@ public:
 //-----------------------------------------------------------------------------
 int ctkPimplTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
 
 
   return EXIT_SUCCESS;

+ 37 - 37
Libs/Core/Testing/Cpp/ctkWorkflowTest1.cpp

@@ -19,7 +19,7 @@
   =========================================================================*/
 
 // QT includes
-#include <QApplication>
+#include <QCoreApplication>
 #include <QTimer>
 
 // CTK includes
@@ -82,19 +82,19 @@ int currentStepAndNumberOfTimesEntryExitTest(ctkWorkflow* workflow, ctkExampleDe
 }
 
 //-----------------------------------------------------------------------------
-int transitionTest(ctkWorkflow* workflow, int defaultTime, QApplication& app, ctkExampleDerivedWorkflowStep* expectedStep, ctkExampleDerivedWorkflowStep* step1, int step1Entry, int step1Exit, ctkExampleDerivedWorkflowStep* step2, int step2Entry, int step2Exit, ctkExampleDerivedWorkflowStep* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleDerivedWorkflowStep* step4=0, int step4Entry=0, int step4Exit=0)
+int transitionTest(ctkWorkflow* workflow, int defaultTime, ctkExampleDerivedWorkflowStep* expectedStep, ctkExampleDerivedWorkflowStep* step1, int step1Entry, int step1Exit, ctkExampleDerivedWorkflowStep* step2, int step2Entry, int step2Exit, ctkExampleDerivedWorkflowStep* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleDerivedWorkflowStep* step4=0, int step4Entry=0, int step4Exit=0)
 {
-  QTimer::singleShot(defaultTime, &app, SLOT(quit()));
-  app.exec();
+  QTimer::singleShot(defaultTime, qApp, SLOT(quit()));
+  qApp->exec();
   return currentStepAndNumberOfTimesEntryExitTest(workflow, expectedStep, step1, step1Entry, step1Exit, step2, step2Entry, step2Exit, step3, step3Entry, step3Exit, step4, step4Entry, step4Exit);
 }
 
 //-----------------------------------------------------------------------------
-int testStartWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app, bool shouldRun, ctkExampleDerivedWorkflowStep* expectedStep=0, ctkExampleDerivedWorkflowStep* step1=0, int step1Entry=0, int step1Exit=0, ctkExampleDerivedWorkflowStep* step2=0, int step2Entry=0, int step2Exit=0, ctkExampleDerivedWorkflowStep* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleDerivedWorkflowStep* step4=0, int step4Entry=0, int step4Exit=0)
+int testStartWorkflow(ctkWorkflow* workflow, int defaultTime, bool shouldRun, ctkExampleDerivedWorkflowStep* expectedStep=0, ctkExampleDerivedWorkflowStep* step1=0, int step1Entry=0, int step1Exit=0, ctkExampleDerivedWorkflowStep* step2=0, int step2Entry=0, int step2Exit=0, ctkExampleDerivedWorkflowStep* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleDerivedWorkflowStep* step4=0, int step4Entry=0, int step4Exit=0)
 {
   workflow->start();
-  QTimer::singleShot(defaultTime, &app, SLOT(quit()));
-  app.exec();
+  QTimer::singleShot(defaultTime, qApp, SLOT(quit()));
+  qApp->exec();
   if (workflow->isRunning() != shouldRun)
     {
     return 0;
@@ -103,11 +103,11 @@ int testStartWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app,
 }
 
 //-----------------------------------------------------------------------------
-int testStopWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app, ctkExampleDerivedWorkflowStep* step1, int step1Entry, int step1Exit, ctkExampleDerivedWorkflowStep* step2, int step2Entry, int step2Exit, ctkExampleDerivedWorkflowStep* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleDerivedWorkflowStep* step4=0, int step4Entry=0, int step4Exit=0)
+int testStopWorkflow(ctkWorkflow* workflow, int defaultTime, ctkExampleDerivedWorkflowStep* step1, int step1Entry, int step1Exit, ctkExampleDerivedWorkflowStep* step2, int step2Entry, int step2Exit, ctkExampleDerivedWorkflowStep* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleDerivedWorkflowStep* step4=0, int step4Entry=0, int step4Exit=0)
 {
   workflow->stop();
-  QTimer::singleShot(defaultTime, &app, SLOT(quit()));
-  app.exec();
+  QTimer::singleShot(defaultTime, qApp, SLOT(quit()));
+  qApp->exec();
   if (workflow->isRunning())
     {
     return 0;
@@ -118,7 +118,7 @@ int testStopWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app,
 //-----------------------------------------------------------------------------
 int ctkWorkflowTest1(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
   int defaultTime = 100;
 
   // create two steps and the workflow
@@ -150,7 +150,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   // workflow with no steps
   // try erroneously starting with no steps
 
-  if (!testStartWorkflow(workflow, defaultTime, app, false))
+  if (!testStartWorkflow(workflow, defaultTime, false))
     {
     std::cerr << "empty workflow is running after start()";
     return EXIT_FAILURE;
@@ -164,7 +164,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
     }
 
   // try erroneously starting with no initial step
-  if (!testStartWorkflow(workflow, defaultTime, app, false))
+  if (!testStartWorkflow(workflow, defaultTime, false))
     {
     std::cerr << "workflow is running after start() with no initial step";
     return EXIT_FAILURE;
@@ -177,7 +177,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   workflow->setInitialStep(step1);
 
   // try starting with one step
-  if (!testStartWorkflow(workflow, defaultTime, app, true, step1, step1, 1, 0, step2, 0, 0))
+  if (!testStartWorkflow(workflow, defaultTime, true, step1, step1, 1, 0, step2, 0, 0))
     {
     std::cerr << "workflow is not running after start() with a single step";
     return EXIT_FAILURE;
@@ -186,7 +186,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   // triggering ValidationTransition and TransitionToPreviousStep
   // should keep us in the same step, when there is only one step
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 1, 0, step2, 0, 0))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 1, 0, step2, 0, 0))
     {
     std::cerr << "error in validation transition in a workflow with a single step";
     return EXIT_FAILURE;
@@ -194,14 +194,14 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // transition to the previous step
   workflow->goBackward();
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 1, 0, step2, 0, 0))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 1, 0, step2, 0, 0))
     {
     std::cerr << "error after transition to previous step in a workflow with a single step";
     return EXIT_FAILURE;
     }
 
   // stop the workflow
-  if (!testStopWorkflow(workflow, defaultTime, app, step1, 1, 1, step2, 0, 0))
+  if (!testStopWorkflow(workflow, defaultTime, step1, 1, 1, step2, 0, 0))
     {
     std::cerr << "workflow with one step still running after stop";
     return EXIT_FAILURE;
@@ -218,7 +218,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
     }
 
   // start the workflow
-  if (!testStartWorkflow(workflow, defaultTime, app, true, step1, step1, 2, 1, step2, 0, 0))
+  if (!testStartWorkflow(workflow, defaultTime, true, step1, step1, 2, 1, step2, 0, 0))
     {
     std::cerr << "workflow is not running after start() with two steps";
     return EXIT_FAILURE;
@@ -245,7 +245,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // Test that the workflow transitions from processing to validation state
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step2, step1, 2, 2, step2, 1, 0))
+  if (!transitionTest(workflow, defaultTime, step2, step1, 2, 2, step2, 1, 0))
     {
     std::cerr << "error transitioning to next step in workflow with two steps";
     return EXIT_FAILURE;
@@ -253,14 +253,14 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // Test that the workflow transitions back to the previous step
   workflow->goBackward();
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 3, 2, step2, 1, 1))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 3, 2, step2, 1, 1))
     {
     std::cerr << "error transitioning to previous step in workflow with step steps";
     return EXIT_FAILURE;
     }
 
   // make sure the workflow stops properly
-  if (!testStopWorkflow(workflow, defaultTime, app, step1, 3, 3, step2, 1, 1))
+  if (!testStopWorkflow(workflow, defaultTime, step1, 3, 3, step2, 1, 1))
     {
     std::cerr << "workflow with two steps is running after stop()";
     return EXIT_FAILURE;
@@ -337,7 +337,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // now that we've stopped and restarted the state machine, we should
   // be back in the initial step (step 1)
-  if (!testStartWorkflow(workflow, defaultTime, app, true, step1, step1, 4, 3, step2, 1, 1, step3, 0, 0))
+  if (!testStartWorkflow(workflow, defaultTime, true, step1, step1, 4, 3, step2, 1, 1, step3, 0, 0))
     {
     std::cerr << "workflow is not running after start() with three steps";
     return EXIT_FAILURE;
@@ -360,7 +360,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   QTimer::singleShot(defaultTime, &app, SLOT(quit()));
   app.exec();
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step3, step1, 4, 4, step2, 2, 2, step3, 1, 0))
+  if (!transitionTest(workflow, defaultTime, step3, step1, 4, 4, step2, 2, 2, step3, 1, 0))
     {
     std::cerr << "error transitioning to step3 in workflow with three steps";
     return EXIT_FAILURE;
@@ -368,14 +368,14 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // Test that the workflow transitions back to the previous step
   workflow->goBackward();
-  if (!transitionTest(workflow, defaultTime, app, step2, step1, 4, 4, step2, 3, 2, step3, 1, 1))
+  if (!transitionTest(workflow, defaultTime, step2, step1, 4, 4, step2, 3, 2, step3, 1, 1))
     {
     std::cerr << "error transitioning to previous step in workflow with three steps";
     return EXIT_FAILURE;
     }
 
   // make sure the workflow stops properly
-  if (!testStopWorkflow(workflow, defaultTime, app, step1, 4, 4, step2, 3, 3, step3, 1, 1))
+  if (!testStopWorkflow(workflow, defaultTime, step1, 4, 4, step2, 3, 3, step3, 1, 1))
     {
     std::cerr << "error stopping workflow with three steps";
     return EXIT_FAILURE;
@@ -385,7 +385,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   // workflow with a finish step (step 3)
 
   // restart the workflow
-  if (!testStartWorkflow(workflow, defaultTime, app, true, step1, step1, 5, 4, step2, 3, 3, step3, 1, 1))
+  if (!testStartWorkflow(workflow, defaultTime, true, step1, step1, 5, 4, step2, 3, 3, step3, 1, 1))
     {
     std::cerr << "workflow with finish step is not running after start()";
     return EXIT_FAILURE;
@@ -393,7 +393,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // try to go automatically to step 3
   workflow->goToStep("Step 3");
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 6, 5, step2, 4, 4, step3, 2, 2))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 6, 5, step2, 4, 4, step3, 2, 2))
     {
     std::cerr << "error after going to finish step";
     return EXIT_FAILURE;
@@ -401,14 +401,14 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // try to go automatically to step 3 again
   workflow->goToStep("Step 3");
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 7, 6, step2, 5, 5, step3, 3, 3))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 7, 6, step2, 5, 5, step3, 3, 3))
     {
     std::cerr << "error after going to finish step the second time";
     return EXIT_FAILURE;
     }
 
   // stop workflow
-  if (!testStopWorkflow(workflow, defaultTime, app, step1, 7, 7, step2, 5, 5, step3, 3, 3))
+  if (!testStopWorkflow(workflow, defaultTime, step1, 7, 7, step2, 5, 5, step3, 3, 3))
     {
     std::cerr << "error stopping workflow with finish step";
     return EXIT_FAILURE;
@@ -422,7 +422,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   workflow->addTransition(step3, step4);
 
   // restart the workflow
-  if (!testStartWorkflow(workflow, defaultTime, app, true, step1, step1, 8, 7, step2, 5, 5, step3, 3, 3, step4, 0, 0))
+  if (!testStartWorkflow(workflow, defaultTime, true, step1, step1, 8, 7, step2, 5, 5, step3, 3, 3, step4, 0, 0))
     {
     std::cerr << "workflow with two finish steps is not running after start()";
     return EXIT_FAILURE;
@@ -430,7 +430,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // try to go automatically to step 3
   workflow->goToStep("Step 3");
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 9, 8, step2, 6, 6, step3, 4, 4, step4, 0, 0))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 9, 8, step2, 6, 6, step3, 4, 4, step4, 0, 0))
     {
     std::cerr << "error going to the first finish step of two";
     return EXIT_FAILURE;
@@ -438,7 +438,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // try to go automatically to step 4
   workflow->goToStep("Step 4");
-  if (!transitionTest(workflow, defaultTime, app, step1, step1, 10, 9, step2, 7, 7, step3, 5, 5, step4, 1, 1))
+  if (!transitionTest(workflow, defaultTime, step1, step1, 10, 9, step2, 7, 7, step3, 5, 5, step4, 1, 1))
     {
     std::cerr << "error going to the second finish step of two";
     return EXIT_FAILURE;
@@ -449,7 +449,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   QTimer::singleShot(defaultTime, &app, SLOT(quit()));
   app.exec();
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step3, step1, 10, 10, step2, 8, 8, step3, 6, 5, step4, 1, 1))
+  if (!transitionTest(workflow, defaultTime, step3, step1, 10, 10, step2, 8, 8, step3, 6, 5, step4, 1, 1))
     {
     std::cerr << "error going from step1 to step3";
     return EXIT_FAILURE;
@@ -457,7 +457,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // try to go automatically to step 4 (another goTo step)
   workflow->goToStep("Step 4");
-  if (!transitionTest(workflow, defaultTime, app, step3, step1, 10, 10, step2, 8, 8, step3, 7, 6, step4, 2, 2))
+  if (!transitionTest(workflow, defaultTime, step3, step1, 10, 10, step2, 8, 8, step3, 7, 6, step4, 2, 2))
     {
     std::cerr << "error going from the first finish step to the second finish step";
     return EXIT_FAILURE;
@@ -468,7 +468,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   QTimer::singleShot(defaultTime, &app, SLOT(quit()));
   app.exec();
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step4, step1, 10, 10, step2, 8, 8, step3, 7, 7, step4, 3, 2))
+  if (!transitionTest(workflow, defaultTime, step4, step1, 10, 10, step2, 8, 8, step3, 7, 7, step4, 3, 2))
     {
     std::cerr << "error going forward past last step - shouldn't let you";
     return EXIT_FAILURE;
@@ -476,7 +476,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
 
   // now try to go from step 4 to step 4 (should loop)
   workflow->goToStep("Step 4");
-  if (!transitionTest(workflow, defaultTime, app, step4, step1, 10, 10, step2, 8, 8, step3, 7, 7, step4, 4, 3))
+  if (!transitionTest(workflow, defaultTime, step4, step1, 10, 10, step2, 8, 8, step3, 7, 7, step4, 4, 3))
     {
     std::cerr << "error looping from step 4 to step 4";
     return EXIT_FAILURE;
@@ -487,7 +487,7 @@ int ctkWorkflowTest1(int argc, char * argv [] )
   QTimer::singleShot(defaultTime, &app, SLOT(quit()));
   app.exec();
   workflow->goToStep("Step 3");
-  if (!transitionTest(workflow, defaultTime, app, step3, step1, 10, 10, step2, 8, 8, step3, 9, 8, step4, 4, 4))
+  if (!transitionTest(workflow, defaultTime, step3, step1, 10, 10, step2, 8, 8, step3, 9, 8, step4, 4, 4))
     {
     std::cerr << "error looping from step 3 to step 3";
     return EXIT_FAILURE;

+ 16 - 16
Libs/Core/Testing/Cpp/ctkWorkflowTest2.cpp

@@ -19,7 +19,7 @@
 =========================================================================*/
 
 // QT includes
-#include <QApplication>
+#include <QCoreApplication>
 #include <QTimer>
 
 // CTK includes
@@ -83,19 +83,19 @@ int currentStepAndNumberOfTimesEntryExitTest(ctkWorkflow* workflow, ctkWorkflowS
 }
 
 //-----------------------------------------------------------------------------
-int transitionTest(ctkWorkflow* workflow, int defaultTime, QApplication& app, ctkWorkflowStep* expectedStep, ctkExampleWorkflowStepUsingSignalsAndSlots* step1, int step1Entry, int step1Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step2, int step2Entry, int step2Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step4=0, int step4Entry=0, int step4Exit=0)
+int transitionTest(ctkWorkflow* workflow, int defaultTime, ctkWorkflowStep* expectedStep, ctkExampleWorkflowStepUsingSignalsAndSlots* step1, int step1Entry, int step1Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step2, int step2Entry, int step2Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step4=0, int step4Entry=0, int step4Exit=0)
 {
-  QTimer::singleShot(defaultTime, &app, SLOT(quit()));
-  app.exec();
+  QTimer::singleShot(defaultTime, qApp, SLOT(quit()));
+  qApp->exec();
   return currentStepAndNumberOfTimesEntryExitTest(workflow, expectedStep, step1, step1Entry, step1Exit, step2, step2Entry, step2Exit, step3, step3Entry, step3Exit, step4, step4Entry, step4Exit);
 }
 
 //-----------------------------------------------------------------------------
-int testStartWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app, bool shouldRun, ctkWorkflowStep* expectedStep=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step1=0, int step1Entry=0, int step1Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step2=0, int step2Entry=0, int step2Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step4=0, int step4Entry=0, int step4Exit=0)
+int testStartWorkflow(ctkWorkflow* workflow, int defaultTime, bool shouldRun, ctkWorkflowStep* expectedStep=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step1=0, int step1Entry=0, int step1Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step2=0, int step2Entry=0, int step2Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step4=0, int step4Entry=0, int step4Exit=0)
 {
   workflow->start();
-  QTimer::singleShot(defaultTime, &app, SLOT(quit()));
-  app.exec();
+  QTimer::singleShot(defaultTime, qApp, SLOT(quit()));
+  qApp->exec();
   if (workflow->isRunning() != shouldRun)
     {
     return 0;
@@ -104,11 +104,11 @@ int testStartWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app,
 }
 
 //-----------------------------------------------------------------------------
-int testStopWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app, ctkExampleWorkflowStepUsingSignalsAndSlots* step1, int step1Entry, int step1Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step2, int step2Entry, int step2Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step4=0, int step4Entry=0, int step4Exit=0)
+int testStopWorkflow(ctkWorkflow* workflow, int defaultTime, ctkExampleWorkflowStepUsingSignalsAndSlots* step1, int step1Entry, int step1Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step2, int step2Entry, int step2Exit, ctkExampleWorkflowStepUsingSignalsAndSlots* step3=0, int step3Entry=0, int step3Exit=0, ctkExampleWorkflowStepUsingSignalsAndSlots* step4=0, int step4Entry=0, int step4Exit=0)
 {
   workflow->stop();
-  QTimer::singleShot(defaultTime, &app, SLOT(quit()));
-  app.exec();
+  QTimer::singleShot(defaultTime, qApp, SLOT(quit()));
+  qApp->exec();
   if (workflow->isRunning())
     {
     return 0;
@@ -119,7 +119,7 @@ int testStopWorkflow(ctkWorkflow* workflow, int defaultTime, QApplication& app,
 //-----------------------------------------------------------------------------
 int ctkWorkflowTest2(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
   int defaultTime = 100;
 
   // create the steps and the workflow
@@ -225,7 +225,7 @@ int ctkWorkflowTest2(int argc, char * argv [] )
     }
 
   // start the workflow
-  if (!testStartWorkflow(workflow, defaultTime, app, 1, step1, qObject1, true, 0, qObject2, 0, 0, qObject3, 0, 0, qObject4, 0, 0))
+  if (!testStartWorkflow(workflow, defaultTime, 1, step1, qObject1, true, 0, qObject2, 0, 0, qObject3, 0, 0, qObject4, 0, 0))
     {
     std::cerr << "error starting workflow";
     return EXIT_FAILURE;
@@ -233,7 +233,7 @@ int ctkWorkflowTest2(int argc, char * argv [] )
 
   // trigger transition to the next step
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step2, qObject1, 1, 1, qObject2, 1, 0, qObject3, 0, 0, qObject4, 0, 0))
+  if (!transitionTest(workflow, defaultTime, step2, qObject1, 1, 1, qObject2, 1, 0, qObject3, 0, 0, qObject4, 0, 0))
     {
     std::cerr << "error transitioning to step 2";
     return EXIT_FAILURE;
@@ -241,7 +241,7 @@ int ctkWorkflowTest2(int argc, char * argv [] )
 
   // trigger transition to the next step
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step3, qObject1, 1, 1, qObject2, 1, 1, qObject3, 1, 0, qObject4, 0, 0))
+  if (!transitionTest(workflow, defaultTime, step3, qObject1, 1, 1, qObject2, 1, 1, qObject3, 1, 0, qObject4, 0, 0))
     {
     std::cerr << "error transitioning to step 3";
     return EXIT_FAILURE;
@@ -249,14 +249,14 @@ int ctkWorkflowTest2(int argc, char * argv [] )
 
   // trigger transition to the next state (this should fail!)
   workflow->goForward();
-  if (!transitionTest(workflow, defaultTime, app, step3, qObject1, 1, 1, qObject2, 1, 1, qObject3, 1, 0, qObject4, 0, 0))
+  if (!transitionTest(workflow, defaultTime, step3, qObject1, 1, 1, qObject2, 1, 1, qObject3, 1, 0, qObject4, 0, 0))
     {
     std::cerr << "error after transition failure at step 3";
     return EXIT_FAILURE;
     }
 
   // make sure the workflow stops properly
-  if (!testStopWorkflow(workflow, defaultTime, app, qObject1, 1, 1, qObject2, 1, 1, qObject3, 1, 1, qObject4, 0, 0))
+  if (!testStopWorkflow(workflow, defaultTime, qObject1, 1, 1, qObject2, 1, 1, qObject3, 1, 1, qObject4, 0, 0))
     {
     std::cerr << "error after stopping workflow";
     return EXIT_FAILURE;

+ 2 - 2
Libs/Core/Testing/Cpp/ctkWorkflowTest3.cpp

@@ -19,7 +19,7 @@
   =========================================================================*/
 
 // QT includes
-#include <QApplication>
+#include <QCoreApplication>
 #include <QTimer>
 
 // CTK includes
@@ -42,7 +42,7 @@
 //-----------------------------------------------------------------------------
 int ctkWorkflowTest3(int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
   int defaultTime = 100;
 
   // create two steps and the workflow

+ 5 - 13
Libs/DICOM/Core/Testing/Cpp/ctkDICOMModelTest1.cpp

@@ -19,10 +19,9 @@
 =========================================================================*/
 
 // Qt includes
-#include <QApplication>
+#include <QCoreApplication>
 #include <QDebug>
 #include <QFileInfo>
-#include <QTreeView>
 #include <QSqlQuery>
 
 // ctkDICOMCore includes
@@ -36,11 +35,11 @@
 
 /* Test from build directory:
  ./CTK-build/bin/CTKDICOMCoreCxxTests ctkDICOMModelTest1 test.db ../CTK/Libs/DICOM/Core/Resources/dicom-sample.sql
+ If you want a test with a GUI, look at ctkDICOMTest2 in DICOM/Widgets
 */
-
 int ctkDICOMModelTest1( int argc, char * argv [] )
 {
-  QApplication app(argc, argv);
+  QCoreApplication app(argc, argv);
   
   if (argc <= 2)
     {
@@ -84,18 +83,11 @@ int ctkDICOMModelTest1( int argc, char * argv [] )
 
     model.setDatabase(myCTK.database());
 
-    QTreeView viewer;
-    viewer.setModel(&model);
-    viewer.setSortingEnabled(true);
-
     model.rowCount();
+
     qDebug() << model.rowCount() << model.columnCount();
     qDebug() << model.index(0,0);
-    viewer.show();
-    if (argc > 3 && QString(argv[3]) == "-I")
-    {
-      return app.exec();
-    }
+
     return EXIT_SUCCESS;
   }
   catch (std::exception e)