Commit 622e04a7 authored by jcfr's avatar jcfr
Browse files

ENH: Add testing to LoadableExtensionTemplate extension

git-svn-id: http://svn.slicer.org/Slicer4/trunk@17070 3bd1e089-480b-0410-8dfb-8563597acbee
parent c1bdec82
......@@ -32,6 +32,8 @@ IF(NOT Slicer_SOURCE_DIR)
SET(EXTENSION_LICENSE_FILE ${Slicer_LICENSE_FILE})
SET(EXTENSION_README_FILE ${Slicer_README_FILE})
INCLUDE(CTest)
ENDIF()
......@@ -88,8 +90,8 @@ slicerMacroBuildQtModule(
if(BUILD_TESTING)
#add_subdirectory(Testing)
endif(BUILD_TESTING)
add_subdirectory(Testing)
endif()
IF(NOT Slicer_SOURCE_DIR)
INCLUDE(SlicerFunctionGenerateExtensionDescription)
......
set(CTEST_PROJECT_NAME "Slicer")
set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "www.cdash.org")
set(CTEST_DROP_LOCATION "/slicer4/submit.php?project=Slicer4")
set(CTEST_DROP_SITE_CDASH TRUE)
#SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "DEBUG_LEAKS_ENABLE_EXIT_ERROR();" )
CREATE_TEST_SOURCELIST(Tests ${EXTENSION_NAME}CxxTests.cxx
#Add tests here
qSlicer${EXTENSION_NAME}ModuleTest1.cxx
#EXTRA_INCLUDE TestingMacros.h
)
SET(LIBRARY_NAME qSlicer${EXTENSION_NAME}Module)
ADD_EXECUTABLE(${EXTENSION_NAME}CxxTests ${Tests})
TARGET_LINK_LIBRARIES(${EXTENSION_NAME}CxxTests ${lib_name})
MACRO(SIMPLE_TEST TESTNAME)
ADD_TEST(NAME ${TESTNAME} COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:${EXTENSION_NAME}CxxTests> ${TESTNAME} ${ARGN})
ENDMACRO()
SIMPLE_TEST( qSlicer${EXTENSION_NAME}ModuleTest1 )
/*==============================================================================
Program: 3D Slicer
Copyright (c) 2010 Kitware Inc.
See Doc/copyright/copyright.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Julien Finet, Kitware Inc.
and was partially funded by NIH grant 3P41RR013218-12S1
==============================================================================*/
// Qt includes
#include <QApplication>
#include <QTimer>
#include <QWidget>
// SlicerQt includes
#include <qSlicerAbstractModuleRepresentation.h>
// SlicerWelcome includes
#include "qSlicerLoadableExtensionTemplateModule.h"
// MRML includes
#include <vtkMRMLScene.h>
// VTK includes
#include <vtkNew.h>
//-----------------------------------------------------------------------------
int qSlicerLoadableExtensionTemplateModuleTest1( int argc, char * argv[] )
{
QApplication app(argc, argv);
qSlicerLoadableExtensionTemplateModule module;
if (module.helpText().isEmpty())
{
std::cerr << "helpText() is empty." << std::endl;
return EXIT_FAILURE;
}
if (module.acknowledgementText().isEmpty())
{
std::cerr << "acknowledgementText() is empty."
<< std::endl;
return EXIT_FAILURE;
}
module.initialize(0);
if (module.appLogic() != 0)
{
std::cerr << "initialize() failed." << std::endl;
return EXIT_FAILURE;
}
vtkNew<vtkMRMLScene> scene;
module.setMRMLScene(scene.GetPointer());
if (module.mrmlScene() != scene.GetPointer())
{
std::cerr << "setMRMLScene() failed." << std::endl;
return EXIT_FAILURE;
}
// Instantiate the logic if any
module.logic();
// Instantiate the widget if any
QWidget* widget = dynamic_cast<QWidget*>(module.widgetRepresentation());
if (widget)
{
widget->show();
}
if (argc < 2 || QString(argv[1]) != "-I")
{
QTimer::singleShot(200, &app, SLOT(quit()));
}
return app.exec();
}
......@@ -62,7 +62,8 @@ qSlicerLoadableExtensionTemplateModule::~qSlicerLoadableExtensionTemplateModule(
//-----------------------------------------------------------------------------
QString qSlicerLoadableExtensionTemplateModule::helpText()const
{
return QString();
return "This LoadableExtensionTemplate module illustrates how a loadable module should "
"be implemented.";
}
//-----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment