explore automatic GUI testing in VS2015, cmake and travis

local works vary good in windows with VS2015
This commit is contained in:
qPCR4vir 2016-03-01 18:59:57 +01:00
parent cbe6399008
commit 976b5ec275
4 changed files with 64 additions and 5 deletions

View File

@ -56,7 +56,7 @@ matrix:
- llvm-toolchain-precise
before_install:
- git clone --depth=50 --branch=dev_nana_in_examples https://github.com/qPCR4vir/nana-demo.git nana-demo
- git clone --depth=50 --branch=testing https://github.com/qPCR4vir/nana-demo.git nana-demo
- export PATH="$HOME/bin:$PATH"
- mkdir ~/bin
- wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true
@ -70,6 +70,7 @@ before_script :
- cd bld
script:
- cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=ON
- cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=ON -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=OFF
- make
- make
- clicked

View File

@ -29,6 +29,9 @@ option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during comp
option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." ON)
option(NANA_CMAKE_BUILD_DEMOS "Build all the demos form the nana_demo repository." OFF)
option(NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS "" ON)
option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF)
option(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING "Add defoult automatic GUI test?" OFF)
# The ISO C++ File System Technical Specification (ISO-TS, or STD) is optional.
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
@ -238,6 +241,17 @@ set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
if (NANA_CMAKE_BUILD_DEMOS)
if(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
add_definitions(-DNANA_AUTOMATIC_GUI_TESTING)
endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
if(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING)
add_definitions(-DNANA_ADD_DEF_AUTOMATIC_GUI_TESTING)
endif(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING)
NANA_ADD_DEF_AUTOMATIC_GUI_TESTING
set (demos calculator helloworld_demo notepad widget_show widget_show2 )
if (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS)
list(APPEND demos file_explorer)

View File

@ -15,6 +15,8 @@
#ifndef NANA_GUI_WVL_HPP
#define NANA_GUI_WVL_HPP
#include "programming_interface.hpp"
#include "screen.hpp"
#include "widgets/form.hpp"
@ -58,6 +60,7 @@ namespace nana
template<typename Form, bool IsVisible = true>
using form_loader = detail::form_loader<Form, IsVisible>;
void exec();
void exec(unsigned wait = 0, std::function<void()> = {});
}//end namespace nana
#endif

View File

@ -13,6 +13,22 @@
#include <nana/gui/wvl.hpp>
#include <nana/gui/detail/bedrock.hpp>
#include <thread>
#include <iostream>
//#define NANA_AUTOMATIC_GUI_TESTING
inline unsigned Wait(unsigned wait = 0)
{
#ifdef NANA_AUTOMATIC_GUI_TESTING
return wait;
#else
return 0;
#endif
}
namespace nana
{
namespace detail
@ -23,8 +39,33 @@ namespace nana
}
}
void exec()
void exec(unsigned wait, std::function<void()> f )
{
#ifdef NANA_ADD_DEF_AUTOMATIC_GUI_TESTING
if (!wait)
wait = 10;
if (!f)
f = []() {API::exit(); };
#endif
wait = Wait(wait);
std::cout << "Will wait " << wait << " sec...\n";
std::thread t([wait, &f]()
{ if (wait)
{
std::cout << "Waiting " << wait << " sec...\n";
std::this_thread::sleep_for(std::chrono::seconds{ wait } );
std::cout << "Waited !! running... \n" ;
f();
//API::exit();
std::cout << "Runed... \n";
}
});
detail::bedrock::instance().pump_event(nullptr, false);
if (t.joinable())
t.join();
}
}//end namespace nana