Merge branch 'hotfix-1.3' into develop

This commit is contained in:
Jinhao
2016-04-18 15:16:03 +08:00
116 changed files with 2343 additions and 1004 deletions

View File

@@ -13,6 +13,11 @@
#include <nana/gui/wvl.hpp>
#include <nana/gui/detail/bedrock.hpp>
#include <nana/std_thread.hpp>
#include <iostream>
#include <chrono>
//#define NANA_AUTOMATIC_GUI_TESTING
namespace nana
{
namespace detail
@@ -23,8 +28,67 @@ namespace nana
}
}
void exec()
void click(widget& w)
{
std::cout << "Automatically clicking widget "<<w.caption()<<":\n";
arg_click arg;
arg.window_handle = w.handle();
w.events().click.emit(arg, w.handle());
}
/// in seconds
void Wait(unsigned wait)
{
if (!wait) return;
std::cout << "waiting " << wait << " sec...\n";
std::this_thread::sleep_for(std::chrono::seconds{ wait });
}
void pump()
{
detail::bedrock::instance().pump_event(nullptr, false);
}
void exec(
unsigned wait, // = 1, ///< for the GUI to be constructed, in seconds
unsigned wait_end, // = 1, ///< for the GUI to be destructed, in seconds
std::function<void()>f // = {} ///< emit events to mimics user actions and may asert results
)
{
#ifdef NANA_AUTOMATIC_GUI_TESTING
std::cout << "Will wait " << wait << " sec...\n";
std::thread t([wait, &f, wait_end]()
{
Wait( wait );
std::cout << "running... \n" ;
if (f)
{
f();
std::cout << "\nCongratulations, this was not trivial !" << std::endl;
}else
{
std::cout << "\nJust a trivial test." << std::endl;
}
std::cout << "Done... \n";
std::cout << "Now again ";
Wait(wait_end);
std::cout << "Done... Now API::exit all ...\n";
API::exit_all();
});
pump();
if (t.joinable())
t.join();
#else
static_cast<void>(wait);
static_cast<void>(wait_end);
static_cast<void>(f); //to eliminte unused parameter compiler warning.
pump();
#endif
}
}//end namespace nana