mirror of https://gitlab.com/cppit/jucipp
8 changed files with 123 additions and 0 deletions
@ -0,0 +1,53 @@ |
|||||||
|
add_definitions(-DBOOST_LOG_DYN_LINK) |
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -Wall -Wextra -Wno-unused-parameter -Wno-reorder") |
||||||
|
|
||||||
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJUCI_TESTS_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\" -Wl,--unresolved-symbols=ignore-in-object-files") |
||||||
|
else() |
||||||
|
message(WARNING "testing only supported for g++") |
||||||
|
return() |
||||||
|
endif() |
||||||
|
|
||||||
|
if(APPLE) |
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -undefined dynamic_lookup") |
||||||
|
link_directories(/usr/local/lib /usr/local/opt/gettext/lib) |
||||||
|
include_directories(/usr/local/opt/gettext/include) |
||||||
|
set(CMAKE_MACOSX_RPATH 1) |
||||||
|
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig") |
||||||
|
endif() |
||||||
|
|
||||||
|
find_package(Boost 1.54 COMPONENTS regex system filesystem REQUIRED) |
||||||
|
set(LIBCLANGMM_INCLUDE_DIR ../libclangmm/src) |
||||||
|
|
||||||
|
include(FindPkgConfig) |
||||||
|
pkg_check_modules(GTKMM gtkmm-3.0 REQUIRED) |
||||||
|
|
||||||
|
set(global_includes |
||||||
|
${Boost_INCLUDE_DIRS} |
||||||
|
${GTKMM_INCLUDE_DIRS} |
||||||
|
${GTKSVMM_INCLUDE_DIRS} |
||||||
|
../src |
||||||
|
../tiny-process-library |
||||||
|
) |
||||||
|
|
||||||
|
set(global_libraries |
||||||
|
${GTKMM_LIBRARIES} |
||||||
|
${GTKSVMM_LIBRARIES} |
||||||
|
${Boost_LIBRARIES} |
||||||
|
) |
||||||
|
|
||||||
|
include_directories(${global_includes}) |
||||||
|
|
||||||
|
add_executable(cmake_test cmake_test.cc |
||||||
|
../src/filesystem.cc ../src/cmake.cc ../src/project_build.cc) |
||||||
|
target_link_libraries(cmake_test ${global_libraries}) |
||||||
|
add_test(cmake_test cmake_test) |
||||||
|
|
||||||
|
#Added for example only, and requires display server to work |
||||||
|
#However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: |
||||||
|
#broadwayd& |
||||||
|
#make test |
||||||
|
add_executable(example_test example_test.cc |
||||||
|
stubs/dispatcher.cc stubs/terminal.cc stubs/info.cc) |
||||||
|
target_link_libraries(example_test ${global_libraries}) |
||||||
|
add_test(example_test example_test) |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
#include <glib.h> |
||||||
|
#include "cmake.h" |
||||||
|
#include "project_build.h" |
||||||
|
#include <boost/filesystem.hpp> |
||||||
|
|
||||||
|
int main() { |
||||||
|
CMake cmake(JUCI_TESTS_PATH); |
||||||
|
|
||||||
|
g_assert(cmake.project_path.filename()=="jucipp"); |
||||||
|
|
||||||
|
auto functions_parameters=cmake.get_functions_parameters("project"); |
||||||
|
g_assert(functions_parameters.at(0).second.at(0)=="juci"); |
||||||
|
|
||||||
|
g_assert(cmake.get_executable(boost::filesystem::path(JUCI_TESTS_PATH)/"cmake_test.cc").filename()=="cmake_test"); |
||||||
|
|
||||||
|
auto build=Project::Build::create(JUCI_TESTS_PATH); |
||||||
|
g_assert(dynamic_cast<Project::CMakeBuild*>(build.get())); |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
#include "terminal.h" |
||||||
|
#include "info.h" |
||||||
|
#include <gtkmm.h> |
||||||
|
|
||||||
|
//In case one has to test functions that include Terminal::print or Info::print
|
||||||
|
//Requires display server to work
|
||||||
|
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment
|
||||||
|
//One also has to include the source stubs/dispatcher.cc in CMakeLists.txt for at least Terminal
|
||||||
|
|
||||||
|
//To run the test using broadway backend:
|
||||||
|
//broadwayd&
|
||||||
|
//make test
|
||||||
|
|
||||||
|
int main() { |
||||||
|
auto app=Gtk::Application::create(); |
||||||
|
Terminal::get().print("some message"); |
||||||
|
Info::get().print("some message"); |
||||||
|
g_assert(true); |
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
#include "dialogs.h" |
||||||
|
|
||||||
|
Dialog::Message::Message(const std::string &text): Gtk::MessageDialog(text, false, Gtk::MessageType::MESSAGE_INFO, Gtk::ButtonsType::BUTTONS_NONE, true) {} |
||||||
|
|
||||||
|
bool Dialog::Message::on_delete_event(GdkEventAny *event) { |
||||||
|
return true; |
||||||
|
} |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
#include "dispatcher.h" |
||||||
|
|
||||||
|
Dispatcher::Dispatcher() {} |
||||||
|
|
||||||
|
Dispatcher::~Dispatcher() {} |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
#include "info.h" |
||||||
|
|
||||||
|
Info::Info() {} |
||||||
|
|
||||||
|
void Info::print(const std::string &text) {} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
#include "terminal.h" |
||||||
|
|
||||||
|
Terminal::Terminal() {} |
||||||
|
|
||||||
|
bool Terminal::on_motion_notify_event(GdkEventMotion* motion_event) {return false;} |
||||||
|
bool Terminal::on_button_press_event(GdkEventButton* button_event) {return false;} |
||||||
|
bool Terminal::on_key_press_event(GdkEventKey *event) {return false;} |
||||||
|
|
||||||
|
size_t Terminal::print(const std::string &message, bool bold) { |
||||||
|
return 0; |
||||||
|
} |
||||||
Loading…
Reference in new issue