unittest/qtwidgets/main.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // TerraLib
21 #include <terralib/color.h>
22 #include <terralib/common.h>
23 #include <terralib/dataaccess.h>
24 #include <terralib/geometry.h>
25 #include <terralib/maptools.h>
26 #include <terralib/postgis.h>
27 #include <terralib/qt/widgets.h>
28 
30 #include <terralib/plugin.h>
31 
32 // cppUnit
33 #include <cppunit/BriefTestProgressListener.h>
34 #include <cppunit/CompilerOutputter.h>
35 #include <cppunit/extensions/HelperMacros.h>
36 #include <cppunit/extensions/TestFactoryRegistry.h>
37 #include <cppunit/TestResult.h>
38 #include <cppunit/TestResultCollector.h>
39 #include <cppunit/TestRunner.h>
40 #include <cppunit/XmlOutputter.h>
41 
43 {
44  try
45  {
47 
48  info = te::plugin::GetInstalledPlugin(TE_PLUGINS_PATH + std::string("/te.da.ogr.teplg.json"));
50 
51  info = te::plugin::GetInstalledPlugin(TE_PLUGINS_PATH + std::string("/te.da.gdal.teplg.json"));
53 
54  info = te::plugin::GetInstalledPlugin(TE_PLUGINS_PATH + std::string("/te.da.pgis.teplg.json"));
56 
58  }
59  catch(const te::common::Exception& e)
60  {
61  throw e;
62  }
63 }
64 
65 
66 int main(int /*argc*/, char** /*argv*/)
67 {
68 
69  try
70  {
71  // initialize Terralib support
73 
74  LoadModules();
75  // it creates the event manager and test controller
76  CPPUNIT_NS::TestResult controller;
77 
78  // it adds a listener that colllects test result
79  CPPUNIT_NS::TestResultCollector result;
80 
81  controller.addListener(&result);
82 
83  // it adds a listener that print dots as test run.
84  CPPUNIT_NS::BriefTestProgressListener progress;
85 
86  controller.addListener(&progress);
87 
88  // it adds the top suite to the test runner
89  CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
90 
91  CPPUNIT_NS::TestRunner runner;
92 
93  runner.addTest(suite);
94 
95  runner.run(controller);
96 
97  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
98 
99  outputter.write();
100 
101  // Printing testResult in XML file
102  // The testResult_*.xml files will be saved at TERRALIB_REPORT_DIR directory.
103  // The styleSheet 'report.xsl' should be at this directory (found originally at <third-party-lib>\cppunit-1.12.1\contrib\xml-xsl).
104  // The "data.zip" (downloaded) containing the data used in unit tests should be at TERRALIB_DATA_DIR
105 
106  CPPUNIT_NS::OFileStream file2( TE_OUTPUT_REPORT_DIR "/testsResult_qtwidgets_xml.xml" );
107  CPPUNIT_NS::XmlOutputter xml( &result, file2 );
108  xml.setStyleSheet( "report.xsl" );
109  xml.write();
110  file2.close();
111 
114 
115  bool resultStatus = result.wasSuccessful();
116 
117  return resultStatus ? EXIT_SUCCESS : EXIT_FAILURE;
118  }
119  catch(const std::exception& e)
120  {
121  std::cout << std::endl << "An exception has occuried: " << e.what() << std::endl;
122 
123  std::cout << "Press Enter to exit..." << std::endl;
124  std::cin.get();
125 
126  return EXIT_FAILURE;
127  }
128  catch(...)
129  {
130  std::cout << std::endl << "An unexpected exception has occuried!" << std::endl;
131 
132  std::cout << "Press Enter to exit..." << std::endl;
133  std::cin.get();
134 
135  return EXIT_FAILURE;
136  }
137 
138 }
139 
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
void LoadModules()
It loads the data source drivers.
void finalize()
It finalizes the TerraLib Platform.
static PluginManager & getInstance()
It returns a reference to the singleton instance.
This file contains include headers for the TerraLib Qt widgets.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
void initialize()
It initializes the TerraLib Platform.
This file contains include headers for the TerraLib PostGIS driver.
This file contains include headers for the Color Model of TerraLib.
This file contains include headers for the TerraLib Common Runtime module.
int main(int, char **)
The basic information about a plugin.
This file contains include headers for the Vector Geometry model of TerraLib.
This file contains include headers for the Data Access module of TerraLib.
This file contains include headers for the Map Tools module of TerraLib.
TEPLUGINEXPORT PluginInfo * GetInstalledPlugin(const std::string &pluginFilePath)
It returns information about a given plugin provided its plugin configuration file name or dir...