diff --git a/Modules/Applications/AppTest/CMakeLists.txt b/Modules/Applications/AppTest/CMakeLists.txt index 306213f5f77437642e7a1ada50537bb3df04b5cc..19b1df67ebdaf01f15a966457a321237ce88a1c0 100644 --- a/Modules/Applications/AppTest/CMakeLists.txt +++ b/Modules/Applications/AppTest/CMakeLists.txt @@ -1,2 +1,4 @@ project(OTBAppTest) + + otb_module_impl() diff --git a/Modules/Applications/AppTest/otb-module.cmake b/Modules/Applications/AppTest/otb-module.cmake index 59b095bad6c66545bc434db373f2196429c95e79..30e0a04eb0d6c03f771eac91ef2c29d983fa85f2 100644 --- a/Modules/Applications/AppTest/otb-module.cmake +++ b/Modules/Applications/AppTest/otb-module.cmake @@ -6,7 +6,6 @@ otb_module(OTBAppTest TEST_DEPENDS OTBTestKernel OTBCommandLine - DESCRIPTION "${DOCUMENTATION}" ) diff --git a/Modules/Applications/AppTest/test/CMakeLists.txt b/Modules/Applications/AppTest/test/CMakeLists.txt index 175e769d7e693a655b130309e78ca0400bc98cf2..e9dadfc3068d4b6b271aefbd0cee29ac5de11c04 100644 --- a/Modules/Applications/AppTest/test/CMakeLists.txt +++ b/Modules/Applications/AppTest/test/CMakeLists.txt @@ -1 +1,14 @@ -otb_module_test() \ No newline at end of file +otb_module_test() + +set(OTBAppTestTests +otbWrapperApplicationDocTests.cxx +otbAppTestTestDriver.cxx +) + +add_executable(otbAppTestTestDriver ${OTBAppTestTests}) +target_link_libraries(otbAppTestTestDriver ${OTBAppTest-Test_LIBRARIES}) +otb_module_target_label(otbAppTestTestDriver) + + +otb_add_test(NAME apCheckDocumentation COMMAND otbAppTestTestDriver + otbWrapperApplicationDocTest ${OTB_BINARY_DIR}/lib/otb/applications) diff --git a/Modules/Applications/AppTest/test/otbAppTestTestDriver.cxx b/Modules/Applications/AppTest/test/otbAppTestTestDriver.cxx new file mode 100644 index 0000000000000000000000000000000000000000..33dab2178c1c09a1aa7d402d203b4762d4f6a9af --- /dev/null +++ b/Modules/Applications/AppTest/test/otbAppTestTestDriver.cxx @@ -0,0 +1,5 @@ +#include "otbTestMain.h" +void RegisterTests() +{ + REGISTER_TEST(otbWrapperApplicationDocTest); +} diff --git a/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx b/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx new file mode 100644 index 0000000000000000000000000000000000000000..01dc19cdbb019791042345d3c05e593c0b48f0a6 --- /dev/null +++ b/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx @@ -0,0 +1,156 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbWrapperApplicationRegistry.h" + +using otb::Wrapper::Application; +using otb::Wrapper::ApplicationRegistry; + +int otbWrapperApplicationDocTest(int argc, char* argv[]) +{ + if (argc < 2) + { + std::cerr << "Usage : " << argv[0] << " [MODULEPATH]" << std::endl; + return EXIT_FAILURE; + } + + // Get the module path list + std::list<std::string> modulePathList; + if (argc > 1) + { + std::copy(argv + 1, argv + argc, std::back_inserter(modulePathList)); + + // Load the path in the environment + std::string specificEnv("ITK_AUTOLOAD_PATH="); + std::list<std::string>::const_iterator it = modulePathList.begin(); + while( it != modulePathList.end() ) + { + ApplicationRegistry::AddApplicationPath( *(it) ); + ++it; + } + } + + bool isOK = true; + + // Get list of available applications + std::vector<std::string> list = ApplicationRegistry::GetAvailableApplications(); + for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it) + { + std::cout << "Testing documentation for application "<< (*it) << " ..." << std::endl; + // Create module + Application::Pointer app = ApplicationRegistry::CreateApplication(*it); + + // Check application availability + if( app.IsNull() ) + { + std::cout<<"Unable to load "<<argv[1]<<" application."<<std::endl; + isOK = false; + continue; + } + + // Check doc element... + if( std::string(app->GetName()) == "" ) + { + std::cout<<"Missing Name."<<std::endl; + isOK = false; + } + if( std::string(app->GetDocName()) == "" ) + { + std::cout<<"Missing Doc Name."<<std::endl; + isOK = false; + } + if( std::string(app->GetDescription()) == "" ) + { + std::cout<<"Missing Description."<<std::endl; + isOK = false; + } + if( std::string(app->GetDocLongDescription()) == "" ) + { + std::cout<<"Missing DocLongDescription."<<std::endl; + isOK = false; + } + else if( std::string(app->GetDocLongDescription()).size() < 30 ) + { + std::cout<<"DocLongDescription too small..."<<std::endl; + isOK = false; + } + if( std::string(app->GetDocAuthors()) == "" ) + { + std::cout<<"Missing DocAuthors."<<std::endl; + isOK = false; + } + if( std::string(app->GetDocLimitations()) == "" ) + { + std::cout<<"Missing DocLimitations."<<std::endl; + isOK = false; + } + if( std::string(app->GetDocSeeAlso()) == "" ) + { + std::cout<<"Missing DocSeeAlso."<<std::endl; + isOK = false; + } + if( app->GetDocTags().size() == 0 ) + { + std::cout<<"Missing DocTags."<<std::endl; + isOK = false; + } + + // Check example data + app->Init(); + otb::Wrapper::DocExampleStructure::Pointer doc = app->GetDocExample(); + if( doc->GetApplicationName() == "" ) + { + std::cout<<"Error in doc example: no aaplication name found."<<std::endl; + isOK = false; + } + if( doc->GetParameterList().size() == 0 ) + { + std::cout<<"Error in doc example: the list of parameter is empty."<<std::endl; + isOK = false; + } + else + { + bool hasValue = false; + unsigned int count = 0; + while ( count<doc->GetParameterList().size() && !hasValue ) + { + if( doc->GetParameterValue(count) != "" ) + { + hasValue = true; + } + count++; + } + + if( !hasValue ) + { + std::cout<<"Error in doc example: no value for the example found !!!"<<std::endl; + isOK = false; + } + } + } + + if( !isOK ) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + +