##// END OF EJS Templates
Inits unit test
Alexandre Leroux -
r742:79898921a450
parent child
Show More
@@ -0,0 +1,50
1 #include "CosinusProvider.h"
2
3 #include <SqpApplication.h>
4
5 #include <QObject>
6 #include <QtTest>
7
8 namespace {
9
10 /// Path for the tests
11 const auto TESTS_RESOURCES_PATH = QFileInfo{
12 QString{MOCKPLUGIN_TESTS_RESOURCES_DIR},
13 "TestCosinusAcquisition"}.absoluteFilePath();
14
15 } // namespace
16
17 /**
18 * @brief The TestCosinusAcquisition class tests acquisition in SciQlop (operations like zooms in,
19 * zooms out, pans) of data from CosinusProvider
20 * @sa CosinusProvider
21 */
22 class TestCosinusAcquisition : public QObject {
23 Q_OBJECT
24
25 private slots:
26 /// Input data for @sa testAcquisition()
27 void testAcquisition_data();
28 void testAcquisition();
29 };
30
31 void TestCosinusAcquisition::testAcquisition_data()
32 {
33 /// @todo
34 }
35
36 void TestCosinusAcquisition::testAcquisition()
37 {
38 /// @todo
39 }
40
41 int main(int argc, char *argv[])
42 {
43 SqpApplication app{argc, argv};
44 app.setAttribute(Qt::AA_Use96Dpi, true);
45 TestCosinusAcquisition testObject{};
46 QTEST_SET_MAIN_SOURCE_PATH
47 return QTest::qExec(&testObject, argc, argv);
48 }
49
50 #include "TestCosinusAcquisition.moc"
@@ -1,157 +1,160
1 ## mockplugin - CMakeLists.txt
1 ## mockplugin - CMakeLists.txt
2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
7 SET(TESTS_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests-resources")
7
8
8 # Include mockplugin directory
9 # Include mockplugin directory
9 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
10 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
10 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
11 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
11
12
12 #
13 #
13 # Find Qt modules
14 # Find Qt modules
14 #
15 #
15 SCIQLOP_FIND_QT(Core Widgets)
16 SCIQLOP_FIND_QT(Core Widgets)
16
17
17 #
18 #
18 # Find dependent libraries
19 # Find dependent libraries
19 # ========================
20 # ========================
20
21
21 # sciqlop plugin
22 # sciqlop plugin
22 find_package(sciqlop-plugin)
23 find_package(sciqlop-plugin)
23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24
25
25 # sciqlop core
26 # sciqlop core
26 find_package(sciqlop-core)
27 find_package(sciqlop-core)
27 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
28 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
28 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29
30
30 # sciqlop gui
31 # sciqlop gui
31 find_package(sciqlop-gui)
32 find_package(sciqlop-gui)
32 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
33 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
33 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
34 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
34
35
35 # Description file
36 # Description file
36 FILE (GLOB_RECURSE PLUGIN_FILE ${RESOURCES_DIR}/mockplugin.json)
37 FILE (GLOB_RECURSE PLUGIN_FILE ${RESOURCES_DIR}/mockplugin.json)
37
38
38 #
39 #
39 # Compile the library
40 # Compile the library
40 #
41 #
41
42
42 ADD_DEFINITIONS(-DMOCKPLUGIN_LIB)
43 ADD_DEFINITIONS(-DMOCKPLUGIN_LIB)
43
44
44 FILE (GLOB_RECURSE MODULE_SOURCES
45 FILE (GLOB_RECURSE MODULE_SOURCES
45 ${INCLUDES_DIR}/*.h
46 ${INCLUDES_DIR}/*.h
46 ${SOURCES_DIR}/*.c
47 ${SOURCES_DIR}/*.c
47 ${SOURCES_DIR}/*.cpp
48 ${SOURCES_DIR}/*.cpp
48 ${SOURCES_DIR}/*.h
49 ${SOURCES_DIR}/*.h
49 ${PLUGIN_FILE})
50 ${PLUGIN_FILE})
50
51
51 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
52 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
52 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
53 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
53 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
54 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
54
55
55 INSTALL(TARGETS ${SQPMOCKPLUGIN_LIBRARY_NAME}
56 INSTALL(TARGETS ${SQPMOCKPLUGIN_LIBRARY_NAME}
56 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
57 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
57 LIBRARY DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR}
58 LIBRARY DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR}
58 ARCHIVE DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR}
59 ARCHIVE DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR}
59 )
60 )
60
61
61
62
62 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
63 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
63 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
64 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
64
65
65 add_dependencies(${SQPMOCKPLUGIN_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
66 add_dependencies(${SQPMOCKPLUGIN_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
66
67
67 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
68 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
68 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
69 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
69 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
70 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
70 IF(BUILD_SHARED_LIBS)
71 IF(BUILD_SHARED_LIBS)
71 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
72 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
72 ELSE()
73 ELSE()
73 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
74 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
74 ENDIF()
75 ENDIF()
75
76
76 # Set the variable to parent scope so that the other projects can copy the
77 # Set the variable to parent scope so that the other projects can copy the
77 # dependent shared libraries
78 # dependent shared libraries
78 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
79 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
79
80
80 # Copy extern shared libraries to the lib folder
81 # Copy extern shared libraries to the lib folder
81 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
82 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
82
83
83 # Add the files to the list of files to be analyzed
84 # Add the files to the list of files to be analyzed
84 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
85 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
85 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
86 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
86 # Vera++ exclusion files
87 # Vera++ exclusion files
87 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
88 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
88 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
89 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
89
90
90 #
91 #
91 # Compile the tests
92 # Compile the tests
92 #
93 #
93 IF(BUILD_TESTS)
94 IF(BUILD_TESTS)
94 INCLUDE_DIRECTORIES(${SOURCES_DIR})
95 INCLUDE_DIRECTORIES(${SOURCES_DIR})
95 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
96 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
96 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
97 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
97 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
98 SET( TEST_LIBRARIES ${SQPMOCKPLUGIN_LIBRARY_NAME})
98
99
99 FOREACH( testFile ${TESTS_SOURCES} )
100 FOREACH( testFile ${TESTS_SOURCES} )
100 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
101 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
101 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
102 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
102
103
103 # Add to the list of sources files all the sources in the same
104 # Add to the list of sources files all the sources in the same
104 # directory that aren't another test
105 # directory that aren't another test
105 FILE (GLOB currentTestSources
106 FILE (GLOB currentTestSources
106 ${testDirectory}/*.c
107 ${testDirectory}/*.c
107 ${testDirectory}/*.cpp
108 ${testDirectory}/*.cpp
108 ${testDirectory}/*.h)
109 ${testDirectory}/*.h)
109 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
110 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
110 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
111 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
111
112
112 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
113 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
113 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
114 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
114 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
115 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
115 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
116 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
116 qt5_use_modules(${testName} Test)
117 qt5_use_modules(${testName} Test)
117
118
118 ADD_TEST( NAME ${testName} COMMAND ${testName} )
119 ADD_TEST( NAME ${testName} COMMAND ${testName} )
119
120
120 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
121 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
121 ENDFOREACH( testFile )
122 ENDFOREACH( testFile )
122
123
123 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
124 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
124 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
125 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
125 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
126 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
126 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
127 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
128
129 ADD_DEFINITIONS(-DMOCKPLUGIN_TESTS_RESOURCES_DIR="${TESTS_RESOURCES_DIR}")
127 ENDIF(BUILD_TESTS)
130 ENDIF(BUILD_TESTS)
128
131
129 #
132 #
130 # Set the files that must be formatted by clang-format.
133 # Set the files that must be formatted by clang-format.
131 #
134 #
132 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
135 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
133 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
136 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
134
137
135 #
138 #
136 # Set the directories that doxygen must browse to generate the
139 # Set the directories that doxygen must browse to generate the
137 # documentation.
140 # documentation.
138 #
141 #
139 # Source directories:
142 # Source directories:
140 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
143 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
141 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
144 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
142 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
145 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
143 # Source directories to exclude from the documentation generation
146 # Source directories to exclude from the documentation generation
144 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
147 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
145 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
148 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
146
149
147 #
150 #
148 # Set the directories with the sources to analyze and propagate the
151 # Set the directories with the sources to analyze and propagate the
149 # modification to the parent scope
152 # modification to the parent scope
150 #
153 #
151 # Source directories to analyze:
154 # Source directories to analyze:
152 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
155 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
153 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
156 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
154 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
157 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
155 # Source directories to exclude from the analysis
158 # Source directories to exclude from the analysis
156 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
159 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
157 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
160 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
General Comments 0
You need to be logged in to leave comments. Login now